-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Python: add BoundMethodValue (round 2) #3407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
semmle-qlci
merged 21 commits into
github:master
from
RasmusWL:python-add-BoundMethodValue-v2
May 25, 2020
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7b8b4af
Python: Add test for call.getFunction().refersTo
RasmusWL a5289bd
Python: Use Object in CallRefersTo test
RasmusWL 06b67e0
Python: Modernise test/library-tests/PointsTo/calls/*
RasmusWL f624754
Python: Use Value in GetACAll test
RasmusWL fc0b022
Python: Add test-cases for BuiltinFunction and BuiltinMethod
RasmusWL 9ec32ee
Python: Add test-cases using keyword arguments
RasmusWL acb506d
Python: Add test for getNamedArgumentForCall
RasmusWL e9859ad
Python: Fix getArgumentForCall when using keyword arguments
RasmusWL 96fdb7a
Python: Add tests for getParameter[byName]
RasmusWL bc92c26
Python: Add BoundMethodValue
RasmusWL 838106d
Python: Refactor get[Named]ArgumentForCall
RasmusWL 061bbb8
Python: Restructure getNamedArgumentForCall
RasmusWL 87d7738
Python: Expand QLDoc for get[Named]ArgumentForCall
RasmusWL dfe7c82
Python: Clean up trailing whitespace
RasmusWL affca1a
Python: Add test-cases using keyword arguments for builtin function
RasmusWL 07ae402
Python: Don't allow getParameter(-1) for BoundMethodValue
RasmusWL 6488714
Python: Autoformat
RasmusWL 9e0d57c
Python: Fix grammar in QLDoc
RasmusWL 87ee6ae
Python: Add a bit of docs to CallableObjectInternal
RasmusWL 4fc3cae
Python: Add test for how arguments to *args and **kwargs are handled
RasmusWL 49d7e12
Python: Remove unnecessary restriction from getNamedArgumentForCall
RasmusWL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
python/ql/test/library-tests/PointsTo/calls/Argument.expected
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
python/ql/test/library-tests/PointsTo/calls/CallPointsTo.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
| 19 | ControlFlowNode for f() | Function f | | ||
| 21 | ControlFlowNode for f() | Function f | | ||
| 22 | ControlFlowNode for C() | class C | | ||
| 23 | ControlFlowNode for Attribute() | Method(Function f, C()) | | ||
| 24 | ControlFlowNode for Attribute() | Method(Function C.n, C()) | | ||
| 25 | ControlFlowNode for Attribute() | Function C.n | | ||
| 29 | ControlFlowNode for staticmethod() | builtin-class staticmethod | | ||
| 33 | ControlFlowNode for Attribute() | Function D.foo | | ||
| 34 | ControlFlowNode for Attribute() | Function D.foo | | ||
| 34 | ControlFlowNode for D() | class D | | ||
| 37 | ControlFlowNode for Attribute() | Method(builtin method append, List) | | ||
| 38 | ControlFlowNode for len() | Builtin-function len | | ||
| 40 | ControlFlowNode for f() | Function f | | ||
| 41 | ControlFlowNode for C() | class C | | ||
| 42 | ControlFlowNode for Attribute() | Method(Function C.n, C()) | | ||
| 45 | ControlFlowNode for open() | Builtin-function open | | ||
| 46 | ControlFlowNode for open() | Builtin-function open | | ||
| 51 | ControlFlowNode for foo() | Function foo | | ||
| 55 | ControlFlowNode for bar() | Function bar | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import python | ||
|
||
from CallNode call, Value func | ||
where call.getFunction().pointsTo(func) | ||
select call.getLocation().getStartLine(), call.toString(), func.toString() |
23 changes: 23 additions & 0 deletions
23
python/ql/test/library-tests/PointsTo/calls/GetACall.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
| 19 | ControlFlowNode for f() | Function f | | ||
| 21 | ControlFlowNode for f() | Function f | | ||
| 22 | ControlFlowNode for C() | class C | | ||
| 23 | ControlFlowNode for Attribute() | Function f | | ||
| 23 | ControlFlowNode for Attribute() | Method(Function f, C()) | | ||
| 24 | ControlFlowNode for Attribute() | Function C.n | | ||
| 24 | ControlFlowNode for Attribute() | Method(Function C.n, C()) | | ||
| 25 | ControlFlowNode for Attribute() | Function C.n | | ||
| 29 | ControlFlowNode for staticmethod() | builtin-class staticmethod | | ||
| 33 | ControlFlowNode for Attribute() | Function D.foo | | ||
| 34 | ControlFlowNode for Attribute() | Function D.foo | | ||
| 34 | ControlFlowNode for D() | class D | | ||
| 37 | ControlFlowNode for Attribute() | Method(builtin method append, List) | | ||
| 37 | ControlFlowNode for Attribute() | builtin method append | | ||
| 38 | ControlFlowNode for len() | Builtin-function len | | ||
| 40 | ControlFlowNode for f() | Function f | | ||
| 41 | ControlFlowNode for C() | class C | | ||
| 42 | ControlFlowNode for Attribute() | Function C.n | | ||
| 42 | ControlFlowNode for Attribute() | Method(Function C.n, C()) | | ||
| 45 | ControlFlowNode for open() | Builtin-function open | | ||
| 46 | ControlFlowNode for open() | Builtin-function open | | ||
| 51 | ControlFlowNode for foo() | Function foo | | ||
| 55 | ControlFlowNode for bar() | Function bar | |
2 changes: 1 addition & 1 deletion
2
...test/library-tests/PointsTo/calls/Call.ql → .../library-tests/PointsTo/calls/GetACall.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import python | ||
|
||
from ControlFlowNode call, FunctionObject func | ||
from ControlFlowNode call, Value func | ||
where call = func.getACall() | ||
select call.getLocation().getStartLine(), call.toString(), func.toString() |
34 changes: 34 additions & 0 deletions
34
python/ql/test/library-tests/PointsTo/calls/getArgumentForCall.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
| 19 | ControlFlowNode for f() | Function f | 0 | ControlFlowNode for w | | ||
| 19 | ControlFlowNode for f() | Function f | 1 | ControlFlowNode for x | | ||
| 19 | ControlFlowNode for f() | Function f | 2 | ControlFlowNode for y | | ||
| 21 | ControlFlowNode for f() | Function f | 0 | ControlFlowNode for y | | ||
| 21 | ControlFlowNode for f() | Function f | 1 | ControlFlowNode for w | | ||
| 21 | ControlFlowNode for f() | Function f | 2 | ControlFlowNode for z | | ||
| 23 | ControlFlowNode for Attribute() | Function f | 0 | ControlFlowNode for c | | ||
| 23 | ControlFlowNode for Attribute() | Function f | 1 | ControlFlowNode for w | | ||
| 23 | ControlFlowNode for Attribute() | Function f | 2 | ControlFlowNode for z | | ||
| 23 | ControlFlowNode for Attribute() | Method(Function f, C()) | 0 | ControlFlowNode for w | | ||
| 23 | ControlFlowNode for Attribute() | Method(Function f, C()) | 1 | ControlFlowNode for z | | ||
| 24 | ControlFlowNode for Attribute() | Function C.n | 0 | ControlFlowNode for c | | ||
| 24 | ControlFlowNode for Attribute() | Function C.n | 1 | ControlFlowNode for x | | ||
| 24 | ControlFlowNode for Attribute() | Method(Function C.n, C()) | 0 | ControlFlowNode for x | | ||
| 25 | ControlFlowNode for Attribute() | Function C.n | 0 | ControlFlowNode for y | | ||
| 25 | ControlFlowNode for Attribute() | Function C.n | 1 | ControlFlowNode for z | | ||
| 33 | ControlFlowNode for Attribute() | Function D.foo | 0 | ControlFlowNode for IntegerLiteral | | ||
| 34 | ControlFlowNode for Attribute() | Function D.foo | 0 | ControlFlowNode for IntegerLiteral | | ||
| 37 | ControlFlowNode for Attribute() | Method(builtin method append, List) | 0 | ControlFlowNode for IntegerLiteral | | ||
| 37 | ControlFlowNode for Attribute() | builtin method append | 0 | ControlFlowNode for l | | ||
| 37 | ControlFlowNode for Attribute() | builtin method append | 1 | ControlFlowNode for IntegerLiteral | | ||
| 38 | ControlFlowNode for len() | Builtin-function len | 0 | ControlFlowNode for l | | ||
| 40 | ControlFlowNode for f() | Function f | 0 | ControlFlowNode for IntegerLiteral | | ||
| 40 | ControlFlowNode for f() | Function f | 1 | ControlFlowNode for IntegerLiteral | | ||
| 40 | ControlFlowNode for f() | Function f | 2 | ControlFlowNode for IntegerLiteral | | ||
| 42 | ControlFlowNode for Attribute() | Function C.n | 0 | ControlFlowNode for c | | ||
| 42 | ControlFlowNode for Attribute() | Function C.n | 1 | ControlFlowNode for IntegerLiteral | | ||
| 42 | ControlFlowNode for Attribute() | Method(Function C.n, C()) | 0 | ControlFlowNode for IntegerLiteral | | ||
| 45 | ControlFlowNode for open() | Builtin-function open | 0 | ControlFlowNode for Str | | ||
| 45 | ControlFlowNode for open() | Builtin-function open | 1 | ControlFlowNode for Str | | ||
| 51 | ControlFlowNode for foo() | Function foo | 0 | ControlFlowNode for IntegerLiteral | | ||
| 51 | ControlFlowNode for foo() | Function foo | 1 | ControlFlowNode for IntegerLiteral | | ||
| 51 | ControlFlowNode for foo() | Function foo | 2 | ControlFlowNode for IntegerLiteral | | ||
| 55 | ControlFlowNode for bar() | Function bar | 0 | ControlFlowNode for IntegerLiteral | |
5 changes: 5 additions & 0 deletions
5
python/ql/test/library-tests/PointsTo/calls/getArgumentForCall.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import python | ||
|
||
from CallNode call, CallableValue callable, int i | ||
select call.getLocation().getStartLine(), call.toString(), callable.toString(), i, | ||
callable.getArgumentForCall(call, i).toString() |
31 changes: 31 additions & 0 deletions
31
python/ql/test/library-tests/PointsTo/calls/getNamedArgumentForCall.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
| 19 | ControlFlowNode for f() | Function f | arg0 | ControlFlowNode for w | | ||
| 19 | ControlFlowNode for f() | Function f | arg1 | ControlFlowNode for x | | ||
| 19 | ControlFlowNode for f() | Function f | arg2 | ControlFlowNode for y | | ||
| 21 | ControlFlowNode for f() | Function f | arg0 | ControlFlowNode for y | | ||
| 21 | ControlFlowNode for f() | Function f | arg1 | ControlFlowNode for w | | ||
| 21 | ControlFlowNode for f() | Function f | arg2 | ControlFlowNode for z | | ||
| 23 | ControlFlowNode for Attribute() | Function f | arg1 | ControlFlowNode for w | | ||
| 23 | ControlFlowNode for Attribute() | Function f | arg2 | ControlFlowNode for z | | ||
| 23 | ControlFlowNode for Attribute() | Function f | self | ControlFlowNode for c | | ||
| 23 | ControlFlowNode for Attribute() | Method(Function f, C()) | arg1 | ControlFlowNode for w | | ||
| 23 | ControlFlowNode for Attribute() | Method(Function f, C()) | arg2 | ControlFlowNode for z | | ||
| 24 | ControlFlowNode for Attribute() | Function C.n | arg1 | ControlFlowNode for x | | ||
| 24 | ControlFlowNode for Attribute() | Function C.n | self | ControlFlowNode for c | | ||
| 24 | ControlFlowNode for Attribute() | Method(Function C.n, C()) | arg1 | ControlFlowNode for x | | ||
| 25 | ControlFlowNode for Attribute() | Function C.n | arg1 | ControlFlowNode for z | | ||
| 25 | ControlFlowNode for Attribute() | Function C.n | self | ControlFlowNode for y | | ||
| 33 | ControlFlowNode for Attribute() | Function D.foo | arg | ControlFlowNode for IntegerLiteral | | ||
| 34 | ControlFlowNode for Attribute() | Function D.foo | arg | ControlFlowNode for IntegerLiteral | | ||
| 37 | ControlFlowNode for Attribute() | builtin method append | self | ControlFlowNode for l | | ||
| 40 | ControlFlowNode for f() | Function f | arg0 | ControlFlowNode for IntegerLiteral | | ||
| 40 | ControlFlowNode for f() | Function f | arg1 | ControlFlowNode for IntegerLiteral | | ||
| 40 | ControlFlowNode for f() | Function f | arg2 | ControlFlowNode for IntegerLiteral | | ||
| 42 | ControlFlowNode for Attribute() | Function C.n | arg1 | ControlFlowNode for IntegerLiteral | | ||
| 42 | ControlFlowNode for Attribute() | Function C.n | self | ControlFlowNode for c | | ||
| 42 | ControlFlowNode for Attribute() | Method(Function C.n, C()) | arg1 | ControlFlowNode for IntegerLiteral | | ||
| 46 | ControlFlowNode for open() | Builtin-function open | file | ControlFlowNode for Str | | ||
| 46 | ControlFlowNode for open() | Builtin-function open | mode | ControlFlowNode for Str | | ||
| 51 | ControlFlowNode for foo() | Function foo | a | ControlFlowNode for IntegerLiteral | | ||
| 55 | ControlFlowNode for bar() | Function bar | a | ControlFlowNode for IntegerLiteral | | ||
| 55 | ControlFlowNode for bar() | Function bar | b | ControlFlowNode for IntegerLiteral | | ||
| 55 | ControlFlowNode for bar() | Function bar | c | ControlFlowNode for IntegerLiteral | |
5 changes: 5 additions & 0 deletions
5
python/ql/test/library-tests/PointsTo/calls/getNamedArgumentForCall.ql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import python | ||
|
||
from CallNode call, CallableValue callable, string name | ||
select call.getLocation().getStartLine(), call.toString(), callable.toString(), name, | ||
callable.getNamedArgumentForCall(call, name).toString() |
12 changes: 12 additions & 0 deletions
12
python/ql/test/library-tests/PointsTo/calls/getParameter.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
| Function C.n | 0 | ControlFlowNode for self | | ||
| Function C.n | 1 | ControlFlowNode for arg1 | | ||
| Function D.foo | 0 | ControlFlowNode for arg | | ||
| Function bar | 0 | ControlFlowNode for a | | ||
| Function f | 0 | ControlFlowNode for arg0 | | ||
| Function f | 1 | ControlFlowNode for arg1 | | ||
| Function f | 2 | ControlFlowNode for arg2 | | ||
| Function foo | 0 | ControlFlowNode for a | | ||
| Method(Function C.n, C()) | 0 | ControlFlowNode for arg1 | | ||
| Method(Function C.n, class C) | 0 | ControlFlowNode for arg1 | | ||
| Method(Function f, C()) | 0 | ControlFlowNode for arg1 | | ||
| Method(Function f, C()) | 1 | ControlFlowNode for arg2 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import python | ||
|
||
from CallableValue callable, int i | ||
select callable.toString(), i, callable.getParameter(i).toString() |
12 changes: 12 additions & 0 deletions
12
python/ql/test/library-tests/PointsTo/calls/getParameterByName.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
| Function C.n | arg1 | ControlFlowNode for arg1 | | ||
| Function C.n | self | ControlFlowNode for self | | ||
| Function D.foo | arg | ControlFlowNode for arg | | ||
| Function bar | a | ControlFlowNode for a | | ||
| Function f | arg0 | ControlFlowNode for arg0 | | ||
| Function f | arg1 | ControlFlowNode for arg1 | | ||
| Function f | arg2 | ControlFlowNode for arg2 | | ||
| Function foo | a | ControlFlowNode for a | | ||
| Method(Function C.n, C()) | arg1 | ControlFlowNode for arg1 | | ||
| Method(Function C.n, class C) | arg1 | ControlFlowNode for arg1 | | ||
| Method(Function f, C()) | arg1 | ControlFlowNode for arg1 | | ||
| Method(Function f, C()) | arg2 | ControlFlowNode for arg2 | |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.