You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: swift/ql/src/queries/Security/CWE-943/PredicateInjection.qhelp
+4-9Lines changed: 4 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -9,25 +9,20 @@ be able to change the overall meaning of the predicate.
9
9
</overview>
10
10
<recommendation>
11
11
<p>
12
-
When building a predicate from untrusted data, pass it to the appropriate <code>arguments</code> parameter
13
-
during initialization, or as an array of substitution variables before evaluation, instead of appending
14
-
or concatenating it to the body of the predicate.
12
+
When building a predicate from untrusted data, you should either pass it to the appropriate <code>arguments</code> parameter during initialization, or as an array of substitution variables before evaluation. You should not append or concatenate it to the body of the predicate.
15
13
</p>
16
14
</recommendation>
17
15
<example>
18
16
<p>
19
-
In the following insecure example, a <code>NSPredicate</code> is built directly from data obtained from an HTTP request,
20
-
which is untrusted, and can be arbitrarily set by an attacker to alter the meaning of the predicate:
17
+
In the following insecure example, <code>NSPredicate</code> is built directly from data obtained from an HTTP request. This is untrusted, and can be arbitrarily set by an attacker to alter the meaning of the predicate:
21
18
</p>
22
19
<samplesrc="PredicateInjectionBad.swift" />
23
20
<p>
24
-
A better way to do this is using the <code>arguments</code> parameter of <code>NSPredicate</code>'s constructor,
25
-
which prevents attackers from altering the meaning of the predicate, even if they control the externally-obtained data,
26
-
as seen in the following secure example:
21
+
A better way to do this is to use the <code>arguments</code> parameter of <code>NSPredicate</code>'s constructor. This prevents attackers from altering the meaning of the predicate, even if they control the externally obtained data, as seen in the following secure example:
0 commit comments