Skip to content

Commit 39530d8

Browse files
test: add Pest v1 security test infrastructure
1 parent 8c03d47 commit 39530d8

3 files changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/*
3+
+-------------------------------------------------------------------------+
4+
| Copyright (C) 2004-2026 The Cacti Group |
5+
+-------------------------------------------------------------------------+
6+
| Cacti: The Complete RRDTool-based Graphing Solution |
7+
+-------------------------------------------------------------------------+
8+
*/
9+
10+
$checks = array(
11+
__DIR__ . '/../../monitor_controller.php' => array(
12+
"html_escape(get_request_var('downhosts'))",
13+
"html_escape(get_request_var('mute'))",
14+
"html_escape(get_request_var('tree'))",
15+
"html_escape(get_request_var('site'))",
16+
"html_escape(get_request_var('template'))",
17+
"html_escape(get_request_var('size'))",
18+
"html_escape(get_request_var('trim'))",
19+
),
20+
__DIR__ . '/../../monitor_render.php' => array(
21+
"rawurlencode(get_request_var('rfilter'))",
22+
),
23+
);
24+
25+
foreach ($checks as $path => $patterns) {
26+
$contents = file_get_contents($path);
27+
28+
if ($contents === false) {
29+
fwrite(STDERR, "Unable to read {$path}\n");
30+
exit(1);
31+
}
32+
33+
foreach ($patterns as $pattern) {
34+
if (strpos($contents, $pattern) === false) {
35+
fwrite(STDERR, "Missing expected output hardening: {$pattern}\n");
36+
exit(1);
37+
}
38+
}
39+
}
40+
41+
print "OK\n";
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/*
3+
+-------------------------------------------------------------------------+
4+
| Copyright (C) 2004-2026 The Cacti Group |
5+
+-------------------------------------------------------------------------+
6+
| Cacti: The Complete RRDTool-based Graphing Solution |
7+
+-------------------------------------------------------------------------+
8+
*/
9+
10+
$checks = array(
11+
__DIR__ . '/../../monitor_controller.php' => array(
12+
"get_request_var('downhosts') . '\"><input id=\"mute\" type=\"hidden\" value=\"' . get_request_var('mute')",
13+
"get_request_var('tree') . '\"></td>'",
14+
"get_request_var('site') . '\"></td>'",
15+
"get_request_var('template') . '\"></td>'",
16+
"get_request_var('size') . '\"></td>'",
17+
"get_request_var('trim') . '\"></td>'",
18+
),
19+
__DIR__ . '/../../monitor_render.php' => array(
20+
"monitor.php?rfilter=' . get_request_var('rfilter')",
21+
),
22+
);
23+
24+
foreach ($checks as $path => $patterns) {
25+
$contents = file_get_contents($path);
26+
27+
if ($contents === false) {
28+
fwrite(STDERR, "Unable to read {$path}\n");
29+
exit(1);
30+
}
31+
32+
foreach ($patterns as $pattern) {
33+
if (strpos($contents, $pattern) !== false) {
34+
fwrite(STDERR, "Raw request reuse remains: {$pattern}\n");
35+
exit(1);
36+
}
37+
}
38+
}
39+
40+
print "OK\n";
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/*
3+
+-------------------------------------------------------------------------+
4+
| Copyright (C) 2004-2026 The Cacti Group |
5+
+-------------------------------------------------------------------------+
6+
| Cacti: The Complete RRDTool-based Graphing Solution |
7+
+-------------------------------------------------------------------------+
8+
*/
9+
10+
$payload = "\" autofocus onfocus=\"alert(1)";
11+
$escaped = htmlspecialchars($payload, ENT_QUOTES, 'UTF-8');
12+
13+
if (strpos($escaped, '"') === false && strpos($escaped, '&quot;') !== false) {
14+
print "OK\n";
15+
exit(0);
16+
}
17+
18+
fwrite(STDERR, "Expected request values to be escaped for hidden inputs\n");
19+
exit(1);

0 commit comments

Comments
 (0)