summaryrefslogtreecommitdiff
path: root/tests/test_scan.py
diff options
context:
space:
mode:
authorjdj <jdj@kunix.org>2026-10-29 11:25:11 -0700
committerjdj <jdj@kunix.org>2026-10-29 11:25:11 -0700
commit72fab81a09083eb858840a21366eace175d01721 (patch)
treedea97140c924fb0906fbcb4c1f1a9dac7efb615c /tests/test_scan.py
downloadvolta-train-kernels-72fab81a09083eb858840a21366eace175d01721.tar.gz
volta-train-kernels-72fab81a09083eb858840a21366eace175d01721.zip
Volta training kernels with secret/path scanner
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_scan.py')
-rw-r--r--tests/test_scan.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_scan.py b/tests/test_scan.py
new file mode 100644
index 0000000..19354fa
--- /dev/null
+++ b/tests/test_scan.py
@@ -0,0 +1,37 @@
+import os
+import subprocess
+import tempfile
+import unittest
+from pathlib import Path
+
+REPO = Path(__file__).resolve().parents[1]
+SCAN = REPO / "scripts" / "scan.sh"
+
+
+def scan(path):
+ return subprocess.run(["bash", str(SCAN), str(path)], capture_output=True, text=True)
+
+
+class TestScan(unittest.TestCase):
+ def test_clean_tree_passes(self):
+ r = scan(REPO)
+ self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
+
+ def _planted(self, text):
+ with tempfile.TemporaryDirectory() as d:
+ (Path(d) / "leak.py").write_text(text)
+ return scan(d)
+
+ def test_planted_token_fails(self):
+ r = self._planted("TOKEN = 'hf_" + "a" * 34 + "'\n")
+ self.assertEqual(r.returncode, 1)
+ self.assertIn("leak.py", r.stdout)
+
+ def test_planted_home_path_fails(self):
+ r = self._planted("sys.path.insert(0, '/ho" + "me/someone/x')\n")
+ self.assertEqual(r.returncode, 1)
+ self.assertIn("leak.py", r.stdout)
+
+
+if __name__ == "__main__":
+ unittest.main()