Rasmus Lerchedahl Petersen
da4aef80e9
Revert "Python: make it a real consistency check"
...
This reverts commit 45411f4a93 .
2023-12-20 16:15:17 +01:00
Rasmus Lerchedahl Petersen
d039ceb689
Python: add test for fields
2023-12-20 15:23:45 +01:00
Rasmus Lerchedahl Petersen
45411f4a93
Python: make it a real consistency check
2023-12-20 14:53:37 +01:00
Rasmus Lerchedahl Petersen
78c484faab
Python: remove support for capturing callbacks
...
This will be added in a follow-up PR instead.
2023-12-18 23:24:57 +01:00
Rasmus Lerchedahl Petersen
479d81fb75
Python: fix nonlocal captured variables
...
This depends on the extractor fix
2023-12-14 10:37:27 +01:00
Rasmus Lerchedahl Petersen
17a0029585
Python: support callbacks to library calls
...
TODO:
The member predicate `LibraryLambdaMethod::getACall` is
currently too permissive.
Ideally, we would have `libraryCallHasLambdaArg`
as in Ruby. But even a more precise
`libraryCall` predicate might be fine.
2023-12-14 10:27:15 +01:00
Rasmus Lerchedahl Petersen
7565873e83
Python: test callbacks to library calls
2023-12-14 10:27:15 +01:00
Rasmus Lerchedahl Petersen
c054ba6a97
python: instantiate module for variable capture
...
This provides variable capture in standard situations:
- nested functions
- lambdas
There are some deficiencies:
- we do not yet handle objects capturing variables.
- we do not handle variables captured via the `nonlocal` keyword.
This should be solved at the AST level, though, and then it
should "just work".
There are still inconsistencies in the case where
a `SynthesizedCaptureNode` has a comprehensions
as its enclosing callable. In this case,
`TFunction(cn.getEnclosingCallable())` is not
defined and so getEnclosingCallable does not exist
for the `CaptureNode`.
2023-12-14 10:25:39 +01:00
Rasmus Lerchedahl Petersen
6db55cd12f
Python: add missing annotation
2023-12-14 10:20:49 +01:00
Rasmus Wriedt Larsen
df9fb141b8
Python: Remove old manual consistency query tests
2023-11-21 11:50:23 +01:00
Rasmus Wriedt Larsen
55f5b26ba6
Python: Accept new ordering of query predicates in .expected
2023-11-15 10:09:54 +01:00
Rasmus Wriedt Larsen
9f43108ba8
Python: Fix DataFlowCall.getEnclosingCallable
...
Now it is aligned with the implementation of DataFlow::Node
See 4bc4e0845d/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPublic.qll (L134-L138)
2023-11-07 11:29:23 +01:00
Rasmus Lerchedahl Petersen
58bf70d61b
Python: filter self steps from use-use flow
...
Factor out use-use flow in order to do this.
Also improve names and comments.
I also wanted to change the types in `difinitionFlowStep`, but
that broke the module instantiation.
2023-11-02 09:31:28 +01:00
Tom Hvitved
d3558f8579
Python: Update expected test output
2023-09-12 21:18:31 +02:00
Jeroen Ketema
dba4460526
Python: Update more inline expectation tests to use the paramterized module
2023-06-20 10:16:15 +02:00
Jeroen Ketema
8f599faf85
Python: Rewrite inline expectation tests to use parameterized module
2023-06-09 10:42:29 +02:00
yoff
25899c15c9
Merge pull request #13098 from hvitved/python/update-consistency-expected
...
Python: Update expected test output
2023-05-10 08:58:27 +02:00
Tom Hvitved
4d84f92e8c
Python: Update expected test output
2023-05-10 08:15:15 +02:00
yoff
1a57f81aca
Merge pull request #12537 from yoff/python/captured-variables-for-typetracking
...
Python: Captured variables for type tracking and the API graph
2023-05-09 12:34:22 +02:00
Mathias Vorreiter Pedersen
e650df810d
Python: Accept consistency changes.
2023-05-03 20:33:00 +01:00
Rasmus Lerchedahl Petersen
6d9fd24f1b
python: update comments
2023-05-03 18:10:15 +02:00
yoff
e49f7a5d33
Update python/ql/test/experimental/dataflow/variable-capture/by_value.py
...
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com >
2023-05-03 18:03:39 +02:00
Rasmus Wriedt Larsen
c89b57997a
Python: Change variable capture tests to use fresh variable names
...
Instead of reusing `nonSink0` for both captureOut1NotCalled and
captureOut2NotCalled tests (I used 1/2 naming scheme to match things up
nicely).
I also added a comment highlighting that `m` is the function that is not
called (since I overlooked that initially :O)
2023-05-02 14:13:56 +02:00
Rasmus Lerchedahl Petersen
00b85cbfb9
python: remove blank line
2023-04-26 16:26:26 +02:00
Rasmus Lerchedahl Petersen
20cbc08627
python: we want empty expected files
...
(thanks @RasmusWL)
2023-04-26 15:54:23 +02:00
Rasmus Lerchedahl Petersen
843329f2fb
python: no longer missing
2023-04-26 15:06:03 +02:00
Rasmus Lerchedahl Petersen
66fdf6b241
python: add test for capturing by value
2023-04-26 15:05:03 +02:00
Rasmus Lerchedahl Petersen
003fece490
python: add test for capturing via global
2023-04-26 14:52:40 +02:00
Rasmus Lerchedahl Petersen
824d4d5413
python: fix test expectations
...
also rename `collections.py` so it does not
clash with the standard library name.
This clash is an issue when testing locally.
2023-04-26 13:31:37 +02:00
yoff
e21e630316
Merge branch 'main' into python/add-test-to-valid
2023-03-21 14:47:17 +01:00
Rasmus Wriedt Larsen
346086524b
Python: Accept dataflow-consistency test changes
...
To PRs must have had a conflict when merged separately
2023-03-21 10:09:01 +01:00
Rasmus Lerchedahl Petersen
6a5db750c4
python: add test to validation (and fix it)
2023-03-20 15:07:46 +01:00
yoff
17c9ba9872
Merge pull request #12464 from yoff/python/add-test-captured-in-collection
...
python: add test for captured variables in lists
2023-03-20 15:01:58 +01:00
Tom Hvitved
404ead8a18
Python: Update expected test output
2023-03-16 08:40:53 +01:00
Rasmus Lerchedahl Petersen
bbb43a53e5
python: add test for captured variables
...
this illustrates that the function implementing
the comprehension does not capture `mod_local`.
We could handle this case specially, by having
a different implementation for `for`, but the
wider issue would remain.
2023-03-09 11:44:58 +01:00
Rasmus Wriedt Larsen
61151d4aa7
Merge branch 'main' into call-graph-code
2023-01-16 13:39:15 +01:00
Tony Torralba
d87c8c75d6
Python: Remove omittable exists variables
2023-01-10 13:37:35 +01:00
Tom Hvitved
39fea378b8
Python: Update expected test output
2022-12-13 09:53:01 +01:00
Rasmus Wriedt Larsen
a826c4f48b
Merge branch 'main' into call-graph-code
2022-12-08 11:39:30 +01:00
Tom Hvitved
8f701cf1cb
Python: Update expected test output
2022-12-05 14:33:06 +01:00
Rasmus Wriedt Larsen
eb600f07b7
Python: Use config for dataflow-consistency.ql
...
And ignore post-update nodes for `**kwargs` arguments
2022-11-22 14:46:30 +01:00
Rasmus Wriedt Larsen
88f703af1f
DataFlow: Accept changes to .expected
2022-11-10 22:13:34 +01:00
Tom Hvitved
f4b82cb2e8
Python: Update expected test output
2022-09-22 15:01:40 +02:00
Rasmus Wriedt Larsen
01d426dc58
Python: Replace rest of from testlib import *
...
I think we should write our tests in a way that puts points-to in the
best condition to resolve calls. Although this specific change did not
change much, it should help set us up for success in the future 👍
2022-02-28 10:58:44 +01:00
Rasmus Lerchedahl Petersen
f6fa1276a6
Python: Add consistency checks
...
to all data-flow test floders
2021-01-29 21:28:43 +01:00
yoff
215986bce5
Apply suggestions from code review
...
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com >
2020-11-24 14:12:23 +01:00
Rasmus Lerchedahl Petersen
05d156ba0f
Python: add comments
2020-11-24 14:11:14 +01:00
Rasmus Lerchedahl Petersen
7cbbf3bbf7
Python: slightly nicer test
2020-11-19 16:20:57 +01:00
Rasmus Lerchedahl Petersen
39f134c1c1
Python: reorganized and added to tests
2020-11-19 12:06:58 +01:00
Rasmus Lerchedahl Petersen
71830abda0
Python: remaining c# tests, except lambdas
...
both via nonlocal and via dict
2020-11-17 08:28:11 +01:00