mirror of
https://github.com/github/codeql.git
synced 2026-03-31 12:48:17 +02:00
Python: Add test for missing relative import in namespace packages
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
from . import helper
|
||||
|
||||
def use_relative():
|
||||
tainted = source()
|
||||
helper.process(tainted)
|
||||
@@ -0,0 +1,2 @@
|
||||
def process(value):
|
||||
sink(value) #$ MISSING: prints=source
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import python
|
||||
import semmle.python.dataflow.new.DataFlow
|
||||
import semmle.python.dataflow.new.TaintTracking
|
||||
import utils.test.InlineExpectationsTest
|
||||
|
||||
private module TestConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node node) {
|
||||
node.(DataFlow::CallCfgNode).getFunction().asCfgNode().(NameNode).getId() = "source"
|
||||
}
|
||||
|
||||
predicate isSink(DataFlow::Node node) {
|
||||
exists(DataFlow::CallCfgNode call |
|
||||
call.getFunction().asCfgNode().(NameNode).getId() = "sink" and
|
||||
node = call.getArg(0)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private module TestFlow = TaintTracking::Global<TestConfig>;
|
||||
|
||||
module FlowTest implements TestSig {
|
||||
string getARelevantTag() { result = "prints" }
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(DataFlow::Node sink |
|
||||
TestFlow::flow(_, sink) and
|
||||
tag = "prints" and
|
||||
location = sink.getLocation() and
|
||||
value = "source" and
|
||||
element = sink.toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
import MakeTest<FlowTest>
|
||||
Reference in New Issue
Block a user