Automattic / Automattic/VIP-Coding-Standards

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

オープン
#473 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
Type: False positive
主要言語
PHP
スター
261
フォーク
44
平均マージ
19分
マージ済み PR(30日)
1

説明

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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、issue に記載されている VIP Go ルールセットの XSS 出力エスケープ処理と $customAutoEscapedFunctions 設定を確認し、次にリンク先の vip-deprecated.php の関数の動作を調べます。第 4 引数の条件付き処理を追加し、提示されている true/デフォルトおよび false の例で期待される警告が出力されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
php, wordpress
領域
tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。