Alexander Whitestone
|
8f24d43c08
|
feat: ML-inspired risk scoring for command approval (#681)
Docker Build and Publish / build-and-push (pull_request) Has been skipped
Contributor Attribution Check / check-attribution (pull_request) Failing after 31s
Supply Chain Audit / Scan PR for supply chain risks (pull_request) Successful in 37s
Tests / e2e (pull_request) Successful in 2m27s
Tests / test (pull_request) Failing after 37m0s
Current tier detection uses keyword matching and regex patterns.
This adds path-aware and context-aware risk scoring.
New tools/risk_scoring.py:
- classify_path_risk(): system paths (90), sensitive user paths (75),
safe paths (10), user paths (50)
- detect_context(): execution vs comment vs documentation vs code block
(documentation contexts reduce risk score)
- get_operation_risk(): read-only ops (cat/grep/find = 5-10) vs
destructive ops (rm=70, mkfs=95, kill=45)
- score_command_risk(): multi-factor RiskScore with tier classification
(SAFE/LOW/MEDIUM/HIGH/CRITICAL), factors list, recommendation
- compare_commands(): side-by-side risk comparison
Key improvements:
- 'cat /etc/passwd' is SAFE (read operation, path irrelevant)
- 'rm /etc/passwd' is CRITICAL (destructive + system path)
- 'rm /tmp/build.log' is MEDIUM (destructive but safe path)
- '# rm -rf /' is LOW (comment context reduces risk)
- 'curl ... | bash' is HIGH (pipe to shell pattern)
Tests: tests/test_risk_scoring.py
Closes #681
|
2026-04-14 19:20:50 -04:00 |
|