mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Python: Add jmespath tests
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.ConceptsTest
|
||||
@@ -0,0 +1,3 @@
|
||||
argumentToEnsureNotTaintedNotMarkedAsSpurious
|
||||
untaintedArgumentToEnsureTaintedNotMarkedAsMissing
|
||||
failures
|
||||
@@ -0,0 +1 @@
|
||||
import experimental.meta.InlineTaintTest
|
||||
@@ -0,0 +1,33 @@
|
||||
import jmespath
|
||||
|
||||
def test_idna():
|
||||
data = TAINTED_DICT
|
||||
|
||||
expression = jmespath.compile("foo.bar")
|
||||
|
||||
ensure_tainted(
|
||||
jmespath.search("foo.bar", data), # $ MISSING: tainted
|
||||
jmespath.search("foo.bar", data=data), # $ MISSING: tainted
|
||||
|
||||
expression.search(data), # $ MISSING: tainted
|
||||
expression.search(value=data) # $ MISSING: tainted
|
||||
)
|
||||
|
||||
# since ```jmespath.search("{wat: `foo`}", {})``` works (and outputs a dictionary),
|
||||
# we _could_ add a taint-step from the search expression to the output. However, it
|
||||
# seems more likely to lead to FPs than good results, so these have deliberately not
|
||||
# been included.
|
||||
|
||||
ts = TAINTED_STRING
|
||||
safe_data = {"foo": "bar"}
|
||||
|
||||
unsafe_expression = jmespath.compile(ts)
|
||||
|
||||
ensure_not_tainted(
|
||||
jmespath.search(ts, safe_data),
|
||||
jmespath.search(expression=ts, data=safe_data),
|
||||
|
||||
unsafe_expression,
|
||||
unsafe_expression.search(safe_data),
|
||||
unsafe_expression.search(value=safe_data),
|
||||
)
|
||||
Reference in New Issue
Block a user