-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix for issue #2056 #2173
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
Fix for issue #2056 #2173
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,62 @@ | ||||||||||||||||
| #include "shared.h" | ||||||||||||||||
| #include "analysisd/eventinfo.h" | ||||||||||||||||
| #include "analysisd/config.h" | ||||||||||||||||
|
|
||||||||||||||||
| /* Mock global config */ | ||||||||||||||||
| /* _Config Config; -- defined in config-live.o */ | ||||||||||||||||
|
|
||||||||||||||||
| /* Stubs for missing symbols */ | ||||||||||||||||
| void *NULL_Decoder = NULL; | ||||||||||||||||
| int ReadConfig(int modules, const char *cfgfile, void *d1, void *d2) { return 0; } | ||||||||||||||||
|
|
||||||||||||||||
| /* External function */ | ||||||||||||||||
| void SyscheckInit(); | ||||||||||||||||
| int DecodeSyscheck(Eventinfo *lf); | ||||||||||||||||
|
|
||||||||||||||||
| int main() | ||||||||||||||||
| { | ||||||||||||||||
| /* Initialize Syscheck DB (Allocate sdb.syscheck_dec) */ | ||||||||||||||||
| SyscheckInit(); | ||||||||||||||||
|
|
||||||||||||||||
| Eventinfo lf; | ||||||||||||||||
| memset(&lf, 0, sizeof(Eventinfo)); | ||||||||||||||||
|
|
||||||||||||||||
| /* Initialize Mock Config */ | ||||||||||||||||
| Config.syscheck_alert_new = 1; /* Crucial to trigger the vulnerable path */ | ||||||||||||||||
|
|
||||||||||||||||
| /* Malformed input: Fewer than 6 tokens in checksum part */ | ||||||||||||||||
| /* Format: checksum filename */ | ||||||||||||||||
| /* Checksum expected: c_sum:md5:sha1... based on ":" parsing */ | ||||||||||||||||
| /* We provide a short checksum string */ | ||||||||||||||||
| char *input_msg = "badchecksum:1234:short /tmp/testfile"; | ||||||||||||||||
|
|
||||||||||||||||
| /* Setup Eventinfo */ | ||||||||||||||||
| lf.log = strdup(input_msg); | ||||||||||||||||
| lf.location = "localhost"; | ||||||||||||||||
|
|
||||||||||||||||
| printf("Attempting to call DecodeSyscheck with malformed input (Regression check)...\n"); | ||||||||||||||||
| fflush(stdout); | ||||||||||||||||
| DecodeSyscheck(&lf); | ||||||||||||||||
| printf("Survived Malformed Input!\n"); | ||||||||||||||||
| fflush(stdout); | ||||||||||||||||
|
|
||||||||||||||||
| /* Cleanup Test Case 1 resources */ | ||||||||||||||||
| free(lf.log); | ||||||||||||||||
| if(lf.full_log) free(lf.full_log); | ||||||||||||||||
| /* Note: other fields leaked for simplicity, just zeroing struct for next test */ | ||||||||||||||||
| memset(&lf, 0, sizeof(Eventinfo)); | ||||||||||||||||
|
|
||||||||||||||||
| /* Test Case 2: Full Checksum with SHA256 */ | ||||||||||||||||
| /* Format: 1:2:3:4:MD5:SHA1:SHA256 */ | ||||||||||||||||
| char *input_msg_full = "ignore:ignore:ignore:ignore:MYMD5:MYSHA1:MYSHA256 /tmp/testfile_sha256"; | ||||||||||||||||
| lf.log = strdup(input_msg_full); | ||||||||||||||||
| lf.location = "localhost"; | ||||||||||||||||
|
|
||||||||||||||||
| printf("Attempting to call DecodeSyscheck with SHA256 input...\n"); | ||||||||||||||||
| fflush(stdout); | ||||||||||||||||
| DecodeSyscheck(&lf); | ||||||||||||||||
| printf("Survived SHA256 Input!\n"); | ||||||||||||||||
| fflush(stdout); | ||||||||||||||||
|
Comment on lines
+37
to
+59
|
||||||||||||||||
|
|
||||||||||||||||
|
||||||||||||||||
| /* Cleanup Test Case 2 resources */ | |
| free(lf.log); | |
| if (lf.full_log) { | |
| free(lf.full_log); | |
| } |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test file doesn't follow the established testing convention used in this codebase. All other test files in src/tests (test_os_crypto.c, test_os_net.c, test_os_regex.c, test_os_xml.c, test_os_zlib.c, test_shared.c) use the Check unit testing framework with START_TEST/END_TEST macros, test suites, and proper test runners. This regression test should be refactored to follow the same pattern for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing copyright header. All other test files in src/tests include a copyright header at the top (e.g., test_os_crypto.c:1-8, test_shared.c:1-8). This file should include the same copyright notice for consistency with the codebase convention.