Skip to content

Commit daa55ea

Browse files
authored
Merge pull request #651 from erik-krogh/patches
various automatic patches applied to codeql-go
2 parents 50457d1 + afe7ee1 commit daa55ea

File tree

17 files changed

+62
-175
lines changed

17 files changed

+62
-175
lines changed

ql/lib/semmle/go/concepts/GeneratedFile.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ module GeneratedFile {
1313
abstract class Range extends File { }
1414

1515
private string generatorCommentRegex() {
16-
result = "Generated By\\b.*\\bDo not edit" or
1716
result =
18-
"This (file|class|interface|art[ei]fact) (was|is|(has been)) (?:auto[ -]?)?gener(e?)ated" or
19-
result = "Any modifications to this file will be lost" or
20-
result =
21-
"This (file|class|interface|art[ei]fact) (was|is) (?:mechanically|automatically) generated" or
22-
result = "The following code was (?:auto[ -]?)?generated (?:by|from)" or
23-
result = "Autogenerated by Thrift" or
24-
result = "(Code g|G)enerated from .* by ANTLR"
17+
[
18+
"Generated By\\b.*\\bDo not edit",
19+
"This (file|class|interface|art[ei]fact) (was|is|(has been)) (?:auto[ -]?)?gener(e?)ated",
20+
"Any modifications to this file will be lost",
21+
"This (file|class|interface|art[ei]fact) (was|is) (?:mechanically|automatically) generated",
22+
"The following code was (?:auto[ -]?)?generated (?:by|from)", "Autogenerated by Thrift",
23+
"(Code g|G)enerated from .* by ANTLR"
24+
]
2525
}
2626

2727
private class CommentHeuristicGeneratedFile extends Range {

ql/lib/semmle/go/controlflow/ControlFlowGraphImpl.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ module CFG {
489489
/**
490490
* A completion indicating that an expression was successfully evaluated to Boolean value `b`.
491491
*
492-
* Note that many Boolean expressions are modelled as having completion `Done()` instead.
492+
* Note that many Boolean expressions are modeled as having completion `Done()` instead.
493493
* Completion `Bool` is only used in contexts where the Boolean value can be determined.
494494
*/
495495
Bool(boolean b) { b = true or b = false } or
@@ -652,7 +652,7 @@ module CFG {
652652

653653
AtomicTree() {
654654
exists(Expr e |
655-
e = this.(Expr) and
655+
e = this and
656656
e.isConst() and
657657
nd = mkExprOrSkipNode(this)
658658
|

ql/lib/semmle/go/dataflow/SsaImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private module Internal {
100100

101101
/**
102102
* Holds if the `i`th node of basic block `bb` may induce a pseudo-definition for
103-
* modelling updates to captured variable `v`. Whether the definition is actually
103+
* modeling updates to captured variable `v`. Whether the definition is actually
104104
* introduced depends on whether `v` is live at this point in the program.
105105
*/
106106
private predicate mayCapture(ReachableBasicBlock bb, int i, SsaSourceVariable v) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ private predicate isPossibleInputNode(DataFlow::Node inputNode, FuncDef fd) {
289289
private ControlFlow::Node getANonTestPassingPredecessor(
290290
ControlFlow::Node succ, DataFlow::Node inputNode
291291
) {
292-
isPossibleInputNode(inputNode, succ.getRoot().(FuncDef)) and
292+
isPossibleInputNode(inputNode, succ.getRoot()) and
293293
result = succ.getAPredecessor() and
294294
not exists(Expr testExpr, DataFlow::Node switchExprNode |
295295
flowsToSwitchExpression(inputNode, switchExprNode) and
@@ -301,7 +301,7 @@ private ControlFlow::Node getANonTestPassingPredecessor(
301301
private ControlFlow::Node getANonTestPassingReachingNodeRecursive(
302302
ControlFlow::Node n, DataFlow::Node inputNode
303303
) {
304-
isPossibleInputNode(inputNode, n.getRoot().(FuncDef)) and
304+
isPossibleInputNode(inputNode, n.getRoot()) and
305305
(
306306
result = n or
307307
result =
@@ -328,7 +328,7 @@ private ControlFlow::Node getANonTestPassingReachingNodeBase(
328328
private predicate mustPassConstantCaseTestToReach(
329329
IR::ReturnInstruction ret, DataFlow::Node inputNode
330330
) {
331-
isPossibleInputNode(inputNode, ret.getRoot().(FuncDef)) and
331+
isPossibleInputNode(inputNode, ret.getRoot()) and
332332
not exists(ControlFlow::Node entry | entry = ret.getRoot().getEntryNode() |
333333
entry = getANonTestPassingReachingNodeBase(ret, inputNode)
334334
)

ql/lib/semmle/go/frameworks/Encoding.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Provides classes modelling taint propagation through marshalling and encoding functions.
2+
* Provides classes modeling taint propagation through marshalling and encoding functions.
33
*/
44

55
import go

ql/lib/semmle/go/frameworks/Protobuf.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module Protobuf {
6060
}
6161

6262
/**
63-
* Additional taint-flow step modelling flow from `MarshalInput.Message` to `MarshalOutput`,
63+
* Additional taint-flow step modeling flow from `MarshalInput.Message` to `MarshalOutput`,
6464
* mediated by a `MarshalOptions.MarshalState` call.
6565
*
6666
* Note we can taint the whole `MarshalOutput` as it only has one field (`Buf`), and taint-

ql/lib/semmle/go/frameworks/Revel.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import go
66
private import semmle.go.security.OpenUrlRedirectCustomizations
77

8-
/** Provides classes and methods modelling the Revel web framework. */
8+
/** Provides classes and methods modeling the Revel web framework. */
99
module Revel {
1010
/** Gets the package name `github.com/revel/revel`. */
1111
string packagePath() { result = package(["github.com/revel", "github.com/robfig"], "revel") }

ql/lib/semmle/go/frameworks/SQL.qll

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,7 @@ module SQL {
143143
or
144144
exists(string tp, string m | f.(Method).hasQualifiedName(gopgorm(), tp, m) |
145145
tp = "Query" and
146-
(
147-
m = "ColumnExpr" or
148-
m = "For" or
149-
m = "Having" or
150-
m = "Where" or
151-
m = "WhereIn" or
152-
m = "WhereInMulti" or
153-
m = "WhereOr"
154-
) and
146+
m = ["ColumnExpr", "For", "Having", "Where", "WhereIn", "WhereInMulti", "WhereOr"] and
155147
arg = 0
156148
or
157149
tp = "Query" and

ql/lib/semmle/go/frameworks/Stdlib.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,7 @@ module URL {
174174
class UrlGetter extends TaintTracking::FunctionModel, Method {
175175
UrlGetter() {
176176
exists(string m | hasQualifiedName("net/url", "URL", m) |
177-
m = "EscapedPath" or
178-
m = "Hostname" or
179-
m = "Port" or
180-
m = "Query" or
181-
m = "RequestURI"
177+
m = ["EscapedPath", "Hostname", "Port", "Query", "RequestURI"]
182178
)
183179
}
184180

ql/lib/semmle/go/frameworks/SystemCommandExecutors.qll

Lines changed: 15 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -126,47 +126,14 @@ private class ShellLike extends DataFlow::Node {
126126
}
127127

128128
private string getASudoCommand() {
129-
result = "sudo" or
130-
result = "sudo_root" or
131-
result = "su" or
132-
result = "sudoedit" or
133-
result = "doas" or
134-
result = "access" or
135-
result = "vsys" or
136-
result = "userv" or
137-
result = "sus" or
138-
result = "super" or
139-
result = "priv" or
140-
result = "calife" or
141-
result = "ssu" or
142-
result = "su1" or
143-
result = "op" or
144-
result = "sudowin" or
145-
result = "sudown" or
146-
result = "chroot" or
147-
result = "fakeroot" or
148-
result = "fakeroot-sysv" or
149-
result = "fakeroot-tcp" or
150-
result = "fstab-decode" or
151-
result = "jrunscript" or
152-
result = "nohup" or
153-
result = "parallel" or
154-
result = "find" or
155-
result = "pkexec" or
156-
result = "sg" or
157-
result = "sem" or
158-
result = "runcon" or
159-
result = "runuser" or
160-
result = "stdbuf" or
161-
result = "system" or
162-
result = "timeout" or
163-
result = "xargs" or
164-
result = "time" or
165-
result = "awk" or
166-
result = "gawk" or
167-
result = "mawk" or
168-
result = "nawk" or
169-
result = "git"
129+
result =
130+
[
131+
"sudo", "sudo_root", "priv", "calife", "ssu", "su1", "op", "sudowin", "sudown", "chroot",
132+
"fakeroot", "fakeroot-sysv", "su", "fakeroot-tcp", "fstab-decode", "jrunscript", "nohup",
133+
"parallel", "find", "pkexec", "sg", "sem", "runcon", "sudoedit", "runuser", "stdbuf",
134+
"system", "timeout", "xargs", "time", "awk", "gawk", "mawk", "nawk", "doas", "git", "access",
135+
"vsys", "userv", "sus", "super"
136+
]
170137
}
171138

172139
/**
@@ -213,31 +180,12 @@ private predicate isSudoOrSimilar(DataFlow::Node node) {
213180
}
214181

215182
private string getAShellCommand() {
216-
result = "bash" or
217-
result = "sh" or
218-
result = "sh.distrib" or
219-
result = "rbash" or
220-
result = "dash" or
221-
result = "zsh" or
222-
result = "csh" or
223-
result = "tcsh" or
224-
result = "fish" or
225-
result = "pwsh" or
226-
result = "elvish" or
227-
result = "oh" or
228-
result = "ion" or
229-
result = "ksh" or
230-
result = "rksh" or
231-
result = "tksh" or
232-
result = "mksh" or
233-
result = "nu" or
234-
result = "oksh" or
235-
result = "osh" or
236-
result = "shpp" or
237-
result = "xiki" or
238-
result = "xonsh" or
239-
result = "yash" or
240-
result = "env"
183+
result =
184+
[
185+
"bash", "sh", "elvish", "oh", "ion", "ksh", "rksh", "tksh", "mksh", "nu", "oksh", "osh",
186+
"sh.distrib", "shpp", "xiki", "xonsh", "yash", "env", "rbash", "dash", "zsh", "csh", "tcsh",
187+
"fish", "pwsh"
188+
]
241189
}
242190

243191
/**
@@ -252,12 +200,7 @@ private predicate isShell(DataFlow::Node node) {
252200
}
253201

254202
private string getAnInterpreterName() {
255-
result = "python" or
256-
result = "php" or
257-
result = "ruby" or
258-
result = "perl" or
259-
result = "node" or
260-
result = "nodejs"
203+
result = ["python", "php", "ruby", "perl", "node", "nodejs"]
261204
}
262205

263206
/**

0 commit comments

Comments
 (0)