From a667ac485a892f30e0e1d31a7c4980c985d1ec8f Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 24 Nov 2026 11:32:03 +0000 Subject: [PATCH] fix(security): give MEDUSA every host worker, also for scans with few files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit security.py capped --workers at the number of files scanned, so a scan of three files used three cores. MEDUSA with scanner slices (Pantheon-Security/medusa#21) splits each file's scanners across all workers, so the cap now only idles cores; an unpatched MEDUSA starts workers on demand and is not affected. 🎯 Fix: 92 % 💥 Break: 5 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 87 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- skills/kvb-check-security/scripts/security.py | 6 +++--- tests/test_security.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/skills/kvb-check-security/scripts/security.py b/skills/kvb-check-security/scripts/security.py index 494b32a..d3b630f 100755 --- a/skills/kvb-check-security/scripts/security.py +++ b/skills/kvb-check-security/scripts/security.py @@ -22,8 +22,8 @@ Args: Scan: The regular files `git diff ` names plus untracked ones, symlinks left out, copied to a temporary tree and scanned once with - `medusa scan --format json -o --no-cache --workers `, w the - files scanned but at most host_workers(), HOME pointing into the temporary + `medusa scan --format json -o --no-cache --workers `, w + host_workers() also for fewer files, HOME pointing into the temporary directory because medusa creates ~/.medusa on start and KNOB set to --timeout (a medusa that ignores KNOB keeps its own cap), read from `/medusa-scan-*.json`: a `findings` list whose entries carry @@ -837,7 +837,7 @@ def scan( return scanned, hit, missed code, out, lasted = medusa_run( [medusa, "scan", str(tree), "--format", "json", "-o", str(reports), "--no-cache", - "--workers", str(min(scanned, host_workers()))], + "--workers", str(host_workers())], work, env, deadline, ) try: diff --git a/tests/test_security.py b/tests/test_security.py index eadca0a..31bfdd2 100644 --- a/tests/test_security.py +++ b/tests/test_security.py @@ -222,7 +222,7 @@ class TestSecurity(unittest.TestCase): argv = json.loads((self.bin / "argv.json").read_text(encoding="utf-8")) self.assertEqual( [argv[0], *argv[2:4], argv[4], *argv[6:]], - ["scan", "--format", "json", "-o", "--no-cache", "--workers", str(min(2, security_module().host_workers()))], + ["scan", "--format", "json", "-o", "--no-cache", "--workers", str(security_module().host_workers())], ) result = self.scan("--json", env=self.env) self.assertNotIn(PLACEHOLDER, result.stdout + result.stderr)