Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 165dcd3

Browse files
committed
Python: Autoformat library-tests.
1 parent 67cb852 commit 165dcd3

11 files changed

Lines changed: 96 additions & 388 deletions

File tree

python/ql/test/library-tests/PointsTo/general/interesting.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
21
import python
32

43
predicate of_interest(ControlFlowNode n, int line) {
54
exists(Location l, File f | l = n.getLocation() |
65
line = l.getStartLine() and
76
f = l.getFile() and
87
f.getName().matches("%test.py%") and
9-
exists(Comment c |
8+
exists(Comment c |
109
c.getLocation().getStartLine() < line and
1110
c.getLocation().getFile() = f
1211
)

python/ql/test/library-tests/PointsTo/new/Util.qll

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ string locate(Location l, string which) {
1313
}
1414

1515
string repr(Object o) {
16-
/* Do not show `unknownValue()` to keep noise levels down.
16+
/*
17+
* Do not show `unknownValue()` to keep noise levels down.
1718
* To show it add:
1819
* `o = unknownValue() and result = "*UNKNOWN VALUE*"`
1920
*/
20-
not o instanceof StringObject and not o = undefinedVariable() and not o = theUnknownType() and
21-
not o = theBoundMethodType() and result = o.toString()
21+
22+
not o instanceof StringObject and
23+
not o = undefinedVariable() and
24+
not o = theUnknownType() and
25+
not o = theBoundMethodType() and
26+
result = o.toString()
2227
or
2328
o = undefinedVariable() and result = "*UNDEFINED*"
2429
or
@@ -30,16 +35,15 @@ string repr(Object o) {
3035
o = theBoundMethodType() and result = "builtin-class method"
3136
}
3237

33-
predicate long_tuple(Value v) {
34-
v.(TupleObjectInternal).length() > 3
35-
}
38+
predicate long_tuple(Value v) { v.(TupleObjectInternal).length() > 3 }
3639

3740
string vrepr(Value v) {
3841
/* Work around differing names in 2/3 */
3942
not v = ObjectInternal::boundMethod() and
40-
not long_tuple(v) and result = v.toString()
43+
not long_tuple(v) and
44+
result = v.toString()
4145
or
4246
v = ObjectInternal::boundMethod() and result = "builtin-class method"
4347
or
4448
long_tuple(v) and result = "(..., ...)"
45-
}
49+
}
Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,18 @@
11
import python
22
import semmle.python.dataflow.StateTracking
33

4-
predicate callTo(CallNode call, string name) {
5-
call.getFunction().(NameNode).getId() = name
6-
}
4+
predicate callTo(CallNode call, string name) { call.getFunction().(NameNode).getId() = name }
75

86
class Initialized extends TrackableState {
9-
107
Initialized() { this = "initialized" }
118

12-
override predicate startsAt(ControlFlowNode f) {
13-
callTo(f, "initialize")
14-
}
15-
9+
override predicate startsAt(ControlFlowNode f) { callTo(f, "initialize") }
1610
}
1711

18-
1912
class Frobnicated extends TrackableState {
20-
2113
Frobnicated() { this = "frobnicated" }
2214

23-
override predicate startsAt(ControlFlowNode f) {
24-
callTo(f, "frobnicate")
25-
}
26-
27-
override predicate endsAt(ControlFlowNode f) {
28-
callTo(f, "defrobnicate")
29-
}
15+
override predicate startsAt(ControlFlowNode f) { callTo(f, "frobnicate") }
3016

17+
override predicate endsAt(ControlFlowNode f) { callTo(f, "defrobnicate") }
3118
}

python/ql/test/library-tests/taint/collections/Taint.qll

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,26 @@ import python
22
import semmle.python.security.TaintTracking
33
import semmle.python.security.strings.Untrusted
44

5-
65
class SimpleSource extends TaintSource {
7-
86
SimpleSource() { this.(NameNode).getId() = "TAINTED_STRING" }
97

10-
override predicate isSourceOf(TaintKind kind) {
11-
kind instanceof ExternalStringKind
12-
}
13-
14-
override string toString() {
15-
result = "taint source"
16-
}
8+
override predicate isSourceOf(TaintKind kind) { kind instanceof ExternalStringKind }
179

10+
override string toString() { result = "taint source" }
1811
}
1912

2013
class ListSource extends TaintSource {
21-
2214
ListSource() { this.(NameNode).getId() = "TAINTED_LIST" }
2315

24-
override predicate isSourceOf(TaintKind kind) {
25-
kind instanceof ExternalStringSequenceKind
26-
}
27-
28-
override string toString() {
29-
result = "list taint source"
30-
}
16+
override predicate isSourceOf(TaintKind kind) { kind instanceof ExternalStringSequenceKind }
3117

18+
override string toString() { result = "list taint source" }
3219
}
3320

3421
class DictSource extends TaintSource {
35-
3622
DictSource() { this.(NameNode).getId() = "TAINTED_DICT" }
3723

38-
override predicate isSourceOf(TaintKind kind) {
39-
kind instanceof ExternalStringDictKind
40-
}
41-
42-
override string toString() {
43-
result = "dict taint source"
44-
}
24+
override predicate isSourceOf(TaintKind kind) { kind instanceof ExternalStringDictKind }
4525

26+
override string toString() { result = "dict taint source" }
4627
}

0 commit comments

Comments
 (0)