Skip to content

Commit c3dc967

Browse files
authored
Merge branch 'main' into constructor
2 parents 349a10c + e0c8a8e commit c3dc967

File tree

6 files changed

+44
-4
lines changed

6 files changed

+44
-4
lines changed

codeql-workspace.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ provide:
2525
- "misc/suite-helpers/qlpack.yml"
2626
- "ruby/extractor-pack/codeql-extractor.yml"
2727
- "swift/extractor-pack/codeql-extractor.yml"
28+
- "swift/integration-tests/qlpack.yml"
2829
- "ql/extractor-pack/codeql-extractor.yml"
2930

3031
versionPolicies:

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowDispatch.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ private module Cached {
497497
FlowSummaryImplSpecific::ParsePositions::isParsedKeywordParameterPosition(_, name)
498498
} or
499499
THashSplatArgumentPosition() or
500+
TSplatAllArgumentPosition() or
500501
TAnyArgumentPosition() or
501502
TAnyKeywordArgumentPosition()
502503

@@ -518,6 +519,7 @@ private module Cached {
518519
FlowSummaryImplSpecific::ParsePositions::isParsedKeywordArgumentPosition(_, name)
519520
} or
520521
THashSplatParameterPosition() or
522+
TSplatAllParameterPosition() or
521523
TAnyParameterPosition() or
522524
TAnyKeywordParameterPosition()
523525
}
@@ -1149,6 +1151,8 @@ class ParameterPosition extends TParameterPosition {
11491151
/** Holds if this position represents a hash-splat parameter. */
11501152
predicate isHashSplat() { this = THashSplatParameterPosition() }
11511153

1154+
predicate isSplatAll() { this = TSplatAllParameterPosition() }
1155+
11521156
/**
11531157
* Holds if this position represents any parameter, except `self` parameters. This
11541158
* includes both positional, named, and block parameters.
@@ -1172,6 +1176,8 @@ class ParameterPosition extends TParameterPosition {
11721176
or
11731177
this.isHashSplat() and result = "**"
11741178
or
1179+
this.isSplatAll() and result = "*"
1180+
or
11751181
this.isAny() and result = "any"
11761182
or
11771183
this.isAnyNamed() and result = "any-named"
@@ -1207,6 +1213,8 @@ class ArgumentPosition extends TArgumentPosition {
12071213
*/
12081214
predicate isHashSplat() { this = THashSplatArgumentPosition() }
12091215

1216+
predicate isSplatAll() { this = TSplatAllArgumentPosition() }
1217+
12101218
/** Gets a textual representation of this position. */
12111219
string toString() {
12121220
this.isSelf() and result = "self"
@@ -1222,6 +1230,8 @@ class ArgumentPosition extends TArgumentPosition {
12221230
this.isAnyNamed() and result = "any-named"
12231231
or
12241232
this.isHashSplat() and result = "**"
1233+
or
1234+
this.isSplatAll() and result = "*"
12251235
}
12261236
}
12271237

@@ -1248,6 +1258,8 @@ predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) {
12481258
or
12491259
ppos.isHashSplat() and apos.isHashSplat()
12501260
or
1261+
ppos.isSplatAll() and apos.isSplatAll()
1262+
or
12511263
ppos.isAny() and argumentPositionIsNotSelf(apos)
12521264
or
12531265
apos.isAny() and parameterPositionIsNotSelf(ppos)

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ private class Argument extends CfgNodes::ExprCfgNode {
241241
this = call.getAnArgument() and
242242
this.getExpr() instanceof HashSplatExpr and
243243
arg.isHashSplat()
244+
or
245+
this = call.getArgument(0) and
246+
this.getExpr() instanceof SplatExpr and
247+
arg.isSplatAll()
244248
}
245249

246250
/** Holds if this expression is the `i`th argument of `c`. */
@@ -276,7 +280,8 @@ private module Cached {
276280
p instanceof SimpleParameter or
277281
p instanceof OptionalParameter or
278282
p instanceof KeywordParameter or
279-
p instanceof HashSplatParameter
283+
p instanceof HashSplatParameter or
284+
p instanceof SplatParameter
280285
} or
281286
TSelfParameterNode(MethodBase m) or
282287
TBlockParameterNode(MethodBase m) or
@@ -616,6 +621,9 @@ private module ParameterNodes {
616621
or
617622
parameter = callable.getAParameter().(HashSplatParameter) and
618623
pos.isHashSplat()
624+
or
625+
parameter = callable.getParameter(0).(SplatParameter) and
626+
pos.isSplatAll()
619627
)
620628
}
621629

ruby/ql/test/library-tests/dataflow/params/params-flow.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ edges
4040
| params_flow.rb:49:13:49:14 | p1 : | params_flow.rb:50:10:50:11 | p1 |
4141
| params_flow.rb:54:9:54:17 | call to taint : | params_flow.rb:49:13:49:14 | p1 : |
4242
| params_flow.rb:57:9:57:17 | call to taint : | params_flow.rb:49:13:49:14 | p1 : |
43+
| params_flow.rb:62:8:62:16 | call to taint : | params_flow.rb:66:13:66:16 | args : |
44+
| params_flow.rb:63:16:63:17 | *x [element 0] : | params_flow.rb:64:10:64:10 | x [element 0] : |
45+
| params_flow.rb:64:10:64:10 | x [element 0] : | params_flow.rb:64:10:64:13 | ...[...] |
46+
| params_flow.rb:66:12:66:16 | * ... [element 0] : | params_flow.rb:63:16:63:17 | *x [element 0] : |
47+
| params_flow.rb:66:13:66:16 | args : | params_flow.rb:66:12:66:16 | * ... [element 0] : |
4348
nodes
4449
| params_flow.rb:9:16:9:17 | p1 : | semmle.label | p1 : |
4550
| params_flow.rb:9:20:9:21 | p2 : | semmle.label | p2 : |
@@ -89,6 +94,12 @@ nodes
8994
| params_flow.rb:50:10:50:11 | p1 | semmle.label | p1 |
9095
| params_flow.rb:54:9:54:17 | call to taint : | semmle.label | call to taint : |
9196
| params_flow.rb:57:9:57:17 | call to taint : | semmle.label | call to taint : |
97+
| params_flow.rb:62:8:62:16 | call to taint : | semmle.label | call to taint : |
98+
| params_flow.rb:63:16:63:17 | *x [element 0] : | semmle.label | *x [element 0] : |
99+
| params_flow.rb:64:10:64:10 | x [element 0] : | semmle.label | x [element 0] : |
100+
| params_flow.rb:64:10:64:13 | ...[...] | semmle.label | ...[...] |
101+
| params_flow.rb:66:12:66:16 | * ... [element 0] : | semmle.label | * ... [element 0] : |
102+
| params_flow.rb:66:13:66:16 | args : | semmle.label | args : |
92103
subpaths
93104
#select
94105
| params_flow.rb:10:10:10:11 | p1 | params_flow.rb:14:12:14:19 | call to taint : | params_flow.rb:10:10:10:11 | p1 | $@ | params_flow.rb:14:12:14:19 | call to taint : | call to taint : |
@@ -111,3 +122,4 @@ subpaths
111122
| params_flow.rb:29:10:29:22 | ( ... ) | params_flow.rb:34:14:34:22 | call to taint : | params_flow.rb:29:10:29:22 | ( ... ) | $@ | params_flow.rb:34:14:34:22 | call to taint : | call to taint : |
112123
| params_flow.rb:50:10:50:11 | p1 | params_flow.rb:54:9:54:17 | call to taint : | params_flow.rb:50:10:50:11 | p1 | $@ | params_flow.rb:54:9:54:17 | call to taint : | call to taint : |
113124
| params_flow.rb:50:10:50:11 | p1 | params_flow.rb:57:9:57:17 | call to taint : | params_flow.rb:50:10:50:11 | p1 | $@ | params_flow.rb:57:9:57:17 | call to taint : | call to taint : |
125+
| params_flow.rb:64:10:64:13 | ...[...] | params_flow.rb:62:8:62:16 | call to taint : | params_flow.rb:64:10:64:13 | ...[...] | $@ | params_flow.rb:62:8:62:16 | call to taint : | call to taint : |

ruby/ql/test/library-tests/dataflow/params/params_flow.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,10 @@ def posargs(p1, *posargs)
5757
posargs(taint(23), *args)
5858

5959
args = [taint(24), taint(25)]
60-
posargs(*args)
60+
posargs(*args)
61+
62+
args = taint(26)
63+
def splatstuff(*x)
64+
sink x[0] # $ hasValueFlow=26
65+
end
66+
splatstuff(*args)

swift/integration-tests/qlpack.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: integration-tests-swift
22
version: 0.0.0
3-
extractor: swift
43
dependencies:
5-
codeql/swift-all: '*'
4+
codeql/swift-all: ${workspace}
5+
tests: .
6+
extractor: swift

0 commit comments

Comments
 (0)