Skip to content

Commit cf094c2

Browse files
committed
adjust which folders are seen as exported to remove an FP
1 parent 848b24c commit cf094c2

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

python/ql/lib/semmle/python/frameworks/Setuptools.qll

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ module Setuptools {
1919
* Gets a file or folder that is exported by a library.
2020
*/
2121
private Container getALibraryExportedContainer() {
22-
result = setupFile().getParent()
22+
// a child folder of the root that has a setup.py file
23+
result = setupFile().getParent().(Folder).getAFolder() and
24+
// where the folder has __init__.py file
25+
exists(result.(Folder).getFile("__init__.py")) and
26+
// and is not a test folder
27+
not result.(Folder).getBaseName() = ["test", "tests", "testing"]
2328
or
2429
// child of a library exported container
2530
result = getALibraryExportedContainer().getAChildContainer() and
@@ -29,9 +34,7 @@ module Setuptools {
2934
or
3035
// or a folder with an __init__.py file
3136
exists(result.(Folder).getFile("__init__.py"))
32-
) and
33-
// that is not a test folder
34-
not result.(Folder).getBaseName() = ["test", "tests", "testing"]
37+
)
3538
}
3639

3740
/**
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import os
2+
3+
def unsafe_setup(name):
4+
os.system("ping " + name) # $result=OK - this is inside a setyp script, so it's fine.

0 commit comments

Comments
 (0)