Skip to content

Commit df15a71

Browse files
committed
Add a ContentSet for any tuple or dictionary element
1 parent 812e8e6 commit df15a71

5 files changed

Lines changed: 11 additions & 9 deletions

File tree

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,15 +1078,15 @@ module Conversions {
10781078
nodeFrom = decoding.getAnInput() and
10791079
nodeTo = decoding.getOutput()
10801080
) and
1081-
(c.isAnyTupleElement() or c.isAnyDictionaryElement())
1081+
c.isAnyTupleOrDictionaryElement()
10821082
}
10831083

10841084
predicate encoderReadStep(Node nodeFrom, ContentSet c, Node nodeTo) {
10851085
exists(Encoding encoding |
10861086
nodeFrom = encoding.getAnInput() and
10871087
nodeTo = encoding.getOutput()
10881088
) and
1089-
(c.isAnyTupleElement() or c.isAnyDictionaryElement())
1089+
c.isAnyTupleOrDictionaryElement()
10901090
}
10911091

10921092
predicate formatReadStep(Node nodeFrom, ContentSet c, Node nodeTo) {

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPublic.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,8 @@ class CapturedVariableContent extends Content, TCapturedVariableContent {
914914
private newtype TContentSet =
915915
TSingletonContent(Content c) or
916916
TAnyTupleElement() or
917-
TAnyDictionaryElement()
917+
TAnyDictionaryElement() or
918+
TAnyTupleOrDictionaryElement()
918919

919920
/**
920921
* An entity that represents a set of `Content`s.
@@ -932,6 +933,9 @@ class ContentSet extends TContentSet {
932933
/** Holds if this content set is the wildcard for all dictionary elements. */
933934
predicate isAnyDictionaryElement() { this = TAnyDictionaryElement() }
934935

936+
/** Holds if this content set is the wildcard for all tuple elements or dictionary elements. */
937+
predicate isAnyTupleOrDictionaryElement() { this = TAnyTupleOrDictionaryElement() }
938+
935939
/** Gets a content that may be stored into when storing into this set. */
936940
Content getAStoreContent() { this = TSingletonContent(result) }
937941

python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ module Input implements InputSig<Location, DataFlowImplSpecific::PythonDataFlow>
8787
cs.isAnyTupleElement() and result = "AnyTupleElement" and arg = ""
8888
or
8989
cs.isAnyDictionaryElement() and result = "AnyDictionaryElement" and arg = ""
90+
or
91+
cs.isAnyTupleOrDictionaryElement() and result = "AnyTupleOrDictionaryElement" and arg = ""
9092
}
9193

9294
bindingset[token]

python/ql/lib/semmle/python/dataflow/new/internal/TaintTrackingPrivate.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ private predicate defaultTaintReadContent(DataFlow::ContentSet contentSet) {
2121
// expand to one row per (node, distinct key or index) and the framework's
2222
// read-set relation grows quadratically). `ContentSet.getAReadContent` expands
2323
// these wildcards back to the specific contents when matching against stores.
24-
contentSet.isAnyTupleElement()
25-
or
26-
contentSet.isAnyDictionaryElement()
24+
contentSet.isAnyTupleOrDictionaryElement()
2725
or
2826
// List and set element content is already imprecise, so no wildcard expansion is
2927
// needed.

python/ql/src/Variables/LoopVariableCapture/LoopVariableCaptureQuery.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ module EscapingCaptureFlowConfig implements DataFlow::ConfigSig {
6161
predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet cs) {
6262
isSink(node) and
6363
(
64-
cs.isAnyTupleElement()
65-
or
66-
cs.isAnyDictionaryElement()
64+
cs.isAnyTupleOrDictionaryElement()
6765
or
6866
cs.getAStoreContent() instanceof DataFlow::ListElementContent
6967
or

0 commit comments

Comments
 (0)