Skip to content

Commit 25965d4

Browse files
committed
msg-filter: abstract out notes about builtin models
... so that semantically equal findings are matched with each other Resolves: https://issues.redhat.com/browse/OSH-700 Closes: #189
1 parent 3c764eb commit 25965d4

10 files changed

+229
-180
lines changed

src/lib/msg-filter.cc

+6-4
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,12 @@ MsgFilter::MsgFilter():
8383
d->addMsgFilter("", "^[0-9]+ (occurrences of warning\\[.*\\] exceeded the specified limit) [0-9]+$",
8484
"NNNN \\1 NNNN");
8585

86-
d->addMsgFilter("UNUSED_VALUE",
87-
"\\(instance [0-9]+\\)");
88-
d->addMsgFilter("STRING_OVERFLOW",
89-
"You might overrun the [0-9][0-9]* byte");
86+
// whether a builtin model was used or not is insignificant for matching the finding
87+
d->addMsgFilter("", " \\[Note: The source code implementation of the function has been overridden by a builtin model.\\]$");
88+
89+
d->addMsgFilter("UNUSED_VALUE", "\\(instance [0-9]+\\)");
90+
d->addMsgFilter("STRING_OVERFLOW", "You might overrun the [0-9][0-9]* byte");
91+
9092
// ignore changes in parameters -> it is still the same UNUSED_VALUE
9193
d->addMsgFilter("UNUSED_VALUE",
9294
"returned by \"([^\\(]+)\\(.*\\)\"",

tests/csdiff/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,6 @@ test_csdiff(diff-misc 23-cov-parser-key-event)
9191
test_csdiff(diff-misc 24-shellcheck-line-content)
9292
test_csdiff(diff-misc 25-llvm-17-path-filter)
9393
test_csdiff(diff-misc 26-too-many-events-filter)
94+
test_csdiff(diff-misc 27-cov-builtin-model)
9495

9596
add_subdirectory(filter-file)

tests/csdiff/diff-misc/27-cov-builtin-model-add-z.err

Whitespace-only changes.

tests/csdiff/diff-misc/27-cov-builtin-model-add.err

Whitespace-only changes.

tests/csdiff/diff-misc/27-cov-builtin-model-fix-z.err

Whitespace-only changes.

tests/csdiff/diff-misc/27-cov-builtin-model-fix.err

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Error: FORWARD_NULL (CWE-476):
2+
kernel-999/arch/x86/boot/compressed/kaslr.c:266:2: path: Condition "!args", taking false branch.
3+
kernel-999/arch/x86/boot/compressed/kaslr.c:271:2: path: Condition "!tmp_cmdline", taking false branch.
4+
kernel-999/arch/x86/boot/compressed/kaslr.c:281:2: path: Condition "*args", taking true branch.
5+
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "!val", taking false branch.
6+
kernel-999/arch/x86/boot/compressed/kaslr.c:287:3: path: Condition "!strcmp(param, "memmap")", taking true branch.
7+
kernel-999/arch/x86/boot/compressed/kaslr.c:289:3: path: Falling through to end of if statement.
8+
kernel-999/arch/x86/boot/compressed/kaslr.c:305:2: path: Jumping back to the beginning of the loop.
9+
kernel-999/arch/x86/boot/compressed/kaslr.c:281:2: path: Condition "*args", taking true branch.
10+
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "!val", taking true branch.
11+
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: var_compare_op: Comparing "val" to null implies that "val" might be null.
12+
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "strcmp(param, "--") == 0", taking false branch.
13+
kernel-999/arch/x86/boot/compressed/kaslr.c:287:3: path: Condition "!strcmp(param, "memmap")", taking false branch.
14+
kernel-999/arch/x86/boot/compressed/kaslr.c:289:10: path: Condition "1", taking true branch.
15+
kernel-999/arch/x86/boot/compressed/kaslr.c:289:10: path: Condition "strstr(param, "hugepages")", taking false branch.
16+
kernel-999/arch/x86/boot/compressed/kaslr.c:291:10: path: Condition "!strcmp(param, "mem")", taking true branch.
17+
kernel-999/arch/x86/boot/compressed/kaslr.c:292:4: alias_transfer: Assigning: "p" = "val".
18+
kernel-999/arch/x86/boot/compressed/kaslr.c:294:4: var_deref_model: Passing null pointer "p" to "strcmp", which dereferences it. [Note: The source code implementation of the function has been overridden by a builtin model.]
19+
# 292| char *p = val;
20+
# 293|
21+
# 294|-> if (!strcmp(p, "nopentium"))
22+
# 295| continue;
23+
# 296| mem_size = memparse(p, &p);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Error: FORWARD_NULL (CWE-476):
2+
kernel-999/arch/x86/boot/compressed/kaslr.c:266:2: path: Condition "!args", taking false branch.
3+
kernel-999/arch/x86/boot/compressed/kaslr.c:271:2: path: Condition "!tmp_cmdline", taking false branch.
4+
kernel-999/arch/x86/boot/compressed/kaslr.c:281:2: path: Condition "*args", taking true branch.
5+
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "!val", taking false branch.
6+
kernel-999/arch/x86/boot/compressed/kaslr.c:287:3: path: Condition "!strcmp(param, "memmap")", taking true branch.
7+
kernel-999/arch/x86/boot/compressed/kaslr.c:289:3: path: Falling through to end of if statement.
8+
kernel-999/arch/x86/boot/compressed/kaslr.c:305:2: path: Jumping back to the beginning of the loop.
9+
kernel-999/arch/x86/boot/compressed/kaslr.c:281:2: path: Condition "*args", taking true branch.
10+
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "!val", taking true branch.
11+
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: var_compare_op: Comparing "val" to null implies that "val" might be null.
12+
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "strcmp(param, "--") == 0", taking false branch.
13+
kernel-999/arch/x86/boot/compressed/kaslr.c:287:3: path: Condition "!strcmp(param, "memmap")", taking false branch.
14+
kernel-999/arch/x86/boot/compressed/kaslr.c:289:10: path: Condition "1", taking true branch.
15+
kernel-999/arch/x86/boot/compressed/kaslr.c:289:10: path: Condition "strstr(param, "hugepages")", taking false branch.
16+
kernel-999/arch/x86/boot/compressed/kaslr.c:291:10: path: Condition "!strcmp(param, "mem")", taking true branch.
17+
kernel-999/arch/x86/boot/compressed/kaslr.c:292:4: alias_transfer: Assigning: "p" = "val".
18+
kernel-999/arch/x86/boot/compressed/kaslr.c:294:4: var_deref_model: Passing null pointer "p" to "strcmp", which dereferences it.
19+
# 292| char *p = val;
20+
# 293|
21+
# 294|-> if (!strcmp(p, "nopentium"))
22+
# 295| continue;
23+
# 296| mem_size = memparse(p, &p);

0 commit comments

Comments
 (0)