88from storage .store import ReviewStore
99
1010
11- async def _new_store (tmp_path ):
11+ def _new_store (tmp_path ):
1212 return ReviewStore (db_url = f"sqlite:///{ tmp_path } /cr.db" )
1313
1414
1515async def test_task_roundtrip (tmp_path ):
16- store = await _new_store (tmp_path )
16+ store = _new_store (tmp_path )
1717 task_id = await store .create_task ("fixture" , "clean.diff" , "local" , True )
1818 assert task_id
1919 await store .update_task (task_id , status = "completed" ,
@@ -26,7 +26,7 @@ async def test_task_roundtrip(tmp_path):
2626
2727
2828async def test_bundle_collects_all_tables (tmp_path ):
29- store = await _new_store (tmp_path )
29+ store = _new_store (tmp_path )
3030 task_id = await store .create_task ("fixture" , "x.diff" , "local" , True )
3131 await store .add_sandbox_run (task_id , script = "check_security.py" , category = "security" ,
3232 status = "ok" , exit_code = 0 , duration_ms = 12 , timed_out = False ,
@@ -51,23 +51,30 @@ async def test_bundle_collects_all_tables(tmp_path):
5151
5252
5353async def test_store_redacts_evidence_and_output (tmp_path ):
54- store = await _new_store (tmp_path )
54+ store = _new_store (tmp_path )
5555 task_id = await store .create_task ("fixture" , "x.diff" , "local" , True )
5656 secret = "sk-abcdefghijklmnopqrstuvwxyz123456"
5757 await store .add_findings (task_id , [Finding (
5858 severity = "critical" , category = "secret_leak" , file = "a.py" , line = 3 ,
5959 title = "secret" , evidence = f'key = "{ secret } "' , confidence = 0.95 )], status = "reported" )
6060 await store .add_sandbox_run (task_id , script = "s.py" , category = "c" , status = "ok" ,
6161 exit_code = 0 , duration_ms = 1 , timed_out = False ,
62- stdout_summary = f"leaked { secret } " , stderr_summary = "" , error_type = "" )
62+ stdout_summary = f"leaked { secret } " ,
63+ stderr_summary = f"stderr leaked { secret } " , error_type = "" )
64+ await store .add_filter_event (task_id , target = f"/path/{ secret } /config" ,
65+ decision = "deny" , rule = "risk_secret" , reason = "file contains secret" )
66+ await store .add_report (task_id , {"conclusion" : "blocked" }, f"# Report\n Secret was: { secret } " )
6367 bundle = await store .get_task_bundle (task_id )
6468 assert secret not in bundle ["findings" ][0 ]["evidence" ]
6569 assert secret not in bundle ["sandbox_runs" ][0 ]["stdout_summary" ]
70+ assert secret not in bundle ["sandbox_runs" ][0 ]["stderr_summary" ]
71+ assert secret not in bundle ["filter_events" ][0 ]["target" ]
72+ assert secret not in bundle ["report" ]["report_md" ]
6673 await store .close ()
6774
6875
6976async def test_unknown_task_returns_none_task (tmp_path ):
70- store = await _new_store (tmp_path )
77+ store = _new_store (tmp_path )
7178 bundle = await store .get_task_bundle ("nope" )
7279 assert bundle ["task" ] is None
7380 await store .close ()
0 commit comments