[Bug] Fix test_os_and_platform_in_query test and rules (#3695)

Co-authored-by: brokensound77 <brokensound77@users.noreply.github.com>

(cherry picked from commit ce21acef9c)
This commit is contained in:
Justin Ibarra
2024-05-20 08:43:30 -07:00
committed by github-actions[bot]
parent 0ab70f13a4
commit e7959e88b9
11 changed files with 40 additions and 34 deletions
@@ -4,7 +4,7 @@ integration = ["endpoint"]
maturity = "production"
min_stack_comments = "New fields added: required_fields, related_integrations, setup"
min_stack_version = "8.3.0"
updated_date = "2023/11/02"
updated_date = "2024/05/17"
[rule]
author = ["Elastic"]
@@ -61,12 +61,13 @@ tags = [
type = "eql"
query = '''
sequence by host.id, process.entity_id with maxspan=5s
[network where event.type == "start" and event.action in ("connection_attempted", "connection_accepted") and
process.name : ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "socat") and destination.ip != null and
not cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1")]
[process where event.type == "start" and event.action == "exec" and
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and (
(process.args : ("-i", "-l")) or (process.parent.name == "socat" and process.parent.args : "*exec*")
[network where event.type == "start" and host.os.type == "linux" and
event.action in ("connection_attempted", "connection_accepted") and
process.name : ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "socat") and destination.ip != null and
not cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1")]
[process where event.type == "start" and host.os.type == "linux" and event.action == "exec" and
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and (
(process.args : ("-i", "-l")) or (process.parent.name == "socat" and process.parent.args : "*exec*")
)]
'''
@@ -4,7 +4,7 @@ integration = ["endpoint"]
maturity = "production"
min_stack_comments = "New fields added: required_fields, related_integrations, setup"
min_stack_version = "8.3.0"
updated_date = "2023/11/02"
updated_date = "2024/05/17"
[rule]
author = ["Elastic"]
@@ -59,12 +59,13 @@ tags = [
type = "eql"
query = '''
sequence by host.id with maxspan=5s
[network where event.type == "start" and event.action in ("connection_attempted", "connection_accepted") and
process.name : ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "socat") and destination.ip != null and
not cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1")] by process.entity_id
[process where event.type == "start" and event.action in ("exec", "fork") and
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and (
(process.args : ("-i", "-l")) or (process.parent.name == "socat" and process.parent.args : "*exec*")
[network where event.type == "start" and host.os.type == "linux" and
event.action in ("connection_attempted", "connection_accepted") and
process.name : ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish", "socat") and destination.ip != null and
not cidrmatch(destination.ip, "127.0.0.0/8", "169.254.0.0/16", "224.0.0.0/4", "::1")] by process.entity_id
[process where event.type == "start" and host.os.type == "linux" and event.action in ("exec", "fork") and
process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and (
(process.args : ("-i", "-l")) or (process.parent.name == "socat" and process.parent.args : "*exec*")
)] by process.parent.entity_id
'''
@@ -4,7 +4,7 @@ integration = ["endpoint"]
maturity = "production"
min_stack_comments = "New fields added: required_fields, related_integrations, setup"
min_stack_version = "8.3.0"
updated_date = "2024/02/21"
updated_date = "2024/05/17"
[transform]
[[transform.osquery]]
@@ -175,10 +175,11 @@ tags = [
timestamp_override = "event.ingested"
type = "eql"
query = '''
file where event.action in ("creation", "file_create_event") and process.name : "kworker*" and not (
(process.name : "kworker*kcryptd*") or
(file.path : ("/var/log/*", "/var/crash/*", "/var/run/*", "/var/lib/systemd/coredump/*", "/var/spool/*"))
)
file where host.os.type == "linux" and event.action in ("creation", "file_create_event") and
process.name : "kworker*" and not (
(process.name : "kworker*kcryptd*") or
(file.path : ("/var/log/*", "/var/crash/*", "/var/run/*", "/var/lib/systemd/coredump/*", "/var/spool/*"))
)
'''
[[rule.threat]]
@@ -4,7 +4,7 @@ integration = ["endpoint"]
maturity = "production"
min_stack_comments = "New fields added: required_fields, related_integrations, setup"
min_stack_version = "8.3.0"
updated_date = "2024/02/21"
updated_date = "2024/05/17"
[transform]
[[transform.osquery]]
@@ -157,8 +157,8 @@ tags = [
timestamp_override = "event.ingested"
type = "eql"
query = '''
process where event.type == "start" and event.action : ("exec", "exec_event") and
process.parent.executable : ("/etc/update-motd.d/*", "/usr/lib/update-notifier/*") and (
process where event.type == "start" and host.os.type == "linux" and event.action : ("exec", "exec_event") and
process.parent.executable : ("/etc/update-motd.d/*", "/usr/lib/update-notifier/*") and (
(process.name in ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and (
(process.args : ("-i", "-l")) or (process.parent.name == "socat" and process.parent.args : "*exec*"))) or
(process.name : ("nc", "ncat", "netcat", "nc.openbsd") and process.args_count >= 3 and
@@ -3,7 +3,7 @@ creation_date = "2023/07/25"
maturity = "production"
min_stack_comments = "New fields added: required_fields, related_integrations, setup"
min_stack_version = "8.3.0"
updated_date = "2024/02/22"
updated_date = "2024/05/17"
integration = ["endpoint"]
[rule]
@@ -36,7 +36,7 @@ tags = [
timestamp_override = "event.ingested"
type = "eql"
query = '''
file where event.action in ("creation", "file_create_event") and file.extension == "swp" and
file where host.os.type == "linux" and event.action in ("creation", "file_create_event") and file.extension == "swp" and
file.path : (
/* common interesting files and locations */
"/etc/.shadow.swp", "/etc/.shadow-.swp", "/etc/.shadow~.swp", "/etc/.gshadow.swp", "/etc/.gshadow-.swp",
@@ -3,7 +3,7 @@ creation_date = "2023/12/11"
maturity = "production"
min_stack_comments = "New fields added: required_fields, related_integrations, setup"
min_stack_version = "8.3.0"
updated_date = "2023/12/11"
updated_date = "2024/05/17"
[rule]
author = ["Elastic"]
@@ -41,7 +41,7 @@ tags = [
timestamp_override = "event.ingested"
type = "threshold"
query = '''
kibana.alert.rule.rule_id:5c81fc9d-1eae-437f-ba07-268472967013 and event.kind:signal
kibana.alert.rule.rule_id:"5c81fc9d-1eae-437f-ba07-268472967013" and host.os.type:linux and event.kind:signal
'''
[[rule.threat]]