Automattic / Automattic/VIP-Coding-Standards

Consider wpcom_vip_get_resized_remote_image_url() as auto-escaping if fourth argument is truthy

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

Descrizione

## Bug Description

The VIP Go standard uses `WordPress.Security.EscapeOutput.OutputNotEscaped` but doesn't recognize that the deprecated [`wpcom_vip_get_resized_remote_image_url()` function](https://github.com/Automattic/vip-go-mu-plugins/blob/dfc36174ce2274def920a9ed4bf88e7d50303b35/vip-helpers/vip-deprecated.php#L1130-L1139) auto-escapes if it's fourth argument is true (default).

Since it's conditional, we can't just add an entry for it to `$customAutoEscapedFunctions` in the VIP Go ruleset (see [here](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#xss-custom-output-escaping-functions)) as otherwise it wouldn't get flagged if the fourth argument was not truthy.

## Minimal Code Snippet

```php
// Should not be flagged.
<?php echo esc_attr($item->name) ?>
```

```php
// Should be flagged.
<?php echo esc_attr($item->name) ?>
```

## Tested Against `master` branch?

- [x] I have verified the issue still exists in the `master` branch of VIPCS.
- [x] 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

Inizia dalla gestione dell’escaping dell’output XSS del ruleset VIP Go e dalla configurazione $customAutoEscapedFunctions descritta nell’issue, quindi esamina il comportamento della funzione collegata in vip-deprecated.php. Aggiungi una gestione condizionale per il quarto argomento e verifica che gli esempi forniti per true/predefinito e false producano gli avvisi previsti.

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

Valutazione

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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.