Skip to content

Commit a2d75c4

Browse files
committed
Merge branch 'main' into rdmarsh/cpp/use-taint-configuration-dtt
2 parents bc36e0d + 01cc2f2 commit a2d75c4

File tree

35 files changed

+1254
-996
lines changed

35 files changed

+1254
-996
lines changed

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,19 @@ private class PrimaryArgumentNode extends ArgumentNode {
3131
override predicate argumentOf(DataFlowCall call, int pos) { op = call.getArgumentOperand(pos) }
3232

3333
override string toString() {
34-
result = "Argument " + op.(PositionalArgumentOperand).getIndex()
34+
exists(Expr unconverted |
35+
unconverted = op.getDef().getUnconvertedResultExpression() and
36+
result = unconverted.toString()
37+
)
3538
or
36-
op instanceof ThisArgumentOperand and result = "This argument"
39+
// Certain instructions don't map to an unconverted result expression. For these cases
40+
// we fall back to a simpler naming scheme. This can happen in IR-generated constructors.
41+
not exists(op.getDef().getUnconvertedResultExpression()) and
42+
(
43+
result = "Argument " + op.(PositionalArgumentOperand).getIndex()
44+
or
45+
op instanceof ThisArgumentOperand and result = "Argument this"
46+
)
3747
}
3848
}
3949

@@ -52,7 +62,18 @@ private class SideEffectArgumentNode extends ArgumentNode {
5262
pos = getArgumentPosOfSideEffect(read.getIndex())
5363
}
5464

55-
override string toString() { result = "Argument " + read.getIndex() + " indirection" }
65+
override string toString() {
66+
result = read.getArgumentDef().getUnconvertedResultExpression().toString() + " indirection"
67+
or
68+
// Some instructions don't map to an unconverted result expression. For these cases
69+
// we fall back to a simpler naming scheme. This can happen in IR-generated constructors.
70+
not exists(read.getArgumentDef().getUnconvertedResultExpression()) and
71+
(
72+
if read.getIndex() = -1
73+
then result = "Argument this indirection"
74+
else result = "Argument " + read.getIndex() + " indirection"
75+
)
76+
}
5677
}
5778

5879
private newtype TReturnKind =

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,14 +658,18 @@ newtype TTranslatedElement =
658658
t instanceof ReferenceType
659659
) and
660660
(
661-
isWrite = true or
661+
isWrite = true and
662+
not call.getTarget().getParameter(n).getType().isDeeplyConstBelow()
663+
or
662664
isWrite = false
663665
)
664666
or
665667
not call.getTarget() instanceof SideEffectFunction and
666668
n = -1 and
667669
(
668-
isWrite = true or
670+
isWrite = true and
671+
not call.getTarget() instanceof ConstMemberFunction
672+
or
669673
isWrite = false
670674
)
671675
) and

cpp/ql/test/library-tests/dataflow/fields/ir-path-flow.expected

Lines changed: 178 additions & 178 deletions
Large diffs are not rendered by default.

cpp/ql/test/library-tests/ir/ir/raw_ir.expected

Lines changed: 389 additions & 455 deletions
Large diffs are not rendered by default.

cpp/ql/test/library-tests/syntax-zoo/dataflow-ir-consistency.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,12 +1492,8 @@ postWithInFlow
14921492
| cpp11.cpp:65:19:65:45 | Store | PostUpdateNode should not be the target of local flow. |
14931493
| cpp11.cpp:82:17:82:55 | Chi | PostUpdateNode should not be the target of local flow. |
14941494
| cpp11.cpp:82:17:82:55 | Chi | PostUpdateNode should not be the target of local flow. |
1495-
| cpp11.cpp:82:45:82:48 | Chi | PostUpdateNode should not be the target of local flow. |
14961495
| defdestructordeleteexpr.cpp:4:9:4:15 | Chi | PostUpdateNode should not be the target of local flow. |
14971496
| deleteexpr.cpp:7:9:7:15 | Chi | PostUpdateNode should not be the target of local flow. |
1498-
| file://:0:0:0:0 | Chi | PostUpdateNode should not be the target of local flow. |
1499-
| file://:0:0:0:0 | Chi | PostUpdateNode should not be the target of local flow. |
1500-
| file://:0:0:0:0 | Chi | PostUpdateNode should not be the target of local flow. |
15011497
| ir.cpp:177:5:177:12 | Chi | PostUpdateNode should not be the target of local flow. |
15021498
| ir.cpp:178:5:178:12 | Chi | PostUpdateNode should not be the target of local flow. |
15031499
| ir.cpp:183:5:183:12 | Chi | PostUpdateNode should not be the target of local flow. |

cpp/ql/test/query-tests/Security/CWE/CWE-079/semmle/CgiXss/CgiXss.expected

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ edges
1212
| search.c:22:24:22:28 | query | search.c:23:39:23:43 | Argument 1 indirection |
1313
| search.c:22:24:22:28 | query | search.c:23:39:23:43 | query |
1414
| search.c:22:24:22:28 | query | search.c:23:39:23:43 | query |
15-
| search.c:51:21:51:26 | call to getenv | search.c:55:5:55:15 | Argument 0 |
16-
| search.c:51:21:51:26 | call to getenv | search.c:55:5:55:15 | Argument 0 |
17-
| search.c:51:21:51:26 | call to getenv | search.c:55:17:55:25 | Argument 0 indirection |
18-
| search.c:51:21:51:26 | call to getenv | search.c:55:17:55:25 | Argument 0 indirection |
19-
| search.c:51:21:51:26 | call to getenv | search.c:57:5:57:15 | Argument 0 |
20-
| search.c:51:21:51:26 | call to getenv | search.c:57:5:57:15 | Argument 0 |
21-
| search.c:51:21:51:26 | call to getenv | search.c:57:17:57:25 | Argument 0 indirection |
22-
| search.c:51:21:51:26 | call to getenv | search.c:57:17:57:25 | Argument 0 indirection |
23-
| search.c:55:5:55:15 | Argument 0 | search.c:14:24:14:28 | query |
24-
| search.c:55:17:55:25 | Argument 0 indirection | search.c:14:24:14:28 | *query |
25-
| search.c:57:5:57:15 | Argument 0 | search.c:22:24:22:28 | query |
26-
| search.c:57:17:57:25 | Argument 0 indirection | search.c:22:24:22:28 | *query |
15+
| search.c:51:21:51:26 | call to getenv | search.c:55:5:55:15 | raw_query |
16+
| search.c:51:21:51:26 | call to getenv | search.c:55:5:55:15 | raw_query |
17+
| search.c:51:21:51:26 | call to getenv | search.c:55:17:55:25 | raw_query indirection |
18+
| search.c:51:21:51:26 | call to getenv | search.c:55:17:55:25 | raw_query indirection |
19+
| search.c:51:21:51:26 | call to getenv | search.c:57:5:57:15 | raw_query |
20+
| search.c:51:21:51:26 | call to getenv | search.c:57:5:57:15 | raw_query |
21+
| search.c:51:21:51:26 | call to getenv | search.c:57:17:57:25 | raw_query indirection |
22+
| search.c:51:21:51:26 | call to getenv | search.c:57:17:57:25 | raw_query indirection |
23+
| search.c:55:5:55:15 | raw_query | search.c:14:24:14:28 | query |
24+
| search.c:55:17:55:25 | raw_query indirection | search.c:14:24:14:28 | *query |
25+
| search.c:57:5:57:15 | raw_query | search.c:22:24:22:28 | query |
26+
| search.c:57:17:57:25 | raw_query indirection | search.c:22:24:22:28 | *query |
2727
nodes
2828
| search.c:14:24:14:28 | *query | semmle.label | *query |
2929
| search.c:14:24:14:28 | query | semmle.label | query |
@@ -43,10 +43,10 @@ nodes
4343
| search.c:23:39:23:43 | query | semmle.label | query |
4444
| search.c:51:21:51:26 | call to getenv | semmle.label | call to getenv |
4545
| search.c:51:21:51:26 | call to getenv | semmle.label | call to getenv |
46-
| search.c:55:5:55:15 | Argument 0 | semmle.label | Argument 0 |
47-
| search.c:55:17:55:25 | Argument 0 indirection | semmle.label | Argument 0 indirection |
48-
| search.c:57:5:57:15 | Argument 0 | semmle.label | Argument 0 |
49-
| search.c:57:17:57:25 | Argument 0 indirection | semmle.label | Argument 0 indirection |
46+
| search.c:55:5:55:15 | raw_query | semmle.label | raw_query |
47+
| search.c:55:17:55:25 | raw_query indirection | semmle.label | raw_query indirection |
48+
| search.c:57:5:57:15 | raw_query | semmle.label | raw_query |
49+
| search.c:57:17:57:25 | raw_query indirection | semmle.label | raw_query indirection |
5050
#select
5151
| search.c:17:8:17:12 | query | search.c:51:21:51:26 | call to getenv | search.c:17:8:17:12 | query | Cross-site scripting vulnerability due to $@. | search.c:51:21:51:26 | call to getenv | this query data |
5252
| search.c:23:39:23:43 | query | search.c:51:21:51:26 | call to getenv | search.c:23:39:23:43 | query | Cross-site scripting vulnerability due to $@. | search.c:51:21:51:26 | call to getenv | this query data |

cpp/ql/test/query-tests/Security/CWE/CWE-114/semmle/UncontrolledProcessOperation/UncontrolledProcessOperation.expected

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ edges
1111
| test.cpp:29:30:29:36 | command | test.cpp:31:10:31:16 | Argument 0 indirection |
1212
| test.cpp:29:30:29:36 | command | test.cpp:31:10:31:16 | command |
1313
| test.cpp:29:30:29:36 | command | test.cpp:31:10:31:16 | command |
14-
| test.cpp:42:7:42:16 | Argument 0 | test.cpp:24:30:24:36 | command |
15-
| test.cpp:42:18:42:23 | call to getenv | test.cpp:42:7:42:16 | Argument 0 |
16-
| test.cpp:42:18:42:23 | call to getenv | test.cpp:42:18:42:34 | Argument 0 indirection |
17-
| test.cpp:42:18:42:34 | (const char *)... | test.cpp:42:7:42:16 | Argument 0 |
18-
| test.cpp:42:18:42:34 | (const char *)... | test.cpp:42:18:42:34 | Argument 0 indirection |
19-
| test.cpp:42:18:42:34 | Argument 0 indirection | test.cpp:24:30:24:36 | *command |
20-
| test.cpp:43:7:43:16 | Argument 0 | test.cpp:29:30:29:36 | command |
21-
| test.cpp:43:18:43:23 | call to getenv | test.cpp:43:7:43:16 | Argument 0 |
22-
| test.cpp:43:18:43:23 | call to getenv | test.cpp:43:18:43:34 | Argument 0 indirection |
23-
| test.cpp:43:18:43:34 | (const char *)... | test.cpp:43:7:43:16 | Argument 0 |
24-
| test.cpp:43:18:43:34 | (const char *)... | test.cpp:43:18:43:34 | Argument 0 indirection |
25-
| test.cpp:43:18:43:34 | Argument 0 indirection | test.cpp:29:30:29:36 | *command |
14+
| test.cpp:42:7:42:16 | call to getenv | test.cpp:24:30:24:36 | command |
15+
| test.cpp:42:18:42:23 | call to getenv | test.cpp:42:7:42:16 | call to getenv |
16+
| test.cpp:42:18:42:23 | call to getenv | test.cpp:42:18:42:34 | call to getenv indirection |
17+
| test.cpp:42:18:42:34 | (const char *)... | test.cpp:42:7:42:16 | call to getenv |
18+
| test.cpp:42:18:42:34 | (const char *)... | test.cpp:42:18:42:34 | call to getenv indirection |
19+
| test.cpp:42:18:42:34 | call to getenv indirection | test.cpp:24:30:24:36 | *command |
20+
| test.cpp:43:7:43:16 | call to getenv | test.cpp:29:30:29:36 | command |
21+
| test.cpp:43:18:43:23 | call to getenv | test.cpp:43:7:43:16 | call to getenv |
22+
| test.cpp:43:18:43:23 | call to getenv | test.cpp:43:18:43:34 | call to getenv indirection |
23+
| test.cpp:43:18:43:34 | (const char *)... | test.cpp:43:7:43:16 | call to getenv |
24+
| test.cpp:43:18:43:34 | (const char *)... | test.cpp:43:18:43:34 | call to getenv indirection |
25+
| test.cpp:43:18:43:34 | call to getenv indirection | test.cpp:29:30:29:36 | *command |
2626
| test.cpp:56:12:56:17 | buffer | test.cpp:62:10:62:15 | (const char *)... |
2727
| test.cpp:56:12:56:17 | buffer | test.cpp:62:10:62:15 | Argument 0 indirection |
2828
| test.cpp:56:12:56:17 | buffer | test.cpp:62:10:62:15 | buffer |
@@ -62,14 +62,14 @@ nodes
6262
| test.cpp:31:10:31:16 | command | semmle.label | command |
6363
| test.cpp:31:10:31:16 | command | semmle.label | command |
6464
| test.cpp:31:10:31:16 | command | semmle.label | command |
65-
| test.cpp:42:7:42:16 | Argument 0 | semmle.label | Argument 0 |
65+
| test.cpp:42:7:42:16 | call to getenv | semmle.label | call to getenv |
6666
| test.cpp:42:18:42:23 | call to getenv | semmle.label | call to getenv |
6767
| test.cpp:42:18:42:34 | (const char *)... | semmle.label | (const char *)... |
68-
| test.cpp:42:18:42:34 | Argument 0 indirection | semmle.label | Argument 0 indirection |
69-
| test.cpp:43:7:43:16 | Argument 0 | semmle.label | Argument 0 |
68+
| test.cpp:42:18:42:34 | call to getenv indirection | semmle.label | call to getenv indirection |
69+
| test.cpp:43:7:43:16 | call to getenv | semmle.label | call to getenv |
7070
| test.cpp:43:18:43:23 | call to getenv | semmle.label | call to getenv |
7171
| test.cpp:43:18:43:34 | (const char *)... | semmle.label | (const char *)... |
72-
| test.cpp:43:18:43:34 | Argument 0 indirection | semmle.label | Argument 0 indirection |
72+
| test.cpp:43:18:43:34 | call to getenv indirection | semmle.label | call to getenv indirection |
7373
| test.cpp:56:12:56:17 | buffer | semmle.label | buffer |
7474
| test.cpp:56:12:56:17 | fgets output argument | semmle.label | fgets output argument |
7575
| test.cpp:62:10:62:15 | (const char *)... | semmle.label | (const char *)... |

0 commit comments

Comments
 (0)