Skip to content

Commit 728ccaf

Browse files
authored
Merge pull request github#9024 from hvitved/dataflow/content-flow-lib
Data flow: Introduce `ContentDataFlow.qll`
2 parents d61f645 + 6345816 commit 728ccaf

File tree

12 files changed

+6135
-91
lines changed

12 files changed

+6135
-91
lines changed

config/identical-files.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImpl3.qll",
2323
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImpl4.qll",
2424
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImpl5.qll",
25+
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImplForContentDataFlow.qll",
2526
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl.qll",
2627
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl2.qll",
2728
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl3.qll",
@@ -559,4 +560,4 @@
559560
"javascript/ql/src/Expressions/TypoDatabase.qll",
560561
"ql/ql/src/codeql_ql/style/TypoDatabase.qll"
561562
]
562-
}
563+
}

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -788,24 +788,31 @@ private module Cached {
788788
cached
789789
predicate readSet(Node node1, ContentSet c, Node node2) { readStep(node1, c, node2) }
790790

791+
cached
792+
predicate storeSet(
793+
Node node1, ContentSet c, Node node2, DataFlowType contentType, DataFlowType containerType
794+
) {
795+
storeStep(node1, c, node2) and
796+
contentType = getNodeDataFlowType(node1) and
797+
containerType = getNodeDataFlowType(node2)
798+
or
799+
exists(Node n1, Node n2 |
800+
n1 = node1.(PostUpdateNode).getPreUpdateNode() and
801+
n2 = node2.(PostUpdateNode).getPreUpdateNode()
802+
|
803+
argumentValueFlowsThrough(n2, TReadStepTypesSome(containerType, c, contentType), n1)
804+
or
805+
readSet(n2, c, n1) and
806+
contentType = getNodeDataFlowType(n1) and
807+
containerType = getNodeDataFlowType(n2)
808+
)
809+
}
810+
791811
private predicate store(
792812
Node node1, Content c, Node node2, DataFlowType contentType, DataFlowType containerType
793813
) {
794-
exists(ContentSet cs | c = cs.getAStoreContent() |
795-
storeStep(node1, cs, node2) and
796-
contentType = getNodeDataFlowType(node1) and
797-
containerType = getNodeDataFlowType(node2)
798-
or
799-
exists(Node n1, Node n2 |
800-
n1 = node1.(PostUpdateNode).getPreUpdateNode() and
801-
n2 = node2.(PostUpdateNode).getPreUpdateNode()
802-
|
803-
argumentValueFlowsThrough(n2, TReadStepTypesSome(containerType, cs, contentType), n1)
804-
or
805-
readSet(n2, cs, n1) and
806-
contentType = getNodeDataFlowType(n1) and
807-
containerType = getNodeDataFlowType(n2)
808-
)
814+
exists(ContentSet cs |
815+
c = cs.getAStoreContent() and storeSet(node1, cs, node2, contentType, containerType)
809816
)
810817
}
811818

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -788,24 +788,31 @@ private module Cached {
788788
cached
789789
predicate readSet(Node node1, ContentSet c, Node node2) { readStep(node1, c, node2) }
790790

791+
cached
792+
predicate storeSet(
793+
Node node1, ContentSet c, Node node2, DataFlowType contentType, DataFlowType containerType
794+
) {
795+
storeStep(node1, c, node2) and
796+
contentType = getNodeDataFlowType(node1) and
797+
containerType = getNodeDataFlowType(node2)
798+
or
799+
exists(Node n1, Node n2 |
800+
n1 = node1.(PostUpdateNode).getPreUpdateNode() and
801+
n2 = node2.(PostUpdateNode).getPreUpdateNode()
802+
|
803+
argumentValueFlowsThrough(n2, TReadStepTypesSome(containerType, c, contentType), n1)
804+
or
805+
readSet(n2, c, n1) and
806+
contentType = getNodeDataFlowType(n1) and
807+
containerType = getNodeDataFlowType(n2)
808+
)
809+
}
810+
791811
private predicate store(
792812
Node node1, Content c, Node node2, DataFlowType contentType, DataFlowType containerType
793813
) {
794-
exists(ContentSet cs | c = cs.getAStoreContent() |
795-
storeStep(node1, cs, node2) and
796-
contentType = getNodeDataFlowType(node1) and
797-
containerType = getNodeDataFlowType(node2)
798-
or
799-
exists(Node n1, Node n2 |
800-
n1 = node1.(PostUpdateNode).getPreUpdateNode() and
801-
n2 = node2.(PostUpdateNode).getPreUpdateNode()
802-
|
803-
argumentValueFlowsThrough(n2, TReadStepTypesSome(containerType, cs, contentType), n1)
804-
or
805-
readSet(n2, cs, n1) and
806-
contentType = getNodeDataFlowType(n1) and
807-
containerType = getNodeDataFlowType(n2)
808-
)
814+
exists(ContentSet cs |
815+
c = cs.getAStoreContent() and storeSet(node1, cs, node2, contentType, containerType)
809816
)
810817
}
811818

0 commit comments

Comments
 (0)