File tree Expand file tree Collapse file tree
python/ql/test/library-tests/dataflow/captured-call-targets Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ | test.py:14:13:14:38 | Attribute() | test.py:3:5:3:25 | Function compile | CallTypeStaticMethod |
2+ | test.py:14:13:14:38 | Attribute() | test.py:9:5:9:25 | Function compile | CallTypeStaticMethod |
3+ | test.py:23:16:23:21 | func() | test.py:29:1:29:12 | Function first | CallTypePlainFunction |
4+ | test.py:23:16:23:21 | func() | test.py:34:1:34:13 | Function second | CallTypePlainFunction |
Original file line number Diff line number Diff line change 1+ import python
2+ private import semmle.python.controlflow.internal.Cfg as Cfg
3+ private import semmle.python.dataflow.new.internal.DataFlowDispatch as Dispatch
4+
5+ from Call call , Function target , Dispatch:: CallType callType
6+ where
7+ exists ( Cfg:: CallNode cfgCall |
8+ cfgCall .getNode ( ) = call and
9+ Dispatch:: resolveCall ( cfgCall , target , callType )
10+ ) and
11+ call .getLocation ( ) .getFile ( ) .getRelativePath ( ) = "test.py" and
12+ target .getLocation ( ) .getFile ( ) .getRelativePath ( ) = "test.py" and
13+ (
14+ call .getFunc ( ) .( Name ) .getId ( ) = "func"
15+ or
16+ call .getFunc ( ) .( Attribute ) .getName ( ) = "compile"
17+ )
18+ select call , target , callType .toString ( )
Original file line number Diff line number Diff line change 1+ class RegexRule :
2+ @staticmethod
3+ def compile (pattern ):
4+ return pattern
5+
6+
7+ class GlobRule :
8+ @staticmethod
9+ def compile (pattern ):
10+ return pattern
11+
12+
13+ def compile_rules (rule_type , patterns ):
14+ return [rule_type .compile (pattern ) for pattern in patterns ]
15+
16+
17+ compile_rules (RegexRule , ["x" ])
18+ compile_rules (GlobRule , ["*" ])
19+
20+
21+ def decorate (func ):
22+ def wrapper ():
23+ return func ()
24+
25+ return wrapper
26+
27+
28+ @decorate
29+ def first ():
30+ return 1
31+
32+
33+ @decorate
34+ def second ():
35+ return 2
36+
37+
38+ first ()
39+ second ()
You can’t perform that action at this time.
0 commit comments