Python: Add type-tracking consistency query

For now I'm only ignoring stdlib nodes, so it's easy for reviewer to see
why we need to have more excludes :)
This commit is contained in:
Rasmus Wriedt Larsen
2024-03-01 10:19:49 +01:00
parent 664dac6b28
commit 9f01ea68f7
2 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
private import python
private import semmle.python.dataflow.new.DataFlow
private import semmle.python.dataflow.new.internal.DataFlowPrivate as DataFlowPrivate
private import semmle.python.dataflow.new.internal.TypeTrackingImpl
private module ConsistencyChecksInput implements ConsistencyChecksInputSig {
predicate unreachableNodeExclude(DataFlow::Node n) {
not exists(n.getLocation().getFile().getRelativePath())
}
}
import ConsistencyChecks<ConsistencyChecksInput>

View File

@@ -0,0 +1,50 @@
unreachableNode
| attribute_tests.py:6:5:6:5 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:12:9:12:9 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:13:5:13:5 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:28:5:28:5 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:29:17:29:17 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:30:5:30:5 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:39:13:39:13 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:45:5:45:5 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:77:10:77:16 | [post] ControlFlowNode for MyClass | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:89:13:89:13 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:95:5:95:5 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:102:13:102:13 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:109:5:109:5 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:117:5:117:5 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:123:5:123:5 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:130:5:130:5 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:137:5:137:5 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:150:18:150:21 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:153:19:153:22 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:156:34:156:37 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:159:12:159:21 | [pre] ControlFlowNode for MyClass2() | Unreachable node in step of kind call. |
| attribute_tests.py:160:7:160:14 | [post] ControlFlowNode for instance | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:167:20:167:23 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:170:19:170:22 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:173:34:173:37 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:177:1:177:8 | [post] ControlFlowNode for instance | Unreachable node in step of kind simpleLocalSmallStep. |
| attribute_tests.py:178:1:178:8 | [post] ControlFlowNode for instance | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:54:5:54:12 | [post] ControlFlowNode for mymodule | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:55:9:55:16 | [post] ControlFlowNode for mymodule | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:72:15:72:15 | [post] ControlFlowNode for x | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:74:13:74:17 | [post] ControlFlowNode for print | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:92:9:92:13 | [post] ControlFlowNode for print | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:98:2:98:13 | [post] ControlFlowNode for my_decorator | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:130:15:130:18 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:133:15:133:18 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:136:15:136:18 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:142:15:142:18 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:145:15:145:18 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:148:15:148:18 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:151:20:151:23 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:152:9:152:12 | [post] ControlFlowNode for self | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:153:9:153:13 | [post] ControlFlowNode for super | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:162:5:162:7 | [post] ControlFlowNode for foo | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:163:9:163:11 | [post] ControlFlowNode for foo | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:179:14:179:24 | [post] ControlFlowNode for get_tracked | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:181:1:181:5 | [post] ControlFlowNode for print | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:188:9:188:13 | [post] ControlFlowNode for print | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:192:9:192:13 | [post] ControlFlowNode for print | Unreachable node in step of kind simpleLocalSmallStep. |
| test.py:208:14:208:30 | [post] ControlFlowNode for yielding_function | Unreachable node in step of kind simpleLocalSmallStep. |