scapy icon indicating copy to clipboard operation
scapy copied to clipboard

Pcapreader() does not work with PosixPath and WindowsPath fix #3596

Open tanwirahmad opened this issue 3 years ago • 10 comments

Pcapreader() works fine even if the provided filename is in PosixPath or WindowsPath type. Fix #3596

I don't know if this PR requires unit tests. If it does, then please guide me where they can be added.

tanwirahmad avatar May 04 '22 15:05 tanwirahmad

I didn't know about os.PathLike. It makes perfect sense!

tanwirahmad avatar May 05 '22 18:05 tanwirahmad

Anyway, not sure it was a good idea after all, since Python 2.7 lacks os.PathLike... Sorry about that :-/

p-l- avatar May 06 '22 07:05 p-l-

Codecov Report

Merging #3597 (4b1e061) into master (53c764d) will increase coverage by 0.02%. The diff coverage is 100.00%.

:exclamation: Current head 4b1e061 differs from pull request most recent head 4f39755. Consider uploading reports for the commit 4f39755 to get more accurate results

@@            Coverage Diff             @@
##           master    #3597      +/-   ##
==========================================
+ Coverage   86.19%   86.21%   +0.02%     
==========================================
  Files         284      296      +12     
  Lines       64874    67082    +2208     
==========================================
+ Hits        55915    57832    +1917     
- Misses       8959     9250     +291     
Impacted Files Coverage Δ
scapy/libs/six.py 70.55% <100.00%> (+0.17%) :arrow_up:
scapy/utils.py 77.27% <100.00%> (+0.44%) :arrow_up:
scapy/__init__.py 74.54% <0.00%> (-8.48%) :arrow_down:
scapy/layers/ntlm.py 44.76% <0.00%> (-5.40%) :arrow_down:
scapy/layers/dhcp.py 82.67% <0.00%> (-4.61%) :arrow_down:
scapy/layers/smb.py 32.37% <0.00%> (-2.12%) :arrow_down:
scapy/layers/sctp.py 95.12% <0.00%> (-1.57%) :arrow_down:
scapy/layers/tls/crypto/cipher_block.py 96.24% <0.00%> (-1.42%) :arrow_down:
scapy/contrib/automotive/scanner/enumerator.py 90.93% <0.00%> (-1.33%) :arrow_down:
scapy/automaton.py 74.23% <0.00%> (-1.30%) :arrow_down:
... and 169 more

codecov[bot] avatar May 06 '22 12:05 codecov[bot]

Sorry, I think it is better to come back to your first option, it was better since it would have worked with Python 2 directly, am I wrong?

p-l- avatar May 06 '22 13:05 p-l-

Unsure this PR is really necessary: there are quite a few ways to get the full absolute path from the Path... object :/

gpotter2 avatar May 09 '22 07:05 gpotter2

@gpotter2 The purpose of this PR is to support os.PathLike objects for Pcapreader(). IMHO, they are more useful than strings based paths.

@p-l- My first option would not have worked for Python 2 because the pathlib library was added in Python 3.4

tanwirahmad avatar May 09 '22 12:05 tanwirahmad

@gpotter2 your call

p-l- avatar May 10 '22 14:05 p-l-

(As for the doc build failure: https://github.com/sphinx-doc/sphinx/issues/10710)

gpotter2 avatar Jul 26 '22 20:07 gpotter2

I am unsure this PR is necessary.

guedou avatar Jul 27 '22 05:07 guedou

I kinda agree. Are we really going to update every function in Scapy to support path stuff, when in one call you can get the absolute path

gpotter2 avatar Jul 27 '22 07:07 gpotter2

I am closing this PR as Scapy maintainers seem that it is not necessary.

guedou avatar Oct 08 '22 10:10 guedou