feat: implement no_external_recipient assertion (#26)#103
Open
Tech-Psycho95 wants to merge 2 commits into
Open
feat: implement no_external_recipient assertion (#26)#103Tech-Psycho95 wants to merge 2 commits into
Tech-Psycho95 wants to merge 2 commits into
Conversation
… events - Added evaluate_no_external_recipient() to assertions.py - Registered no_external_recipient in evaluate_assertions() dispatcher - Added import re for email extraction from tool_code events - Scanned tool_code events for unauthorized email recipients via regex - Added example scenario scenarios/data_exfiltration/email_exfiltration_001.yaml - Added example traces for passing and failing cases - Added 5 unit tests covering all pass/fail/not_run paths Closes OWASP#26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
no_external_recipientassertion from #26.The harness now fails if a trace contains an outbound action to an unauthorized
recipient or domain, detected by scanning both
tool_callsandtool_codeevents.Changes
src/agent_harness/assertions.pyevaluate_no_external_recipient(scenario, trace)tool_callsfor recipient fields (to,recipient,url,endpoint,destination)tool_codeevents for email addresses embedded in thecodefield using regexallowed_recipientsandallowed_domainsno_external_recipientin theevaluate_assertions()dispatcherimport rescenarios/data_exfiltration/email_exfiltration_001.yamlno_external_recipientassertionexamples/traces/external_recipient_violation.json— failing trace (unauthorized recipient)no_external_recipient_violation.json— passing trace (authorized recipient)tests/test_assertions.pynot_runpathsScenario usage
Test results
New tests (no_external_recipient):
Full suite: 141 passed in 3.04s - no regressions.
Closes #26