Skip to content

Commit 5b90eb0

Browse files
authored
Merge pull request #277 from niveshdandyan/add-full-event-log
feat: add full event log export for all scan events
2 parents 796bd33 + 2c33451 commit 5b90eb0

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

agentic_security/probe_actor/fuzzer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ async def perform_single_shot_scan(
423423

424424
yield ScanResult.status_msg("Scan completed.")
425425
fuzzer_state.export_failures("failures.csv")
426+
fuzzer_state.export_full_log("full_scan_log.csv")
426427

427428

428429
async def perform_many_shot_scan(
@@ -558,6 +559,7 @@ async def perform_many_shot_scan(
558559

559560
yield ScanResult.status_msg("Scan completed.")
560561
fuzzer_state.export_failures("failures.csv")
562+
fuzzer_state.export_full_log("full_scan_log.csv")
561563

562564

563565
def scan_router(

agentic_security/probe_actor/state.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,45 @@ def export_failures(self, filename: str = "failures.csv"):
4545
failure_data, columns=["module", "prompt", "status_code", "content"]
4646
)
4747
df.to_csv(filename, index=False)
48+
49+
def export_full_log(self, filename: str = "full_scan_log.csv"):
50+
"""Export a complete log of all events (errors, refusals, and successful outputs)"""
51+
log_data = []
52+
53+
# Add errors
54+
for module_name, prompt, status_code, error_msg in self.errors:
55+
log_data.append({
56+
"event_type": "error",
57+
"module": module_name,
58+
"prompt": prompt,
59+
"status_code": status_code,
60+
"content": error_msg,
61+
"refused": None,
62+
})
63+
64+
# Add refusals
65+
for module_name, prompt, status_code, response_text in self.refusals:
66+
log_data.append({
67+
"event_type": "refusal",
68+
"module": module_name,
69+
"prompt": prompt,
70+
"status_code": status_code,
71+
"content": response_text,
72+
"refused": True,
73+
})
74+
75+
# Add all outputs (including successful ones)
76+
for module_name, prompt, response_text, refused in self.outputs:
77+
# Skip if already logged as refusal to avoid duplicates
78+
if not refused:
79+
log_data.append({
80+
"event_type": "success",
81+
"module": module_name,
82+
"prompt": prompt,
83+
"status_code": 200,
84+
"content": response_text,
85+
"refused": False,
86+
})
87+
88+
df = pd.DataFrame(log_data)
89+
df.to_csv(filename, index=False)

0 commit comments

Comments
 (0)