Skip to content

Commit f8eaa1e

Browse files
authored
Merge pull request #922 from jketema/jketema/dataflow
Convert more queries to the new dataflow library
2 parents 363faea + b18c7b4 commit f8eaa1e

File tree

55 files changed

+642
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+642
-104
lines changed

c/cert/src/rules/CON30-C/CleanUpThreadSpecificStorage.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
import cpp
2121
import codingstandards.c.cert
22-
import codingstandards.cpp.Concurrency
23-
import semmle.code.cpp.dataflow.DataFlow
22+
import codingstandards.cpp.ConcurrencyNew
23+
import semmle.code.cpp.dataflow.new.DataFlow
2424

2525
module TssCreateToTssDeleteConfig implements DataFlow::ConfigSig {
2626
predicate isSource(DataFlow::Node node) {

c/cert/src/rules/CON33-C/RaceConditionsWhenUsingLibraryFunctions.ql

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

1919
import cpp
2020
import codingstandards.c.cert
21-
import codingstandards.cpp.Concurrency
21+
import codingstandards.cpp.ConcurrencyNew
2222

2323
from ThreadedCFN node
2424
where

c/cert/src/rules/CON34-C/AppropriateThreadObjectStorageDurations.ql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import cpp
2121
import codingstandards.c.cert
2222
import codingstandards.c.Objects
23-
import codingstandards.cpp.Concurrency
24-
import semmle.code.cpp.dataflow.DataFlow
23+
import codingstandards.cpp.ConcurrencyNew
24+
import semmle.code.cpp.dataflow.new.DataFlow
2525
import semmle.code.cpp.commons.Alloc
2626

2727
from C11ThreadCreateCall tcc, Expr arg
@@ -53,6 +53,7 @@ where
5353
not exists(TSSSetFunctionCall tss, DataFlow::Node src |
5454
// there should be dataflow from somewhere (the same somewhere)
5555
// into each of the first arguments
56+
exists(Expr e | e = src.asDefinition() or e = src.asDefiningArgument()) and
5657
DataFlow::localFlow(src, DataFlow::exprNode(tsg.getArgument(0))) and
5758
DataFlow::localFlow(src, DataFlow::exprNode(tss.getArgument(0)))
5859
)

c/cert/src/rules/CON34-C/ThreadObjectStorageDurationsNotInitialized.ql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
import cpp
2222
import codingstandards.c.cert
23-
import codingstandards.cpp.Concurrency
24-
import semmle.code.cpp.dataflow.DataFlow
23+
import codingstandards.cpp.ConcurrencyNew
24+
import semmle.code.cpp.dataflow.new.DataFlow
2525

2626
from TSSGetFunctionCall tsg, ThreadedFunction tf
2727
where
@@ -31,7 +31,8 @@ where
3131
// however, there does not exist a proper sequencing.
3232
not exists(TSSSetFunctionCall tss, DataFlow::Node src |
3333
// there should be dataflow from somewhere (the same somewhere)
34-
// into each of the first arguments
34+
// into each of the first argument
35+
exists(Expr e | e = src.asDefinition() or e = src.asDefiningArgument()) and
3536
DataFlow::localFlow(src, DataFlow::exprNode(tsg.getArgument(0))) and
3637
DataFlow::localFlow(src, DataFlow::exprNode(tss.getArgument(0)))
3738
)

c/cert/src/rules/CON37-C/DoNotCallSignalInMultithreadedProgram.ql

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

2020
import cpp
2121
import codingstandards.c.cert
22-
import codingstandards.cpp.Concurrency
22+
import codingstandards.cpp.ConcurrencyNew
2323

2424
from FunctionCall fc
2525
// This should only be applied in the context of a multi-threaded program (since

c/cert/src/rules/CON40-C/AtomicVariableTwiceInExpression.ql

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

2020
import cpp
2121
import codingstandards.c.cert
22-
import codingstandards.cpp.Concurrency
22+
import codingstandards.cpp.ConcurrencyNew
2323

2424
from MacroInvocation mi, Variable v, Locatable whereFound
2525
where

c/cert/src/rules/CON41-C/WrapFunctionsThatCanFailSpuriouslyInLoop.ql

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

2020
import cpp
2121
import codingstandards.c.cert
22-
import codingstandards.cpp.Concurrency
22+
import codingstandards.cpp.ConcurrencyNew
2323

2424
from AtomicCompareExchange ace
2525
where

c/cert/src/rules/FIO37-C/SuccessfulFgetsOrFgetwsMayReturnAnEmptyString.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import cpp
1919
import codingstandards.c.cert
2020
import codingstandards.cpp.FgetsErrorManagement
2121
import codingstandards.cpp.Dereferenced
22-
import semmle.code.cpp.dataflow.DataFlow
22+
import semmle.code.cpp.dataflow.new.DataFlow
2323

2424
/*
2525
* CFG nodes that follows a successful call to `fgets`

c/cert/test/rules/CON30-C/CleanUpThreadSpecificStorage.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 (CleanUpThreadSpecificStorage.ql:25,46-54)
2-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (CleanUpThreadSpecificStorage.ql:26,22-30)
3-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (CleanUpThreadSpecificStorage.ql:35,20-28)
4-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (CleanUpThreadSpecificStorage.ql:45,35-43)
5-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (CleanUpThreadSpecificStorage.ql:53,36-44)
6-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (CleanUpThreadSpecificStorage.ql:55,36-44)
71
| test.c:27:3:27:12 | call to tss_create | Resources used by thread specific storage may not be cleaned up. |
82
| test.c:49:3:49:12 | call to tss_create | Resources used by thread specific storage may not be cleaned up. |
93
| test.c:71:3:71:12 | call to tss_create | Resources used by thread specific storage may not be cleaned up. |

c/cert/test/rules/CON34-C/AppropriateThreadObjectStorageDurations.expected

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:35,14-22)
2-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:37,22-30)
3-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:39,22-30)
4-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:42,45-53)
5-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:52,33-41)
6-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:52,58-66)
7-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:53,42-50)
8-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:56,9-17)
9-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:56,34-42)
10-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:57,9-17)
11-
WARNING: module 'DataFlow' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:57,34-42)
12-
WARNING: module 'TaintTracking' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:42,9-22)
13-
WARNING: module 'TaintTracking' has been deprecated and may be removed in future (AppropriateThreadObjectStorageDurations.ql:52,7-20)
141
| test.c:23:3:23:13 | call to thrd_create | $@ not declared with appropriate storage duration | test.c:23:24:23:29 | & ... | Shared object |
152
| test.c:74:3:74:13 | call to thrd_create | $@ not declared with appropriate storage duration | test.c:74:24:74:24 | p | Shared object |
163
| test.c:85:3:85:13 | call to thrd_create | $@ not declared with appropriate storage duration | test.c:85:24:85:24 | p | Shared object |

0 commit comments

Comments
 (0)