codejury 0.10.6__tar.gz → 0.12.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codejury-0.12.0/PKG-INFO +102 -0
- codejury-0.12.0/README.md +72 -0
- codejury-0.12.0/codejury/__init__.py +14 -0
- codejury-0.12.0/codejury/analysis/repo_model.py +180 -0
- codejury-0.12.0/codejury/cli.py +142 -0
- codejury-0.12.0/codejury/data/agent/full-review.md +102 -0
- codejury-0.12.0/codejury/data/agent/security-review-memory.md +30 -0
- codejury-0.12.0/codejury/data/entrypoints.yaml +16 -0
- codejury-0.12.0/codejury/data/rules/SKILL.md +41 -0
- codejury-0.12.0/codejury/data/rules/authentication-jwt.md +21 -0
- codejury-0.12.0/codejury/data/rules/broken-access-control.md +27 -0
- codejury-0.12.0/codejury/data/rules/command-injection.md +25 -0
- codejury-0.12.0/codejury/data/rules/idor.md +24 -0
- codejury-0.12.0/codejury/data/rules/insecure-crypto.md +22 -0
- codejury-0.12.0/codejury/data/rules/insecure-deserialization.md +22 -0
- codejury-0.12.0/codejury/data/rules/mass-assignment.md +21 -0
- codejury-0.12.0/codejury/data/rules/path-traversal.md +22 -0
- codejury-0.12.0/codejury/data/rules/secrets.md +20 -0
- codejury-0.12.0/codejury/data/rules/sql-injection.md +25 -0
- codejury-0.12.0/codejury/data/rules/ssrf.md +22 -0
- codejury-0.12.0/codejury/data/rules/xss.md +24 -0
- codejury-0.12.0/codejury/diff/__init__.py +0 -0
- codejury-0.12.0/codejury/diff/debate.py +104 -0
- codejury-0.12.0/codejury/diff/debate_prompts.py +102 -0
- codejury-0.12.0/codejury/diff/engine.py +33 -0
- codejury-0.12.0/codejury/diff/findings_filter.py +39 -0
- codejury-0.12.0/codejury/diff/prompts.py +65 -0
- codejury-0.12.0/codejury/diff/report.py +120 -0
- codejury-0.12.0/codejury/diff/rules.py +71 -0
- codejury-0.12.0/codejury/domain/finding.py +70 -0
- codejury-0.12.0/codejury/fullreview/__init__.py +0 -0
- codejury-0.12.0/codejury/fullreview/scaffold.py +77 -0
- codejury-0.12.0/codejury/providers/factory.py +30 -0
- codejury-0.12.0/codejury/resources.py +13 -0
- codejury-0.12.0/codejury.egg-info/PKG-INFO +102 -0
- codejury-0.12.0/codejury.egg-info/SOURCES.txt +65 -0
- {codejury-0.10.6 → codejury-0.12.0}/pyproject.toml +3 -3
- codejury-0.12.0/tests/test_diff_debate.py +105 -0
- codejury-0.12.0/tests/test_diff_engine.py +95 -0
- codejury-0.12.0/tests/test_diff_report.py +66 -0
- codejury-0.12.0/tests/test_full_review_scaffold.py +74 -0
- codejury-0.12.0/tests/test_repo_model.py +152 -0
- codejury-0.12.0/tests/test_rules.py +58 -0
- codejury-0.10.6/PKG-INFO +0 -241
- codejury-0.10.6/README.md +0 -211
- codejury-0.10.6/codejury/__init__.py +0 -13
- codejury-0.10.6/codejury/agents/__init__.py +0 -6
- codejury-0.10.6/codejury/agents/base.py +0 -21
- codejury-0.10.6/codejury/agents/debate.py +0 -207
- codejury-0.10.6/codejury/agents/mock.py +0 -37
- codejury-0.10.6/codejury/agents/parsing.py +0 -45
- codejury-0.10.6/codejury/agents/refuter.py +0 -76
- codejury-0.10.6/codejury/agents/verifier.py +0 -143
- codejury-0.10.6/codejury/analysis/provenance.py +0 -253
- codejury-0.10.6/codejury/analysis/taint.py +0 -303
- codejury-0.10.6/codejury/assembly.py +0 -141
- codejury-0.10.6/codejury/baseline.py +0 -58
- codejury-0.10.6/codejury/cli.py +0 -399
- codejury-0.10.6/codejury/data/capabilities/authentication.yaml +0 -67
- codejury-0.10.6/codejury/data/capabilities/authorization.yaml +0 -55
- codejury-0.10.6/codejury/data/capabilities/business_logic.yaml +0 -58
- codejury-0.10.6/codejury/data/capabilities/crypto.yaml +0 -78
- codejury-0.10.6/codejury/data/capabilities/data_protection.yaml +0 -57
- codejury-0.10.6/codejury/data/capabilities/dependency_config.yaml +0 -79
- codejury-0.10.6/codejury/data/capabilities/error_logging.yaml +0 -49
- codejury-0.10.6/codejury/data/capabilities/excessive_agency.yaml +0 -64
- codejury-0.10.6/codejury/data/capabilities/input_validation.yaml +0 -171
- codejury-0.10.6/codejury/data/capabilities/insecure_output_handling.yaml +0 -65
- codejury-0.10.6/codejury/data/capabilities/model_supply_chain.yaml +0 -59
- codejury-0.10.6/codejury/data/capabilities/output_encoding.yaml +0 -56
- codejury-0.10.6/codejury/data/capabilities/prompt_injection.yaml +0 -67
- codejury-0.10.6/codejury/data/capabilities/secrets.yaml +0 -72
- codejury-0.10.6/codejury/data/capabilities/session.yaml +0 -60
- codejury-0.10.6/codejury/data/golden/ag_allowlist_safe.yaml +0 -16
- codejury-0.10.6/codejury/data/golden/ag_arbitrary_tool_vuln.yaml +0 -14
- codejury-0.10.6/codejury/data/golden/ag_destructive_no_confirm_vuln.yaml +0 -14
- codejury-0.10.6/codejury/data/golden/ag_fixed_enum_safe.yaml +0 -19
- codejury-0.10.6/codejury/data/golden/ag_human_approval_safe.yaml +0 -13
- codejury-0.10.6/codejury/data/golden/ag_model_confirmed_vuln.yaml +0 -16
- codejury-0.10.6/codejury/data/golden/authn_bcrypt_password.yaml +0 -5
- codejury-0.10.6/codejury/data/golden/authn_jwt_noverify_vuln.yaml +0 -6
- codejury-0.10.6/codejury/data/golden/authn_jwt_verified_safe.yaml +0 -6
- codejury-0.10.6/codejury/data/golden/authn_sha256_checksum_safe.yaml +0 -6
- codejury-0.10.6/codejury/data/golden/authn_sha256_password.yaml +0 -6
- codejury-0.10.6/codejury/data/golden/authn_weak_hash_indirect_vuln.yaml +0 -14
- codejury-0.10.6/codejury/data/golden/authz_idor_vuln.yaml +0 -6
- codejury-0.10.6/codejury/data/golden/authz_owner_safe.yaml +0 -5
- codejury-0.10.6/codejury/data/golden/business_logic_atomic_safe.yaml +0 -15
- codejury-0.10.6/codejury/data/golden/business_logic_price_tamper_vuln.yaml +0 -14
- codejury-0.10.6/codejury/data/golden/business_logic_server_checked_safe.yaml +0 -15
- codejury-0.10.6/codejury/data/golden/business_logic_toctou_vuln.yaml +0 -14
- codejury-0.10.6/codejury/data/golden/cmdi_fixed_argv_safe.yaml +0 -22
- codejury-0.10.6/codejury/data/golden/cmdi_ossystem_vuln.yaml +0 -5
- codejury-0.10.6/codejury/data/golden/cmdi_subprocess_safe.yaml +0 -5
- codejury-0.10.6/codejury/data/golden/crypto_aesgcm_nonce_safe.yaml +0 -13
- codejury-0.10.6/codejury/data/golden/crypto_aesgcm_safe.yaml +0 -6
- codejury-0.10.6/codejury/data/golden/crypto_ecb_vuln.yaml +0 -6
- codejury-0.10.6/codejury/data/golden/crypto_static_iv_vuln.yaml +0 -14
- codejury-0.10.6/codejury/data/golden/data_protection_cleartext_http_vuln.yaml +0 -11
- codejury-0.10.6/codejury/data/golden/data_protection_encrypted_at_rest_safe.yaml +0 -11
- codejury-0.10.6/codejury/data/golden/data_protection_plaintext_pii_vuln.yaml +0 -14
- codejury-0.10.6/codejury/data/golden/data_protection_tokenized_safe.yaml +0 -16
- codejury-0.10.6/codejury/data/golden/dependency_config_debug_off_safe.yaml +0 -12
- codejury-0.10.6/codejury/data/golden/dependency_config_debug_true_vuln.yaml +0 -11
- codejury-0.10.6/codejury/data/golden/dependency_config_tls_verify_off_vuln.yaml +0 -11
- codejury-0.10.6/codejury/data/golden/dependency_config_tls_verify_on_safe.yaml +0 -11
- codejury-0.10.6/codejury/data/golden/deserialize_json_safe.yaml +0 -13
- codejury-0.10.6/codejury/data/golden/deserialize_pickle_vuln.yaml +0 -12
- codejury-0.10.6/codejury/data/golden/error_logging_redacted_safe.yaml +0 -11
- codejury-0.10.6/codejury/data/golden/error_logging_reraise_safe.yaml +0 -15
- codejury-0.10.6/codejury/data/golden/error_logging_secret_leak_vuln.yaml +0 -12
- codejury-0.10.6/codejury/data/golden/error_logging_swallow_vuln.yaml +0 -14
- codejury-0.10.6/codejury/data/golden/ioh_escaped_output_safe.yaml +0 -12
- codejury-0.10.6/codejury/data/golden/ioh_exec_output_vuln.yaml +0 -13
- codejury-0.10.6/codejury/data/golden/ioh_innerhtml_output_vuln.yaml +0 -13
- codejury-0.10.6/codejury/data/golden/ioh_json_response_safe.yaml +0 -15
- codejury-0.10.6/codejury/data/golden/ioh_output_to_sql_vuln.yaml +0 -15
- codejury-0.10.6/codejury/data/golden/ioh_schema_validated_safe.yaml +0 -13
- codejury-0.10.6/codejury/data/golden/literal_eval_safe.yaml +0 -14
- codejury-0.10.6/codejury/data/golden/output_encoding_header_injection_vuln.yaml +0 -11
- codejury-0.10.6/codejury/data/golden/path_basename_safe.yaml +0 -15
- codejury-0.10.6/codejury/data/golden/path_contained_safe.yaml +0 -8
- codejury-0.10.6/codejury/data/golden/path_traversal_vuln.yaml +0 -5
- codejury-0.10.6/codejury/data/golden/pi_delimited_data_safe.yaml +0 -15
- codejury-0.10.6/codejury/data/golden/pi_format_role_vuln.yaml +0 -16
- codejury-0.10.6/codejury/data/golden/pi_indirect_rag_vuln.yaml +0 -16
- codejury-0.10.6/codejury/data/golden/pi_system_concat_vuln.yaml +0 -13
- codejury-0.10.6/codejury/data/golden/pi_user_content_concat_safe.yaml +0 -18
- codejury-0.10.6/codejury/data/golden/pi_user_role_safe.yaml +0 -14
- codejury-0.10.6/codejury/data/golden/sc_pinned_safe.yaml +0 -11
- codejury-0.10.6/codejury/data/golden/sc_safetensors_safe.yaml +0 -12
- codejury-0.10.6/codejury/data/golden/sc_torch_load_vuln.yaml +0 -11
- codejury-0.10.6/codejury/data/golden/sc_trust_remote_code_vuln.yaml +0 -12
- codejury-0.10.6/codejury/data/golden/secrets_env_safe.yaml +0 -5
- codejury-0.10.6/codejury/data/golden/secrets_from_config_safe.yaml +0 -12
- codejury-0.10.6/codejury/data/golden/secrets_hardcoded_token_vuln.yaml +0 -13
- codejury-0.10.6/codejury/data/golden/secrets_hardcoded_vuln.yaml +0 -5
- codejury-0.10.6/codejury/data/golden/session_cookie_flags_safe.yaml +0 -10
- codejury-0.10.6/codejury/data/golden/session_fixation_vuln.yaml +0 -16
- codejury-0.10.6/codejury/data/golden/session_insecure_cookie_vuln.yaml +0 -11
- codejury-0.10.6/codejury/data/golden/session_secure_cookie_safe.yaml +0 -18
- codejury-0.10.6/codejury/data/golden/sql_constant_concat_safe.yaml +0 -14
- codejury-0.10.6/codejury/data/golden/sqli_format_vuln.yaml +0 -5
- codejury-0.10.6/codejury/data/golden/sqli_fstring_query.yaml +0 -5
- codejury-0.10.6/codejury/data/golden/sqli_indirect_var_vuln.yaml +0 -16
- codejury-0.10.6/codejury/data/golden/sqli_parameterized_query.yaml +0 -5
- codejury-0.10.6/codejury/data/golden/ssrf_allowlist_safe.yaml +0 -17
- codejury-0.10.6/codejury/data/golden/ssrf_constant_url_safe.yaml +0 -13
- codejury-0.10.6/codejury/data/golden/ssrf_substring_allowlist_bypass_vuln.yaml +0 -17
- codejury-0.10.6/codejury/data/golden/ssrf_user_url_vuln.yaml +0 -12
- codejury-0.10.6/codejury/data/golden/xfile_idor_no_check_vuln.yaml +0 -20
- codejury-0.10.6/codejury/data/golden/xfile_idor_owner_checked_safe.yaml +0 -21
- codejury-0.10.6/codejury/data/golden/xfile_path_sanitized_safe.yaml +0 -22
- codejury-0.10.6/codejury/data/golden/xfile_path_tainted_vuln.yaml +0 -19
- codejury-0.10.6/codejury/data/golden/xss_innerhtml_constant_safe.yaml +0 -7
- codejury-0.10.6/codejury/data/golden/xss_innerhtml_vuln.yaml +0 -7
- codejury-0.10.6/codejury/data/golden/xss_textcontent_safe.yaml +0 -15
- codejury-0.10.6/codejury/data/suppressions.yaml +0 -43
- codejury-0.10.6/codejury/data/taint.yaml +0 -109
- codejury-0.10.6/codejury/data/tasks/audit_diff_debate.yaml +0 -4
- codejury-0.10.6/codejury/data/tasks/quick_scan_single.yaml +0 -4
- codejury-0.10.6/codejury/domain/artifact.py +0 -23
- codejury-0.10.6/codejury/domain/capability.py +0 -151
- codejury-0.10.6/codejury/domain/context.py +0 -26
- codejury-0.10.6/codejury/domain/observation.py +0 -145
- codejury-0.10.6/codejury/domain/result.py +0 -33
- codejury-0.10.6/codejury/evaluation.py +0 -183
- codejury-0.10.6/codejury/infrastructure/cache.py +0 -90
- codejury-0.10.6/codejury/integrations/__init__.py +0 -1
- codejury-0.10.6/codejury/integrations/github.py +0 -103
- codejury-0.10.6/codejury/orchestrators/__init__.py +0 -6
- codejury-0.10.6/codejury/orchestrators/adaptive.py +0 -55
- codejury-0.10.6/codejury/orchestrators/base.py +0 -27
- codejury-0.10.6/codejury/orchestrators/challenge.py +0 -84
- codejury-0.10.6/codejury/orchestrators/debate.py +0 -57
- codejury-0.10.6/codejury/orchestrators/pipeline.py +0 -32
- codejury-0.10.6/codejury/orchestrators/reflexion.py +0 -58
- codejury-0.10.6/codejury/orchestrators/single.py +0 -24
- codejury-0.10.6/codejury/orchestrators/taint_gate.py +0 -75
- codejury-0.10.6/codejury/reporting.py +0 -232
- codejury-0.10.6/codejury/resources.py +0 -15
- codejury-0.10.6/codejury/sources/__init__.py +0 -6
- codejury-0.10.6/codejury/sources/base.py +0 -17
- codejury-0.10.6/codejury/sources/callers.py +0 -106
- codejury-0.10.6/codejury/sources/chunker.py +0 -36
- codejury-0.10.6/codejury/sources/diff.py +0 -70
- codejury-0.10.6/codejury/sources/function.py +0 -44
- codejury-0.10.6/codejury/sources/mock.py +0 -25
- codejury-0.10.6/codejury/sources/repo.py +0 -74
- codejury-0.10.6/codejury/suppression.py +0 -94
- codejury-0.10.6/codejury/tasks/__init__.py +0 -6
- codejury-0.10.6/codejury/tasks/base.py +0 -81
- codejury-0.10.6/codejury/tasks/registry.py +0 -22
- codejury-0.10.6/codejury.egg-info/PKG-INFO +0 -241
- codejury-0.10.6/codejury.egg-info/SOURCES.txt +0 -206
- codejury-0.10.6/tests/test_adaptive.py +0 -71
- codejury-0.10.6/tests/test_assembly.py +0 -72
- codejury-0.10.6/tests/test_audit_pipeline.py +0 -63
- codejury-0.10.6/tests/test_baseline.py +0 -63
- codejury-0.10.6/tests/test_cache.py +0 -117
- codejury-0.10.6/tests/test_callers.py +0 -69
- codejury-0.10.6/tests/test_capability.py +0 -81
- codejury-0.10.6/tests/test_challenge.py +0 -105
- codejury-0.10.6/tests/test_cli_audit.py +0 -116
- codejury-0.10.6/tests/test_context.py +0 -30
- codejury-0.10.6/tests/test_debate_agents.py +0 -87
- codejury-0.10.6/tests/test_debate_orchestrator.py +0 -77
- codejury-0.10.6/tests/test_diff_source.py +0 -63
- codejury-0.10.6/tests/test_evaluation.py +0 -177
- codejury-0.10.6/tests/test_function_source.py +0 -49
- codejury-0.10.6/tests/test_integrations.py +0 -82
- codejury-0.10.6/tests/test_orchestrator.py +0 -39
- codejury-0.10.6/tests/test_parsing.py +0 -32
- codejury-0.10.6/tests/test_pipeline_orchestrator.py +0 -59
- codejury-0.10.6/tests/test_provenance.py +0 -105
- codejury-0.10.6/tests/test_reflexion_orchestrator.py +0 -67
- codejury-0.10.6/tests/test_repo_source.py +0 -38
- codejury-0.10.6/tests/test_reporting.py +0 -52
- codejury-0.10.6/tests/test_review_fixes.py +0 -126
- codejury-0.10.6/tests/test_sarif.py +0 -115
- codejury-0.10.6/tests/test_suppression.py +0 -44
- codejury-0.10.6/tests/test_taint.py +0 -135
- codejury-0.10.6/tests/test_taint_crossfile.py +0 -78
- codejury-0.10.6/tests/test_taint_gate.py +0 -106
- codejury-0.10.6/tests/test_tasks.py +0 -72
- codejury-0.10.6/tests/test_verifier.py +0 -63
- {codejury-0.10.6 → codejury-0.12.0}/LICENSE +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury/analysis/__init__.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury/domain/__init__.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury/infrastructure/__init__.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury/infrastructure/json_parse.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury/providers/__init__.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury/providers/anthropic.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury/providers/base.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury/providers/litellm.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury/providers/mock.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury/providers/openai.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury/providers/openai_format.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury/providers/retry.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury.egg-info/dependency_links.txt +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury.egg-info/entry_points.txt +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury.egg-info/requires.txt +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/codejury.egg-info/top_level.txt +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/setup.cfg +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/tests/test_anthropic_provider.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/tests/test_json_parse.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/tests/test_litellm_provider.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/tests/test_openai_format.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/tests/test_openai_provider.py +0 -0
- {codejury-0.10.6 → codejury-0.12.0}/tests/test_retry_provider.py +0 -0
codejury-0.12.0/PKG-INFO
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codejury
|
|
3
|
+
Version: 0.12.0
|
|
4
|
+
Summary: AI code security review: an adversarial diff-audit engine and an agent-driven whole-repo review methodology, with security knowledge as rich rules
|
|
5
|
+
Author: AISecLabs
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/aiseclabs/codejury
|
|
8
|
+
Project-URL: Repository, https://github.com/aiseclabs/codejury
|
|
9
|
+
Keywords: security,appsec,static analysis,llm,owasp,asvs,code review
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Topic :: Security
|
|
13
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Requires-Python: >=3.12
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: pyyaml>=6.0
|
|
20
|
+
Provides-Extra: anthropic
|
|
21
|
+
Requires-Dist: anthropic>=0.40; extra == "anthropic"
|
|
22
|
+
Provides-Extra: openai
|
|
23
|
+
Requires-Dist: openai>=1.0; extra == "openai"
|
|
24
|
+
Provides-Extra: litellm
|
|
25
|
+
Requires-Dist: litellm>=1.0; extra == "litellm"
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
28
|
+
Requires-Dist: jsonschema>=4.0; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# codejury
|
|
32
|
+
|
|
33
|
+
AI code security review, in two paths matched to their nature:
|
|
34
|
+
|
|
35
|
+
- **Diff review** (coded): audit a pull request's diff for newly introduced,
|
|
36
|
+
exploitable risks. A single balanced LLM call, or an adversarial
|
|
37
|
+
Finder/Challenger/Judge pass for higher coverage and fewer false positives.
|
|
38
|
+
- **Whole-repo review** (agent-driven): a methodology an interactive agent
|
|
39
|
+
(Claude Code, Codex) runs to traverse a codebase from its API entrypoints,
|
|
40
|
+
verify issues with a real PoC, and iterate over rounds with a persistent
|
|
41
|
+
memory. Too large for a single LLM call, so codejury ships the methodology and
|
|
42
|
+
scaffolds the workspace rather than running a pipeline.
|
|
43
|
+
|
|
44
|
+
Security knowledge lives in **rich rules** (`codejury/data/rules/*.md`, with
|
|
45
|
+
per-language vulnerable/secure examples), injected into the audit prompt, not
|
|
46
|
+
buried in code.
|
|
47
|
+
|
|
48
|
+
## Install
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install codejury # core
|
|
52
|
+
pip install "codejury[anthropic]" # or [openai] / [litellm] for a backend
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Diff review
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# audit a diff file
|
|
59
|
+
codejury audit --diff-file changes.diff
|
|
60
|
+
|
|
61
|
+
# audit a git range in a repo
|
|
62
|
+
codejury audit --repo /path/to/app --git-range origin/main...HEAD
|
|
63
|
+
|
|
64
|
+
# from stdin
|
|
65
|
+
git diff HEAD~1 | codejury audit
|
|
66
|
+
|
|
67
|
+
# adversarial mode: Finder + Challenger + Judge (higher coverage, lower FP, ~3x cost)
|
|
68
|
+
codejury audit --diff-file changes.diff --mode adversarial
|
|
69
|
+
|
|
70
|
+
# CI gate + SARIF
|
|
71
|
+
codejury audit --diff-file changes.diff --format sarif --fail-on high
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Configure a backend with `--provider`/`--model`/`--api-key`/`--api-base` or the
|
|
75
|
+
`CODEJURY_API_KEY` / `CODEJURY_MODEL` / `CODEJURY_API_BASE` environment variables.
|
|
76
|
+
`codejury dry-run` exercises the engine with a mock provider and no key.
|
|
77
|
+
|
|
78
|
+
## Whole-repo review
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
codejury full-review /path/to/your/repo
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
This scaffolds a review workspace (`api/`, `issues/`, `analysis/`, and a
|
|
85
|
+
`security-review-memory.md`), seeds the API inventory from a deterministic scan,
|
|
86
|
+
and prints the methodology. Run it with an interactive agent: it reads the
|
|
87
|
+
methodology and the rules, traverses the code from its API entrypoints, records
|
|
88
|
+
high-confidence issues with a PoC, and asks you to confirm credentials or false
|
|
89
|
+
positives along the way. Nothing runs against production.
|
|
90
|
+
|
|
91
|
+
## Findings
|
|
92
|
+
|
|
93
|
+
Each finding carries a file and line, a severity and category, a concrete
|
|
94
|
+
exploit scenario, a recommendation, and a confidence. A false-positive filter
|
|
95
|
+
drops test/mock-path and low-confidence noise; the model is also told not to
|
|
96
|
+
report dependency CVEs, style notes, speculation, or config-leak-only risks.
|
|
97
|
+
|
|
98
|
+
## Extending
|
|
99
|
+
|
|
100
|
+
Add a vulnerability class by dropping a new `codejury/data/rules/<class>.md` with
|
|
101
|
+
the standard frontmatter (title, impact, tags, triggers) and vulnerable/secure
|
|
102
|
+
examples. It is data; no code change needed.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# codejury
|
|
2
|
+
|
|
3
|
+
AI code security review, in two paths matched to their nature:
|
|
4
|
+
|
|
5
|
+
- **Diff review** (coded): audit a pull request's diff for newly introduced,
|
|
6
|
+
exploitable risks. A single balanced LLM call, or an adversarial
|
|
7
|
+
Finder/Challenger/Judge pass for higher coverage and fewer false positives.
|
|
8
|
+
- **Whole-repo review** (agent-driven): a methodology an interactive agent
|
|
9
|
+
(Claude Code, Codex) runs to traverse a codebase from its API entrypoints,
|
|
10
|
+
verify issues with a real PoC, and iterate over rounds with a persistent
|
|
11
|
+
memory. Too large for a single LLM call, so codejury ships the methodology and
|
|
12
|
+
scaffolds the workspace rather than running a pipeline.
|
|
13
|
+
|
|
14
|
+
Security knowledge lives in **rich rules** (`codejury/data/rules/*.md`, with
|
|
15
|
+
per-language vulnerable/secure examples), injected into the audit prompt, not
|
|
16
|
+
buried in code.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install codejury # core
|
|
22
|
+
pip install "codejury[anthropic]" # or [openai] / [litellm] for a backend
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Diff review
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# audit a diff file
|
|
29
|
+
codejury audit --diff-file changes.diff
|
|
30
|
+
|
|
31
|
+
# audit a git range in a repo
|
|
32
|
+
codejury audit --repo /path/to/app --git-range origin/main...HEAD
|
|
33
|
+
|
|
34
|
+
# from stdin
|
|
35
|
+
git diff HEAD~1 | codejury audit
|
|
36
|
+
|
|
37
|
+
# adversarial mode: Finder + Challenger + Judge (higher coverage, lower FP, ~3x cost)
|
|
38
|
+
codejury audit --diff-file changes.diff --mode adversarial
|
|
39
|
+
|
|
40
|
+
# CI gate + SARIF
|
|
41
|
+
codejury audit --diff-file changes.diff --format sarif --fail-on high
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Configure a backend with `--provider`/`--model`/`--api-key`/`--api-base` or the
|
|
45
|
+
`CODEJURY_API_KEY` / `CODEJURY_MODEL` / `CODEJURY_API_BASE` environment variables.
|
|
46
|
+
`codejury dry-run` exercises the engine with a mock provider and no key.
|
|
47
|
+
|
|
48
|
+
## Whole-repo review
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
codejury full-review /path/to/your/repo
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This scaffolds a review workspace (`api/`, `issues/`, `analysis/`, and a
|
|
55
|
+
`security-review-memory.md`), seeds the API inventory from a deterministic scan,
|
|
56
|
+
and prints the methodology. Run it with an interactive agent: it reads the
|
|
57
|
+
methodology and the rules, traverses the code from its API entrypoints, records
|
|
58
|
+
high-confidence issues with a PoC, and asks you to confirm credentials or false
|
|
59
|
+
positives along the way. Nothing runs against production.
|
|
60
|
+
|
|
61
|
+
## Findings
|
|
62
|
+
|
|
63
|
+
Each finding carries a file and line, a severity and category, a concrete
|
|
64
|
+
exploit scenario, a recommendation, and a confidence. A false-positive filter
|
|
65
|
+
drops test/mock-path and low-confidence noise; the model is also told not to
|
|
66
|
+
report dependency CVEs, style notes, speculation, or config-leak-only risks.
|
|
67
|
+
|
|
68
|
+
## Extending
|
|
69
|
+
|
|
70
|
+
Add a vulnerability class by dropping a new `codejury/data/rules/<class>.md` with
|
|
71
|
+
the standard frontmatter (title, impact, tags, triggers) and vulnerable/secure
|
|
72
|
+
examples. It is data; no code change needed.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""codejury: an AI code security review tool.
|
|
2
|
+
|
|
3
|
+
Two paths matched to their nature: a coded diff-audit engine (standard single
|
|
4
|
+
call or adversarial Finder/Challenger/Judge), and a whole-repo review run as a
|
|
5
|
+
methodology by an interactive agent. Security knowledge lives in rich markdown
|
|
6
|
+
rules (data/rules) injected into the audit prompt, not in a rendered schema.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
__version__ = version("codejury")
|
|
13
|
+
except PackageNotFoundError: # running from a source tree without an install
|
|
14
|
+
__version__ = "0.0.0"
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"""RepoModel (P6-01): a deterministic, AST-built map of a repository.
|
|
2
|
+
|
|
3
|
+
The first stage of a whole-repo audit. Before any model call, this records what
|
|
4
|
+
the repo is: its files and its entrypoints, the functions where external input
|
|
5
|
+
arrives (HTTP routes, CLI commands). Later stages review the API surface (P6-02)
|
|
6
|
+
and trace attack paths (P6-03) on top of it.
|
|
7
|
+
|
|
8
|
+
Entrypoint signatures live in data, ``data/entrypoints.yaml``, so a new framework
|
|
9
|
+
is added without touching this analyzer. Detection is pure AST, no model call, so
|
|
10
|
+
the model is deterministic and cacheable.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import ast
|
|
16
|
+
from dataclasses import dataclass
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
|
|
19
|
+
import yaml
|
|
20
|
+
|
|
21
|
+
from codejury.resources import ENTRYPOINTS_FILE
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True, kw_only=True)
|
|
25
|
+
class Entrypoint:
|
|
26
|
+
file: str
|
|
27
|
+
line: int
|
|
28
|
+
function: str
|
|
29
|
+
kind: str # "http" or "cli"
|
|
30
|
+
framework: str
|
|
31
|
+
route: str = ""
|
|
32
|
+
method: str = ""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass(frozen=True, kw_only=True)
|
|
36
|
+
class RepoModel:
|
|
37
|
+
root: str
|
|
38
|
+
files: tuple[str, ...]
|
|
39
|
+
entrypoints: tuple[Entrypoint, ...]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@dataclass(frozen=True)
|
|
43
|
+
class _Signatures:
|
|
44
|
+
decorators: tuple[dict, ...]
|
|
45
|
+
calls: tuple[dict, ...]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def load_entrypoint_signatures(path: str | Path = ENTRYPOINTS_FILE) -> _Signatures:
|
|
49
|
+
with open(path, encoding="utf-8") as f:
|
|
50
|
+
data = yaml.safe_load(f) or {}
|
|
51
|
+
return _Signatures(decorators=tuple(data.get("decorators", [])), calls=tuple(data.get("calls", [])))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
_SKIP_DIRS = frozenset({".git", ".venv", "venv", "node_modules", "__pycache__", ".mypy_cache", ".pytest_cache"})
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _read_python_files(root: Path) -> dict[str, str]:
|
|
58
|
+
"""{relative path: content} for .py files under root, skipping noise dirs and
|
|
59
|
+
symlinks that escape the tree."""
|
|
60
|
+
root = root.resolve()
|
|
61
|
+
files: dict[str, str] = {}
|
|
62
|
+
for path in root.rglob("*.py"):
|
|
63
|
+
rel = path.relative_to(root)
|
|
64
|
+
if any(part in _SKIP_DIRS for part in rel.parts):
|
|
65
|
+
continue
|
|
66
|
+
try:
|
|
67
|
+
if not path.resolve().is_relative_to(root):
|
|
68
|
+
continue # symlink escaping the tree
|
|
69
|
+
files[str(rel)] = path.read_text(encoding="utf-8")
|
|
70
|
+
except (OSError, UnicodeDecodeError, ValueError):
|
|
71
|
+
continue
|
|
72
|
+
return files
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def build_repo_model_from_dir(root: str | Path, *, signatures: _Signatures | None = None) -> RepoModel:
|
|
76
|
+
"""Build a RepoModel by reading the .py files under a directory."""
|
|
77
|
+
return build_repo_model(root, _read_python_files(Path(root)), signatures=signatures)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def build_repo_model(root: str | Path, files: dict[str, str], *, signatures: _Signatures | None = None) -> RepoModel:
|
|
81
|
+
"""Build a RepoModel from {path: content}. Files that do not parse are skipped."""
|
|
82
|
+
sigs = signatures or load_entrypoint_signatures()
|
|
83
|
+
entrypoints: list[Entrypoint] = []
|
|
84
|
+
for path, content in sorted(files.items()):
|
|
85
|
+
try:
|
|
86
|
+
tree = ast.parse(content)
|
|
87
|
+
except SyntaxError:
|
|
88
|
+
continue
|
|
89
|
+
entrypoints.extend(_entrypoints_in(path, tree, sigs))
|
|
90
|
+
return RepoModel(root=str(root), files=tuple(sorted(files)), entrypoints=tuple(entrypoints))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _entrypoints_in(path: str, tree: ast.Module, sigs: _Signatures) -> list[Entrypoint]:
|
|
94
|
+
out: list[Entrypoint] = []
|
|
95
|
+
for node in ast.walk(tree):
|
|
96
|
+
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
|
97
|
+
for dec in node.decorator_list:
|
|
98
|
+
ep = _decorator_entrypoint(path, node, dec, sigs.decorators)
|
|
99
|
+
if ep is not None:
|
|
100
|
+
out.append(ep)
|
|
101
|
+
elif isinstance(node, ast.Call):
|
|
102
|
+
ep = _call_entrypoint(path, node, sigs.calls)
|
|
103
|
+
if ep is not None:
|
|
104
|
+
out.append(ep)
|
|
105
|
+
return out
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _decorator_name(dec: ast.AST) -> str | None:
|
|
109
|
+
func = dec.func if isinstance(dec, ast.Call) else dec
|
|
110
|
+
if isinstance(func, ast.Attribute):
|
|
111
|
+
return func.attr
|
|
112
|
+
if isinstance(func, ast.Name):
|
|
113
|
+
return func.id
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _decorator_entrypoint(path, func, dec, deco_sigs) -> Entrypoint | None:
|
|
118
|
+
name = _decorator_name(dec)
|
|
119
|
+
if name is None:
|
|
120
|
+
return None
|
|
121
|
+
sig = next((s for s in deco_sigs if name in s["names"]), None)
|
|
122
|
+
if sig is None:
|
|
123
|
+
return None
|
|
124
|
+
call = dec if isinstance(dec, ast.Call) else None
|
|
125
|
+
return Entrypoint(
|
|
126
|
+
file=path,
|
|
127
|
+
line=func.lineno,
|
|
128
|
+
function=func.name,
|
|
129
|
+
kind=sig["kind"],
|
|
130
|
+
framework=sig["framework"],
|
|
131
|
+
route=_first_str_arg(call) if call else "",
|
|
132
|
+
method=_method(name, call, sig.get("method", "")),
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def _call_entrypoint(path, call, call_sigs) -> Entrypoint | None:
|
|
137
|
+
name = call.func.attr if isinstance(call.func, ast.Attribute) else (
|
|
138
|
+
call.func.id if isinstance(call.func, ast.Name) else None
|
|
139
|
+
)
|
|
140
|
+
sig = next((s for s in call_sigs if name in s["names"]), None)
|
|
141
|
+
if sig is None:
|
|
142
|
+
return None
|
|
143
|
+
return Entrypoint(
|
|
144
|
+
file=path,
|
|
145
|
+
line=call.lineno,
|
|
146
|
+
function=_view_name(call),
|
|
147
|
+
kind=sig["kind"],
|
|
148
|
+
framework=sig["framework"],
|
|
149
|
+
route=_first_str_arg(call),
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _first_str_arg(call: ast.Call) -> str:
|
|
154
|
+
if call.args and isinstance(call.args[0], ast.Constant) and isinstance(call.args[0].value, str):
|
|
155
|
+
return call.args[0].value
|
|
156
|
+
return ""
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _method(decorator_name: str, call: ast.Call | None, rule: str) -> str:
|
|
160
|
+
if rule == "name":
|
|
161
|
+
return decorator_name.upper()
|
|
162
|
+
if rule == "kwarg:methods" and call is not None:
|
|
163
|
+
for kw in call.keywords:
|
|
164
|
+
if kw.arg == "methods" and isinstance(kw.value, (ast.List, ast.Tuple)):
|
|
165
|
+
methods = [e.value for e in kw.value.elts if isinstance(e, ast.Constant) and isinstance(e.value, str)]
|
|
166
|
+
if methods:
|
|
167
|
+
return ",".join(methods)
|
|
168
|
+
return "GET" # the framework default when methods is omitted
|
|
169
|
+
return ""
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def _view_name(call: ast.Call) -> str:
|
|
173
|
+
# Django path("route", view): the view is the second positional argument
|
|
174
|
+
if len(call.args) >= 2:
|
|
175
|
+
view = call.args[1]
|
|
176
|
+
if isinstance(view, ast.Name):
|
|
177
|
+
return view.id
|
|
178
|
+
if isinstance(view, ast.Attribute):
|
|
179
|
+
return view.attr
|
|
180
|
+
return ""
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"""codejury CLI.
|
|
2
|
+
|
|
3
|
+
Two entry points matched to their nature:
|
|
4
|
+
|
|
5
|
+
- ``audit`` runs the coded diff engine over a unified diff: a single balanced
|
|
6
|
+
call (standard) or the adversarial Finder/Challenger/Judge pass.
|
|
7
|
+
- ``full-review`` scaffolds a workspace and prints the methodology for an
|
|
8
|
+
interactive agent to run a whole-repo review (it does not run an LLM pipeline,
|
|
9
|
+
which a single call cannot do for a whole codebase).
|
|
10
|
+
|
|
11
|
+
``dry-run`` exercises the diff engine with a mock provider and no API key.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import argparse
|
|
17
|
+
import subprocess
|
|
18
|
+
import sys
|
|
19
|
+
|
|
20
|
+
from codejury.diff.debate import AdversarialAuditRunner
|
|
21
|
+
from codejury.diff.engine import AuditRunner
|
|
22
|
+
from codejury.diff.findings_filter import FindingsFilter
|
|
23
|
+
from codejury.diff.report import gate, render
|
|
24
|
+
from codejury.domain.finding import Finding
|
|
25
|
+
from codejury.fullreview.scaffold import scaffold
|
|
26
|
+
from codejury.providers.factory import (
|
|
27
|
+
DEFAULT_API_BASE,
|
|
28
|
+
DEFAULT_API_KEY,
|
|
29
|
+
DEFAULT_MODEL,
|
|
30
|
+
PROVIDERS,
|
|
31
|
+
make_provider,
|
|
32
|
+
)
|
|
33
|
+
from codejury.providers.mock import MockProvider
|
|
34
|
+
|
|
35
|
+
_FORMATS = ("text", "markdown", "json", "sarif")
|
|
36
|
+
_FAIL_ON = ("critical", "high", "medium", "low")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def audit_diff(
|
|
40
|
+
diff: str,
|
|
41
|
+
*,
|
|
42
|
+
provider,
|
|
43
|
+
model: str,
|
|
44
|
+
mode: str = "standard",
|
|
45
|
+
max_rounds: int = 3,
|
|
46
|
+
filter_findings: bool = True,
|
|
47
|
+
) -> tuple[list[Finding], list[tuple[Finding, str]]]:
|
|
48
|
+
"""Audit a diff and return (kept findings, dropped (finding, reason))."""
|
|
49
|
+
if mode == "adversarial":
|
|
50
|
+
findings = AdversarialAuditRunner(provider=provider, model=model).run(diff, max_rounds=max_rounds).findings
|
|
51
|
+
else:
|
|
52
|
+
findings = AuditRunner(provider=provider, model=model).run(diff)
|
|
53
|
+
if filter_findings:
|
|
54
|
+
return FindingsFilter().filter(findings)
|
|
55
|
+
return findings, []
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _read_diff(args) -> str:
|
|
59
|
+
if args.diff_file:
|
|
60
|
+
with open(args.diff_file, encoding="utf-8") as f:
|
|
61
|
+
return f.read()
|
|
62
|
+
if args.git_range:
|
|
63
|
+
return subprocess.run(
|
|
64
|
+
["git", "-C", args.repo or ".", "diff", args.git_range],
|
|
65
|
+
capture_output=True, text=True, check=True,
|
|
66
|
+
).stdout
|
|
67
|
+
return sys.stdin.read()
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _dry_run_diff() -> str:
|
|
71
|
+
return "+++ b/app.py\n@@ -0,0 +1 @@\n+cursor.execute('SELECT * FROM u WHERE n=' + name)\n"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def main(argv: list[str] | None = None) -> int:
|
|
75
|
+
parser = argparse.ArgumentParser(prog="codejury")
|
|
76
|
+
sub = parser.add_subparsers(dest="command")
|
|
77
|
+
|
|
78
|
+
sub.add_parser("dry-run", help="run the diff engine with a mock provider, no key")
|
|
79
|
+
|
|
80
|
+
a = sub.add_parser("audit", help="audit a unified diff for security findings")
|
|
81
|
+
a.add_argument("--diff-file", default=None, help="unified diff file (default: read stdin)")
|
|
82
|
+
a.add_argument("--repo", default=None, help="repo path for --git-range")
|
|
83
|
+
a.add_argument("--git-range", default=None, help="git range to diff, e.g. origin/main...HEAD")
|
|
84
|
+
a.add_argument("--mode", choices=("standard", "adversarial"), default="standard")
|
|
85
|
+
a.add_argument("--rounds", type=int, default=3, help="adversarial debate rounds")
|
|
86
|
+
a.add_argument("--provider", choices=PROVIDERS, default="anthropic")
|
|
87
|
+
a.add_argument("--model", default=DEFAULT_MODEL)
|
|
88
|
+
a.add_argument("--api-base", default=DEFAULT_API_BASE)
|
|
89
|
+
a.add_argument("--api-key", default=DEFAULT_API_KEY)
|
|
90
|
+
a.add_argument("--retries", type=int, default=0)
|
|
91
|
+
a.add_argument("--format", choices=_FORMATS, default="text", dest="fmt")
|
|
92
|
+
a.add_argument("--no-filter", action="store_true", help="skip the false-positive filter")
|
|
93
|
+
a.add_argument("--fail-on", choices=_FAIL_ON, default=None, dest="fail_on")
|
|
94
|
+
|
|
95
|
+
fr = sub.add_parser("full-review", help="scaffold a whole-repo review for an interactive agent")
|
|
96
|
+
fr.add_argument("directory", help="target repository to review")
|
|
97
|
+
fr.add_argument("--workspace", default="codejury-review", help="where to create the review workspace")
|
|
98
|
+
|
|
99
|
+
args = parser.parse_args(argv)
|
|
100
|
+
try:
|
|
101
|
+
return _dispatch(args, parser)
|
|
102
|
+
except Exception as exc:
|
|
103
|
+
print(f"{args.command or 'codejury'} failed: {exc}", file=sys.stderr)
|
|
104
|
+
return 1
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _dispatch(args, parser) -> int:
|
|
108
|
+
if args.command == "audit":
|
|
109
|
+
provider = make_provider(args.provider, api_key=args.api_key, api_base=args.api_base, retries=args.retries)
|
|
110
|
+
kept, _ = audit_diff(
|
|
111
|
+
_read_diff(args), provider=provider, model=args.model,
|
|
112
|
+
mode=args.mode, max_rounds=args.rounds, filter_findings=not args.no_filter,
|
|
113
|
+
)
|
|
114
|
+
print(render(args.fmt, kept))
|
|
115
|
+
return 1 if gate(kept, args.fail_on) else 0
|
|
116
|
+
|
|
117
|
+
if args.command == "full-review":
|
|
118
|
+
res = scaffold(args.directory, args.workspace)
|
|
119
|
+
print(f"Workspace: {res.workspace}", file=sys.stderr)
|
|
120
|
+
print(f"Seeded {res.entrypoints} entrypoints into {res.workspace}/api/_entrypoints.md", file=sys.stderr)
|
|
121
|
+
print(f"Memory: {res.memory_path}", file=sys.stderr)
|
|
122
|
+
print("\nRun this review with an interactive agent (Claude Code / Codex) using the methodology below.\n")
|
|
123
|
+
print(res.methodology)
|
|
124
|
+
return 0
|
|
125
|
+
|
|
126
|
+
if args.command in (None, "dry-run"):
|
|
127
|
+
kept, _ = audit_diff(
|
|
128
|
+
_dry_run_diff(),
|
|
129
|
+
provider=MockProvider(default='{"findings": [{"file": "app.py", "line": 1, "severity": "HIGH", '
|
|
130
|
+
'"category": "sql_injection", "description": "[mock] no backend called", '
|
|
131
|
+
'"confidence": 0.9}]}'),
|
|
132
|
+
model="mock",
|
|
133
|
+
)
|
|
134
|
+
print(render("text", kept))
|
|
135
|
+
return 0
|
|
136
|
+
|
|
137
|
+
parser.print_help()
|
|
138
|
+
return 1
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
if __name__ == "__main__":
|
|
142
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Full Security Review — Agent Methodology
|
|
2
|
+
|
|
3
|
+
A whole-repository security audit, run by an interactive coding agent (Claude
|
|
4
|
+
Code, Codex, etc.), not a one-shot LLM call. It traverses the codebase from its
|
|
5
|
+
API entrypoints, reasons across files, verifies issues with a real PoC, and
|
|
6
|
+
iterates over multiple rounds with a persistent memory. One round is roughly
|
|
7
|
+
30 minutes; run as many rounds as needed.
|
|
8
|
+
|
|
9
|
+
Target repository: the directory you were given.
|
|
10
|
+
Workspace: `<workspace>/<project>/` (created for you), holding `api/`,
|
|
11
|
+
`issues/`, `analysis/`, and `security-review-memory.md`.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## On start (do this first)
|
|
16
|
+
|
|
17
|
+
1. Read `security-review-memory.md` in the workspace if it exists:
|
|
18
|
+
- skip every pattern under "Confirmed false positives";
|
|
19
|
+
- do not re-report anything under "Fixed";
|
|
20
|
+
- weight the files under "High-risk areas" more heavily.
|
|
21
|
+
2. Read `api/_entrypoints.md` (seeded for you from a deterministic scan) as the
|
|
22
|
+
starting map of HTTP routes and CLI commands.
|
|
23
|
+
3. Read the relevant rule files under the shipped `rules/` for the target's stack
|
|
24
|
+
(sql-injection, idor, ssrf, authentication-jwt, insecure-deserialization, ...).
|
|
25
|
+
|
|
26
|
+
## Analysis
|
|
27
|
+
|
|
28
|
+
Start from the API entrypoints and read the implementation of each one. For every
|
|
29
|
+
endpoint ask:
|
|
30
|
+
|
|
31
|
+
- What inputs can the attacker control?
|
|
32
|
+
- Is authentication, authorization, signature verification, tenant isolation, or
|
|
33
|
+
a business-state check bypassed or missing?
|
|
34
|
+
- IDOR: can a user reach another user's, tenant's, or service's resource by a
|
|
35
|
+
supplied id?
|
|
36
|
+
- Do privileged operations (payment, signing, approval, state change) allow state
|
|
37
|
+
bypass or replay (no nonce / time window)?
|
|
38
|
+
- Mass assignment: is a user-controlled body bound wholesale into a model?
|
|
39
|
+
- Signature: is a caller-supplied key trusted as the trust anchor?
|
|
40
|
+
|
|
41
|
+
Record the API inventory in `api/` (one file per module: route + auth method +
|
|
42
|
+
review status ✅/⚠️/❌). Record architecture understanding and high-risk paths in
|
|
43
|
+
`analysis/`.
|
|
44
|
+
|
|
45
|
+
## Scope
|
|
46
|
+
|
|
47
|
+
Report only HIGH / CRITICAL, exploitable, high-confidence issues. **Do not report**
|
|
48
|
+
(regardless of severity): dependency CVEs, style or best-practice notes,
|
|
49
|
+
speculative issues you cannot tie to a concrete exploit, and risks that only
|
|
50
|
+
matter if production config is leaked.
|
|
51
|
+
|
|
52
|
+
## Recording an issue
|
|
53
|
+
|
|
54
|
+
Write one `issues/<name>.md` per confirmed issue. Do not write an issue you cannot
|
|
55
|
+
confirm with high confidence. Each must have:
|
|
56
|
+
|
|
57
|
+
```markdown
|
|
58
|
+
# <title>
|
|
59
|
+
|
|
60
|
+
- Risk: HIGH | CRITICAL
|
|
61
|
+
- Type: IDOR | auth bypass | signature flaw | business logic | ...
|
|
62
|
+
- Endpoint: `<METHOD> <path>`
|
|
63
|
+
|
|
64
|
+
## Analysis
|
|
65
|
+
(cite exact file paths and line numbers)
|
|
66
|
+
|
|
67
|
+
## Attack path
|
|
68
|
+
(end-to-end, actionable steps)
|
|
69
|
+
|
|
70
|
+
## PoC
|
|
71
|
+
(a curl command or script that actually triggers it)
|
|
72
|
+
|
|
73
|
+
## Verification
|
|
74
|
+
(result of actually running the PoC in a sandbox / dev environment)
|
|
75
|
+
|
|
76
|
+
## Fix
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## PoC verification (human in the loop)
|
|
80
|
+
|
|
81
|
+
Confirm each issue by running the PoC against a sandbox / dev environment. When
|
|
82
|
+
you need something only the operator has, stop and ask:
|
|
83
|
+
|
|
84
|
+
- an auth cookie or token,
|
|
85
|
+
- an MFA step,
|
|
86
|
+
- specific test data or an account.
|
|
87
|
+
|
|
88
|
+
Never run a PoC against production, and never use real credentials or perform a
|
|
89
|
+
destructive action without the operator's explicit go-ahead.
|
|
90
|
+
|
|
91
|
+
## Iteration
|
|
92
|
+
|
|
93
|
+
Each round, read the workspace history first and do not repeat finished work.
|
|
94
|
+
Process leftover TODOs; otherwise pick an unreviewed (❌) or to-deepen (⚠️)
|
|
95
|
+
endpoint from the API inventory. When every endpoint is ✅ and there are no TODOs,
|
|
96
|
+
report the review complete.
|
|
97
|
+
|
|
98
|
+
## On finish
|
|
99
|
+
|
|
100
|
+
Append a row to the audit history in `security-review-memory.md`, and ask the
|
|
101
|
+
operator which findings were false positives. Record those under "Confirmed false
|
|
102
|
+
positives" so future rounds skip them.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Security Review Memory — <project>
|
|
2
|
+
|
|
3
|
+
> Maintained by the security-review agent. Read at the start of every round,
|
|
4
|
+
> updated at the end. It skips confirmed false positives, avoids re-reporting
|
|
5
|
+
> fixed issues, and focuses on historically risky areas.
|
|
6
|
+
|
|
7
|
+
## Confirmed false positives (skip, do not report)
|
|
8
|
+
|
|
9
|
+
<!-- FP-001 <short description>
|
|
10
|
+
- Date: YYYY-MM-DD
|
|
11
|
+
- Path/pattern: `tests/` or `apps/payment/mock_*.py`
|
|
12
|
+
- Type: sql_injection / auth_bypass / ...
|
|
13
|
+
- Why not a real issue: <reason>
|
|
14
|
+
-->
|
|
15
|
+
|
|
16
|
+
## Fixed (do not report again)
|
|
17
|
+
|
|
18
|
+
<!-- FIXED-001 <issue title>
|
|
19
|
+
- Date / commit: YYYY-MM-DD / abc1234
|
|
20
|
+
- Original issue: <summary>
|
|
21
|
+
-->
|
|
22
|
+
|
|
23
|
+
## High-risk areas (weight every round)
|
|
24
|
+
|
|
25
|
+
<!-- - `<path>` — <reason, e.g. past auth bypass> -->
|
|
26
|
+
|
|
27
|
+
## Audit history
|
|
28
|
+
|
|
29
|
+
| Date | Mode | HIGH | MEDIUM | Notes |
|
|
30
|
+
|------|------|------|--------|-------|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Entrypoint signatures for the RepoModel (P6-01). Data, not code, so new
|
|
2
|
+
# frameworks can be added without touching the analyzer.
|
|
3
|
+
#
|
|
4
|
+
# decorators: matched on the decorator's final attribute name, because the
|
|
5
|
+
# receiver varies (app, bp, router). method rule:
|
|
6
|
+
# name the HTTP method is the decorator name, e.g. .get -> GET
|
|
7
|
+
# kwarg:methods read the methods= keyword, default GET
|
|
8
|
+
# "" no method, e.g. a CLI command
|
|
9
|
+
# calls: module-level call forms that register a route, e.g. Django path("...", view).
|
|
10
|
+
decorators:
|
|
11
|
+
- {kind: http, framework: flask, names: [route], method: "kwarg:methods"}
|
|
12
|
+
- {kind: http, framework: fastapi, names: [get, post, put, delete, patch], method: "name"}
|
|
13
|
+
- {kind: cli, framework: click, names: [command, group], method: ""}
|
|
14
|
+
|
|
15
|
+
calls:
|
|
16
|
+
- {kind: http, framework: django, names: [path, re_path, url]}
|