Skip to content

sendpfast: report a missing tcpreplay instead of UnboundLocalError - #5204

Merged
gpotter2 merged 1 commit into
secdev:masterfrom
kratos0718:sendpfast-missing-tcpreplay
Sep 28, 2026
Merged

gpotter2 merged 1 commit into
secdev:masterfrom
kratos0718:sendpfast-missing-tcpreplay

Conversation

@kratos0718

Copy link
Copy Markdown
Contributor

Description

When tcpreplay can't be started (not installed, or a wrong conf.prog.tcpreplay), Popen raises before cmd is bound, and the finally block's cmd.communicate() then raises UnboundLocalError. ContextManagerSubprocess only recognises EnvironmentError, so instead of "Could not execute tcpreplay, is it installed?" the user gets "execution failed" and an UnboundLocalError traceback.

This initialises cmd to None and only reads the process output when it actually started. With conf.prog.tcpreplay = "/nonexistent/tcpreplay" the log now says Could not execute /nonexistent/tcpreplay, is it installed?. I added a regression test next to the existing sendpfast one that fails on master and passes with the change. test/regression.uts otherwise gives the same results as on master locally (2 unrelated local failures in both).

AI-assisted: Claude Code helped find the issue and draft the change. I reviewed the code and ran the tests myself.

When tcpreplay could not be started, Popen raised before cmd was bound
and the finally block's cmd.communicate() raised UnboundLocalError.
ContextManagerSubprocess then logged "execution failed" with that
error instead of "Could not execute tcpreplay, is it installed?".

AI-Assisted: yes (Claude Code)
@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 22.22222% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.87%. Comparing base (c5e9a5b) to head (99136db).

Files with missing lines Patch % Lines
scapy/sendrecv.py 22.22% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5204      +/-   ##
==========================================
- Coverage   81.16%   80.87%   -0.29%     
==========================================
  Files         393      393              
  Lines       98107    98109       +2     
==========================================
- Hits        79629    79349     -280     
- Misses      18478    18760     +282     
Files with missing lines Coverage Δ
scapy/sendrecv.py 87.05% <22.22%> (-0.11%) ⬇️

... and 21 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gpotter2
gpotter2 merged commit 15ce846 into secdev:master Sep 28, 2026
22 of 23 checks passed
@gpotter2

Copy link
Copy Markdown
Member

Thanks for the PR !

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.

2 participants