Skip to content

Commit e293289

Browse files
authored
Merge pull request #949 from jketema/dataflow-new
Update more queries to the new dataflow library
2 parents 3287062 + 5e701b5 commit e293289

File tree

34 files changed

+169
-103
lines changed

34 files changed

+169
-103
lines changed

c/cert/src/rules/STR31-C/StringsHasSufficientSpaceForTheNullTerminator.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import cpp
2222
import codingstandards.c.cert
23-
import semmle.code.cpp.dataflow.TaintTracking
23+
import semmle.code.cpp.dataflow.new.TaintTracking
2424
import codingstandards.cpp.PossiblyUnsafeStringOperation
2525

2626
/**

c/cert/test/rules/STR31-C/StringsHasSufficientSpaceForTheNullTerminator.expected

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (StringsHasSufficientSpaceForTheNullTerminator.ql:62,31-39)
2-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (StringsHasSufficientSpaceForTheNullTerminator.ql:62,55-63)
3-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (StringsHasSufficientSpaceForTheNullTerminator.ql:68,31-39)
4-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (StringsHasSufficientSpaceForTheNullTerminator.ql:68,54-62)
5-
WARNING: module 'TaintTracking' has been deprecated and may be removed in future (StringsHasSufficientSpaceForTheNullTerminator.ql:62,5-18)
6-
WARNING: module 'TaintTracking' has been deprecated and may be removed in future (StringsHasSufficientSpaceForTheNullTerminator.ql:68,5-18)
71
| test.c:10:20:10:24 | Cod | Expression produces or consumes a string that may not have sufficient space for a null-terminator. |
82
| test.c:16:3:16:9 | call to strncpy | Expression produces or consumes a string that may not have sufficient space for a null-terminator. |
93
| test.c:26:3:26:10 | call to snprintf | Expression produces or consumes a string that may not have sufficient space for a null-terminator. |
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
problems
2-
| test.c:11:8:11:12 | c_str | test.c:18:16:18:21 | call to getenv | test.c:11:8:11:12 | c_str | The object returned by the function getenv should not be modified. |
2+
| test.c:11:7:11:12 | * ... | test.c:18:16:18:21 | call to getenv | test.c:11:7:11:12 | * ... | The object returned by the function getenv should not be modified. |
3+
| test.c:11:8:11:12 | c_str | test.c:18:16:18:21 | call to getenv | test.c:11:7:11:12 | * ... | The object returned by the function getenv should not be modified. |
34
| test.c:67:5:67:9 | conv4 | test.c:64:11:64:20 | call to localeconv | test.c:67:5:67:9 | conv4 | The object returned by the function localeconv should not be modified. |
45
| test.c:76:5:76:8 | conv | test.c:72:25:72:34 | call to localeconv | test.c:76:5:76:8 | conv | The object returned by the function localeconv should not be modified. |
56
edges
6-
| test.c:8:18:8:22 | c_str | test.c:11:8:11:12 | c_str | provenance | |
7+
| test.c:8:18:8:22 | c_str | test.c:11:7:11:12 | * ... | provenance | |
8+
| test.c:18:16:18:21 | call to getenv | test.c:18:16:18:21 | call to getenv | provenance | |
79
| test.c:18:16:18:21 | call to getenv | test.c:24:9:24:12 | env1 | provenance | |
810
| test.c:24:9:24:12 | env1 | test.c:8:18:8:22 | c_str | provenance | |
9-
| test.c:64:11:64:20 | call to localeconv | test.c:67:5:67:9 | conv4 | provenance | |
10-
| test.c:72:25:72:34 | call to localeconv | test.c:76:5:76:8 | conv | provenance | |
11+
| test.c:64:3:64:22 | ... = ... | test.c:67:5:67:9 | conv4 | provenance | |
12+
| test.c:64:11:64:20 | call to localeconv | test.c:64:3:64:22 | ... = ... | provenance | |
13+
| test.c:72:25:72:34 | call to localeconv | test.c:72:25:72:34 | call to localeconv | provenance | |
14+
| test.c:72:25:72:34 | call to localeconv | test.c:73:24:73:28 | conv4 | provenance | |
15+
| test.c:73:24:73:28 | conv4 | test.c:76:5:76:8 | conv | provenance | |
1116
nodes
1217
| test.c:8:18:8:22 | c_str | semmle.label | c_str |
13-
| test.c:11:8:11:12 | c_str | semmle.label | c_str |
18+
| test.c:11:7:11:12 | * ... | semmle.label | * ... |
19+
| test.c:18:16:18:21 | call to getenv | semmle.label | call to getenv |
1420
| test.c:18:16:18:21 | call to getenv | semmle.label | call to getenv |
1521
| test.c:24:9:24:12 | env1 | semmle.label | env1 |
22+
| test.c:64:3:64:22 | ... = ... | semmle.label | ... = ... |
1623
| test.c:64:11:64:20 | call to localeconv | semmle.label | call to localeconv |
1724
| test.c:67:5:67:9 | conv4 | semmle.label | conv4 |
1825
| test.c:72:25:72:34 | call to localeconv | semmle.label | call to localeconv |
26+
| test.c:72:25:72:34 | call to localeconv | semmle.label | call to localeconv |
27+
| test.c:73:24:73:28 | conv4 | semmle.label | conv4 |
1928
| test.c:76:5:76:8 | conv | semmle.label | conv |
2029
subpaths

c/common/test/rules/donotuserelationaloperatorswithdifferingarrays/DoNotUseRelationalOperatorsWithDifferingArrays.expected

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,35 @@ problems
1010
| test.c:25:7:25:14 | ... >= ... | test.c:7:14:7:15 | l1 | test.c:25:7:25:8 | p1 | Compare operation >= comparing left operand pointing to array $@ and other operand pointing to array $@. | test.c:2:7:2:8 | l1 | l1 | test.c:4:7:4:8 | l3 | l3 |
1111
| test.c:25:7:25:14 | ... >= ... | test.c:25:13:25:14 | l3 | test.c:25:13:25:14 | l3 | Compare operation >= comparing right operand pointing to array $@ and other operand pointing to array $@. | test.c:4:7:4:8 | l3 | l3 | test.c:2:7:2:8 | l1 | l1 |
1212
edges
13+
| test.c:6:13:6:14 | l1 | test.c:6:13:6:14 | l1 | provenance | |
1314
| test.c:6:13:6:14 | l1 | test.c:13:12:13:13 | p0 | provenance | |
14-
| test.c:7:14:7:15 | l1 | test.c:7:14:7:18 | access to array | provenance | Config |
15-
| test.c:7:14:7:18 | access to array | test.c:11:7:11:8 | p1 | provenance | |
16-
| test.c:7:14:7:18 | access to array | test.c:13:7:13:8 | p1 | provenance | |
17-
| test.c:7:14:7:18 | access to array | test.c:15:13:15:14 | p1 | provenance | |
18-
| test.c:7:14:7:18 | access to array | test.c:17:7:17:8 | p1 | provenance | |
19-
| test.c:7:14:7:18 | access to array | test.c:23:13:23:14 | p1 | provenance | |
20-
| test.c:7:14:7:18 | access to array | test.c:25:7:25:8 | p1 | provenance | |
21-
| test.c:8:14:8:15 | l1 | test.c:8:14:8:18 | access to array | provenance | Config |
22-
| test.c:8:14:8:18 | access to array | test.c:11:12:11:13 | p2 | provenance | |
23-
| test.c:8:14:8:18 | access to array | test.c:21:7:21:8 | p2 | provenance | |
24-
| test.c:9:14:9:15 | l2 | test.c:9:14:9:18 | access to array | provenance | Config |
25-
| test.c:9:14:9:18 | access to array | test.c:21:12:21:13 | p3 | provenance | |
15+
| test.c:7:13:7:18 | & ... | test.c:7:13:7:18 | & ... | provenance | |
16+
| test.c:7:13:7:18 | & ... | test.c:11:7:11:8 | p1 | provenance | |
17+
| test.c:7:13:7:18 | & ... | test.c:13:7:13:8 | p1 | provenance | |
18+
| test.c:7:13:7:18 | & ... | test.c:15:13:15:14 | p1 | provenance | |
19+
| test.c:7:13:7:18 | & ... | test.c:17:7:17:8 | p1 | provenance | |
20+
| test.c:7:13:7:18 | & ... | test.c:23:13:23:14 | p1 | provenance | |
21+
| test.c:7:13:7:18 | & ... | test.c:25:7:25:8 | p1 | provenance | |
22+
| test.c:7:14:7:15 | l1 | test.c:7:13:7:18 | & ... | provenance | Config |
23+
| test.c:8:13:8:18 | & ... | test.c:8:13:8:18 | & ... | provenance | |
24+
| test.c:8:13:8:18 | & ... | test.c:11:12:11:13 | p2 | provenance | |
25+
| test.c:8:13:8:18 | & ... | test.c:21:7:21:8 | p2 | provenance | |
26+
| test.c:8:14:8:15 | l1 | test.c:8:13:8:18 | & ... | provenance | Config |
27+
| test.c:9:13:9:18 | & ... | test.c:9:13:9:18 | & ... | provenance | |
28+
| test.c:9:13:9:18 | & ... | test.c:21:12:21:13 | p3 | provenance | |
29+
| test.c:9:14:9:15 | l2 | test.c:9:13:9:18 | & ... | provenance | Config |
2630
nodes
2731
| test.c:6:13:6:14 | l1 | semmle.label | l1 |
32+
| test.c:6:13:6:14 | l1 | semmle.label | l1 |
33+
| test.c:7:13:7:18 | & ... | semmle.label | & ... |
34+
| test.c:7:13:7:18 | & ... | semmle.label | & ... |
2835
| test.c:7:14:7:15 | l1 | semmle.label | l1 |
29-
| test.c:7:14:7:18 | access to array | semmle.label | access to array |
36+
| test.c:8:13:8:18 | & ... | semmle.label | & ... |
37+
| test.c:8:13:8:18 | & ... | semmle.label | & ... |
3038
| test.c:8:14:8:15 | l1 | semmle.label | l1 |
31-
| test.c:8:14:8:18 | access to array | semmle.label | access to array |
39+
| test.c:9:13:9:18 | & ... | semmle.label | & ... |
40+
| test.c:9:13:9:18 | & ... | semmle.label | & ... |
3241
| test.c:9:14:9:15 | l2 | semmle.label | l2 |
33-
| test.c:9:14:9:18 | access to array | semmle.label | access to array |
3442
| test.c:11:7:11:8 | p1 | semmle.label | p1 |
3543
| test.c:11:12:11:13 | p2 | semmle.label | p2 |
3644
| test.c:13:7:13:8 | p1 | semmle.label | p1 |

c/common/test/rules/onlyfreememoryallocateddynamicallyshared/OnlyFreeMemoryAllocatedDynamicallyShared.expected

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ problems
77
| test.c:26:8:26:8 | p | test.c:25:13:25:14 | & ... | test.c:26:8:26:8 | p | Free expression frees memory which was not dynamically allocated. |
88
edges
99
| test.c:18:24:18:26 | ptr | test.c:18:36:18:38 | ptr | provenance | |
10+
| test.c:25:13:25:14 | & ... | test.c:25:13:25:14 | & ... | provenance | |
1011
| test.c:25:13:25:14 | & ... | test.c:26:8:26:8 | p | provenance | |
11-
| test.c:27:7:27:8 | & ... | test.c:28:15:28:15 | p | provenance | |
12+
| test.c:27:3:27:8 | ... = ... | test.c:28:15:28:15 | p | provenance | |
13+
| test.c:27:7:27:8 | & ... | test.c:27:3:27:8 | ... = ... | provenance | |
1214
| test.c:28:15:28:15 | p | test.c:18:24:18:26 | ptr | provenance | |
1315
nodes
1416
| test.c:8:8:8:10 | g_p | semmle.label | g_p |
@@ -18,7 +20,9 @@ nodes
1820
| test.c:18:24:18:26 | ptr | semmle.label | ptr |
1921
| test.c:18:36:18:38 | ptr | semmle.label | ptr |
2022
| test.c:25:13:25:14 | & ... | semmle.label | & ... |
23+
| test.c:25:13:25:14 | & ... | semmle.label | & ... |
2124
| test.c:26:8:26:8 | p | semmle.label | p |
25+
| test.c:27:3:27:8 | ... = ... | semmle.label | ... = ... |
2226
| test.c:27:7:27:8 | & ... | semmle.label | & ... |
2327
| test.c:28:15:28:15 | p | semmle.label | p |
2428
subpaths

cpp/autosar/src/rules/A8-4-11/SmartPointerAsParameterWithoutLifetimeSemantics.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import cpp
1717
import codingstandards.cpp.autosar
1818
import codingstandards.cpp.SmartPointers
19-
import semmle.code.cpp.dataflow.DataFlow
19+
import semmle.code.cpp.dataflow.new.DataFlow
2020
import codingstandards.cpp.standardlibrary.Utility
2121

2222
Expr lifetimeAffectingSmartPointerExpr(Function f) {

cpp/autosar/src/rules/A8-4-9/InOutParametersDeclaredAsTNotModified.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import codingstandards.cpp.autosar
2121
import codingstandards.cpp.FunctionParameter
2222
import codingstandards.cpp.ConstHelpers
2323
import codingstandards.cpp.Operator
24-
import semmle.code.cpp.dataflow.DataFlow
24+
import semmle.code.cpp.dataflow.new.DataFlow
2525

2626
/**
2727
* Non-const T& `Parameter`s to `Function`s

cpp/autosar/src/rules/M9-3-1/ConstMemberFunctionReturnsNonConstPointer.ql

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import cpp
2020
import codingstandards.cpp.autosar
21-
import semmle.code.cpp.dataflow.DataFlow
21+
import semmle.code.cpp.dataflow.new.DataFlow
2222

2323
class ReferenceTypeWithNonConstBaseType extends ReferenceType {
2424
ReferenceTypeWithNonConstBaseType() { not this.getBaseType().isConst() }
@@ -46,14 +46,16 @@ class ConstMemberFunctionWithRetNonConst extends ConstMemberFunction {
4646
from ConstMemberFunctionWithRetNonConst fun, Locatable f
4747
where
4848
not isExcluded(fun, ConstPackage::constMemberFunctionReturnsNonConstPointerQuery()) and
49-
exists(ReturnStmt ret |
49+
exists(ReturnStmt ret, DataFlow::Node vaNode, DataFlow::Node retNode |
5050
ret.getEnclosingFunction() = fun and
51+
retNode.asIndirectExpr() = ret.getExpr() and
5152
(
52-
f.(MemberVariable).getDeclaringType() = fun.getDeclaringType() and
53-
DataFlow::localExprFlow(f.(MemberVariable).getAnAccess(), ret.getExpr())
53+
vaNode.asIndirectExpr() = f.(MemberVariable).getAnAccess() and
54+
f.(MemberVariable).getDeclaringType() = fun.getDeclaringType()
5455
or
55-
DataFlow::localExprFlow(f.(ThisExpr), ret.getExpr())
56-
)
56+
vaNode.asIndirectExpr() = f.(ThisExpr)
57+
) and
58+
DataFlow::localFlow(vaNode, retNode)
5759
)
5860
select fun, "Const member function returns a " + fun.getReturnTypeCategory() + " to class data $@.",
5961
f, f.toString()
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (SmartPointerAsParameterWithoutLifetimeSemantics.ql:47,3-11)
2-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (SmartPointerAsParameterWithoutLifetimeSemantics.ql:56,5-13)
31
| test.cpp:7:41:7:43 | up1 | Function $@ takes smart pointer parameter 'up1' but does not implement any lifetime-affecting operations. | test.cpp:7:6:7:18 | smart_ptr_get | smart_ptr_get |
42
| test.cpp:16:53:16:55 | sp1 | Function $@ takes smart pointer parameter 'sp1' but does not implement any lifetime-affecting operations. | test.cpp:16:6:16:29 | smart_ptr_ref_assign_ref | smart_ptr_ref_assign_ref |
53
| test.cpp:28:55:28:57 | sp1 | Function $@ takes smart pointer parameter 'sp1' but does not implement any lifetime-affecting operations. | test.cpp:28:6:28:31 | smart_ptr_ref_noncompliant | smart_ptr_ref_noncompliant |

cpp/autosar/test/rules/A8-4-9/InOutParametersDeclaredAsTNotModified.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (InOutParametersDeclaredAsTNotModified.ql:50,7-15)
2-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (InOutParametersDeclaredAsTNotModified.ql:64,7-15)
31
| test.cpp:4:13:4:13 | i | In-out parameter i that is not written to. |
42
| test.cpp:7:22:7:24 | str | In-out parameter str that is not read from. |
53
| test.cpp:18:14:18:14 | i | In-out parameter i that is not read from. |

0 commit comments

Comments
 (0)