Automattic / Automattic/VIP-Coding-Standards

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

Aperta
#832 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
PHP
Stelle
261
Fork
44
Merge medio
19m
PR unite (30g)
1

Descrizione

## 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
php
Ambito
security, tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.