- Notifications
You must be signed in to change notification settings - Fork 603
[Bug] Fix test_os_and_platform_in_query test and rules #3695
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
[Bug] Fix test_os_and_platform_in_query test and rules #3695
Conversation
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.
Good catch!
if rule.path.parent.name == "windows": | ||
if not any(field.startswith("winlog.") for field in fields): | ||
self.assertIn("host.os.type", fields, err_msg) | ||
else: |
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.
nit:
By the time we get here, we've already checked "host.os.type" not in fields:
, so we probably dont need to assertIn
again. Something like self.assertTrue(any(field.startswith("winlog.") for field in fields), "some more appropriate message about winlog and host.os.type"
might be better.
Then in the else, self.fail(err_msg)
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.
I think you're reading it wrong. If winlog fields are present, the check is abandoned.
I initially had it collapsed more but it was much more readable this way.
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.
I mean compare line 52 & 56 for example or 52 & 58.
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.
🟢 Manual review, looks good to me! 👍
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> Removed changes from: - rules/macos/credential_access_promt_for_pwd_via_osascript.toml - rules/macos/credential_access_suspicious_web_browser_sensitive_file_access.toml - rules/macos/initial_access_suspicious_mac_ms_office_child_process.toml (selectively cherry picked from commit ce21ace)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> Removed changes from: - rules/macos/credential_access_promt_for_pwd_via_osascript.toml - rules/macos/credential_access_suspicious_web_browser_sensitive_file_access.toml - rules/macos/initial_access_suspicious_mac_ms_office_child_process.toml (selectively cherry picked from commit ce21ace)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> Removed changes from: - rules/macos/credential_access_promt_for_pwd_via_osascript.toml - rules/macos/credential_access_suspicious_web_browser_sensitive_file_access.toml - rules/macos/initial_access_suspicious_mac_ms_office_child_process.toml (selectively cherry picked from commit ce21ace)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> Removed changes from: - rules/macos/credential_access_promt_for_pwd_via_osascript.toml - rules/macos/credential_access_suspicious_web_browser_sensitive_file_access.toml - rules/macos/initial_access_suspicious_mac_ms_office_child_process.toml (selectively cherry picked from commit ce21ace)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> Removed changes from: - rules/macos/credential_access_suspicious_web_browser_sensitive_file_access.toml - rules/macos/initial_access_suspicious_mac_ms_office_child_process.toml (selectively cherry picked from commit ce21ace)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> Removed changes from: - rules/macos/credential_access_suspicious_web_browser_sensitive_file_access.toml - rules/macos/initial_access_suspicious_mac_ms_office_child_process.toml (selectively cherry picked from commit ce21ace)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> Removed changes from: - rules/macos/credential_access_suspicious_web_browser_sensitive_file_access.toml - rules/macos/initial_access_suspicious_mac_ms_office_child_process.toml (selectively cherry picked from commit ce21ace)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> Removed changes from: - rules/macos/credential_access_suspicious_web_browser_sensitive_file_access.toml - rules/macos/initial_access_suspicious_mac_ms_office_child_process.toml (selectively cherry picked from commit ce21ace)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> (cherry picked from commit ce21ace)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> (cherry picked from commit ce21ace)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> (cherry picked from commit ce21ace)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> (cherry picked from commit ce21ace)
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com>
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com>
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com>
Issues
related to #2761
Summary
A bug was unintentionally introduced in #2761 where the
test_os_and_platform_in_query
was updated to only test on rules when they arewindows
and do not includewinlog
fields, ignoring all other OS's. This fixes the logic and updates some rules that merged in the mean time without thehost.os.type
set.