Skip to content

Commit 843ac7c

Browse files
committed
Add SPURIOUS: tags
1 parent a2c5d4c commit 843ac7c

34 files changed

Lines changed: 68 additions & 68 deletions

File tree

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-190/AllocMultiplicationOverflow/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void test()
1616

1717
if ((x <= 1000) && (y <= 1000))
1818
{
19-
char *buffer5 = (char *)malloc(x * y); // $ Alert // GOOD [FALSE POSITIVE]
19+
char *buffer5 = (char *)malloc(x * y); // $ SPURIOUS: Alert // GOOD [FALSE POSITIVE]
2020
}
2121

2222
size_t size1 = x * y; // $ Source

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-193/constant-size/test.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ char testStrncmp2(char *arr) {
135135
if(strncmp(arr, "<test>", 6) == 0) {
136136
arr += 6; // $ Alert
137137
}
138-
return *arr; // $ Sink // GOOD [FALSE POSITIVE]
138+
return *arr; // $ SPURIOUS: Sink // GOOD [FALSE POSITIVE]
139139
}
140140

141141
void testStrncmp1() {
@@ -144,7 +144,7 @@ void testStrncmp1() {
144144
}
145145

146146
void countdownBuf1(int **p) {
147-
*--(*p) = 1; // $ Sink // GOOD [FALSE POSITIVE]
147+
*--(*p) = 1; // $ SPURIOUS: Sink // GOOD [FALSE POSITIVE]
148148
*--(*p) = 2; // GOOD
149149
*--(*p) = 3; // GOOD
150150
*--(*p) = 4; // GOOD
@@ -258,7 +258,7 @@ void call_use(unsigned char* p, int n) {
258258
if(n == 3) {
259259
unsigned char x = p[0];
260260
unsigned char y = p[1];
261-
unsigned char z = p[2]; // $ Alert // GOOD [FALSE POSITIVE]: `call_use(buffer2, 2)` won't reach this point.
261+
unsigned char z = p[2]; // $ SPURIOUS: Alert // GOOD [FALSE POSITIVE]: `call_use(buffer2, 2)` won't reach this point.
262262
use(x, y, z);
263263
}
264264
}
@@ -296,7 +296,7 @@ int guardingCallee(int *arr, int size) {
296296

297297
int sum;
298298
for (int i = 0; i < size; i++) {
299-
sum += arr[i]; // $ Alert // GOOD [FALSE POSITIVE] - guarded by size
299+
sum += arr[i]; // $ SPURIOUS: Alert // GOOD [FALSE POSITIVE] - guarded by size
300300
}
301301
return sum;
302302
}
@@ -319,7 +319,7 @@ void correlatedCondition(int num) {
319319
end = temp + 56;
320320
}
321321
else if (num < 64) {
322-
end = temp + 64; // $ Alert // GOOD [FALSE POSITVE]
322+
end = temp + 64; // $ SPURIOUS: Alert // GOOD [FALSE POSITVE]
323323
}
324324
char *temp2 = temp + num;
325325
while(temp2 != end) { // $ Sink

cpp/ql/test/query-tests/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int Foo::test(int (*baz)(int))
163163

164164
if (1) foo(
165165
i++
166-
), j++; // $ Alert // GOOD? [FALSE POSITIVE]
166+
), j++; // $ SPURIOUS: Alert // GOOD? [FALSE POSITIVE]
167167

168168
if (1) baz(
169169
i++

cpp/ql/test/query-tests/Best Practices/Likely Errors/OffsetUseBeforeRangeCheck/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void test(char *buffer, int bufferSize)
3636

3737
// look for 'ab'
3838
for (i = 0; i < bufferSize; i++) {
39-
if ((buffer[i] == 'a') && (i < bufferSize - 1) && (buffer[i + 1] == 'b')) // $ Alert // GOOD [FALSE POSITIVE]
39+
if ((buffer[i] == 'a') && (i < bufferSize - 1) && (buffer[i + 1] == 'b')) // $ SPURIOUS: Alert // GOOD [FALSE POSITIVE]
4040
break;
4141
}
4242

cpp/ql/test/query-tests/Best Practices/Unused Entities/UnusedStaticVariables/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ static int staticVar6 = 6; // $ Alert // BAD (unused)
99
static __attribute__((__unused__)) int staticVar7; // GOOD (unused but this is expected)
1010
const int constVar8 = 8; // $ Alert // BAD (const defaults to static)
1111
extern const int constVar9 = 9; // GOOD
12-
static int staticVar10 = 10; // $ Alert // GOOD [FALSE POSITIVE] (referenced in a never instantiated template)
12+
static int staticVar10 = 10; // $ SPURIOUS: Alert // GOOD [FALSE POSITIVE] (referenced in a never instantiated template)
1313

1414
void f()
1515
{

cpp/ql/test/query-tests/Critical/MemoryFreed/my_auto_ptr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ template<class T>
5252
class AutoContainer2
5353
{
5454
public:
55-
AutoContainer2() : v(new T) // $ Alert[cpp/memory-never-freed] // GOOD [FALSE POSITIVE]
55+
AutoContainer2() : v(new T) // $ SPURIOUS: Alert[cpp/memory-never-freed] // GOOD [FALSE POSITIVE]
5656
{
57-
ns::my_auto_ptr<T> ap(new T); // $ Alert[cpp/memory-never-freed] // GOOD [FALSE POSITIVE]
57+
ns::my_auto_ptr<T> ap(new T); // $ SPURIOUS: Alert[cpp/memory-never-freed] // GOOD [FALSE POSITIVE]
5858
}
5959

6060
ns::my_auto_ptr<T> v;
@@ -68,7 +68,7 @@ class AutoCloner
6868
AutoCloner(AutoCloner &from) : val(from.val) {};
6969

7070
ns::my_auto_ptr<AutoCloner> clone() {
71-
return ns::my_auto_ptr<AutoCloner>(new AutoCloner(*this)); // $ Alert[cpp/memory-never-freed] // GOOD [FALSE POSITIVE]
71+
return ns::my_auto_ptr<AutoCloner>(new AutoCloner(*this)); // $ SPURIOUS: Alert[cpp/memory-never-freed] // GOOD [FALSE POSITIVE]
7272
}
7373

7474
private:

cpp/ql/test/query-tests/Critical/MemoryFreed/test_free.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,17 @@ void test_loop3(char ** a, char ** b) {
233233
free(*a); // $ Source[cpp/use-after-free]
234234
a++;
235235
}
236-
use(*a); // $ Alert[cpp/use-after-free] // GOOD [FALSE POSITIVE]
236+
use(*a); // $ SPURIOUS: Alert[cpp/use-after-free] // GOOD [FALSE POSITIVE]
237237

238238
for (;*b; b++) {
239239
free(*b); // $ Source[cpp/use-after-free]
240240
}
241-
use(*b); // $ Alert[cpp/use-after-free] // GOOD [FALSE POSITIVE]
241+
use(*b); // $ SPURIOUS: Alert[cpp/use-after-free] // GOOD [FALSE POSITIVE]
242242
}
243243

244244
void test_deref(char **a) {
245245
free(*a); // $ Source[cpp/use-after-free]
246-
use(*a); // $ Alert[cpp/use-after-free] // GOOD [FALSE POSITIVE]
246+
use(*a); // $ SPURIOUS: Alert[cpp/use-after-free] // GOOD [FALSE POSITIVE]
247247
}
248248

249249
// Refs

cpp/ql/test/query-tests/Critical/MissingCheckScanf/test.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,15 @@ int main()
269269

270270
set_by_ref(i);
271271
scanf("%d", &i); // $ Source[cpp/missing-check-scanf]
272-
use(i); // $ Alert[cpp/missing-check-scanf] // GOOD [FALSE POSITIVE]
272+
use(i); // $ SPURIOUS: Alert[cpp/missing-check-scanf] // GOOD [FALSE POSITIVE]
273273
}
274274

275275
{
276276
int i;
277277

278278
set_by_ptr(&i);
279279
scanf("%d", &i); // $ Source[cpp/missing-check-scanf]
280-
use(i); // $ Alert[cpp/missing-check-scanf] // GOOD [FALSE POSITIVE]
280+
use(i); // $ SPURIOUS: Alert[cpp/missing-check-scanf] // GOOD [FALSE POSITIVE]
281281
}
282282

283283
{
@@ -401,7 +401,7 @@ char *my_string_copy() {
401401
for (int i = 0; i < len; i += 2) {
402402
unsigned int u;
403403
sscanf(src + i, "%2x", &u); // $ Source[cpp/missing-check-scanf]
404-
*ptr++ = (char) u; // $ Alert[cpp/missing-check-scanf] // GOOD [FALSE POSITIVE]? src+i+{0,1} are always valid %x digits, so this should be OK.
404+
*ptr++ = (char) u; // $ SPURIOUS: Alert[cpp/missing-check-scanf] // GOOD [FALSE POSITIVE]? src+i+{0,1} are always valid %x digits, so this should be OK.
405405
}
406406
*ptr++ = 0;
407407
return DST_STRING;
@@ -413,14 +413,14 @@ void scan_and_write() {
413413
if (scanf("%d", &i) < 1) { // $ Source[cpp/missing-check-scanf]
414414
i = 0;
415415
}
416-
use(i); // $ Alert[cpp/missing-check-scanf] // GOOD [FALSE POSITIVE]: variable is overwritten with a default value when scanf fails
416+
use(i); // $ SPURIOUS: Alert[cpp/missing-check-scanf] // GOOD [FALSE POSITIVE]: variable is overwritten with a default value when scanf fails
417417
}
418418
{
419419
int i;
420420
if (scanf("%d", &i) != 1) { // $ Source[cpp/missing-check-scanf]
421421
i = 0;
422422
}
423-
use(i); // $ Alert[cpp/missing-check-scanf] // GOOD [FALSE POSITIVE]: variable is overwritten with a default value when scanf fails
423+
use(i); // $ SPURIOUS: Alert[cpp/missing-check-scanf] // GOOD [FALSE POSITIVE]: variable is overwritten with a default value when scanf fails
424424
}
425425
}
426426

@@ -481,7 +481,7 @@ void multiple_checks() {
481481

482482
if (res >= 0) {
483483
if (res != 0) {
484-
use(i); // $ Alert[cpp/missing-check-scanf] // GOOD: checks return value [FALSE POSITIVE]
484+
use(i); // $ SPURIOUS: Alert[cpp/missing-check-scanf] // GOOD: checks return value [FALSE POSITIVE]
485485
}
486486
}
487487
}
@@ -492,7 +492,7 @@ void multiple_checks() {
492492

493493
if (res < 0) return;
494494
if (res != 0) {
495-
use(i); // $ Alert[cpp/missing-check-scanf] // GOOD: checks return value [FALSE POSITIVE]
495+
use(i); // $ SPURIOUS: Alert[cpp/missing-check-scanf] // GOOD: checks return value [FALSE POSITIVE]
496496
}
497497
}
498498

cpp/ql/test/query-tests/JPL_C/LOC-4/Rule 29/NonConstFunctionPointer/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ void test()
1717

1818
funPtr1(); // $ Alert // BAD
1919
funPtr2(); // $ Alert // BAD
20-
funPtr3(); // $ Alert // GOOD [FALSE POSITIVE]
20+
funPtr3(); // $ SPURIOUS: Alert // GOOD [FALSE POSITIVE]
2121
}

cpp/ql/test/query-tests/Likely Bugs/Arithmetic/PointlessComparison/PointlessComparison.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ int overeager_wraparound(unsigned int u32bound, unsigned long long u64bound) {
261261

262262
int negative_zero(double dbl) {
263263
if (dbl >= 0) {
264-
return dbl >= -dbl; // $ Alert[cpp/constant-comparison] // GOOD [FALSE POSITIVE]
264+
return dbl >= -dbl; // $ SPURIOUS: Alert[cpp/constant-comparison] // GOOD [FALSE POSITIVE]
265265
}
266266
return 0;
267267
}

0 commit comments

Comments
 (0)