Skip to content
Merged
Changes from all commits
Commits
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
10 changes: 6 additions & 4 deletions tests/Unit/OrderBySessionHardeningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
expect($htmlUtilitySource)->toContain('cacti_build_sort_fragment($column, $direction)');
});

test('get_order_string rebuilds ORDER BY from validated session sort_data', function () use ($htmlUtilitySource) {
test('get_order_string normalizes, validates and builds the sort fragment', function () use ($htmlUtilitySource) {
$start = strpos($htmlUtilitySource, 'function get_order_string()');
expect($start)->not->toBeFalse();

$body = substr($htmlUtilitySource, $start, 1800);
expect($body)->toContain("if (isset(\$_SESSION['sort_data'][\$page]) && is_array(\$_SESSION['sort_data'][\$page]))");
expect($body)->toContain("\$_SESSION['sort_string'][\$page] = 'ORDER BY ' . implode(', ', \$order_parts);");
$next = strpos($htmlUtilitySource, "\nfunction ", $start + 1);
$body = $next === false ? substr($htmlUtilitySource, $start) : substr($htmlUtilitySource, $start, $next - $start);
expect($body)->toContain("cacti_normalize_sort_column(get_nfilter_request_var('sort_column'))");
expect($body)->toContain('cacti_build_sort_fragment($sort_column, $sort_dir)');
expect($body)->toContain('validate_sort_column($request_column, $page)');
Comment thread
somethingwithproof marked this conversation as resolved.
});