-
Notifications
You must be signed in to change notification settings - Fork 39
test: add Pest v1 security test infrastructure #214
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?php | ||
| /* | ||
| +-------------------------------------------------------------------------+ | ||
| | Copyright (C) 2004-2026 The Cacti Group | | ||
| +-------------------------------------------------------------------------+ | ||
| | Cacti: The Complete RRDTool-based Graphing Solution | | ||
| +-------------------------------------------------------------------------+ | ||
| */ | ||
|
|
||
| $checks = array( | ||
| __DIR__ . '/../../monitor_controller.php' => array( | ||
| "html_escape(get_request_var('downhosts'))", | ||
| "html_escape(get_request_var('mute'))", | ||
| "html_escape(get_request_var('tree'))", | ||
| "html_escape(get_request_var('site'))", | ||
| "html_escape(get_request_var('template'))", | ||
| "html_escape(get_request_var('size'))", | ||
| "html_escape(get_request_var('trim'))", | ||
| ), | ||
| __DIR__ . '/../../monitor_render.php' => array( | ||
| "rawurlencode(get_request_var('rfilter'))", | ||
| ), | ||
| ); | ||
|
Comment on lines
+10
to
+23
|
||
|
|
||
| foreach ($checks as $path => $patterns) { | ||
| $contents = file_get_contents($path); | ||
|
|
||
| if ($contents === false) { | ||
| fwrite(STDERR, "Unable to read {$path}\n"); | ||
| exit(1); | ||
| } | ||
|
|
||
| foreach ($patterns as $pattern) { | ||
| if (strpos($contents, $pattern) === false) { | ||
| fwrite(STDERR, "Missing expected output hardening: {$pattern}\n"); | ||
| exit(1); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| print "OK\n"; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <?php | ||
| /* | ||
| +-------------------------------------------------------------------------+ | ||
| | Copyright (C) 2004-2026 The Cacti Group | | ||
| +-------------------------------------------------------------------------+ | ||
| | Cacti: The Complete RRDTool-based Graphing Solution | | ||
| +-------------------------------------------------------------------------+ | ||
| */ | ||
|
|
||
|
Comment on lines
+1
to
+9
|
||
| $checks = array( | ||
| __DIR__ . '/../../monitor_controller.php' => array( | ||
| "get_request_var('downhosts') . '\"><input id=\"mute\" type=\"hidden\" value=\"' . get_request_var('mute')", | ||
| "get_request_var('tree') . '\"></td>'", | ||
| "get_request_var('site') . '\"></td>'", | ||
| "get_request_var('template') . '\"></td>'", | ||
| "get_request_var('size') . '\"></td>'", | ||
| "get_request_var('trim') . '\"></td>'", | ||
| ), | ||
|
Comment on lines
+10
to
+18
|
||
| __DIR__ . '/../../monitor_render.php' => array( | ||
| "monitor.php?rfilter=' . get_request_var('rfilter')", | ||
| ), | ||
| ); | ||
|
|
||
| foreach ($checks as $path => $patterns) { | ||
| $contents = file_get_contents($path); | ||
|
|
||
| if ($contents === false) { | ||
| fwrite(STDERR, "Unable to read {$path}\n"); | ||
| exit(1); | ||
| } | ||
|
|
||
| foreach ($patterns as $pattern) { | ||
| if (strpos($contents, $pattern) !== false) { | ||
| fwrite(STDERR, "Raw request reuse remains: {$pattern}\n"); | ||
| exit(1); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| print "OK\n"; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||||||||||||||||||||||
| <?php | ||||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||||
| +-------------------------------------------------------------------------+ | ||||||||||||||||||||||||||
| | Copyright (C) 2004-2026 The Cacti Group | | ||||||||||||||||||||||||||
| +-------------------------------------------------------------------------+ | ||||||||||||||||||||||||||
| | Cacti: The Complete RRDTool-based Graphing Solution | | ||||||||||||||||||||||||||
| +-------------------------------------------------------------------------+ | ||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| $payload = "\" autofocus onfocus=\"alert(1)"; | ||||||||||||||||||||||||||
| $escaped = htmlspecialchars($payload, ENT_QUOTES, 'UTF-8'); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if (strpos($escaped, '"') === false && strpos($escaped, '"') !== false) { | ||||||||||||||||||||||||||
| print "OK\n"; | ||||||||||||||||||||||||||
| exit(0); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| fwrite(STDERR, "Expected request values to be escaped for hidden inputs\n"); | ||||||||||||||||||||||||||
| exit(1); | ||||||||||||||||||||||||||
|
Comment on lines
+10
to
+19
|
||||||||||||||||||||||||||
| $payload = "\" autofocus onfocus=\"alert(1)"; | |
| $escaped = htmlspecialchars($payload, ENT_QUOTES, 'UTF-8'); | |
| if (strpos($escaped, '"') === false && strpos($escaped, '"') !== false) { | |
| print "OK\n"; | |
| exit(0); | |
| } | |
| fwrite(STDERR, "Expected request values to be escaped for hidden inputs\n"); | |
| exit(1); | |
| fwrite(STDOUT, "SKIP: This file does not exercise plugin rendering; replace with a test that asserts escaping in actual rendered HTML.\n"); | |
| exit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is titled/described as adding “Pest v1” infrastructure, but this file is a standalone PHP script (no Pest/PHPUnit usage) and there’s no runner wiring in the repo CI to execute it. Either align the PR description/title to what’s being added, or add the actual Pest-based harness + CI/composer invocation so these checks run.