Skip to content

Conversation

brokensound77
Copy link
Contributor

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 are windows and do not include winlog fields, ignoring all other OS's. This fixes the logic and updates some rules that merged in the mean time without the host.os.type set.

@brokensound77 brokensound77 added bug Something isn't working Rule: Tuning tweaking or tuning an existing rule labels May 18, 2024
@brokensound77 brokensound77 requested a review from w0rk3r May 18, 2024 04:06
Copy link
Contributor

@Mikaayenson Mikaayenson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Comment on lines +54 to +57
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:
Copy link
Contributor

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)

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@eric-forte-elastic eric-forte-elastic left a 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! 👍

@brokensound77 brokensound77 merged commit ce21ace into elastic:main May 20, 2024
@brokensound77 brokensound77 deleted the fix-host-os-type-test-and-rules branch May 20, 2024 15:43
protectionsmachine pushed a commit that referenced this pull request May 20, 2024
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)
protectionsmachine pushed a commit that referenced this pull request May 20, 2024
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)
protectionsmachine pushed a commit that referenced this pull request May 20, 2024
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)
protectionsmachine pushed a commit that referenced this pull request May 20, 2024
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)
protectionsmachine pushed a commit that referenced this pull request May 20, 2024
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)
protectionsmachine pushed a commit that referenced this pull request May 20, 2024
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)
protectionsmachine pushed a commit that referenced this pull request May 20, 2024
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)
protectionsmachine pushed a commit that referenced this pull request May 20, 2024
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)
protectionsmachine pushed a commit that referenced this pull request May 20, 2024
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> (cherry picked from commit ce21ace)
protectionsmachine pushed a commit that referenced this pull request May 20, 2024
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> (cherry picked from commit ce21ace)
protectionsmachine pushed a commit that referenced this pull request May 20, 2024
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> (cherry picked from commit ce21ace)
protectionsmachine pushed a commit that referenced this pull request May 20, 2024
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com> (cherry picked from commit ce21ace)
Mikaayenson pushed a commit that referenced this pull request May 20, 2024
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com>
Mikaayenson pushed a commit that referenced this pull request May 20, 2024
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com>
Mikaayenson pushed a commit that referenced this pull request May 20, 2024
Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport: auto bug Something isn't working Domain: Endpoint OS: Linux OS: macOS Rule: Tuning tweaking or tuning an existing rule

4 participants