File tree Expand file tree Collapse file tree 5 files changed +40
-10
lines changed
python/ql/test/library-tests/PointsTo/regressions/missing Expand file tree Collapse file tree 5 files changed +40
-10
lines changed Original file line number Diff line number Diff line change 1
1
import python
2
2
3
- from NameNode name , CallNode call , string debug
3
+ from ControlFlowNode arg , CallNode call , string debug
4
4
where
5
- call .getAnArg ( ) = name and
5
+ call .getAnArg ( ) = arg and
6
6
call .getFunction ( ) .( NameNode ) .getId ( ) = "check" and
7
- if exists ( name .pointsTo ( ) )
8
- then debug = name .pointsTo ( ) .toString ( )
7
+ if exists ( arg .pointsTo ( ) )
8
+ then debug = arg .pointsTo ( ) .toString ( )
9
9
else debug = "<MISSING pointsTo()>"
10
- select name , debug
10
+ select arg , debug
Original file line number Diff line number Diff line change 1
1
import python
2
2
3
- from NameNode name , CallNode call , string debug
3
+ from ControlFlowNode arg , CallNode call , string debug
4
4
where
5
- call .getAnArg ( ) = name and
5
+ call .getAnArg ( ) = arg and
6
6
call .getFunction ( ) .( NameNode ) .getId ( ) = "check" and
7
- if exists ( name .pointsTo ( ) )
8
- then debug = name .pointsTo ( ) .toString ( )
7
+ if exists ( arg .pointsTo ( ) )
8
+ then debug = arg .pointsTo ( ) .toString ( )
9
9
else debug = "<MISSING pointsTo()>"
10
- select name , debug
10
+ select arg , debug
Original file line number Diff line number Diff line change
1
+ | test.py:10:11:10:14 | ControlFlowNode for open | <MISSING pointsTo()> |
2
+ | test.py:14:11:14:14 | ControlFlowNode for open | Builtin-function open |
Original file line number Diff line number Diff line change
1
+ import python
2
+
3
+ from ControlFlowNode arg , CallNode call , string debug
4
+ where
5
+ call .getAnArg ( ) = arg and
6
+ call .getFunction ( ) .( NameNode ) .getId ( ) = "check" and
7
+ if exists ( arg .pointsTo ( ) )
8
+ then debug = arg .pointsTo ( ) .toString ( )
9
+ else debug = "<MISSING pointsTo()>"
10
+ select arg , debug
Original file line number Diff line number Diff line change
1
+ # Points-to information seems to be missing if our analysis thinks the enclosing function
2
+ # is never called. However, as illustrated by the code below, it's easy to fool our
3
+ # analysis :(
4
+
5
+ # This was inspired by a problem in real code, where our analysis doesn't have any
6
+ # points-to information about the `open` call in
7
+ # https://google-gruyere.appspot.com/code/gruyere.py on line 227
8
+
9
+ def _func_not_called (filename , mode = 'rb' ):
10
+ check (open )
11
+ return open (filename , mode )
12
+
13
+ def _func_called (filename , mode = 'rb' ):
14
+ check (open )
15
+ return open (filename , mode )
16
+
17
+ globals ()['_func_not_called' ]('test.txt' )
18
+ _func_called ('test.txt' )
You can’t perform that action at this time.
0 commit comments