Skip to content

smbserver: fix reserved name check on Python 3.15 - #5269

Merged
gpotter2 merged 4 commits into
secdev:masterfrom
b84330808:fix-smbserver-is-reserved-py315
Nov 11, 2026
Merged

gpotter2 merged 4 commits into
secdev:masterfrom
b84330808:fix-smbserver-is-reserved-py315

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

Description

PurePath.is_reserved() was removed in Python 3.15. On Windows, SMB_Server.lookup_file() calls it for every CREATE request, so the SMB server raises AttributeError on 3.15. This uses os.path.isreserved() on Python 3.13+ (where it exists) and keeps is_reserved() for older versions.

Added a test in test/scapy/layers/smbclientserver.uts that serves a file to the Scapy smbclient, which goes through lookup_file().

AI-Assisted: yes (Claude Opus 5.5). I ran the tests locally and reviewed the change.

PurePath.is_reserved() was removed in Python 3.15, so on Windows every
CREATE request made SMB_Server.lookup_file() raise AttributeError. Use
os.path.isreserved() on Python 3.13+.

AI-Assisted: yes (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@gpotter2

gpotter2 commented Nov 4, 2026

Copy link
Copy Markdown
Member

Could you define a util function in scapy/compat.py that does that? Thanks

Comment thread test/scapy/layers/smbclientserver.uts Resolved
@gpotter2

gpotter2 commented Nov 4, 2026

Copy link
Copy Markdown
Member

Thanks for the PR, I made minor comments.

Add isreserved() to scapy/compat.py, with a unit test, and use it in
smbserver. Move the smbserver test next to the other server tests and
use run_smbserver() like they do.

AI-Assisted: yes (Claude Opus 5.5)
@b84330808

Copy link
Copy Markdown
Contributor Author

Done: added isreserved() to scapy/compat.py and moved the test next to the other server tests. Thanks!

Comment thread scapy/compat.py Resolved
Reserved names only exist on Windows, so the helper returns False
elsewhere and smbserver no longer checks WINDOWS itself.

AI-Assisted: yes (Claude Opus 5.5)
Comment thread scapy/compat.py Resolved
@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.58%. Comparing base (56ba487) to head (d5fa627).
⚠️ Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
scapy/compat.py 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5269      +/-   ##
==========================================
+ Coverage   80.55%   80.58%   +0.03%     
==========================================
  Files         375      375              
  Lines       98399    98519     +120     
==========================================
+ Hits        79263    79391     +128     
+ Misses      19136    19128       -8     
Files with missing lines Coverage Δ
scapy/layers/smbserver.py 74.67% <100.00%> (+2.06%) ⬆️
scapy/compat.py 85.07% <81.81%> (-0.64%) ⬇️

... and 22 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 065c136 into secdev:master Nov 11, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants