Skip to content

Commit 7d84cfa

Browse files
committed
Java: Add MapKeyContent and MapValueContent.
1 parent 3986274 commit 7d84cfa

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

java/ql/src/semmle/code/java/dataflow/ExternalFlow.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ module CsvValidation {
460460
summaryModel(_, _, _, _, _, _, input, _, _) and pred = "summary"
461461
|
462462
specSplit(input, part, _) and
463-
not part.regexpMatch("|ReturnValue|ArrayElement|Element") and
463+
not part.regexpMatch("|ReturnValue|ArrayElement|Element|MapKey|MapValue") and
464464
not (part = "Argument" and pred = "sink") and
465465
not parseArg(part, _) and
466466
msg = "Unrecognized input specification \"" + part + "\" in " + pred + " model."
@@ -472,7 +472,7 @@ module CsvValidation {
472472
summaryModel(_, _, _, _, _, _, _, output, _) and pred = "summary"
473473
|
474474
specSplit(output, part, _) and
475-
not part.regexpMatch("|ReturnValue|ArrayElement|Element") and
475+
not part.regexpMatch("|ReturnValue|ArrayElement|Element|MapKey|MapValue") and
476476
not (part = ["Argument", "Parameter"] and pred = "source") and
477477
not parseArg(part, _) and
478478
not parseParam(part, _) and
@@ -690,10 +690,10 @@ private SummaryComponent interpretComponent(string c) {
690690
c = "ArrayElement" and result = SummaryComponent::content(any(ArrayContent c0))
691691
or
692692
c = "Element" and result = SummaryComponent::content(any(CollectionContent c0))
693-
// or
694-
// c = "MapKey" and result = SummaryComponent::content(any(MapKeyContent c0))
695-
// or
696-
// c = "MapValue" and result = SummaryComponent::content(any(MapValueContent c0))
693+
or
694+
c = "MapKey" and result = SummaryComponent::content(any(MapKeyContent c0))
695+
or
696+
c = "MapValue" and result = SummaryComponent::content(any(MapValueContent c0))
697697
)
698698
}
699699

java/ql/src/semmle/code/java/dataflow/internal/DataFlowPrivate.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ private predicate instanceFieldAssign(Expr src, FieldAccess fa) {
8484

8585
private newtype TContent =
8686
TFieldContent(InstanceField f) or
87+
TArrayContent() or
8788
TCollectionContent() or
88-
TArrayContent()
89+
TMapKeyContent() or
90+
TMapValueContent()
8991

9092
/**
9193
* A reference contained in an object. Examples include instance fields, the
@@ -114,12 +116,20 @@ class FieldContent extends Content, TFieldContent {
114116
}
115117
}
116118

119+
class ArrayContent extends Content, TArrayContent {
120+
override string toString() { result = "[]" }
121+
}
122+
117123
class CollectionContent extends Content, TCollectionContent {
118-
override string toString() { result = "collection" }
124+
override string toString() { result = "<element>" }
119125
}
120126

121-
class ArrayContent extends Content, TArrayContent {
122-
override string toString() { result = "array" }
127+
class MapKeyContent extends Content, TMapKeyContent {
128+
override string toString() { result = "<map.key>" }
129+
}
130+
131+
class MapValueContent extends Content, TMapValueContent {
132+
override string toString() { result = "<map.value>" }
123133
}
124134

125135
/**

0 commit comments

Comments
 (0)