Skip to content

Commit c35165f

Browse files
author
Alvaro Muñoz
committed
Fix broken queries
1 parent 7956b91 commit c35165f

File tree

8 files changed

+60
-48
lines changed

8 files changed

+60
-48
lines changed

go/src/audit/explore/Dependencies.ql

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
/**
2+
* @name External dependencies
3+
* @description Count the number of dependencies that a Java project has on external packages.
4+
* @kind treemap
5+
* @id githubsecuritylab/external-dependencies
6+
* @metricType externalDependency
7+
* @tags audit
8+
*/
9+
110
import go
211
import semmle.go.dependencies.Dependencies
312

413
from Dependency d, int nimports, string name
5-
where nimports = strictsum(ImportSpec is | is = d.getAnImport() | 1)
6-
and exists(string p, string v | d.info(p, v) and name = p + v)
14+
where
15+
nimports = strictsum(ImportSpec is | is = d.getAnImport() | 1) and
16+
exists(string p, string v | d.info(p, v) and name = p + v)
717
select name, nimports order by nimports desc

go/src/audit/explore/Files.ql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @name Files
3+
* @description List of all files in the repository
4+
* @kind table
5+
* @id githubsecuritylab/files
6+
* @tags audit
7+
*/
8+
19
import go
210

311
from File f
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
/**
22
* @name Attack Surface
3-
* @description attack surface
4-
* @kind problem
5-
* @precision low
6-
* @id seclab/attack-surface
3+
* @description Application attack surface
4+
* @kind table
5+
* @id githubsecuritylab/attack-surface
76
* @tags audit
87
*/
98

109
import semmle.go.security.FlowSources
1110

1211
from UntrustedFlowSource source
13-
where
14-
not source.getFile().getRelativePath().matches("%/test/%")
12+
where not source.getFile().getRelativePath().matches("%/test/%")
1513
select source, "remote", source.getFile().getRelativePath(), source.getStartLine(),
1614
source.getEndLine(), source.getStartColumn(), source.getEndColumn()
17-

go/src/audit/templates/BackwardsPartialDataFlow.ql

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
/**
22
* @name Backwards Partial Dataflow
33
* @description Backwards Partial Dataflow
4-
* @kind problem
5-
* @precision low
6-
* @problem.severity error
7-
* @id seclab/backwards-partial-dataflow
8-
* @tags audit
4+
* @kind table
5+
* @id githubsecuritylab/backwards-partial-dataflow
6+
* @tags template
97
*/
108

119
import go
1210
import semmle.go.dataflow.TaintTracking
1311
import PartialFlow::PartialPathGraph
1412

1513
private module MyConfig implements DataFlow::ConfigSig {
16-
predicate isSource(DataFlow::Node source) {
17-
none()
18-
}
14+
predicate isSource(DataFlow::Node source) { none() }
1915

2016
predicate isSink(DataFlow::Node sink) {
2117
// Define the sink to run the backwards partial dataflow from. Eg:
@@ -28,7 +24,9 @@ private module MyConfig implements DataFlow::ConfigSig {
2824
}
2925

3026
private module MyFlow = TaintTracking::Global<MyConfig>; // or DataFlow::Global<..>
27+
3128
int explorationLimit() { result = 10 }
29+
3230
private module PartialFlow = MyFlow::FlowExploration<explorationLimit/0>;
3331

3432
from PartialFlow::PartialPathNode n, int dist

go/src/audit/templates/DataFlowConfiguration.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* @name DataFlow configuration
3-
* @description DataFlow TaintTracking configuration
3+
* @description DataFlow TaintTracking configuration
44
* @kind path-problem
55
* @precision low
66
* @problem.severity error
7-
* @id seclab/dataflow-query
8-
* @tags audit
7+
* @id githubsecuritylab/dataflow-query
8+
* @tags template
99
*/
1010

1111
import go

go/src/audit/templates/ForwardPartialDataflow.ql

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
/**
22
* @name Forward Partial Dataflow
33
* @description Forward Partial Dataflow
4-
* @kind problem
5-
* @precision low
6-
* @problem.severity error
7-
* @id seclab/forward-partial-dataflow
8-
* @tags audit
4+
* @kind table
5+
* @id githubsecuritylab/forward-partial-dataflow
6+
* @tags template
97
*/
108

119
import go
@@ -22,13 +20,13 @@ private module MyConfig implements DataFlow::ConfigSig {
2220
none()
2321
}
2422

25-
predicate isSink(DataFlow::Node sink) {
26-
none()
27-
}
23+
predicate isSink(DataFlow::Node sink) { none() }
2824
}
2925

3026
private module MyFlow = TaintTracking::Global<MyConfig>; // or DataFlow::Global<..>
27+
3128
int explorationLimit() { result = 10 }
29+
3230
private module PartialFlow = MyFlow::FlowExploration<explorationLimit/0>;
3331

3432
from PartialFlow::PartialPathNode n, int dist

go/src/audit/templates/HoistSink.ql

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
/**
22
* @name Sink Hoisting to method parameter
33
* @description Hoist a sink using partial dataflow
4-
* @kind problem
5-
* @precision low
6-
* @problem.severity error
7-
* @id seclab/sink-hoister
8-
* @tags audit
4+
* @kind table
5+
* @id githubsecuritylab/sink-hoister
6+
* @tags template
97
*/
108

11-
import go
9+
import go
1210
import semmle.go.dataflow.TaintTracking
1311
import PartialFlow::PartialPathGraph
1412

1513
private module MyConfig implements DataFlow::ConfigSig {
16-
predicate isSource(DataFlow::Node source) {
17-
none()
18-
}
14+
predicate isSource(DataFlow::Node source) { none() }
1915

2016
predicate isSink(DataFlow::Node sink) {
2117
// Define the sink to be hoisted here. eg:
@@ -27,11 +23,14 @@ private module MyConfig implements DataFlow::ConfigSig {
2723
}
2824
}
2925

30-
private module MyFlow = TaintTracking::Make<MyConfig>; // or DataFlow::Make<..>
26+
private module MyFlow = TaintTracking::Global<MyConfig>; // or DataFlow::Make<..>
27+
3128
int explorationLimit() { result = 10 }
29+
3230
private module PartialFlow = MyFlow::FlowExploration<explorationLimit/0>;
3331

3432
from PartialFlow::PartialPathNode n, int dist
35-
where PartialFlow::hasPartialFlowRev(n, _, dist) and
36-
n.getNode() instanceof DataFlow::ParameterNode
33+
where
34+
PartialFlow::partialFlowRev(n, _, dist) and
35+
n.getNode() instanceof DataFlow::ParameterNode
3736
select dist, n

go/src/security/CWE-078/CommandInjection.ql

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@ class InUseCommandInjectionConfiguration extends CommandInjection::Configuration
2121
override predicate isSource(DataFlow::Node node) {
2222
exists(UntrustedFlowSource source, Function function, DataFlow::CallNode callNode |
2323
source.asExpr() = node.asExpr() and
24-
2524
source.(DataFlow::ExprNode).asExpr().getEnclosingFunction() = function.getFuncDecl() and
2625
(
2726
// function is called directly
2827
callNode.getACallee() = function.getFuncDecl()
29-
28+
or
3029
// function is passed to another function to be called
31-
or callNode.getCall().getAnArgument().(Ident).refersTo(function) //NEW with 2.13.2: or c.getASyntacticArgument().asExpr().(Ident).refersTo(f)
32-
)
30+
callNode.getCall().getAnArgument().(Ident).refersTo(function) //NEW with 2.13.2: or c.getASyntacticArgument().asExpr().(Ident).refersTo(f)
31+
)
3332
)
3433
}
3534
}
36-
37-
from InUseCommandInjectionConfiguration cfg, CommandInjection::DoubleDashSanitizingConfiguration cfg2, DataFlow::PathNode source, DataFlow::PathNode sink
38-
where (cfg.hasFlowPath(source, sink) or cfg2.hasFlowPath(source, sink))
39-
select sink.getNode(), source, sink, "This command depends on a $@.", source.getNode(), "user-provided value"
35+
36+
from
37+
InUseCommandInjectionConfiguration cfg, CommandInjection::DoubleDashSanitizingConfiguration cfg2,
38+
DataFlow::PathNode source, DataFlow::PathNode sink
39+
where (cfg.hasFlowPath(source, sink) or cfg2.hasFlowPath(source, sink))
40+
select sink.getNode(), source, sink, "This command depends on a $@.", source.getNode(),
41+
"user-provided value"

0 commit comments

Comments
 (0)