Skip to content

Commit 14a4f62

Browse files
committed
feat(java): Add PartialPaths queries
1 parent d1645e7 commit 14a4f62

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @name Partial Path Query from Sink
3+
* @kind path-problem
4+
* @problem.severity warning
5+
* @security-severity 1.0
6+
* @sub-severity low
7+
* @precision low
8+
* @id java/debugging/partial-path-from-sink
9+
* @tags debugging
10+
*/
11+
12+
import java
13+
import ghsl
14+
import semmle.code.java.dataflow.DataFlow
15+
import semmle.code.java.dataflow.FlowSources
16+
import semmle.code.java.dataflow.TaintTracking
17+
18+
// Partial Graph
19+
private module RemoteFlowsConfig implements DataFlow::ConfigSig {
20+
predicate isSource(DataFlow::Node source) { any() }
21+
22+
predicate isSink(DataFlow::Node sink) { sink instanceof AllSinks }
23+
}
24+
25+
int explorationLimit() { result = 10 }
26+
27+
private module RemoteFlows = DataFlow::Global<RemoteFlowsConfig>;
28+
29+
private module RemoteFlowsPartial = RemoteFlows::FlowExplorationRev<explorationLimit/0>;
30+
31+
private import RemoteFlowsPartial::PartialPathGraph
32+
33+
from RemoteFlowsPartial::PartialPathNode source, RemoteFlowsPartial::PartialPathNode sink
34+
where
35+
// Only show sinks from a certain file
36+
findByLocation(sink.getNode(), "File.java", _) and
37+
// Only show sources that match our criteria
38+
// checkSource(source.getNode()) and
39+
// Partical Path
40+
RemoteFlowsPartial::partialFlow(source, sink, _)
41+
select sink.getNode(), source, sink, "Partial Graph $@.", source.getNode(), "user-provided value"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* @name Partial Path Query from Source
3+
* @kind path-problem
4+
* @problem.severity warning
5+
* @security-severity 1.0
6+
* @sub-severity low
7+
* @precision low
8+
* @id java/debugging/partial-path-from-source
9+
* @tags debugging
10+
*/
11+
12+
import java
13+
import ghsl
14+
import semmle.code.java.dataflow.DataFlow
15+
import semmle.code.java.dataflow.FlowSources
16+
import semmle.code.java.dataflow.TaintTracking
17+
18+
class Sources extends AllSources {
19+
Sources() {
20+
findByLocation(this, "App.java", _)
21+
}
22+
23+
}
24+
25+
// Partial Graph
26+
private module RemoteFlowsConfig implements DataFlow::ConfigSig {
27+
predicate isSource(DataFlow::Node source) { source instanceof Sources }
28+
29+
predicate isSink(DataFlow::Node sink) { none() }
30+
}
31+
32+
int explorationLimit() { result = 10 }
33+
34+
private module RemoteFlows = DataFlow::Global<RemoteFlowsConfig>;
35+
36+
private module RemoteFlowsPartial = RemoteFlows::FlowExplorationFwd<explorationLimit/0>;
37+
38+
private import RemoteFlowsPartial::PartialPathGraph
39+
40+
from RemoteFlowsPartial::PartialPathNode source, RemoteFlowsPartial::PartialPathNode sink
41+
where
42+
// Filter by file (line number)
43+
// findByLocation(source.getNode(), "File.java", _) and
44+
// Filter by if the sink is callable
45+
// isCallable(sink.getNode()) and
46+
// Perform Partial Flow query
47+
RemoteFlowsPartial::partialFlow(source, sink, _)
48+
select sink.getNode(), source, sink, "Partial Graph $@.", source.getNode(), "user-provided value"

0 commit comments

Comments
 (0)