|
| 1 | +private import python |
| 2 | +private import semmle.python.dataflow.new.DataFlow |
| 3 | +private import semmle.python.dataflow.new.internal.DataFlowPrivate as DataFlowPrivate |
| 4 | +private import semmle.python.dataflow.new.internal.TypeTrackingImpl |
| 5 | + |
| 6 | +private module ConsistencyChecksInput implements ConsistencyChecksInputSig { |
| 7 | + predicate unreachableNodeExclude(DataFlow::Node n) { |
| 8 | + n instanceof DataFlowPrivate::SyntheticPostUpdateNode |
| 9 | + or |
| 10 | + n instanceof DataFlowPrivate::SyntheticPreUpdateNode |
| 11 | + or |
| 12 | + // TODO: when adding support for proper content, handle **kwargs passing better! |
| 13 | + n instanceof DataFlowPrivate::SynthDictSplatArgumentNode |
| 14 | + or |
| 15 | + // TODO: when adding support for proper content, handle unpacking tuples in match |
| 16 | + // cases better, such as |
| 17 | + // |
| 18 | + // match (NONSOURCE, SOURCE): |
| 19 | + // case (x, y): ... |
| 20 | + exists(DataFlow::Node m | |
| 21 | + m.asCfgNode().getNode() instanceof MatchCapturePattern |
| 22 | + or |
| 23 | + m.asCfgNode().getNode() instanceof MatchAsPattern |
| 24 | + or |
| 25 | + m.asCfgNode().getNode() instanceof MatchOrPattern |
| 26 | + | |
| 27 | + TypeTrackingInput::simpleLocalSmallStep*(m, n) |
| 28 | + ) |
| 29 | + or |
| 30 | + // TODO: when adding support for proper content, handle iterable unpacking better |
| 31 | + // such as `for k,v in items:`, or `a, (b,c) = ...` |
| 32 | + n instanceof DataFlow::IterableSequenceNode |
| 33 | + or |
| 34 | + // We have missing use-use flow in |
| 35 | + // https://github.com/python/cpython/blob/0fb18b02c8ad56299d6a2910be0bab8ad601ef24/Lib/socketserver.py#L276-L303 |
| 36 | + // which I couldn't just fix. We ignore the problems here, and instead rely on the |
| 37 | + // test-case added in https://github.com/github/codeql/pull/15841 |
| 38 | + n.getLocation().getFile().getAbsolutePath().matches("%/socketserver.py") |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +import ConsistencyChecks<ConsistencyChecksInput> |
0 commit comments