From a215d60b077c54684955dfca4aa4bb8a0fe844cb Mon Sep 17 00:00:00 2001
From: AmirNCI
Date: Wed, 21 Oct 2026 14:30:16 +0100
Subject: [PATCH] SECFOO-22 Fix filter dropdowns blocked by the portal CSP
The portal's Content-Security-Policy (default-src 'self', no
'unsafe-inline') blocks every inline event handler, not just onclick.
Five filter dropdowns still used onchange="this.form.submit()", so on
app.secfoo.com choosing a status/project silently did nothing (local
`secfoo serve` sends no CSP, so it only looked fine there):
- assessments/list.html (status)
- sast_findings_list.html, sca_vulnerabilities_list.html,
secret_scanning_findings_list.html (project)
- activities/detail.html (diagram project)
Replace them with a data-autosubmit attribute handled by a delegated
"change" listener in static/js/interactive.js, the same pattern used
for data-href/data-confirm. Widen the regression test from onclick to
any inline on...= handler, which is why these were missed.
Co-Authored-By: Claude Opus 5.5
---
src/secfoo/web/static/js/interactive.js | 11 +++++++++++
src/secfoo/web/templates/activities/detail.html | 2 +-
.../templates/activities/sast_findings_list.html | 2 +-
.../activities/sca_vulnerabilities_list.html | 2 +-
.../activities/secret_scanning_findings_list.html | 2 +-
src/secfoo/web/templates/assessments/list.html | 2 +-
tests/test_web/test_no_inline_scripts.py | 15 +++++++++------
7 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/src/secfoo/web/static/js/interactive.js b/src/secfoo/web/static/js/interactive.js
index ceb7e8d..e223c15 100644
--- a/src/secfoo/web/static/js/interactive.js
+++ b/src/secfoo/web/static/js/interactive.js
@@ -22,6 +22,17 @@
// -- a normal form-submit button that just asks for confirmation
// first; cancelling prevents the submit (replaces the old
// onclick="return confirm(...)" pattern, also CSP-blocked).
+//
+// -- submits its enclosing form as soon as the selection changes
+// (replaces the old onchange="this.form.submit()" filter dropdowns,
+// which the CSP blocked the same way).
+document.addEventListener("change", function (event) {
+ const field = event.target.closest("[data-autosubmit]");
+ if (field && field.form) {
+ field.form.submit();
+ }
+});
+
document.addEventListener("click", function (event) {
const deleteButton = event.target.closest("[data-delete-url]");
if (deleteButton) {
diff --git a/src/secfoo/web/templates/activities/detail.html b/src/secfoo/web/templates/activities/detail.html
index fc0b5e9..5ec2450 100644
--- a/src/secfoo/web/templates/activities/detail.html
+++ b/src/secfoo/web/templates/activities/detail.html
@@ -102,7 +102,7 @@