Python points-to: Improve handling of attributes.

This commit is contained in:
Mark Shannon
2019-05-10 16:04:26 +01:00
parent 992ee2f150
commit 76c43b491f
6 changed files with 63 additions and 26 deletions

View File

@@ -2,8 +2,10 @@
| b_condition.py:43 | v2_3 | x | Pi(v2_2) [true] | int 1 | import |
| b_condition.py:47 | v2_4 | x | Pi(v2_2) [false] | int 1 | import |
| b_condition.py:47 | v2_5 | x | phi(v2_3, v2_4) | int 1 | import |
| f_finally.py:3 | self_3 | _close | phi(self_1, self_2) | None | runtime |
| f_finally.py:3 | self_3 | _closed | phi(self_1, self_2) | bool True | runtime |
| f_finally.py:4 | self_1 | _closed | AttributeAssignment '_closed'(self_0) | bool True | runtime |
| f_finally.py:10 | self_2 | _close | AttributeAssignment '_close'(self_1) | None | runtime |
| f_finally.py:10 | self_2 | _closed | AttributeAssignment '_close'(self_1) | bool True | runtime |
| g_class_init.py:6 | self_1 | y | SelfCallsiteRefinement(self_0) | int 2 | runtime |
| g_class_init.py:6 | self_1 | z | SelfCallsiteRefinement(self_0) | int 3 | runtime |
@@ -16,27 +18,10 @@
| g_class_init.py:13 | self_0 | y | ParameterDefinition | int 2 | code/g_class_init.py:11 from code/g_class_init.py:6 from runtime |
| g_class_init.py:14 | self_1 | y | AttributeAssignment 'z'(self_0) | int 2 | code/g_class_init.py:11 from code/g_class_init.py:6 from runtime |
| g_class_init.py:14 | self_1 | z | AttributeAssignment 'z'(self_0) | int 3 | code/g_class_init.py:11 from code/g_class_init.py:6 from runtime |
| g_class_init.py:16 | self_0 | x | ParameterDefinition | int 1 | runtime |
| g_class_init.py:16 | self_0 | y | ParameterDefinition | int 2 | runtime |
| g_class_init.py:16 | self_0 | z | ParameterDefinition | int 3 | runtime |
| g_class_init.py:19 | self_1 | x | Pi(self_0) [true] | int 1 | runtime |
| g_class_init.py:19 | self_1 | y | Pi(self_0) [true] | int 2 | runtime |
| g_class_init.py:19 | self_1 | z | Pi(self_0) [true] | int 3 | runtime |
| g_class_init.py:20 | self_2 | x | Pi(self_0) [false] | int 1 | runtime |
| g_class_init.py:20 | self_2 | z | Pi(self_0) [false] | int 3 | runtime |
| g_class_init.py:20 | self_3 | x | phi(self_1, self_2) | int 1 | runtime |
| g_class_init.py:20 | self_3 | y | phi(self_1, self_2) | int 2 | runtime |
| g_class_init.py:20 | self_3 | z | phi(self_1, self_2) | int 3 | runtime |
| g_class_init.py:46 | self_3 | version | phi(self_1, self_2) | 'v2' | runtime |
| g_class_init.py:46 | self_3 | version | phi(self_1, self_2) | 'v3' | runtime |
| g_class_init.py:48 | self_1 | version | AttributeAssignment 'version'(self_0) | 'v2' | runtime |
| g_class_init.py:50 | self_2 | version | AttributeAssignment 'version'(self_0) | 'v3' | runtime |
| g_class_init.py:52 | self_0 | version | ParameterDefinition | 'v2' | runtime |
| g_class_init.py:52 | self_0 | version | ParameterDefinition | 'v3' | runtime |
| g_class_init.py:52 | self_2 | version | Pi(self_0) [false] | 'v3' | runtime |
| g_class_init.py:52 | self_3 | version | phi(self_1, self_2) | 'v2' | runtime |
| g_class_init.py:52 | self_3 | version | phi(self_1, self_2) | 'v3' | runtime |
| g_class_init.py:54 | self_1 | version | Pi(self_0) [true] | 'v2' | runtime |
| k_getsetattr.py:6 | self_0 | a | ParameterDefinition | float 7.0 | code/k_getsetattr.py:15 from runtime |
| k_getsetattr.py:6 | self_0 | c | ParameterDefinition | int 2 | code/k_getsetattr.py:15 from runtime |
| k_getsetattr.py:7 | self_1 | a | ArgumentRefinement(self_0) | int 0 | code/k_getsetattr.py:15 from runtime |
@@ -76,6 +61,6 @@
| k_getsetattr.py:27 | c2_1 | a | AttributeAssignment 'a'(c2_0) | int 20 | runtime |
| k_getsetattr.py:28 | c2_2 | a | phi(c2_0, c2_1) | int 20 | runtime |
| k_getsetattr.py:31 | c3_1 | a | AttributeAssignment 'a'(c3_0) | int 30 | runtime |
| m_attributes.py:6 | self_1 | a | AttributeAssignment 'a'(self_0) | Unknown value | runtime |
| m_attributes.py:6 | self_1 | a | AttributeAssignment 'a'(self_0) | int 17 | runtime |
| m_attributes.py:6 | self_1 | a | AttributeAssignment 'a'(self_0) | int 100 | code/m_attributes.py:13 from import |
| m_attributes.py:8 | self_0 | a | ParameterDefinition | int 17 | runtime |

View File

@@ -1,12 +1,12 @@
import python
private import semmle.python.pointsto.PointsTo
private import semmle.python.pointsto.PointsToContext
private import semmle.python.objects.ObjectInternal
import Util
from EssaVariable var, string name, Object o, PointsToContext ctx
where PointsTo::Test::ssa_variable_named_attribute_points_to(var, ctx, name, o, _, _) and not var.getSourceVariable() instanceof SpecialSsaSourceVariable
from EssaVariable var, string name, ObjectInternal o, Context ctx
where AttributePointsTo::variableAttributePointsTo(var, ctx, name, o, _) and not var.getSourceVariable() instanceof SpecialSsaSourceVariable
select
locate(var.getDefinition().getLocation(), "abdfgikm"), var.getRepresentation(),
name, var.getDefinition().getRepresentation(), repr(o), ctx
name, var.getDefinition().getRepresentation(), o, ctx