Skip to content

Commit 60970ff

Browse files
authored
Merge pull request github#16571 from owen-mc/go/remove-step-duplication-in-config
Go: remove flow step duplication in configs
2 parents c820234 + b2deea4 commit 60970ff

File tree

8 files changed

+29
-133
lines changed

8 files changed

+29
-133
lines changed

go/ql/lib/semmle/go/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ abstract class FunctionModel extends Function {
214214
}
215215

216216
/**
217-
* Holds if the additional step from `src` to `sink` should be included in all
217+
* Holds if the additional step from `node1` to `node2` should be included in all
218218
* global taint flow configurations.
219219
*/
220-
predicate defaultAdditionalTaintStep(DataFlow::Node src, DataFlow::Node sink, string model) {
221-
localAdditionalTaintStep(src, sink, model)
220+
predicate defaultAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2, string model) {
221+
localAdditionalTaintStep(node1, node2, model)
222222
}
223223

224224
/**

go/ql/lib/semmle/go/security/CleartextLogging.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ module CleartextLogging {
8484
or
8585
// taint steps that do not include flow through fields. Field reads would produce FPs due to
8686
// the additional taint step above that taints whole structs from individual field writes.
87-
TaintTracking::localTaintStep(src, trg) and
87+
TaintTracking::defaultAdditionalTaintStep(src, trg, _) and
8888
not TaintTracking::fieldReadStep(src, trg) and
8989
// Also exclude protobuf field fetches, since they amount to single field reads.
9090
not any(Protobuf::GetMethod gm).taintStep(src, trg)

go/ql/lib/semmle/go/security/OpenUrlRedirect.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ module OpenUrlRedirect {
7171

7272
predicate isAdditionalFlowStep(DataFlow::Node pred, DataFlow::Node succ) {
7373
// taint steps that do not include flow through fields
74-
TaintTracking::localTaintStep(pred, succ) and not TaintTracking::fieldReadStep(pred, succ)
74+
TaintTracking::defaultAdditionalTaintStep(pred, succ, _) and
75+
not TaintTracking::fieldReadStep(pred, succ)
7576
or
7677
// explicit extra taint steps for this query
7778
any(AdditionalStep s).hasTaintStep(pred, succ)

go/ql/src/experimental/frameworks/DecompressionBombsCustomizations.qll

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,6 @@ module DecompressionBombs {
140140
}
141141

142142
override predicate isAdditionalFlowStep(DataFlow::Node fromNode, DataFlow::Node toNode) {
143-
exists(DataFlow::FieldReadNode fi |
144-
fi.getType().hasQualifiedName("github.com/klauspost/compress/zip", "Reader")
145-
|
146-
fromNode = fi.getBase() and
147-
toNode = fi
148-
)
149-
or
150143
exists(Method m, DataFlow::CallNode call |
151144
m.hasQualifiedName("github.com/klauspost/compress/zip", "File", ["Open", "OpenRaw"]) and
152145
call = m.getACall()

go/ql/test/experimental/CWE-522-DecompressionBombs/DecompressionBombs.expected

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@ edges
2525
| test.go:130:33:130:40 | filename | test.go:130:2:130:41 | ... := ...[0] | provenance | Config |
2626
| test.go:132:3:132:19 | ... := ...[0] | test.go:134:37:134:38 | rc | provenance | |
2727
| test.go:132:12:132:12 | f | test.go:132:3:132:19 | ... := ...[0] | provenance | MaD:8 |
28-
| test.go:143:2:143:59 | ... := ...[0] | test.go:144:20:144:37 | implicit dereference | provenance | |
28+
| test.go:143:2:143:59 | ... := ...[0] | test.go:145:12:145:12 | f | provenance | |
2929
| test.go:143:51:143:58 | filename | test.go:143:2:143:59 | ... := ...[0] | provenance | Config |
30-
| test.go:144:20:144:37 | implicit dereference | test.go:144:20:144:37 | implicit dereference | provenance | |
31-
| test.go:144:20:144:37 | implicit dereference | test.go:144:20:144:37 | implicit read of field Reader | provenance | |
32-
| test.go:144:20:144:37 | implicit dereference | test.go:144:20:144:37 | implicit read of field Reader | provenance | Config |
33-
| test.go:144:20:144:37 | implicit read of field Reader | test.go:145:12:145:12 | f | provenance | |
3430
| test.go:145:12:145:12 | f | test.go:145:12:145:19 | call to Open | provenance | Config |
3531
| test.go:145:12:145:19 | call to Open | test.go:147:37:147:38 | rc | provenance | |
3632
| test.go:158:19:158:22 | definition of file | test.go:159:25:159:28 | file | provenance | |
@@ -215,8 +211,6 @@ nodes
215211
| test.go:134:37:134:38 | rc | semmle.label | rc |
216212
| test.go:143:2:143:59 | ... := ...[0] | semmle.label | ... := ...[0] |
217213
| test.go:143:51:143:58 | filename | semmle.label | filename |
218-
| test.go:144:20:144:37 | implicit dereference | semmle.label | implicit dereference |
219-
| test.go:144:20:144:37 | implicit read of field Reader | semmle.label | implicit read of field Reader |
220214
| test.go:145:12:145:12 | f | semmle.label | f |
221215
| test.go:145:12:145:19 | call to Open | semmle.label | call to Open |
222216
| test.go:147:37:147:38 | rc | semmle.label | rc |

go/ql/test/library-tests/semmle/go/frameworks/Echo/OpenRedirect.expected

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
edges
2-
| test.go:172:2:172:6 | definition of param | test.go:173:20:173:24 | param | provenance | |
3-
| test.go:172:2:172:6 | definition of param | test.go:173:20:173:24 | param | provenance | Config |
4-
| test.go:172:11:172:32 | call to Param | test.go:172:2:172:6 | definition of param | provenance | |
5-
| test.go:172:11:172:32 | call to Param | test.go:172:2:172:6 | definition of param | provenance | Config |
6-
| test.go:178:2:178:6 | definition of param | test.go:182:24:182:28 | param | provenance | |
7-
| test.go:178:2:178:6 | definition of param | test.go:182:24:182:28 | param | provenance | Config |
8-
| test.go:178:11:178:32 | call to Param | test.go:178:2:178:6 | definition of param | provenance | |
9-
| test.go:178:11:178:32 | call to Param | test.go:178:2:178:6 | definition of param | provenance | Config |
2+
| test.go:172:11:172:32 | call to Param | test.go:173:20:173:24 | param | provenance | |
3+
| test.go:178:11:178:32 | call to Param | test.go:182:24:182:28 | param | provenance | |
104
| test.go:182:24:182:28 | param | test.go:182:20:182:28 | ...+... | provenance | Config |
11-
| test.go:190:2:190:4 | definition of url | test.go:193:21:193:23 | url | provenance | |
12-
| test.go:190:2:190:4 | definition of url | test.go:193:21:193:23 | url | provenance | Config |
13-
| test.go:190:9:190:26 | star expression | test.go:190:2:190:4 | definition of url | provenance | |
14-
| test.go:190:9:190:26 | star expression | test.go:190:2:190:4 | definition of url | provenance | Config |
155
| test.go:190:9:190:26 | star expression | test.go:190:10:190:26 | selection of URL | provenance | Config |
6+
| test.go:190:9:190:26 | star expression | test.go:193:21:193:23 | url | provenance | |
167
| test.go:190:10:190:26 | selection of URL | test.go:190:9:190:26 | star expression | provenance | Config |
178
| test.go:193:21:193:23 | url | test.go:193:21:193:32 | call to String | provenance | Config |
189
nodes
19-
| test.go:172:2:172:6 | definition of param | semmle.label | definition of param |
2010
| test.go:172:11:172:32 | call to Param | semmle.label | call to Param |
2111
| test.go:173:20:173:24 | param | semmle.label | param |
22-
| test.go:178:2:178:6 | definition of param | semmle.label | definition of param |
2312
| test.go:178:11:178:32 | call to Param | semmle.label | call to Param |
2413
| test.go:182:20:182:28 | ...+... | semmle.label | ...+... |
2514
| test.go:182:24:182:28 | param | semmle.label | param |
26-
| test.go:190:2:190:4 | definition of url | semmle.label | definition of url |
2715
| test.go:190:9:190:26 | star expression | semmle.label | star expression |
2816
| test.go:190:10:190:26 | selection of URL | semmle.label | selection of URL |
2917
| test.go:193:21:193:23 | url | semmle.label | url |

go/ql/test/query-tests/Security/CWE-312/CleartextLogging.expected

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,30 @@
11
edges
2-
| klog.go:20:3:25:3 | range statement[1] | klog.go:20:13:20:19 | definition of headers | provenance | |
3-
| klog.go:20:3:25:3 | range statement[1] | klog.go:20:13:20:19 | definition of headers | provenance | Config |
4-
| klog.go:20:13:20:19 | definition of headers | klog.go:21:27:21:33 | headers | provenance | |
5-
| klog.go:20:13:20:19 | definition of headers | klog.go:21:27:21:33 | headers | provenance | Config |
2+
| klog.go:20:3:25:3 | range statement[1] | klog.go:21:27:21:33 | headers | provenance | |
63
| klog.go:20:30:20:37 | selection of Header | klog.go:20:3:25:3 | range statement[1] | provenance | Config |
7-
| klog.go:21:4:24:4 | range statement[1] | klog.go:21:11:21:16 | definition of header | provenance | |
8-
| klog.go:21:4:24:4 | range statement[1] | klog.go:21:11:21:16 | definition of header | provenance | Config |
9-
| klog.go:21:11:21:16 | definition of header | klog.go:22:15:22:20 | header | provenance | |
10-
| klog.go:21:11:21:16 | definition of header | klog.go:22:15:22:20 | header | provenance | Config |
4+
| klog.go:21:4:24:4 | range statement[1] | klog.go:22:15:22:20 | header | provenance | |
115
| klog.go:21:27:21:33 | headers | klog.go:21:4:24:4 | range statement[1] | provenance | Config |
126
| klog.go:28:13:28:20 | selection of Header | klog.go:28:13:28:41 | call to Get | provenance | Config |
137
| overrides.go:9:9:9:16 | password | overrides.go:13:14:13:23 | call to String | provenance | |
148
| passwords.go:8:12:8:12 | definition of x | passwords.go:9:14:9:14 | x | provenance | |
15-
| passwords.go:8:12:8:12 | definition of x | passwords.go:9:14:9:14 | x | provenance | Config |
169
| passwords.go:30:8:30:15 | password | passwords.go:8:12:8:12 | definition of x | provenance | |
1710
| passwords.go:34:28:34:35 | password | passwords.go:34:14:34:35 | ...+... | provenance | Config |
18-
| passwords.go:36:2:36:5 | definition of obj1 | passwords.go:39:14:39:17 | obj1 | provenance | |
19-
| passwords.go:36:2:36:5 | definition of obj1 | passwords.go:39:14:39:17 | obj1 | provenance | Config |
20-
| passwords.go:36:10:38:2 | struct literal | passwords.go:36:2:36:5 | definition of obj1 | provenance | |
21-
| passwords.go:36:10:38:2 | struct literal | passwords.go:36:2:36:5 | definition of obj1 | provenance | Config |
11+
| passwords.go:36:10:38:2 | struct literal | passwords.go:39:14:39:17 | obj1 | provenance | |
2212
| passwords.go:37:13:37:13 | x | passwords.go:36:10:38:2 | struct literal | provenance | Config |
23-
| passwords.go:41:2:41:5 | definition of obj2 | passwords.go:44:14:44:17 | obj2 | provenance | |
24-
| passwords.go:41:2:41:5 | definition of obj2 | passwords.go:44:14:44:17 | obj2 | provenance | Config |
25-
| passwords.go:41:10:43:2 | struct literal | passwords.go:41:2:41:5 | definition of obj2 | provenance | |
26-
| passwords.go:41:10:43:2 | struct literal | passwords.go:41:2:41:5 | definition of obj2 | provenance | Config |
13+
| passwords.go:41:10:43:2 | struct literal | passwords.go:44:14:44:17 | obj2 | provenance | |
2714
| passwords.go:42:6:42:13 | password | passwords.go:41:10:43:2 | struct literal | provenance | Config |
2815
| passwords.go:46:6:46:9 | definition of obj3 | passwords.go:47:14:47:17 | obj3 | provenance | |
29-
| passwords.go:46:6:46:9 | definition of obj3 | passwords.go:47:14:47:17 | obj3 | provenance | Config |
3016
| passwords.go:48:11:48:18 | password | passwords.go:46:6:46:9 | definition of obj3 | provenance | Config |
31-
| passwords.go:85:2:85:14 | definition of utilityObject | passwords.go:88:14:88:26 | utilityObject | provenance | |
32-
| passwords.go:85:2:85:14 | definition of utilityObject | passwords.go:88:14:88:26 | utilityObject | provenance | Config |
33-
| passwords.go:85:19:87:2 | struct literal | passwords.go:85:2:85:14 | definition of utilityObject | provenance | |
34-
| passwords.go:85:19:87:2 | struct literal | passwords.go:85:2:85:14 | definition of utilityObject | provenance | Config |
17+
| passwords.go:85:19:87:2 | struct literal | passwords.go:88:14:88:26 | utilityObject | provenance | |
3518
| passwords.go:86:16:86:36 | call to make | passwords.go:85:19:87:2 | struct literal | provenance | Config |
36-
| passwords.go:90:2:90:7 | definition of secret | passwords.go:91:23:91:28 | secret | provenance | |
37-
| passwords.go:90:2:90:7 | definition of secret | passwords.go:91:23:91:28 | secret | provenance | Config |
38-
| passwords.go:90:12:90:19 | password | passwords.go:90:2:90:7 | definition of secret | provenance | |
39-
| passwords.go:90:12:90:19 | password | passwords.go:90:2:90:7 | definition of secret | provenance | Config |
19+
| passwords.go:90:12:90:19 | password | passwords.go:91:23:91:28 | secret | provenance | |
4020
| passwords.go:101:33:101:40 | password | passwords.go:101:15:101:40 | ...+... | provenance | Config |
4121
| passwords.go:107:34:107:41 | password | passwords.go:107:16:107:41 | ...+... | provenance | Config |
4222
| passwords.go:112:33:112:40 | password | passwords.go:112:15:112:40 | ...+... | provenance | Config |
4323
| passwords.go:116:28:116:36 | password1 | passwords.go:116:28:116:45 | call to String | provenance | Config |
4424
| passwords.go:116:28:116:45 | call to String | passwords.go:116:14:116:45 | ...+... | provenance | Config |
45-
| passwords.go:118:2:118:7 | definition of config | passwords.go:125:14:125:19 | config | provenance | |
46-
| passwords.go:118:2:118:7 | definition of config | passwords.go:125:14:125:19 | config | provenance | Config |
47-
| passwords.go:118:2:118:7 | definition of config [x] | passwords.go:126:14:126:19 | config [x] | provenance | |
48-
| passwords.go:118:2:118:7 | definition of config [y] | passwords.go:127:14:127:19 | config [y] | provenance | |
49-
| passwords.go:118:12:123:2 | struct literal | passwords.go:118:2:118:7 | definition of config | provenance | |
50-
| passwords.go:118:12:123:2 | struct literal | passwords.go:118:2:118:7 | definition of config | provenance | Config |
51-
| passwords.go:118:12:123:2 | struct literal [x] | passwords.go:118:2:118:7 | definition of config [x] | provenance | |
52-
| passwords.go:118:12:123:2 | struct literal [y] | passwords.go:118:2:118:7 | definition of config [y] | provenance | |
25+
| passwords.go:118:12:123:2 | struct literal | passwords.go:125:14:125:19 | config | provenance | |
26+
| passwords.go:118:12:123:2 | struct literal [x] | passwords.go:126:14:126:19 | config [x] | provenance | |
27+
| passwords.go:118:12:123:2 | struct literal [y] | passwords.go:127:14:127:19 | config [y] | provenance | |
5328
| passwords.go:119:13:119:13 | x | passwords.go:118:12:123:2 | struct literal | provenance | Config |
5429
| passwords.go:121:13:121:20 | password | passwords.go:118:12:123:2 | struct literal | provenance | Config |
5530
| passwords.go:121:13:121:20 | password | passwords.go:118:12:123:2 | struct literal [x] | provenance | |
@@ -69,10 +44,8 @@ edges
6944
| protos/query/query.pb.go:119:10:119:10 | x [pointer, Description] | protos/query/query.pb.go:119:10:119:10 | implicit dereference [Description] | provenance | |
7045
nodes
7146
| klog.go:20:3:25:3 | range statement[1] | semmle.label | range statement[1] |
72-
| klog.go:20:13:20:19 | definition of headers | semmle.label | definition of headers |
7347
| klog.go:20:30:20:37 | selection of Header | semmle.label | selection of Header |
7448
| klog.go:21:4:24:4 | range statement[1] | semmle.label | range statement[1] |
75-
| klog.go:21:11:21:16 | definition of header | semmle.label | definition of header |
7649
| klog.go:21:27:21:33 | headers | semmle.label | headers |
7750
| klog.go:22:15:22:20 | header | semmle.label | header |
7851
| klog.go:28:13:28:20 | selection of Header | semmle.label | selection of Header |
@@ -118,23 +91,19 @@ nodes
11891
| passwords.go:32:12:32:19 | password | semmle.label | password |
11992
| passwords.go:34:14:34:35 | ...+... | semmle.label | ...+... |
12093
| passwords.go:34:28:34:35 | password | semmle.label | password |
121-
| passwords.go:36:2:36:5 | definition of obj1 | semmle.label | definition of obj1 |
12294
| passwords.go:36:10:38:2 | struct literal | semmle.label | struct literal |
12395
| passwords.go:37:13:37:13 | x | semmle.label | x |
12496
| passwords.go:39:14:39:17 | obj1 | semmle.label | obj1 |
125-
| passwords.go:41:2:41:5 | definition of obj2 | semmle.label | definition of obj2 |
12697
| passwords.go:41:10:43:2 | struct literal | semmle.label | struct literal |
12798
| passwords.go:42:6:42:13 | password | semmle.label | password |
12899
| passwords.go:44:14:44:17 | obj2 | semmle.label | obj2 |
129100
| passwords.go:46:6:46:9 | definition of obj3 | semmle.label | definition of obj3 |
130101
| passwords.go:47:14:47:17 | obj3 | semmle.label | obj3 |
131102
| passwords.go:48:11:48:18 | password | semmle.label | password |
132103
| passwords.go:51:14:51:27 | fixed_password | semmle.label | fixed_password |
133-
| passwords.go:85:2:85:14 | definition of utilityObject | semmle.label | definition of utilityObject |
134104
| passwords.go:85:19:87:2 | struct literal | semmle.label | struct literal |
135105
| passwords.go:86:16:86:36 | call to make | semmle.label | call to make |
136106
| passwords.go:88:14:88:26 | utilityObject | semmle.label | utilityObject |
137-
| passwords.go:90:2:90:7 | definition of secret | semmle.label | definition of secret |
138107
| passwords.go:90:12:90:19 | password | semmle.label | password |
139108
| passwords.go:91:23:91:28 | secret | semmle.label | secret |
140109
| passwords.go:101:15:101:40 | ...+... | semmle.label | ...+... |
@@ -146,9 +115,6 @@ nodes
146115
| passwords.go:116:14:116:45 | ...+... | semmle.label | ...+... |
147116
| passwords.go:116:28:116:36 | password1 | semmle.label | password1 |
148117
| passwords.go:116:28:116:45 | call to String | semmle.label | call to String |
149-
| passwords.go:118:2:118:7 | definition of config | semmle.label | definition of config |
150-
| passwords.go:118:2:118:7 | definition of config [x] | semmle.label | definition of config [x] |
151-
| passwords.go:118:2:118:7 | definition of config [y] | semmle.label | definition of config [y] |
152118
| passwords.go:118:12:123:2 | struct literal | semmle.label | struct literal |
153119
| passwords.go:118:12:123:2 | struct literal [x] | semmle.label | struct literal [x] |
154120
| passwords.go:118:12:123:2 | struct literal [y] | semmle.label | struct literal [y] |

0 commit comments

Comments
 (0)