Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 46acce0

Browse files
committed
add support for the Subclass token
1 parent a02e812 commit 46acce0

4 files changed

Lines changed: 12 additions & 1 deletion

File tree

python/ql/lib/semmle/python/frameworks/data/internal/ApiGraphModelsSpecific.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ API::Node getExtraSuccessorFromNode(API::Node node, AccessPathToken token) {
5757
or
5858
token.getName() = "Awaited" and
5959
result = node.getAwaited()
60+
or
61+
token.getName() = "Subclass" and
62+
result = node.getASubclass*()
6063
// Some features don't have MaD tokens yet, they would need to be added to API-graphs first.
6164
// - decorators ("DecoratedClass", "DecoratedMember", "DecoratedParameter")
6265
// - Array/Map elements ("ArrayElement", "Element", "MapKey", "MapValue")

python/ql/test/library-tests/frameworks/data/test.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ isSource
4040
| test.py:25:34:25:39 | ControlFlowNode for second | test-source |
4141
| test.py:39:11:39:20 | ControlFlowNode for Await | test-source |
4242
| test.py:41:8:41:27 | ControlFlowNode for Attribute() | test-source |
43+
| test.py:46:7:46:16 | ControlFlowNode for SubClass() | test-source |
4344
syntaxErrors
4445
| Member[foo |
4546
| Member[foo] .Member[bar] |

python/ql/test/library-tests/frameworks/data/test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ async def async_func():
3838
prom = CommonTokens.makePromise(1);
3939
val = await prom
4040

41-
inst = CommonTokens.Class()
41+
inst = CommonTokens.Class()
42+
43+
class SubClass (CommonTokens.Super):
44+
pass
45+
46+
sub = SubClass()

python/ql/test/library-tests/frameworks/data/test.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Sinks extends ModelInput::SinkModelCsv {
5454
}
5555

5656
// TODO: Commonly used tokens
57+
// TODO: Should `instance()` be shorthand for `subClass*().getReturn()`?
5758
// TODO: Uniform tokens for fields
5859
// TODO: Non-positional arguments (including Named parameters)
5960
// TODO: Any argument
@@ -74,6 +75,7 @@ class Sources extends ModelInput::SourceModelCsv {
7475
// Common tokens.
7576
"testlib;;Member[CommonTokens].Member[makePromise].ReturnValue.Awaited;test-source", //
7677
"testlib;;Member[CommonTokens].Member[Class].Instance;test-source", //
78+
"testlib;;Member[CommonTokens].Member[Super].Subclass.Instance;test-source", //
7779
]
7880
}
7981
}

0 commit comments

Comments
 (0)