Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Tighten the privileged close hook boundary

pulse-triage[bot]6575ebd92898
diff --git a/scripts/check_workflow_trust.py b/scripts/check_workflow_trust.py
index 9c20c12a42..a5d0f45b40 100644
--- a/scripts/check_workflow_trust.py
+++ b/scripts/check_workflow_trust.py
@@ -860,6 +860,10 @@ def _is_hardened_closed_pr_cancellation(path: Path, lines: list[str]) -> bool:
" pull-requests: read",
]:
return False
+ if sum(
+ bool(PERMISSIONS_RE.match(line.split("#", 1)[0])) for line in lines
+ ) != 1:
+ return False
if any(RUN_RE.match(line.split("#", 1)[0]) for line in lines):
return False
diff --git a/scripts/tests/test_workflow_trust.py b/scripts/tests/test_workflow_trust.py
index a45006836c..c88c299621 100644
--- a/scripts/tests/test_workflow_trust.py
+++ b/scripts/tests/test_workflow_trust.py
@@ -401,6 +401,22 @@ steps:
any("pull_request_target is prohibited" in finding for finding in findings)
)
+ excess_permissions = workflow.replace(
+ " timeout-minutes: 5",
+ " timeout-minutes: 5\n"
+ " permissions:\n"
+ " actions: write\n"
+ " contents: write\n"
+ " pull-requests: read",
+ )
+ findings = self.audit(
+ excess_permissions,
+ workflow_trust.SAFE_PULL_REQUEST_TARGET_WORKFLOW,
+ )
+ self.assertTrue(
+ any("pull_request_target is prohibited" in finding for finding in findings)
+ )
+
findings = self.audit(workflow)
self.assertTrue(
any("pull_request_target is prohibited" in finding for finding in findings)