Skip to content

Commit 18054e5

Browse files
authored
fix: harden crypto live pool audit gate (#101)
1 parent ff83a08 commit 18054e5

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ jobs:
3131
python -m pip install -r "$REQ_FILE"
3232
python -m pip install ruff
3333
34+
- name: Verify dependencies
35+
run: |
36+
set -euo pipefail
37+
python -m pip check
38+
3439
- name: Run ruff
3540
run: |
3641
set -euo pipefail

scripts/gate_codex_app_review.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def compile_patterns(policy: dict[str, Any]) -> list[re.Pattern[str]]:
104104
# ─── static guard ────────────────────────────────────────────────────────────
105105

106106
_SENSITIVE = re.compile(
107-
r'(?:api[_\s]?key|secret|password|token|credential|private[_\s]?key)\s*[:=]\s*["\']'
107+
r'(?P<field>api[_\s]?key|secret|password|token|credential|private[_\s]?key)\s*[:=]\s*["\']'
108108
r'(?!\$\{\{|{{|example|placeholder|test|your[-_\s]|xxx|TODO|CHANGEME)[^"\']{12,}["\']',
109109
re.IGNORECASE,
110110
)
@@ -129,7 +129,8 @@ def scan_diff(diff_text: str, path_patterns: list[re.Pattern[str]]) -> list[str]
129129
continue
130130
m = _SENSITIVE.search(line[1:])
131131
if m:
132-
violations.append(f"**Hardcoded secret** in `{current}`: `{m.group(0)[:100]}`")
132+
field = re.sub(r"\s+", "_", m.group("field").strip().lower())
133+
violations.append(f"**Hardcoded secret** in `{current}`: `{field}=<redacted>`")
133134
return list(dict.fromkeys(violations))
134135

135136

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from __future__ import annotations
2+
3+
import unittest
4+
5+
from scripts.gate_codex_app_review import scan_diff
6+
7+
8+
class GateCodexAppReviewTests(unittest.TestCase):
9+
def test_scan_diff_redacts_hardcoded_secret_values(self) -> None:
10+
secret_field = "API" + "_KEY"
11+
secret_value = "super" + "secretvalue123456"
12+
diff_text = (
13+
"diff --git a/example.env b/example.env\n"
14+
"--- a/example.env\n"
15+
"+++ b/example.env\n"
16+
f'+{secret_field} = "{secret_value}"\n'
17+
)
18+
19+
violations = scan_diff(diff_text, [])
20+
21+
self.assertEqual(len(violations), 1)
22+
self.assertIn("<redacted>", violations[0])
23+
self.assertIn("api_key", violations[0])
24+
self.assertNotIn(secret_value, violations[0])
25+
26+
27+
if __name__ == "__main__":
28+
unittest.main()

0 commit comments

Comments
 (0)