[File] Misidentified python script
Steve Grubb
sgrubb at redhat.com
Mon Mar 2 15:14:00 UTC 2020
Hello,
I run across an issue that I find curious. On linux systems, we have a file:
/usr/share/tracker/stop-words/stopwords.en
It is detected as "Python script, ASCII text executable". It looks like this:
home
if
else
elseif
then
for
next
case
and
assert
def
del
elif
exec
from
global
import
uses
lambda
not
or
pass
Some of the debug output looks like this:
48: > 0 search/8192,=import,""]
0 == 0 = 1
bb=[0x5650bf4da2d0,4655], 0 [b=0x5650bf4da2d0,4655], [o=0, c=1]
mget(type=17, flag=0, offset=0, o=0, nbytes=4655, il=0, nc=0)
mget/96 @0:
a\na's\nable\nabout\nabove\naccording\naccordingly\nacross\nactually\nafter\nafterwards\nagain\nagainst\nain\000
49: >> 0 regex,=^from[ \t\f\r\n]+([A-Za-z0-9_]|\.)+[ \t\f\r\n]
+import.*$,"Python script text executable"]
0 == 0 = 1
[try ascmagic 1]
I can see how it is matching the from and then import. However, I think the
regex is assuming too much. You cannot have a carriage return between from
and import and whatever python module you are importing. You get something
like this if you do:
File "./test.py", line 2
import
^
SyntaxError: invalid syntax
I don't know if anything can be done about this since it is suspiciously
close to actual code. But, I thought this should be pointed out.
Best Regards,
-Steve
More information about the File
mailing list