Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve output escaping, input sanitizing and logging #252

Draft
wants to merge 49 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ee743f1
Improve output escaping.
gudmdharalds Feb 28, 2022
330ddae
Update SvgScanLookForSpecificTokensTest.php
gudmdharalds Feb 28, 2022
98b00d5
Fixing WP CS
gudmdharalds Feb 28, 2022
27f7e01
Merge branch 'fix-output-escaping' of github.com:Automattic/vip-go-ci…
gudmdharalds Feb 28, 2022
7580df2
Merge branch 'main' into fix-output-escaping
gudmdharalds Mar 2, 2022
2c6127c
Merge branch 'main' into fix-output-escaping
gudmdharalds Mar 22, 2022
392a8c0
main.php: Add space to URL logged for usability
gudmdharalds Mar 23, 2022
ab471d6
Update reports.php
gudmdharalds Mar 23, 2022
15516fd
Update ReportCreateScanDetailsSoftwareVersionsTest.php
gudmdharalds Mar 23, 2022
86c0e2a
Merge branch 'main' into fix-output-escaping
gudmdharalds Mar 28, 2022
bafb0d9
Merge branch 'main' into fix-output-escaping
gudmdharalds Mar 31, 2022
53ea919
Merge branch 'main' into fix-output-escaping
gudmdharalds Apr 25, 2022
4d9ae0b
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jun 3, 2022
24b8b2c
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jun 16, 2022
4a3c40d
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jun 22, 2022
a93dde2
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jul 6, 2022
1c1cbdf
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jul 6, 2022
2233e82
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jul 19, 2022
a188fa7
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jul 19, 2022
b9b487e
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Aug 8, 2022
e175a5c
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Sep 8, 2022
b8e95d3
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Sep 15, 2022
6958596
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Sep 27, 2022
2224ded
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Sep 28, 2022
f14c2f0
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Oct 6, 2022
5834669
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Oct 17, 2022
3fe5dbf
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Oct 27, 2022
9949694
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Nov 2, 2022
4efc266
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Nov 11, 2022
b79763e
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Nov 14, 2022
b1b024c
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Nov 17, 2022
c04d70f
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Dec 12, 2022
22decef
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jan 20, 2023
a50a0a7
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jan 24, 2023
fb8f53b
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jan 26, 2023
acb7b0f
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jan 26, 2023
4edb5e4
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jan 26, 2023
5db52dc
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Feb 3, 2023
ca7ded4
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Feb 14, 2023
da82e1b
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Feb 14, 2023
b2b3b9c
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Feb 20, 2023
4126453
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Feb 21, 2023
a456ec2
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Feb 22, 2023
b203f88
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Feb 23, 2023
33ae4d1
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Jun 12, 2023
7e60479
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Sep 12, 2023
b9b9ada
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Sep 25, 2023
9c379f4
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Oct 12, 2023
7d30f4e
Merge branch 'trunk' into fix-output-escaping
gudmdharalds Aug 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auto-approval.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function vipgoci_auto_approval_non_approval(
$options['repo-name'],
(int) $pr_number,
(int) $pr_item_review->id,
'Dismissing obsolete review; not approved any longer',
vipgoci_output_html_escape( 'Dismissing obsolete review; not approved any longer' ),
$options['token']
);
}
Expand Down
3 changes: 1 addition & 2 deletions github-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1292,8 +1292,7 @@ function vipgoci_github_pr_reviews_dismiss_with_non_active_comments(
$options['repo-name'],
$pr_number,
$pr_review->id,
'Dismissing review as all inline comments ' .
'are obsolete by now',
'Dismissing review as all inline comments are obsolete by now',
$options['token']
);
}
Expand Down
6 changes: 4 additions & 2 deletions reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function vipgoci_report_create_scan_details_software_versions(

$details .= '<ul>' . PHP_EOL;

$details .= '<li>vip-go-ci version: <code>' . vipgoci_output_sanitize_version_number( VIPGOCI_VERSION ) . '</code></li>' . PHP_EOL;
$details .= '<li><a href="https://github.com/Automattic/vip-go-ci">vip-go-ci</a> version: <code>' . vipgoci_output_sanitize_version_number( VIPGOCI_VERSION ) . '</code></li>' . PHP_EOL;

$php_runtime_version = phpversion();

Expand Down Expand Up @@ -649,6 +649,8 @@ function vipgoci_report_maybe_no_issues_found(

$no_issues_msg .= ' (commit-ID: ' . $commit_id . ')';

$no_issues_msg = vipgoci_output_html_escape( $no_issues_msg );

/*
* If we have informational message, append it.
*/
Expand Down Expand Up @@ -1440,7 +1442,7 @@ function vipgoci_report_submit_pr_review_from_results(
$repo_name,
$github_token,
$pr_number,
VIPGOCI_GITHUB_ERROR_STR,
vipgoci_output_html_escape( VIPGOCI_GITHUB_ERROR_STR ),
$commit_id
);
}
Expand Down
2 changes: 1 addition & 1 deletion svg-scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function vipgoci_svg_look_for_specific_tokens(

$results['files'][ $temp_file_name ]['messages'][] =
array(
'message' => 'Found forbidden tag in SVG file: \'' . $disallowed_token . '\'',
'message' => vipgoci_output_html_escape( 'Found forbidden tag in SVG file: \'' . $disallowed_token . '\'' ),
'line' => $line_no,
'level' => 'ERROR',
);
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/SvgScanLookForSpecificTokensTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testSpecificTokens1() {
);

$results_expected = json_decode(
'{"totals":{"errors":1,"warnings":0,"fixable":0},"files":{"' . addcslashes( $temp_file_name, '/' ) . '":{"errors":1,"messages":[{"message":"Found forbidden tag in SVG file: \'<?php\'","line":6,"level":"ERROR"}]}}}',
'{"totals":{"errors":1,"warnings":0,"fixable":0},"files":{"' . addcslashes( $temp_file_name, '/' ) . '":{"errors":1,"messages":[{"message":"Found forbidden tag in SVG file: &#039;&lt;?php&#039;","line":6,"level":"ERROR"}]}}}',
true
);

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/ReportCreateScanDetailsSoftwareVersionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testCreateDetails1(): void {
);

$this->assertStringContainsString(
'<li>vip-go-ci version: <code>' . VIPGOCI_VERSION . '</code></li>',
'<li><a href="https://github.com/Automattic/vip-go-ci">vip-go-ci</a> version: <code>' . VIPGOCI_VERSION . '</code></li>',
$actual_output
);

Expand Down Expand Up @@ -150,7 +150,7 @@ public function testCreateDetails2(): void {
);

$this->assertStringContainsString(
'<li>vip-go-ci version: <code>' . VIPGOCI_VERSION . '</code></li>',
'<li><a href="https://github.com/Automattic/vip-go-ci">vip-go-ci</a> version: <code>' . VIPGOCI_VERSION . '</code></li>',
$actual_output
);

Expand Down
Loading