Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msg-filter: abstract out notes about builtin models #189

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/lib/msg-filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ MsgFilter::MsgFilter():
d->addMsgFilter("", "^[0-9]+ (occurrences of warning\\[.*\\] exceeded the specified limit) [0-9]+$",
"NNNN \\1 NNNN");

d->addMsgFilter("UNUSED_VALUE",
"\\(instance [0-9]+\\)");
d->addMsgFilter("STRING_OVERFLOW",
"You might overrun the [0-9][0-9]* byte");
// whether a builtin model was used or not is insignificant for matching the finding
d->addMsgFilter("", " \\[Note: The source code implementation of the function has been overridden by a builtin model.\\]$");

d->addMsgFilter("UNUSED_VALUE", "\\(instance [0-9]+\\)");
d->addMsgFilter("STRING_OVERFLOW", "You might overrun the [0-9][0-9]* byte");

// ignore changes in parameters -> it is still the same UNUSED_VALUE
d->addMsgFilter("UNUSED_VALUE",
"returned by \"([^\\(]+)\\(.*\\)\"",
Expand Down
1 change: 1 addition & 0 deletions tests/csdiff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,6 @@ test_csdiff(diff-misc 23-cov-parser-key-event)
test_csdiff(diff-misc 24-shellcheck-line-content)
test_csdiff(diff-misc 25-llvm-17-path-filter)
test_csdiff(diff-misc 26-too-many-events-filter)
test_csdiff(diff-misc 27-cov-builtin-model)

add_subdirectory(filter-file)
Empty file.
Empty file.
Empty file.
Empty file.
23 changes: 23 additions & 0 deletions tests/csdiff/diff-misc/27-cov-builtin-model-new.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Error: FORWARD_NULL (CWE-476):
kernel-999/arch/x86/boot/compressed/kaslr.c:266:2: path: Condition "!args", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:271:2: path: Condition "!tmp_cmdline", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:281:2: path: Condition "*args", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "!val", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:287:3: path: Condition "!strcmp(param, "memmap")", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:289:3: path: Falling through to end of if statement.
kernel-999/arch/x86/boot/compressed/kaslr.c:305:2: path: Jumping back to the beginning of the loop.
kernel-999/arch/x86/boot/compressed/kaslr.c:281:2: path: Condition "*args", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "!val", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: var_compare_op: Comparing "val" to null implies that "val" might be null.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "strcmp(param, "--") == 0", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:287:3: path: Condition "!strcmp(param, "memmap")", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:289:10: path: Condition "1", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:289:10: path: Condition "strstr(param, "hugepages")", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:291:10: path: Condition "!strcmp(param, "mem")", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:292:4: alias_transfer: Assigning: "p" = "val".
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.]
# 292| char *p = val;
# 293|
# 294|-> if (!strcmp(p, "nopentium"))
# 295| continue;
# 296| mem_size = memparse(p, &p);
23 changes: 23 additions & 0 deletions tests/csdiff/diff-misc/27-cov-builtin-model-old.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Error: FORWARD_NULL (CWE-476):
kernel-999/arch/x86/boot/compressed/kaslr.c:266:2: path: Condition "!args", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:271:2: path: Condition "!tmp_cmdline", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:281:2: path: Condition "*args", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "!val", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:287:3: path: Condition "!strcmp(param, "memmap")", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:289:3: path: Falling through to end of if statement.
kernel-999/arch/x86/boot/compressed/kaslr.c:305:2: path: Jumping back to the beginning of the loop.
kernel-999/arch/x86/boot/compressed/kaslr.c:281:2: path: Condition "*args", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "!val", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: var_compare_op: Comparing "val" to null implies that "val" might be null.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "strcmp(param, "--") == 0", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:287:3: path: Condition "!strcmp(param, "memmap")", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:289:10: path: Condition "1", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:289:10: path: Condition "strstr(param, "hugepages")", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:291:10: path: Condition "!strcmp(param, "mem")", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:292:4: alias_transfer: Assigning: "p" = "val".
kernel-999/arch/x86/boot/compressed/kaslr.c:294:4: var_deref_model: Passing null pointer "p" to "strcmp", which dereferences it.
# 292| char *p = val;
# 293|
# 294|-> if (!strcmp(p, "nopentium"))
# 295| continue;
# 296| mem_size = memparse(p, &p);
Loading