Automattic / Automattic/VIP-Coding-Standards

WordPressVIPMinimum.Security.PHPFilterFunctions.MissingThirdParameter shouldn't report for SCRIPT_FILENAME,...

Ouverte
#832 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
PHP
Étoiles
261
Forks
44
Merge moyen
19 min
PR mergées (30 j)
1

Description

## Bug Description

Since filter_input always acts on the original data, which can also not be modified in userland, all values that are specified by the SAPI itself are safe and do not need sanitizing.
These are:
https://github.com/php/php-src/blob/master/sapi/cli/php_cli.c#L330-L347
PHP_SELF
SCRIPT_NAME
SCRIPT_FILENAME
PATH_TRANSLATED
DOCUMENT_ROOT

For fpm these are provided by apache/nginx and no further validation is required, since PHP would not even process the request if any of those were invalid

## Minimal Code Snippet

```php
echo filter_input( INPUT_SERVER, 'DOCUMENT_ROOT' );
```

## Error Code

WordPressVIPMinimum.Security.PHPFilterFunctions.MissingThirdParameter

## Environment

VIPCS version | 3.0.1

## Tested Against `main` branch?

- [ ] I have verified the issue still exists in the `main` branch of VIPCS.
- [ ] I have verified the issue still exists in the `develop` branch of VIPCS.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Start with the WordPressVIPMinimum.Security.PHPFilterFunctions.MissingThirdParameter rule and the filter_input(INPUT_SERVER, ...) entry point shown in the snippet. Review the listed SAPI-provided variables in php-src/sapi/cli/php_cli.c, lines 330-347, and confirm the rule no longer reports those cases while retaining its existing report for other inputs.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
php
Domaine
security, tooling
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.