1313from .policy_evaluator import evaluate_policy
1414from .policy_parser import build_policy
1515from .presentation import effective_policy_evaluation , summarize_violations_by_rule
16- from .report_json import render_report_json , render_summary_json
16+ from .report_json import render_policy_json , render_report_json , render_summary_json
1717from .report_md import render_report_markdown
1818from .report_sarif import render_report_sarif_output
1919from .risk import evaluate_risks , summarize_risks
@@ -31,7 +31,10 @@ def build_parser() -> argparse.ArgumentParser:
3131 "compare" ,
3232 help = "Compare two dependency inputs and write JSON and/or Markdown reports." ,
3333 description = "Compare two local dependency inputs and emit deterministic reports." ,
34- epilog = "Exit codes: 0 = success/no blocking violations, 1 = blocking policy violations, 2 = usage/parse/runtime error." ,
34+ epilog = (
35+ "Exit codes: 0 = success/no blocking violations, "
36+ "1 = blocking policy violations, 2 = usage/parse/runtime error."
37+ ),
3538 )
3639 compare .add_argument ("--before" , type = Path , required = True , help = "Path to the before input." )
3740 compare .add_argument ("--after" , type = Path , required = True , help = "Path to the after input." )
@@ -59,7 +62,18 @@ def build_parser() -> argparse.ArgumentParser:
5962 help = "Select a PEP 735 [dependency-groups] group when a compared input is pyproject.toml." ,
6063 )
6164 compare .add_argument ("--out-json" , type = Path , default = None , help = "Write a JSON report to this path." )
62- compare .add_argument ("--summary-json" , type = Path , default = None , help = "Write the stable JSON summary object to this path." )
65+ compare .add_argument (
66+ "--summary-json" ,
67+ type = Path ,
68+ default = None ,
69+ help = "Write the stable JSON summary object to this path." ,
70+ )
71+ compare .add_argument (
72+ "--policy-json" ,
73+ type = Path ,
74+ default = None ,
75+ help = "Write policy evaluation and policy finding JSON sections to this path." ,
76+ )
6377 compare .add_argument ("--out-md" , type = Path , default = None , help = "Write a Markdown report to this path." )
6478 compare .add_argument (
6579 "--out-sarif" ,
@@ -91,7 +105,10 @@ def build_parser() -> argparse.ArgumentParser:
91105 compare .add_argument (
92106 "--enrich-pypi" ,
93107 action = "store_true" ,
94- help = "Opt-in PyPI provenance and integrity enrichment. Default behavior remains offline with no network access." ,
108+ help = (
109+ "Opt-in PyPI provenance and integrity enrichment. "
110+ "Default behavior remains offline with no network access."
111+ ),
95112 )
96113 compare .add_argument (
97114 "--pypi-timeout" ,
@@ -139,8 +156,17 @@ def run_compare(args: argparse.Namespace) -> int:
139156 scorecard_timeout = getattr (args , "scorecard_timeout" , DEFAULT_SCORECARD_TIMEOUT_SECONDS )
140157
141158 summary_json = getattr (args , "summary_json" , None )
142- if args .out_json is None and summary_json is None and args .out_md is None and args .out_sarif is None :
143- raise ValueError ("at least one of --out-json, --summary-json, --out-md, or --out-sarif must be provided" )
159+ policy_json = getattr (args , "policy_json" , None )
160+ if (
161+ args .out_json is None
162+ and summary_json is None
163+ and policy_json is None
164+ and args .out_md is None
165+ and args .out_sarif is None
166+ ):
167+ raise ValueError (
168+ "at least one of --out-json, --summary-json, --policy-json, --out-md, or --out-sarif must be provided"
169+ )
144170 if pypi_timeout <= 0 :
145171 raise ValueError ("--pypi-timeout must be a positive number of seconds." )
146172 if scorecard_timeout <= 0 :
@@ -232,6 +258,8 @@ def run_compare(args: argparse.Namespace) -> int:
232258 _write_text (args .out_json , render_report_json (report ))
233259 if summary_json is not None :
234260 _write_text (summary_json , render_summary_json (report ))
261+ if policy_json is not None :
262+ _write_text (policy_json , render_policy_json (report ))
235263 if args .out_md is not None :
236264 _write_text (args .out_md , render_report_markdown (report ))
237265 if args .out_sarif is not None :
0 commit comments