-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathPartialPathsFromSink.ql
More file actions
59 lines (50 loc) · 1.69 KB
/
PartialPathsFromSink.ql
File metadata and controls
59 lines (50 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* @name Partial Path Query from Sink
* @kind path-problem
* @problem.severity warning
* @security-severity 1.0
* @sub-severity low
* @precision low
* @id py/debugging/partial-path-from-sink
* @tags debugging
*/
import python
import semmle.python.dataflow.new.DataFlow
import semmle.python.dataflow.new.TaintTracking
import semmle.python.Concepts
import semmle.python.dataflow.new.RemoteFlowSources
import semmle.python.dataflow.new.BarrierGuards
import semmle.python.ApiGraphs
// Helpers
private import ghsl.Helpers
// Manual Sinks
class ManualSinks extends DataFlow::Node {
ManualSinks() { this = API::moduleImport("any").getMember("any").getACall() }
}
/**
* Partial Graph module interface
*/
module RemoteFlowsConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { none() }
predicate isSink(DataFlow::Node sink) {
// List of dangerous sinks (SQL Injection, Command Injection, etc.)
dangerousSinks(sink)
or
// List of manually added sinks (above)
sink instanceof ManualSinks
}
}
// Set the limit of the exloration depth
int explorationLimit() { result = 10 }
module RemoteFlows = DataFlow::Global<RemoteFlowsConfig>;
module RemoteFlowsPartial = RemoteFlows::FlowExplorationRev<explorationLimit/0>;
import RemoteFlowsPartial::PartialPathGraph
from RemoteFlowsPartial::PartialPathNode source, RemoteFlowsPartial::PartialPathNode sink
where RemoteFlowsPartial::partialFlow(source, sink, _)
/// Filter by location
// and findByLocation(source.getNode(), "app.py", 20)
//
/// Filter by Function Parameters
// and functionParameters(source.getNode())
//
select sink.getNode(), source, sink, "Partial Graph $@.", source.getNode(), "user-provided value"