Skip to content

Commit c1b90c8

Browse files
committed
Python: Apply suggested change
1 parent a057365 commit c1b90c8

File tree

1 file changed

+2
-29
lines changed

1 file changed

+2
-29
lines changed

python/ql/src/experimental/Security/CWE-176/UnicodeBypassValidationQuery.qll

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,35 +43,8 @@ class Configuration extends TaintTracking::Configuration {
4343
or
4444
exists(RegexExecution re | nodeFrom = re.getString() and nodeTo = re)
4545
or
46-
// String methods
47-
exists(MethodCallNode call, string method_name |
48-
nodeTo = call and call.getMethodName() = method_name
49-
|
50-
call.calls(nodeFrom, method_name) and
51-
method_name in [
52-
"capitalize", "casefold", "center", "expandtabs", "format", "format_map", "join",
53-
"ljust", "lstrip", "lower", "replace", "rjust", "rstrip", "strip", "swapcase", "title",
54-
"upper", "zfill", "encode", "decode"
55-
]
56-
or
57-
method_name = "replace" and
58-
nodeFrom = call.getArg(1)
59-
or
60-
method_name = "format" and
61-
nodeFrom = call.getArg(_)
62-
or
63-
// str -> List[str]
64-
call.calls(nodeFrom, method_name) and
65-
method_name in ["partition", "rpartition", "rsplit", "split", "splitlines"]
66-
or
67-
// Iterable[str] -> str
68-
method_name = "join" and
69-
nodeFrom = call.getArg(0)
70-
or
71-
// Mapping[str, Any] -> str
72-
method_name = "format_map" and
73-
nodeFrom = call.getArg(0)
74-
)
46+
stringManipulation(nodeFrom, nodeTo) and
47+
not nodeTo.(DataFlow::MethodCallNode).getMethodName() in ["encode", "decode"]
7548
) and
7649
stateFrom instanceof PreValidation and
7750
stateTo instanceof PostValidation

0 commit comments

Comments
 (0)