Skip to content

Commit e1753ae

Browse files
committed
C++: Convert qlref tests to inline expectations
1 parent c3a0b65 commit e1753ae

734 files changed

Lines changed: 4115 additions & 3781 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
jsf/4.13 Functions/AV Rule 107.ql
1+
query: jsf/4.13 Functions/AV Rule 107.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Best Practices/Hiding/LocalVariableHidesGlobalVariable.ql
1+
query: Best Practices/Hiding/LocalVariableHidesGlobalVariable.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

cpp/ql/test/examples/BadLocking/UnintendedDeclaration.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void test1()
4848

4949
void test2()
5050
{
51-
Lock<Mutex> myLock(); // BAD (interpreted as a function declaration, this does nothing)
51+
Lock<Mutex> myLock(); // $ Alert[cpp/function-in-block] // BAD (interpreted as a function declaration, this does nothing)
5252

5353
// ...
5454
}
@@ -62,14 +62,14 @@ void test3()
6262

6363
void test4()
6464
{
65-
Lock<Mutex>(myMutex); // BAD (creates an uninitialized variable called `myMutex`, probably not intended)
65+
Lock<Mutex>(myMutex); // $ Alert[cpp/local-variable-hides-global-variable] // BAD (creates an uninitialized variable called `myMutex`, probably not intended)
6666

6767
// ...
6868
}
6969

7070
void test5()
7171
{
72-
Lock<Mutex> myLock(Mutex); // BAD (interpreted as a function declaration, this does nothing)
72+
Lock<Mutex> myLock(Mutex); // $ Alert[cpp/function-in-block] // BAD (interpreted as a function declaration, this does nothing)
7373

7474
// ...
7575
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
experimental/Security/CWE/CWE-020/NoCheckBeforeUnsafePutUser.ql
1+
query: experimental/Security/CWE/CWE-020/NoCheckBeforeUnsafePutUser.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
experimental/Security/CWE/CWE-020/LateCheckOfFunctionArgument.ql
1+
query: experimental/Security/CWE/CWE-020/LateCheckOfFunctionArgument.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-020/semmle/tests/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ void workFunction_0(char *s) {
33
char buf[80], buf1[8];
44
if(len<0) return;
55
memset(buf,0,len); //GOOD
6-
memset(buf1,0,len1); //BAD
6+
memset(buf1,0,len1); // $ Alert //BAD
77
if(len1<0) return;
88
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
experimental/Security/CWE/CWE-078/WordexpTainted.ql
1+
query: experimental/Security/CWE/CWE-078/WordexpTainted.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-078/test.cpp

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

2020
int wordexp(const char *restrict s, wordexp_t *restrict p, int flags);
2121

22-
int main(int argc, char** argv) {
22+
int main(int argc, char** argv) { // $ Source
2323
char *filePath = argv[2];
2424

2525
{
2626
// BAD: the user string is injected directly into `wordexp` which performs command substitution
2727

2828
wordexp_t we;
29-
wordexp(filePath, &we, 0);
29+
wordexp(filePath, &we, 0); // $ Alert
3030
}
3131

3232
{
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
experimental/Security/CWE/CWE-1041/FindWrapperFunctions.ql
1+
query: experimental/Security/CWE/CWE-1041/FindWrapperFunctions.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-1041/semmle/tests/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void myFclose(FILE * fmy)
2020
int main(int argc, char *argv[])
2121
{
2222
fe = fopen("myFile.txt", "wt");
23-
fclose(fe); // BAD
23+
fclose(fe); // $ Alert // BAD
2424
fe = fopen("myFile.txt", "wt");
2525
myFclose(fe); // GOOD
2626
return 0;

0 commit comments

Comments
 (0)