[File] Python file misdetection
Christos Zoulas
christos at zoulas.com
Wed Nov 30 20:30:38 UTC 2022
> On Nov 29, 2022, at 5:37 PM, Steve Grubb <sgrubb at redhat.com> wrote:
>
> Hello,
>
> I run across a case where python files get misdetected when an import
> statement is commented out. For example:
>
> #!/bin/sh
> echo DEFANGED.1
> exit
> #!/usr/bin/python3
> import os
> os.system("ls")
>
> file --mime-type example.py
> example.py: text/x-script.python
>
> #!/usr/bin/python3
> #import os
> os.system("ls")
>
> file --mime-type example.py
> example.py: text/x-objective-c
>
> It matches Objective-C with a strength of 25, where #!\040/usr/bin/python has
> a strength of 15. It would seem very plausible for someone to occassionally
> comment out an import statement. I'm wondering why an Objective-C construct
> would be stronger than a python shebang (which should be conclusive)? Not
> sure which of the two to adjust.
What version of file is that? I can't reproduce it.
Best,
christos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <https://mailman.astron.com/pipermail/file/attachments/20221130/3b842b40/attachment.asc>
More information about the File
mailing list