Skip to content

Commit c521b98

Browse files
committed
feat(go): Update dependencies and add GHSL sources and sinks implementation
1 parent 2c21736 commit c521b98

File tree

4 files changed

+101
-10
lines changed

4 files changed

+101
-10
lines changed

go/lib/codeql-pack.lock.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/dataflow:
5-
version: 1.1.8
5+
version: 2.0.4
66
codeql/go-all:
7-
version: 3.0.1
7+
version: 4.2.2
88
codeql/mad:
9-
version: 1.0.14
9+
version: 1.0.20
1010
codeql/ssa:
11-
version: 1.0.14
11+
version: 1.0.20
1212
codeql/threat-models:
13-
version: 1.0.14
13+
version: 1.0.20
1414
codeql/tutorial:
15-
version: 1.0.14
15+
version: 1.0.20
1616
codeql/typetracking:
17-
version: 1.0.14
17+
version: 2.0.4
1818
codeql/util:
19-
version: 2.0.1
19+
version: 2.0.7
2020
compiled: false

go/lib/ghsl.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import go
2+
import ghsl.Utils
3+
import ghsl.LocalSources
4+
import ghsl.Sinks

go/lib/ghsl/Sinks.qll

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
private import go
2+
private import semmle.go.dataflow.DataFlow
3+
private import semmle.go.security.CommandInjectionCustomizations
4+
private import semmle.go.security.OpenUrlRedirectCustomizations
5+
private import semmle.go.security.ReflectedXssCustomizations
6+
private import semmle.go.security.RequestForgeryCustomizations
7+
private import semmle.go.security.SqlInjectionCustomizations
8+
private import semmle.go.security.UnsafeUnzipSymlinkCustomizations
9+
private import semmle.go.security.XPathInjectionCustomizations
10+
private import semmle.go.security.ZipSlipCustomizations
11+
12+
/**
13+
* List of all the sinks that we want to check.
14+
*/
15+
class AllSinks extends DataFlow::Node {
16+
private string sink;
17+
18+
AllSinks() {
19+
this instanceof CommandInjection::Sink and
20+
sink = "command-injection"
21+
or
22+
this instanceof OpenUrlRedirect::Sink and
23+
sink = "open-url-redirect"
24+
or
25+
this instanceof ReflectedXss::Sink and
26+
sink = "reflected-xss"
27+
or
28+
this instanceof RequestForgery::Sink and
29+
sink = "request-forgery"
30+
or
31+
this instanceof SqlInjection::Sink and
32+
sink = "sql-injection"
33+
or
34+
this instanceof UnsafeUnzipSymlink::EvalSymlinksSink and
35+
sink = "unsafe-unzip"
36+
or
37+
this instanceof XPathInjection::Sink and
38+
sink = "xpath-injection"
39+
or
40+
this instanceof ZipSlip::Sink and
41+
sink = "zip-slip"
42+
}
43+
44+
/**
45+
* Gets the sink sink type.
46+
*/
47+
string sinkType() { result = sink }
48+
}

go/lib/ghsl/Utils.qll

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
1-
import go
2-
import semmle.go.frameworks.stdlib.Fmt
1+
private import go
2+
private import semmle.go.dataflow.DataFlow
3+
private import semmle.go.dataflow.TaintTracking
4+
private import semmle.go.frameworks.stdlib.Fmt
5+
6+
/**
7+
* Find Node at Location
8+
*/
9+
predicate filterByLocation(DataFlow::Node node, string relative_path, int linenumber) {
10+
node.getLocation().getFile().getRelativePath() = relative_path and
11+
node.getLocation().getStartLine() = linenumber
12+
}
13+
14+
/**
15+
* List of all the souces
16+
*/
17+
class AllSources extends DataFlow::Node {
18+
private string threatmodel;
19+
20+
AllSources() {
21+
this instanceof RemoteFlowSource::Range and
22+
threatmodel = "remote"
23+
or
24+
this instanceof LocalSources and
25+
threatmodel = "local"
26+
}
27+
28+
/**
29+
* Gets the source threat model.
30+
*/
31+
string getThreatModel() { result = threatmodel }
32+
}
33+
34+
/**
35+
* Local sources
36+
*/
37+
class LocalSources extends DataFlow::Node {
38+
LocalSources() {
39+
this.(SourceNode).getThreatModel() = "local"
40+
}
41+
}
342

443
class DynamicStrings extends DataFlow::Node {
544
DynamicStrings() {

0 commit comments

Comments
 (0)