Rasmus Lerchedahl Petersen
6730396ad6
Python: Remove tests from non-test directory
2021-02-01 08:52:00 +01:00
Rasmus Lerchedahl Petersen
f6fa1276a6
Python: Add consistency checks
...
to all data-flow test floders
2021-01-29 21:28:43 +01:00
Rasmus Lerchedahl Petersen
23d3343bfb
Merge branch 'main' of github.com:github/codeql into python-dataflow-modernize-tests
2021-01-19 18:24:52 +01:00
Rasmus Wriedt Larsen
e5e8ec6ecc
Python: Add a few test-cases for barrier guards and references
...
I'm not sure references is the best name, but it's the best I could come up with
jsut now
2020-12-07 15:27:20 +01:00
CodeQL CI
e266cedc84
Merge pull request #4700 from RasmusWL/python-add-code-injection-FP
...
Approved by tausbn
2020-12-02 16:29:21 +00:00
Rasmus Wriedt Larsen
a0c7365ae6
Python: Proper models of json.loads and json.dumps
2020-11-27 15:57:56 +01:00
Rasmus Wriedt Larsen
cc9a7fe4fe
Python: Move BarrierGuards to own file
2020-11-27 12:09:57 +01:00
Rasmus Lerchedahl Petersen
da805f8242
Merge remote-tracking branch 'upstream/main' into python-dataflow-modernize-tests
2020-11-24 10:56:22 +01:00
Rasmus Lerchedahl Petersen
a19304a4a0
Python: Factor out prettyPrinter and update tests
2020-11-24 02:17:38 +01:00
Rasmus Wriedt Larsen
f35ffa5632
Python: Add support for x in ["safe", "also_safe"] (and not in)
2020-11-23 10:42:24 +01:00
Rasmus Wriedt Larsen
431aab45f7
Python: Add support for x != "safe" BarrierGuard
2020-11-23 10:36:55 +01:00
Rasmus Wriedt Larsen
18041fd059
Python: Expand string-const-compare tests
...
Also moved file to reflect that. Added tests of
+ `!=`
+ `in`
+ `not in`
2020-11-23 10:36:49 +01:00
Rasmus Wriedt Larsen
08bcba98e6
Python: Add BarrierGuard test with exception inside unsafe branch
2020-11-20 11:55:07 +01:00
Rasmus Wriedt Larsen
34f78d4211
Python: Add BarrierGuard test with return inside unsafe branch
2020-11-20 11:52:36 +01:00
Rasmus Wriedt Larsen
12b36b2245
Python: Highlight that safe or also_safe doesn't clear taint :(
2020-11-20 10:43:46 +01:00
Rasmus Wriedt Larsen
1a52f17da3
Python: Add StringConstCompare BarrierGuard
2020-11-20 10:40:04 +01:00
Rasmus Wriedt Larsen
a82936c904
Python: Enable test for sanitizer-guard and logic expressions
...
`not` is not working properly, but otherwise pretty good
2020-11-20 10:06:25 +01:00
Rasmus Wriedt Larsen
b3d3d6e142
Python: Move logical test of sanitizers
...
Don't know why it would ever have been under default sanitizers :D
2020-11-19 16:46:07 +01:00
Anders Schack-Mulligen
89ef6ea4eb
C++/C#/Java/JavaScript/Python: Autoformat set literals.
2020-11-10 13:32:27 +01:00
Taus Brock-Nannestad
5dadb0f476
Python: Fix imports in tests
2020-11-02 23:02:29 +01:00
Rasmus Wriedt Larsen
247fd4f5f3
Python: Make encoding/decoding preserve taint automatically
...
With the way we have set things up, there is no way to opt out of this behavior.
2020-11-02 14:53:30 +01:00
yoff
5f6f85c998
Merge pull request #4465 from tausbn/python-remove-essa-flow
...
Python: Remove flow between ESSA variables
2020-10-14 15:37:39 +02:00
Taus Brock-Nannestad
fdb489fc93
Python: Remove flow between ESSA variables
...
This required a minor change in the type tracker implementation, but
apart from that no other changes appear to be needed. Seems to clean
up the test output quite a bit.
2020-10-13 16:35:41 +02:00
Rasmus Wriedt Larsen
76c9b8c49f
Python: Expose importNode instead of importModule/importMember
...
Since predicate name `import` is not allowed, I adopted `importNode` as it sort
of matches what `exprNode` does.
---
Due to only using `importMember` in `os_attr` we previously didn't handle
`import os.path as alias` :|
I did creat a hotfix for this (https://github.com/github/codeql/pull/4446 ), but
in doing so I realized the core of the problem: We're exposing ourselves to
making these kinds of mistakes by having BOTH importModule and importMember, and
we don't really gain anything from doing this!
We do loose the ability to easily only modeling `from mod import val` and not
`import mod.val`, but I don't think that will ever be relevant.
This change will also make us to recognize some invalid code, for example in
import os.system as runtime_error
we would now model that `runtime_error` is a reference to the `os.system`
function (although the actual import would result in a runtime error).
Overall these are tradeoffs I'm willing to make, as it does makes things simpler
from a QL modeling point of view, and THAT sounds nice 👍
2020-10-13 15:03:22 +02:00
Rasmus Wriedt Larsen
4bfd55f1af
Python: Show problem with os.path modeling
...
This is not a very good test for showing that we don't handle direct imports,
but it was the best I had available without inventing something new. It's very
fragile, since any of these would propagate taint (due to handling all `join`
calls as if the qualifier was a string):
ospath_alias.join(ts)
ospath_alias.join(ts, "foo", "bar")
But this test DOES serve the purpose of illustrating that my fix works :D
2020-10-13 14:50:00 +02:00
Rasmus Wriedt Larsen
1595fed2d6
Python: Add preliminary taint tests for pathlib
2020-09-30 11:44:37 +02:00
Rasmus Wriedt Larsen
0542c3b91e
Python: Model os.path.join and add taint-step
2020-09-30 11:42:36 +02:00
Rasmus Wriedt Larsen
efa2484718
Python: Add taint test for os.path.join
...
Surprisingly the first two just worked, due to our very general handling of any
`join` methods :D
2020-09-30 11:35:21 +02:00
Rasmus Wriedt Larsen
aa6fad558c
Python: Minor cleanup in taint-step tests
2020-09-30 11:15:53 +02:00
Taus
9d7a2d2b5d
Merge branch 'main' into python-add-global-flow-steps
2020-09-21 13:50:20 +02:00
Taus Brock-Nannestad
f93c44a688
Python: Fix typo
2020-09-17 13:26:55 +02:00
Taus Brock-Nannestad
1d462ae156
Python: Fix misnamed variable.
2020-09-17 13:22:27 +02:00
Taus Brock-Nannestad
797ac23db7
Python: Clean up global flow test
2020-09-17 13:20:58 +02:00
Taus Brock-Nannestad
9458861b18
Python: Add missing global flow test
2020-09-17 12:04:30 +02:00
Taus Brock-Nannestad
ee76d9b33d
Python: Clean up tests
2020-09-16 19:04:27 +02:00
Rasmus Lerchedahl Petersen
e46ae9b98d
Python: Move some query predicates to debug
2020-09-15 21:45:47 +02:00
Taus Brock-Nannestad
7cdd290b90
Python: Disregard module-time reads.
2020-09-15 18:25:24 +02:00
Taus Brock-Nannestad
d5e9f36747
Python: Add "enclosing callable" for ModuleVariableNode
...
I've named this `DataFlowModuleScope` since it's not really a
callable (and all of the relevant methods are empty anyway).
2020-09-15 14:23:20 +02:00
Taus Brock-Nannestad
3727c48227
Python: Record test changes
...
Some of the places where flow has disappeared look a bit suspect, so I
don't consider this to be the final word on these tests.
2020-09-14 18:12:20 +02:00
Rasmus Lerchedahl Petersen
ecc5a4a1f6
Python: testIsTrue -> branch
2020-09-14 15:32:03 +02:00
yoff
2a4e28db16
Apply suggestions from code review
...
Will make the same renames in the changed code also..
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com >
2020-09-14 15:28:01 +02:00
Rasmus Lerchedahl Petersen
033529e85e
Python: avoid creating big predicate
2020-09-14 15:24:46 +02:00
Rasmus Lerchedahl Petersen
543876f980
Python: Fix getAGuardedNode
2020-09-14 14:46:15 +02:00
Rasmus Lerchedahl Petersen
0eb8b6c7b0
Python: Address review
2020-09-11 14:24:49 +02:00
Rasmus Lerchedahl Petersen
5dbb4af5b5
Python: Implement BarrierGuard
2020-09-11 11:55:51 +02:00
Rasmus Lerchedahl Petersen
2eb8ea85fb
Python: update test expectations
2020-09-10 10:59:26 +02:00
Rasmus Lerchedahl Petersen
deb1a4ceb9
Merge branch 'main' of github.com:github/codeql into SharedDataflow_UseUseFlow
2020-09-10 10:55:34 +02:00
Rasmus Wriedt Larsen
b8e057f7ad
Python: isSanitizerGuard test is future work
2020-09-09 15:57:53 +02:00
Rasmus Lerchedahl Petersen
b1567827a0
Python: Repair flow out of post-update nodes
2020-09-09 15:52:07 +02:00
Rasmus Wriedt Larsen
ab8cc23ce7
Python: Expand on taint sanitizer tests
...
Most interesting to look at the custom sanitizers. Once we have use-use flow, we
should handle this case:
```
s = TAINTED_STRING
emulated_authentication_check(s)
ensure_not_tainted(s)
```
2020-09-09 13:57:25 +02:00