Python points-to: Add objects representing missing modules and their attributes.

This commit is contained in:
Mark Shannon
2019-04-26 15:53:39 +01:00
parent b10a7cd3a4
commit bf78c62594
19 changed files with 252 additions and 18 deletions

View File

@@ -0,0 +1,7 @@
| absent.py:3:8:3:11 | ControlFlowNode for ImportExpr | Missing module xxxx |
| absent.py:4:1:4:4 | ControlFlowNode for xxxx | Missing module xxxx |
| absent.py:6:6:6:9 | ControlFlowNode for ImportExpr | Missing module xxxx |
| absent.py:6:18:6:21 | ControlFlowNode for ImportMember | Missing module attribute xxxx.open |
| absent.py:8:1:8:4 | ControlFlowNode for open | Missing module attribute xxxx.open |
| absent.py:12:8:12:13 | ControlFlowNode for ImportExpr | Module module |
| absent.py:14:1:14:6 | ControlFlowNode for module | Module module |

View File

@@ -0,0 +1,9 @@
import python
import semmle.python.objects.Modules
from Value val, ControlFlowNode f
where //val = Value::named(name) and
f.pointsTo(val)
select f, val

View File

@@ -0,0 +1,14 @@
#There is no xxxx, rely on AbsentModule
import xxxx
xxxx
from xxxx import open
open()
#This is be present, so shouldn't be missing
import module
module

View File

@@ -1,2 +1,3 @@
| 41 | ControlFlowNode for func1 | Function func1 | test.py:23 |
| 42 | ControlFlowNode for func2 | Function wrapper | test.py:10 |
| 43 | ControlFlowNode for func3 | Function wrapper | test.py:17 |

View File

@@ -341,7 +341,6 @@
| 263 | ControlFlowNode for Attribute | int 3 |
| 263 | ControlFlowNode for IntegerLiteral | int 3 |
| 263 | ControlFlowNode for self | self |
| 264 | ControlFlowNode for Attribute | int 0 |
| 264 | ControlFlowNode for Attribute | int 3 |
| 264 | ControlFlowNode for self | self |
| 267 | ControlFlowNode for Derived4 | class Derived4 |

View File

@@ -344,7 +344,6 @@
| 263 | ControlFlowNode for Attribute | int 3 | builtin-class int |
| 263 | ControlFlowNode for IntegerLiteral | int 3 | builtin-class int |
| 263 | ControlFlowNode for self | self | class G |
| 264 | ControlFlowNode for Attribute | int 0 | builtin-class int |
| 264 | ControlFlowNode for Attribute | int 3 | builtin-class int |
| 264 | ControlFlowNode for self | self | class G |
| 267 | ControlFlowNode for Derived4 | class Derived4 | builtin-class type |

View File

@@ -51,8 +51,6 @@
| test.py | 314 | ControlFlowNode for b | NoneType None | 311 |
| test.py | 332 | ControlFlowNode for Attribute | NoneType None | 322 |
| test.py | 332 | ControlFlowNode for Attribute | int 4 | 322 |
| test.py | 337 | ControlFlowNode for Attribute | NoneType None | 324 |
| test.py | 337 | ControlFlowNode for Attribute | int 3 | 324 |
| test.py | 347 | ControlFlowNode for Attribute | NoneType None | 322 |
| test.py | 347 | ControlFlowNode for Attribute | int 4 | 322 |
| test.py | 357 | ControlFlowNode for g1 | float 7.0 | 356 |

View File

@@ -51,8 +51,6 @@
| test.py | 314 | ControlFlowNode for b | NoneType None | builtin-class NoneType | 311 |
| test.py | 332 | ControlFlowNode for Attribute | NoneType None | builtin-class NoneType | 322 |
| test.py | 332 | ControlFlowNode for Attribute | int 4 | builtin-class int | 322 |
| test.py | 337 | ControlFlowNode for Attribute | NoneType None | builtin-class NoneType | 324 |
| test.py | 337 | ControlFlowNode for Attribute | int 3 | builtin-class int | 324 |
| test.py | 347 | ControlFlowNode for Attribute | NoneType None | builtin-class NoneType | 322 |
| test.py | 347 | ControlFlowNode for Attribute | int 4 | builtin-class int | 322 |
| test.py | 357 | ControlFlowNode for g1 | float 7.0 | builtin-class float | 356 |

View File

@@ -1074,6 +1074,7 @@ WARNING: Predicate points_to has been deprecated and may be removed in future (P
| t_type.py:7 | ControlFlowNode for type | builtin-class type | builtin-class type | 7 | import |
| t_type.py:7 | ControlFlowNode for type() | builtin-class module | builtin-class type | 7 | import |
| t_type.py:9 | ControlFlowNode for type | builtin-class type | builtin-class type | 9 | import |
| t_type.py:9 | ControlFlowNode for type() | *UNKNOWN TYPE* | *UNKNOWN TYPE* | 9 | import |
| t_type.py:10 | ControlFlowNode for Dict | Dict | builtin-class dict | 10 | import |
| t_type.py:10 | ControlFlowNode for Tuple | Tuple | builtin-class tuple | 10 | import |
| t_type.py:10 | ControlFlowNode for object | builtin-class object | builtin-class type | 10 | import |

View File

@@ -827,6 +827,7 @@
| t_type.py:7 | ControlFlowNode for sys | import | Module sys | builtin-class module |
| t_type.py:7 | ControlFlowNode for type | import | builtin-class type | builtin-class type |
| t_type.py:7 | ControlFlowNode for type() | import | builtin-class module | builtin-class type |
| t_type.py:8 | ControlFlowNode for ImportExpr | import | Missing module module | builtin-class module |
| t_type.py:9 | ControlFlowNode for type | import | builtin-class type | builtin-class type |
| t_type.py:10 | ControlFlowNode for Dict | import | Dict | builtin-class dict |
| t_type.py:10 | ControlFlowNode for Tuple | import | (builtin-class object) | builtin-class tuple |