Skip to content

Commit 75373ee

Browse files
committed
unified: Use proper accessor when accessing operand of token
1 parent 3bf191f commit 75373ee

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎unified/ql/lib/codeql/unified/internal/mad/LegacyMaD.qll‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ private DataFlow::Node getSinkFromCall(CallExpr call, AccessPathToken token) {
224224
arg.getName() + ":" = token.getAnArgument()
225225
)
226226
or
227-
token = "Argument[self]" and
227+
token.getName() = "Argument" and
228+
token.getAnArgument() = "self" and
228229
result.isReceiverArgument(call)
229230
}
230231

@@ -263,7 +264,8 @@ private DataFlow::Node getSourceFromCallable(Callable callable, AccessPathToken
263264
param.getExternalName() + ":" = token.getAnArgument()
264265
)
265266
or
266-
token = "Parameter[self]" and
267+
token.getName() = "Parameter" and
268+
token.getAnArgument() = "self" and
267269
result.isReceiverParameter(callable)
268270
}
269271

‎unified/ql/test/library-tests/mad/test.expected‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ isSink
1616
| test.swift:101:18:101:24 | fileURL | path-injection |
1717
| test.swift:107:23:107:34 | seedFilePath | path-injection |
1818
| test.swift:119:29:119:34 | string | path-injection |
19+
| test.swift:137:5:139:5 | [self arg] ... .sinkArgs(...) | shorthand-sink |
1920
| test.swift:138:9:138:14 | string | shorthand-sink |
2021
isSource
2122
| test.swift:4:5:4:27 | String(...) | remote |
@@ -26,4 +27,5 @@ isSource
2627
| test.swift:10:5:12:24 | String(...) | local |
2728
| test.swift:13:5:15:28 | String(...) | local |
2829
| test.swift:29:29:29:32 | text | local |
30+
| test.swift:129:5:133:5 | [self param] func ShorthandTestSub.sourceParams | shorthand-source |
2931
| test.swift:130:11:130:11 | x | shorthand-source |

‎unified/ql/test/library-tests/mad/test.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ class ShorthandTestSub: ShorthandTest {
130130
_ x: String // $ isSource=shorthand-source
131131
) {
132132
_ = self
133-
} // $ MISSING: isSource=shorthand-source
133+
} // $ isSource=shorthand-source
134134
}
135135

136136
func testShorthandTokens(obj: ShorthandTest, string: String) {
137137
obj.sinkArgs(
138138
string // $ isSink=shorthand-sink
139-
) // $ MISSING: isSink=shorthand-sink
139+
) // $ isSink=shorthand-sink
140140
}

0 commit comments

Comments
 (0)