Skip to content

Commit f1905f2

Browse files
committed
Swift: Remove special case from swift/unsafe-js-eval.
1 parent 4380495 commit f1905f2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

swift/ql/lib/codeql/swift/security/UnsafeJsEvalExtensions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ private class DefaultUnsafeJsEvalAdditionalTaintStep extends UnsafeJsEvalAdditio
118118
exists(CallExpr ce, Expr self, AbstractClosureExpr closure |
119119
ce.getStaticTarget()
120120
.getName()
121-
.matches(["withContiguousStorageIfAvailable(%)", "withUnsafeBufferPointer(%)"]) and
121+
.matches(["withUnsafeBufferPointer(%)"]) and
122122
self = ce.getQualifier() and
123123
ce.getArgument(0).getExpr() = closure
124124
|

swift/ql/test/query-tests/Security/CWE-094/UnsafeJsEval.expected

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ edges
4747
| UnsafeJsEval.swift:276:13:276:13 | string : | UnsafeJsEval.swift:277:26:277:26 | string |
4848
| UnsafeJsEval.swift:279:13:279:13 | string : | UnsafeJsEval.swift:280:26:280:26 | string |
4949
| UnsafeJsEval.swift:285:13:285:13 | string : | UnsafeJsEval.swift:286:3:286:10 | .utf16 : |
50-
| UnsafeJsEval.swift:286:3:286:10 | .utf16 : | UnsafeJsEval.swift:286:51:286:51 | stringBytes : |
50+
| UnsafeJsEval.swift:286:3:286:10 | .utf16 : | file://:0:0:0:0 | [summary param] this in withContiguousStorageIfAvailable(_:) : |
5151
| UnsafeJsEval.swift:286:51:286:51 | stringBytes : | UnsafeJsEval.swift:287:31:287:97 | call to JSStringCreateWithCharacters(_:_:) : |
5252
| UnsafeJsEval.swift:286:51:286:51 | stringBytes : | UnsafeJsEval.swift:291:17:291:17 | jsstr |
5353
| UnsafeJsEval.swift:287:16:287:98 | call to JSStringRetain(_:) : | UnsafeJsEval.swift:291:17:291:17 | jsstr |
@@ -64,6 +64,8 @@ edges
6464
| UnsafeJsEval.swift:301:31:301:84 | call to JSStringCreateWithUTF8CString(_:) : | UnsafeJsEval.swift:305:17:305:17 | jsstr |
6565
| UnsafeJsEval.swift:318:24:318:87 | call to String.init(contentsOf:) : | UnsafeJsEval.swift:320:44:320:74 | ... .+(_:_:) ... |
6666
| file://:0:0:0:0 | [summary param] 0 in String.init(decoding:as:) : | file://:0:0:0:0 | [summary] to write: return (return) in String.init(decoding:as:) : |
67+
| file://:0:0:0:0 | [summary param] this in withContiguousStorageIfAvailable(_:) : | file://:0:0:0:0 | [summary] to write: argument 0.parameter 0 in withContiguousStorageIfAvailable(_:) : |
68+
| file://:0:0:0:0 | [summary] to write: argument 0.parameter 0 in withContiguousStorageIfAvailable(_:) : | UnsafeJsEval.swift:286:51:286:51 | stringBytes : |
6769
nodes
6870
| UnsafeJsEval.swift:69:2:73:5 | [summary param] 0 in WKUserScript.init(source:injectionTime:forMainFrameOnly:) : | semmle.label | [summary param] 0 in WKUserScript.init(source:injectionTime:forMainFrameOnly:) : |
6971
| UnsafeJsEval.swift:75:2:80:5 | [summary param] 0 in WKUserScript.init(source:injectionTime:forMainFrameOnly:in:) : | semmle.label | [summary param] 0 in WKUserScript.init(source:injectionTime:forMainFrameOnly:in:) : |
@@ -106,6 +108,8 @@ nodes
106108
| UnsafeJsEval.swift:318:24:318:87 | call to String.init(contentsOf:) : | semmle.label | call to String.init(contentsOf:) : |
107109
| UnsafeJsEval.swift:320:44:320:74 | ... .+(_:_:) ... | semmle.label | ... .+(_:_:) ... |
108110
| file://:0:0:0:0 | [summary param] 0 in String.init(decoding:as:) : | semmle.label | [summary param] 0 in String.init(decoding:as:) : |
111+
| file://:0:0:0:0 | [summary param] this in withContiguousStorageIfAvailable(_:) : | semmle.label | [summary param] this in withContiguousStorageIfAvailable(_:) : |
112+
| file://:0:0:0:0 | [summary] to write: argument 0.parameter 0 in withContiguousStorageIfAvailable(_:) : | semmle.label | [summary] to write: argument 0.parameter 0 in withContiguousStorageIfAvailable(_:) : |
109113
| file://:0:0:0:0 | [summary] to write: return (return) in Data.init(_:) : | semmle.label | [summary] to write: return (return) in Data.init(_:) : |
110114
| file://:0:0:0:0 | [summary] to write: return (return) in String.init(decoding:as:) : | semmle.label | [summary] to write: return (return) in String.init(decoding:as:) : |
111115
| file://:0:0:0:0 | [summary] to write: return (return) in WKUserScript.init(source:injectionTime:forMainFrameOnly:) : | semmle.label | [summary] to write: return (return) in WKUserScript.init(source:injectionTime:forMainFrameOnly:) : |

0 commit comments

Comments
 (0)