Skip to content

autorun: clear builtins._ so a False result does not fail later tests - #5221

Open
DresslerFrank wants to merge 1 commit into
secdev:masterfrom
DresslerFrank:remove-dead-session-save
Open

DresslerFrank wants to merge 1 commit into
secdev:masterfrom
DresslerFrank:remove-dead-session-save

Conversation

@DresslerFrank

Copy link
Copy Markdown
Contributor

Tests that followed one ending in False were reported as failed. UTScapy uses the last expression value as the result, and a successful assert does not replace it. autorun_commands did not delete builtins._ at the start of a test, so the previous False stayed in place.

The following uts file demonstrates the problem:

% False result carries over

+ Carry over

= one
False

= two
assert True

two raises nothing and does not set a new value, but it was reported as failed.

The purpose of the scapy_session code was unclear. The history showed that it belonged to session save/load, removed in 13621d1 ("Sessions removed"), and that this code had been left behind. Searching the rest of the tree for those leftovers by hand looked like more work than it was worth, and a good fit for AI, so I asked it to find and remove them as well.

Fixes #5220

AI-Assisted: yes (Grok 4.7)

Tests that followed one ending in False were reported as failed. UTScapy
uses the last expression value as the result, and a successful assert
does not replace it. autorun_commands did not delete builtins._ at the
start of a test, so the previous False stayed in place.

The following uts file demonstrates the problem:

    % False result carries over

    + Carry over

    = one
    False

    = two
    assert True

`two` raises nothing and does not set a new value, but it was reported
as failed.

The purpose of the scapy_session code was unclear. The history showed
that it belonged to session save/load, removed in 13621d1 ("Sessions
removed"), and that this code had been left behind. Searching the rest
of the tree for those leftovers by hand looked like more work than it
was worth, and a good fit for AI, so I asked it to find and remove
them as well.

Fixes secdev#5220

AI-Assisted: yes (Grok 4.7)

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread scapy/autorun.py
interp = ScapyAutorunInterpreter(locals=my_globals)
try:
del builtins.__dict__["scapy_session"]["_"]
del builtins.__dict__["_"]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the important change that fixes UTScapy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UTS incorrectly shows some tests as failing following an unsccessful test

1 participant