Skip to content

can, isotp, soft: threding fixes and small buffer device support impr…#4983

Open
BenGardiner wants to merge 1 commit intosecdev:masterfrom
BenGardiner:soft_isotp_socket_fixes
Open

can, isotp, soft: threding fixes and small buffer device support impr…#4983
BenGardiner wants to merge 1 commit intosecdev:masterfrom
BenGardiner:soft_isotp_socket_fixes

Conversation

@BenGardiner
Copy link
Copy Markdown
Contributor

Checklist :

  • [Y] If you are new to Scapy: I have checked CONTRIBUTING.md (esp. section submitting-pull-requests)
  • [Y] I squashed commits belonging together
  • [Y] I added unit tests or explained why they are not relevant
  • [Y] I executed the regression tests (using tox)
  • [Y] If the PR is still not finished, please create a Draft Pull Request
  • [Y] This PR uses (partially) AI-generated code. If so:
    • [Y] I ensured the generated code follows the internal concepts of scapy
    • [Y] This PR has a test coverage > 90%
    • [Y] I reviewed every generated line

I understand that failing to mention the use of AI may result in a ban. (We do not forbid it, but you must play fair. Be warned !)

  • try harder to drain before close to avoid warnings
  • unit tests to trigger issues encountered using soft sockt with slcan, candle, cantact on windows
  • threading robustness improvements
  • robustness improvements when using can adapters with small buffers
  • improvements to the heuristics for detecting can adapters with no hardware filtering

cc @polybassa this is the isotp soft socket stuff extrated from PR #4961

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 68.67470% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.15%. Comparing base (1745d39) to head (31c2c4b).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
scapy/contrib/cansocket_python_can.py 71.42% 14 Missing ⚠️
scapy/contrib/isotp/isotp_soft_socket.py 64.70% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4983      +/-   ##
==========================================
- Coverage   80.27%   77.15%   -3.12%     
==========================================
  Files         382      364      -18     
  Lines       94349    94071     -278     
==========================================
- Hits        75736    72583    -3153     
- Misses      18613    21488    +2875     
Files with missing lines Coverage Δ
scapy/contrib/isotp/isotp_soft_socket.py 63.01% <64.70%> (-21.52%) ⬇️
scapy/contrib/cansocket_python_can.py 80.10% <71.42%> (-3.43%) ⬇️

... and 304 files with indirect coverage changes

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

log_automotive.info("Target reset")
if self.reset_handler:
self.reset_handler()
result = self.reset_handler()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you please elaborate this use case a little more?

Why would the reset handler be used as a socket factory.

The proper place for a socket factory would be the reconnect handler.

By treating the reset_handler as socket factory would implicitly combine two different use cases.

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.

Yeo. It is use error to pass in a socket factory for a reset handler. It can happen though . I've done it . I added this to guard against that particular foot gun. So that if someone screws up the long running scanner call there is a graceful recovery and some results can still be obtained

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry. This code goes even against the mypy typing. reset_handler should be a Callable[[], None]. If a user ignores that, it's not the job of the reset_target function to fix this.

If you think such a check is necessary, I would recommend a validation function inside init.
This would force someone to pass proper callbacks.

IMHO, the proper way would be to rely on the typechecker, and if someone disrespects that, he has to take care about the consequences.

@polybassa
Copy link
Copy Markdown
Contributor

Looks good, beside this one comment.

Thanks for the PR.

…ovements

* try harder to drain before close to avoid warnings
* unit tests to trigger issues encountered using soft sockt with slcan,
  candle, cantact on windows
* threading robustness improvements
* robustness improvements when using can adapters with small buffers
* improvements to the heuristics for detecting can adapters with no
  hardware filtering
@BenGardiner BenGardiner force-pushed the soft_isotp_socket_fixes branch from 4299c6b to 31c2c4b Compare April 28, 2026 21:28
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