|
| 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