Automattic / Automattic/VIP-Coding-Standards

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

Đang mở
#473 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Type: False positive
Ngôn ngữ chính
PHP
Star
261
Fork
44
Merge trung bình
19 phút
Pull request đã merge (30 ngày)
1

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với cách xử lý escaping đầu ra XSS của ruleset VIP Go và cấu hình $customAutoEscapedFunctions được mô tả trong issue, sau đó kiểm tra hành vi của hàm được liên kết trong vip-deprecated.php. Thêm xử lý có điều kiện cho đối số thứ tư và xác minh rằng các ví dụ được cung cấp cho true/mặc định và false tạo ra các cảnh báo như mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
php, wordpress
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.