Skip to content

Commit 5cdd60d

Browse files
committed
Python: Add jmespath tests
1 parent 6bdd7df commit 5cdd60d

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

python/ql/test/library-tests/frameworks/jmespath/ConceptsTest.expected

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import python
2+
import experimental.meta.ConceptsTest
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
argumentToEnsureNotTaintedNotMarkedAsSpurious
2+
untaintedArgumentToEnsureTaintedNotMarkedAsMissing
3+
failures
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import experimental.meta.InlineTaintTest
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import jmespath
2+
3+
def test_idna():
4+
data = TAINTED_DICT
5+
6+
expression = jmespath.compile("foo.bar")
7+
8+
ensure_tainted(
9+
jmespath.search("foo.bar", data), # $ MISSING: tainted
10+
jmespath.search("foo.bar", data=data), # $ MISSING: tainted
11+
12+
expression.search(data), # $ MISSING: tainted
13+
expression.search(value=data) # $ MISSING: tainted
14+
)
15+
16+
# since ```jmespath.search("{wat: `foo`}", {})``` works (and outputs a dictionary),
17+
# we _could_ add a taint-step from the search expression to the output. However, it
18+
# seems more likely to lead to FPs than good results, so these have deliberately not
19+
# been included.
20+
21+
ts = TAINTED_STRING
22+
safe_data = {"foo": "bar"}
23+
24+
unsafe_expression = jmespath.compile(ts)
25+
26+
ensure_not_tainted(
27+
jmespath.search(ts, safe_data),
28+
jmespath.search(expression=ts, data=safe_data),
29+
30+
unsafe_expression,
31+
unsafe_expression.search(safe_data),
32+
unsafe_expression.search(value=safe_data),
33+
)

0 commit comments

Comments
 (0)