Skip to content

Commit 287bc40

Browse files
authored
Merge pull request github#3743 from tausbn/python-fix-deprecated-terms
Python: Fix a bunch of deprecated terms.
2 parents 7f29465 + 5d5f1b4 commit 287bc40

29 files changed

+51
-51
lines changed

python/ql/src/Classes/ConflictingAttributesInBaseClasses.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ predicate calls_super(FunctionObject f) {
3131
)
3232
}
3333

34-
/** Holds if the given name is white-listed for some reason */
35-
predicate whitelisted(string name) {
34+
/** Holds if the given name is allowed for some reason */
35+
predicate allowed(string name) {
3636
/*
3737
* The standard library specifically recommends this :(
3838
* See https://docs.python.org/3/library/socketserver.html#asynchronous-mixins
@@ -53,7 +53,7 @@ where
5353
not name.matches("\\_\\_%\\_\\_") and
5454
not calls_super(o1) and
5555
not does_nothing(o2) and
56-
not whitelisted(name) and
56+
not allowed(name) and
5757
not o1.overrides(o2) and
5858
not o2.overrides(o1) and
5959
not c.declaresAttribute(name)

python/ql/src/Metrics/FLinesOfDuplicatedCode.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ where
2020
count(int line |
2121
exists(DuplicateBlock d | d.sourceFile() = f |
2222
line in [d.sourceStartLine() .. d.sourceEndLine()] and
23-
not whitelistedLineForDuplication(f, line)
23+
not allowlistedLineForDuplication(f, line)
2424
)
2525
)
2626
select f, n order by n desc

python/ql/src/Metrics/FLinesOfSimilarCode.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ where
2020
count(int line |
2121
exists(SimilarBlock d | d.sourceFile() = f |
2222
line in [d.sourceStartLine() .. d.sourceEndLine()] and
23-
not whitelistedLineForDuplication(f, line)
23+
not allowlistedLineForDuplication(f, line)
2424
)
2525
)
2626
select f, n order by n desc

python/ql/src/Security/CWE-020/IncompleteUrlSubstringSanitization.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
<p>
6969

7070
The second two examples show safe checks.
71-
In <code>safe1</code>, a white-list is used. Although fairly inflexible,
71+
In <code>safe1</code>, an allowlist is used. Although fairly inflexible,
7272
this is easy to get right and is most likely to be safe.
7373
</p>
7474
<p>

python/ql/src/Security/CWE-020/examples/IncompleteUrlSubstringSanitization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ def unsafe2(request):
2121

2222

2323

24-
#Simplest and safest approach is to use a white-list
24+
#Simplest and safest approach is to use an allowlist
2525

2626
@app.route('/some/path/good1')
2727
def safe1(request):
28-
whitelist = [
28+
allowlist = [
2929
"example.com/home",
3030
"example.com/login",
3131
]
3232
target = request.args.get('target', '')
33-
if target in whitelist:
33+
if target in allowlist:
3434
return redirect(target)
3535

3636
#More complex example allowing sub-domains.

python/ql/src/Security/CWE-022/PathInjection.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Ideally, follow these rules:
2626
<li>Do not allow directory separators such as "/" or "\" (depending on the file system).</li>
2727
<li>Do not rely on simply replacing problematic sequences such as "../". For example, after
2828
applying this filter to ".../...//", the resulting string would still be "../".</li>
29-
<li>Use a whitelist of known good patterns.</li>
29+
<li>Use an allowlist of known good patterns.</li>
3030
</ul>
3131
</recommendation>
3232

python/ql/src/Security/CWE-078/CommandInjection.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ safe before using it.</p>
2525

2626
<p>The following example shows two functions. The first is unsafe as it takes a shell script that can be changed
2727
by a user, and passes it straight to <code>subprocess.call()</code> without examining it first.
28-
The second is safe as it selects the command from a predefined white-list.</p>
28+
The second is safe as it selects the command from a predefined allowlist.</p>
2929

3030
<sample src="examples/command_injection.py" />
3131

python/ql/src/Security/CWE-078/examples/command_injection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ def command_execution_unsafe(request):
1919
def command_execution_safe(request):
2020
if request.method == 'POST':
2121
action = request.POST.get('action', '')
22-
#GOOD -- Use a whitelist
22+
#GOOD -- Use an allowlist
2323
subprocess.call(["application", COMMANDS[action]])

python/ql/src/Variables/ShadowBuiltin.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import python
1616
import Shadowing
1717
import semmle.python.types.Builtins
1818

19-
predicate white_list(string name) {
19+
predicate allow_list(string name) {
2020
/* These are rarely used and thus unlikely to be confusing */
2121
name = "iter" or
2222
name = "next" or
@@ -51,7 +51,7 @@ predicate shadows(Name d, string name, Function scope, int line) {
5151
) and
5252
d.getScope() = scope and
5353
d.getLocation().getStartLine() = line and
54-
not white_list(name) and
54+
not allow_list(name) and
5555
not optimizing_parameter(d)
5656
}
5757

python/ql/src/analysis/Sanity.ql renamed to python/ql/src/analysis/Consistency.ql

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* @name Sanity check
3-
* @description General sanity check to be run on any and all code. Should never produce any results.
4-
* @id py/sanity-check
2+
* @name Consistency check
3+
* @description General consistency check to be run on any and all code. Should never produce any results.
4+
* @id py/consistency-check
55
*/
66

77
import python
@@ -24,7 +24,7 @@ predicate uniqueness_error(int number, string what, string problem) {
2424
)
2525
}
2626

27-
predicate ast_sanity(string clsname, string problem, string what) {
27+
predicate ast_consistency(string clsname, string problem, string what) {
2828
exists(AstNode a | clsname = a.getAQlClass() |
2929
uniqueness_error(count(a.toString()), "toString", problem) and
3030
what = "at " + a.getLocation().toString()
@@ -39,7 +39,7 @@ predicate ast_sanity(string clsname, string problem, string what) {
3939
)
4040
}
4141

42-
predicate location_sanity(string clsname, string problem, string what) {
42+
predicate location_consistency(string clsname, string problem, string what) {
4343
exists(Location l | clsname = l.getAQlClass() |
4444
uniqueness_error(count(l.toString()), "toString", problem) and what = "at " + l.toString()
4545
or
@@ -65,7 +65,7 @@ predicate location_sanity(string clsname, string problem, string what) {
6565
)
6666
}
6767

68-
predicate cfg_sanity(string clsname, string problem, string what) {
68+
predicate cfg_consistency(string clsname, string problem, string what) {
6969
exists(ControlFlowNode f | clsname = f.getAQlClass() |
7070
uniqueness_error(count(f.getNode()), "getNode", problem) and
7171
what = "at " + f.getLocation().toString()
@@ -80,7 +80,7 @@ predicate cfg_sanity(string clsname, string problem, string what) {
8080
)
8181
}
8282

83-
predicate scope_sanity(string clsname, string problem, string what) {
83+
predicate scope_consistency(string clsname, string problem, string what) {
8484
exists(Scope s | clsname = s.getAQlClass() |
8585
uniqueness_error(count(s.getEntryNode()), "getEntryNode", problem) and
8686
what = "at " + s.getLocation().toString()
@@ -125,7 +125,7 @@ private predicate introspected_builtin_object(Object o) {
125125
py_cobject_sources(o, 0)
126126
}
127127

128-
predicate builtin_object_sanity(string clsname, string problem, string what) {
128+
predicate builtin_object_consistency(string clsname, string problem, string what) {
129129
exists(Object o |
130130
clsname = o.getAQlClass() and
131131
what = best_description_builtin_object(o) and
@@ -146,7 +146,7 @@ predicate builtin_object_sanity(string clsname, string problem, string what) {
146146
)
147147
}
148148

149-
predicate source_object_sanity(string clsname, string problem, string what) {
149+
predicate source_object_consistency(string clsname, string problem, string what) {
150150
exists(Object o | clsname = o.getAQlClass() and not o.isBuiltin() |
151151
uniqueness_error(count(o.getOrigin()), "getOrigin", problem) and
152152
what = "at " + o.getOrigin().getLocation().toString()
@@ -161,7 +161,7 @@ predicate source_object_sanity(string clsname, string problem, string what) {
161161
)
162162
}
163163

164-
predicate ssa_sanity(string clsname, string problem, string what) {
164+
predicate ssa_consistency(string clsname, string problem, string what) {
165165
/* Zero or one definitions of each SSA variable */
166166
exists(SsaVariable var | clsname = var.getAQlClass() |
167167
uniqueness_error(strictcount(var.getDefinition()), "getDefinition", problem) and
@@ -196,7 +196,7 @@ predicate ssa_sanity(string clsname, string problem, string what) {
196196
)
197197
}
198198

199-
predicate function_object_sanity(string clsname, string problem, string what) {
199+
predicate function_object_consistency(string clsname, string problem, string what) {
200200
exists(FunctionObject func | clsname = func.getAQlClass() |
201201
what = func.getName() and
202202
(
@@ -229,7 +229,7 @@ predicate intermediate_origins(ControlFlowNode use, ControlFlowNode inter, Objec
229229
)
230230
}
231231

232-
predicate points_to_sanity(string clsname, string problem, string what) {
232+
predicate points_to_consistency(string clsname, string problem, string what) {
233233
exists(Object obj |
234234
multiple_origins_per_object(obj) and
235235
clsname = obj.getAQlClass() and
@@ -245,7 +245,7 @@ predicate points_to_sanity(string clsname, string problem, string what) {
245245
)
246246
}
247247

248-
predicate jump_to_definition_sanity(string clsname, string problem, string what) {
248+
predicate jump_to_definition_consistency(string clsname, string problem, string what) {
249249
problem = "multiple (jump-to) definitions" and
250250
exists(Expr use |
251251
strictcount(getUniqueDefinition(use)) > 1 and
@@ -254,7 +254,7 @@ predicate jump_to_definition_sanity(string clsname, string problem, string what)
254254
)
255255
}
256256

257-
predicate file_sanity(string clsname, string problem, string what) {
257+
predicate file_consistency(string clsname, string problem, string what) {
258258
exists(File file, Folder folder |
259259
clsname = file.getAQlClass() and
260260
problem = "has same name as a folder" and
@@ -269,7 +269,7 @@ predicate file_sanity(string clsname, string problem, string what) {
269269
)
270270
}
271271

272-
predicate class_value_sanity(string clsname, string problem, string what) {
272+
predicate class_value_consistency(string clsname, string problem, string what) {
273273
exists(ClassValue value, ClassValue sup, string attr |
274274
what = value.getName() and
275275
sup = value.getASuperType() and
@@ -283,16 +283,16 @@ predicate class_value_sanity(string clsname, string problem, string what) {
283283

284284
from string clsname, string problem, string what
285285
where
286-
ast_sanity(clsname, problem, what) or
287-
location_sanity(clsname, problem, what) or
288-
scope_sanity(clsname, problem, what) or
289-
cfg_sanity(clsname, problem, what) or
290-
ssa_sanity(clsname, problem, what) or
291-
builtin_object_sanity(clsname, problem, what) or
292-
source_object_sanity(clsname, problem, what) or
293-
function_object_sanity(clsname, problem, what) or
294-
points_to_sanity(clsname, problem, what) or
295-
jump_to_definition_sanity(clsname, problem, what) or
296-
file_sanity(clsname, problem, what) or
297-
class_value_sanity(clsname, problem, what)
286+
ast_consistency(clsname, problem, what) or
287+
location_consistency(clsname, problem, what) or
288+
scope_consistency(clsname, problem, what) or
289+
cfg_consistency(clsname, problem, what) or
290+
ssa_consistency(clsname, problem, what) or
291+
builtin_object_consistency(clsname, problem, what) or
292+
source_object_consistency(clsname, problem, what) or
293+
function_object_consistency(clsname, problem, what) or
294+
points_to_consistency(clsname, problem, what) or
295+
jump_to_definition_consistency(clsname, problem, what) or
296+
file_consistency(clsname, problem, what) or
297+
class_value_consistency(clsname, problem, what)
298298
select clsname + " " + what + " has " + problem

0 commit comments

Comments
 (0)