From 7d84cfacefe2682b414951fe1fbb48efa8d7ac8a Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Thu, 15 Apr 2021 16:22:51 +0200 Subject: [PATCH] Java: Add MapKeyContent and MapValueContent. --- .../code/java/dataflow/ExternalFlow.qll | 12 +++++------ .../dataflow/internal/DataFlowPrivate.qll | 20 ++++++++++++++----- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/java/ql/src/semmle/code/java/dataflow/ExternalFlow.qll b/java/ql/src/semmle/code/java/dataflow/ExternalFlow.qll index c1ad6eb4ecf..7d70017c6d8 100644 --- a/java/ql/src/semmle/code/java/dataflow/ExternalFlow.qll +++ b/java/ql/src/semmle/code/java/dataflow/ExternalFlow.qll @@ -460,7 +460,7 @@ module CsvValidation { summaryModel(_, _, _, _, _, _, input, _, _) and pred = "summary" | specSplit(input, part, _) and - not part.regexpMatch("|ReturnValue|ArrayElement|Element") and + not part.regexpMatch("|ReturnValue|ArrayElement|Element|MapKey|MapValue") and not (part = "Argument" and pred = "sink") and not parseArg(part, _) and msg = "Unrecognized input specification \"" + part + "\" in " + pred + " model." @@ -472,7 +472,7 @@ module CsvValidation { summaryModel(_, _, _, _, _, _, _, output, _) and pred = "summary" | specSplit(output, part, _) and - not part.regexpMatch("|ReturnValue|ArrayElement|Element") and + not part.regexpMatch("|ReturnValue|ArrayElement|Element|MapKey|MapValue") and not (part = ["Argument", "Parameter"] and pred = "source") and not parseArg(part, _) and not parseParam(part, _) and @@ -690,10 +690,10 @@ private SummaryComponent interpretComponent(string c) { c = "ArrayElement" and result = SummaryComponent::content(any(ArrayContent c0)) or c = "Element" and result = SummaryComponent::content(any(CollectionContent c0)) - // or - // c = "MapKey" and result = SummaryComponent::content(any(MapKeyContent c0)) - // or - // c = "MapValue" and result = SummaryComponent::content(any(MapValueContent c0)) + or + c = "MapKey" and result = SummaryComponent::content(any(MapKeyContent c0)) + or + c = "MapValue" and result = SummaryComponent::content(any(MapValueContent c0)) ) } diff --git a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowPrivate.qll b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowPrivate.qll index c425eaa1185..23d84c10c9f 100644 --- a/java/ql/src/semmle/code/java/dataflow/internal/DataFlowPrivate.qll +++ b/java/ql/src/semmle/code/java/dataflow/internal/DataFlowPrivate.qll @@ -84,8 +84,10 @@ private predicate instanceFieldAssign(Expr src, FieldAccess fa) { private newtype TContent = TFieldContent(InstanceField f) or + TArrayContent() or TCollectionContent() or - TArrayContent() + TMapKeyContent() or + TMapValueContent() /** * A reference contained in an object. Examples include instance fields, the @@ -114,12 +116,20 @@ class FieldContent extends Content, TFieldContent { } } -class CollectionContent extends Content, TCollectionContent { - override string toString() { result = "collection" } +class ArrayContent extends Content, TArrayContent { + override string toString() { result = "[]" } } -class ArrayContent extends Content, TArrayContent { - override string toString() { result = "array" } +class CollectionContent extends Content, TCollectionContent { + override string toString() { result = "" } +} + +class MapKeyContent extends Content, TMapKeyContent { + override string toString() { result = "" } +} + +class MapValueContent extends Content, TMapValueContent { + override string toString() { result = "" } } /**