policies.py 652 B

12345678910111213141516171819
  1. DEFAULT_INVARIANT_POLICY = """from invariant.detectors import semgrep, secrets, CodeIssue
  2. raise "Disallow secrets in bash commands [risk=medium]" if:
  3. (call: ToolCall)
  4. call is tool:cmd_run
  5. any(secrets(call.function.arguments.command))
  6. raise "Vulnerability in python code [risk=medium]" if:
  7. (call: ToolCall)
  8. call is tool:ipython_run_cell
  9. semgrep_res := semgrep(call.function.arguments.code, lang="python")
  10. any(semgrep_res)
  11. raise "Vulnerability in bash command [risk=medium]" if:
  12. (call: ToolCall)
  13. call is tool:cmd_run
  14. semgrep_res := semgrep(call.function.arguments.command, lang="bash")
  15. any(semgrep_res)
  16. """