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

Skip to content

Commit b0ebb5b

Browse files
committed
Python: Adjust tag format
1 parent 9338374 commit b0ebb5b

4 files changed

Lines changed: 20 additions & 17 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import dill
22

3-
dill.loads(payload) # $UNSAFE_getAnInput=payload $UNSAFE_getOutput=Attribute() $UNSAFE_getFormat=dill
4-
dill.loads(payload, encoding='latin1') # $UNSAFE_getAnInput=payload $UNSAFE_getOutput=Attribute() $UNSAFE_getFormat=dill
3+
dill.loads(payload) # $decodeInput=payload $decodeOutput=Attribute() $decodeFormat=dill $decodeUnsafe=
4+
dill.loads(payload, encoding='latin1') # $decodeInput=payload $decodeOutput=Attribute() $decodeFormat=dill $decodeUnsafe=

python/ql/test/experimental/library-tests/frameworks/stdlib/Decoding.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
@app.route("/")
1111
def hello():
1212
payload = request.args.get("payload")
13-
pickle.loads(payload) # $UNSAFE_getAnInput=payload $UNSAFE_getOutput=Attribute() $UNSAFE_getFormat=pickle
14-
pickle.loads(payload, encoding='latin1') # $UNSAFE_getAnInput=payload $UNSAFE_getOutput=Attribute() $UNSAFE_getFormat=pickle
15-
marshal.loads(payload) # $UNSAFE_getAnInput=payload $UNSAFE_getOutput=Attribute() $UNSAFE_getFormat=marshal
13+
pickle.loads(payload) # $decodeInput=payload $decodeOutput=Attribute() $decodeFormat=pickle $decodeUnsafe=
14+
pickle.loads(payload, encoding='latin1') # $decodeInput=payload $decodeOutput=Attribute() $decodeFormat=pickle $decodeUnsafe=
15+
marshal.loads(payload) # $decodeInput=payload $decodeOutput=Attribute() $decodeFormat=pickle $decodeUnsafe=

python/ql/test/experimental/library-tests/frameworks/yaml/Decoding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
@app.route("/")
1111
def hello():
1212
payload = request.args.get("payload")
13-
yaml.load(payload) # $UNSAFE_getAnInput=payload $UNSAFE_getOutput=Attribute() $UNSAFE_getFormat=YAML
14-
yaml.load(payload, Loader=SafeLoader) # $getAnInput=payload $getOutput=Attribute() $getFormat=YAML
13+
yaml.load(payload) # $decodeInput=payload $decodeOutput=Attribute() $decodeFormat=YAML $decodeUnsafe=
14+
yaml.load(payload, Loader=SafeLoader) # $decodeInput=payload $decodeOutput=Attribute() $decodeFormat=YAML

python/ql/test/experimental/meta/ConceptsTest.qll

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,24 @@ class SystemCommandExecutionTest extends InlineExpectationsTest {
3636
class DecodingTest extends InlineExpectationsTest {
3737
DecodingTest() { this = "DecodingTest" }
3838

39-
override string getARelevantTag() { result in ["getAnInput", "getOutput", "getFormat"] }
39+
override string getARelevantTag() {
40+
result in ["decodeInput", "decodeOutput", "decodeFormat", "decodeUnsafe"]
41+
}
4042

4143
override predicate hasActualResult(Location location, string element, string tag, string value) {
4244
exists(location.getFile().getRelativePath()) and
43-
exists(Decoding d, string unsafe |
44-
(
45-
d.unsafe() and unsafe = "UNSAFE_"
46-
or
47-
not d.unsafe() and unsafe = ""
48-
) and
45+
exists(Decoding d |
4946
(
5047
exists(DataFlow::Node data |
5148
location = data.getLocation() and
5249
element = data.toString() and
5350
value = value_from_expr(data.asExpr()) and
5451
(
5552
data = d.getAnInput() and
56-
tag = unsafe + "getAnInput"
53+
tag = "decodeInput"
5754
or
5855
data = d.getOutput() and
59-
tag = unsafe + "getOutput"
56+
tag = "decodeOutput"
6057
)
6158
)
6259
or
@@ -65,8 +62,14 @@ class DecodingTest extends InlineExpectationsTest {
6562
element = format and
6663
value = format and
6764
format = d.getFormat() and
68-
tag = unsafe + "getFormat"
65+
tag = "decodeFormat"
6966
)
67+
or
68+
d.unsafe() and
69+
location = d.getLocation() and
70+
element = d.toString() and
71+
value = "" and
72+
tag = "decodeUnsafe"
7073
)
7174
)
7275
}

0 commit comments

Comments
 (0)