From 6f2cfa0ba8aed54d1e36d76ddcb48f3e1a82e30b Mon Sep 17 00:00:00 2001 From: Taus Date: Tue, 15 Oct 2024 11:52:37 +0000 Subject: [PATCH] Python: Update `CopySummary` to use `getMaDRepresentation` Demonstrates the somewhat more ergonomic way to use `getMaDRepresentation` when specifying summaries. Note that this slightly extends the previous definition, in that `DictionaryContentAny` is now _also_ propagated by a call to the `.copy()` method, but I think this is correct. --- .../ql/lib/semmle/python/frameworks/Stdlib.qll | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/python/ql/lib/semmle/python/frameworks/Stdlib.qll b/python/ql/lib/semmle/python/frameworks/Stdlib.qll index 2bec246bfc0..f208f19c74c 100644 --- a/python/ql/lib/semmle/python/frameworks/Stdlib.qll +++ b/python/ql/lib/semmle/python/frameworks/Stdlib.qll @@ -4537,21 +4537,9 @@ module StdlibPrivate { override DataFlow::ArgumentNode getACallback() { none() } override predicate propagatesFlow(string input, string output, boolean preservesValue) { - exists(string content | - content = "ListElement" - or - content = "SetElement" - or - exists(DataFlow::TupleElementContent tc, int i | i = tc.getIndex() | - content = "TupleElement[" + i.toString() + "]" - ) - or - exists(DataFlow::DictionaryElementContent dc, string key | key = dc.getKey() | - content = "DictionaryElement[" + key + "]" - ) - | - input = "Argument[self]." + content and - output = "ReturnValue." + content and + exists(DataFlow::Content c | + input = "Argument[self]." + c.getMaDRepresentation() and + output = "ReturnValue." + c.getMaDRepresentation() and preservesValue = true ) or