-
Notifications
You must be signed in to change notification settings - Fork 521
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
[FR] Add Integration Schema Query Validation #2470
[FR] Add Integration Schema Query Validation #2470
Conversation
…ration manifest file
Update Jan 17 2023Based on some preliminary testing, some rules will have to be tuned.
There are some other ones, but before rules are tuned, I want to locally go through more rules that fail. Note: You'll need to uncomment the lines to validate if you want to see the errors. |
Update Feb 1
|
…ub.com:elastic/detection-rules into 1994-add-integration-specific-query-validation
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.
LGTM, great work!
Checks:
✅ Reviewed rule updates regarding missing system
integration tag.
✅ NON_DATASET_PACKAGES
in definitions.py looks good
✅ Reviewed KQLValidator
and EQLValidator
validation logic that relies on get_packaged_integrations
and validate_integration
if they apply
✅ Reviewed build_integrations_schema
function in integrations.py
✅ Reviewed find_latest_compatible_version
function in integrations.py
✅ Reviewed get_integration_schema_data
function in integrations.py
✅ Tested show-latest-compatible
command for endpoint and stack version 8.5
✅ Unit tests passing
…ub.com:elastic/detection-rules into 1994-add-integration-specific-query-validation
Stealing from Terrence's checklist above where applicable ^ ✅ Reviewed |
integrations_schemas = load_integrations_schemas() | ||
|
||
# validate the query against related integration fields | ||
if isinstance(data, QueryRuleData) and data.language != 'lucene' and meta.maturity == "production": |
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: Maybe data.language
should use data.get()
?
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.
Then again, this case (where data.language
is invalid/not set) might have already been caught in schema validation.
Removed changes from: - rules/integrations/azure/initial_access_consent_grant_attack_via_azure_registered_application.toml - rules/linux/credential_access_bruteforce_password_guessing.toml - rules/linux/credential_access_potential_linux_ssh_bruteforce.toml - rules/linux/credential_access_potential_linux_ssh_bruteforce_root.toml - rules/windows/collection_email_outlook_mailbox_via_com.toml - rules/windows/credential_access_bruteforce_admin_account.toml - rules/windows/credential_access_bruteforce_multiple_logon_failure_followed_by_success.toml - rules/windows/credential_access_bruteforce_multiple_logon_failure_same_srcip.toml - rules/windows/credential_access_dcsync_replication_rights.toml - rules/windows/credential_access_disable_kerberos_preauth.toml - rules/windows/credential_access_ldap_attributes.toml - rules/windows/credential_access_lsass_memdump_handle_access.toml - rules/windows/credential_access_remote_sam_secretsdump.toml - rules/windows/credential_access_saved_creds_vault_winlog.toml - rules/windows/credential_access_seenabledelegationprivilege_assigned_to_user.toml - rules/windows/credential_access_shadow_credentials.toml - rules/windows/credential_access_spn_attribute_modified.toml - rules/windows/credential_access_suspicious_winreg_access_via_sebackup_priv.toml - rules/windows/defense_evasion_clearing_windows_security_logs.toml - rules/windows/discovery_privileged_localgroup_membership.toml - rules/windows/discovery_whoami_command_activity.toml - rules/windows/lateral_movement_remote_service_installed_winlog.toml - rules/windows/lateral_movement_remote_task_creation_winlog.toml - rules/windows/lateral_movement_service_control_spawned_script_int.toml - rules/windows/persistence_ad_adminsdholder.toml - rules/windows/persistence_dontexpirepasswd_account.toml - rules/windows/persistence_msds_alloweddelegateto_krbtgt.toml - rules/windows/persistence_remote_password_reset.toml - rules/windows/persistence_scheduled_task_creation_winlog.toml - rules/windows/persistence_scheduled_task_updated.toml - rules/windows/persistence_sdprop_exclusion_dsheuristics.toml - rules/windows/persistence_service_windows_service_winlog.toml - rules/windows/persistence_temp_scheduled_task.toml - rules/windows/persistence_user_account_added_to_privileged_group_ad.toml - rules/windows/privilege_escalation_create_process_as_different_user.toml - rules/windows/privilege_escalation_credroaming_ldap.toml - rules/windows/privilege_escalation_group_policy_iniscript.toml - rules/windows/privilege_escalation_group_policy_privileged_groups.toml - rules/windows/privilege_escalation_group_policy_scheduled_task.toml - rules/windows/privilege_escalation_krbrelayup_service_creation.toml - rules/windows/privilege_escalation_samaccountname_spoofing_attack.toml - rules/windows/privilege_escalation_suspicious_dnshostname_update.toml - rules/windows/privilege_escalation_windows_service_via_unusual_client.toml (selectively cherry picked from commit 1784429)
Removed changes from: - rules/integrations/azure/initial_access_consent_grant_attack_via_azure_registered_application.toml - rules/linux/credential_access_bruteforce_password_guessing.toml - rules/linux/credential_access_potential_linux_ssh_bruteforce.toml - rules/linux/credential_access_potential_linux_ssh_bruteforce_root.toml - rules/windows/collection_email_outlook_mailbox_via_com.toml - rules/windows/credential_access_bruteforce_admin_account.toml - rules/windows/credential_access_bruteforce_multiple_logon_failure_followed_by_success.toml - rules/windows/credential_access_bruteforce_multiple_logon_failure_same_srcip.toml - rules/windows/credential_access_dcsync_replication_rights.toml - rules/windows/credential_access_disable_kerberos_preauth.toml - rules/windows/credential_access_ldap_attributes.toml - rules/windows/credential_access_lsass_memdump_handle_access.toml - rules/windows/credential_access_remote_sam_secretsdump.toml - rules/windows/credential_access_saved_creds_vault_winlog.toml - rules/windows/credential_access_seenabledelegationprivilege_assigned_to_user.toml - rules/windows/credential_access_shadow_credentials.toml - rules/windows/credential_access_spn_attribute_modified.toml - rules/windows/credential_access_suspicious_winreg_access_via_sebackup_priv.toml - rules/windows/defense_evasion_clearing_windows_security_logs.toml - rules/windows/discovery_privileged_localgroup_membership.toml - rules/windows/discovery_whoami_command_activity.toml - rules/windows/lateral_movement_remote_service_installed_winlog.toml - rules/windows/lateral_movement_remote_task_creation_winlog.toml - rules/windows/lateral_movement_service_control_spawned_script_int.toml - rules/windows/persistence_ad_adminsdholder.toml - rules/windows/persistence_dontexpirepasswd_account.toml - rules/windows/persistence_msds_alloweddelegateto_krbtgt.toml - rules/windows/persistence_remote_password_reset.toml - rules/windows/persistence_scheduled_task_creation_winlog.toml - rules/windows/persistence_scheduled_task_updated.toml - rules/windows/persistence_sdprop_exclusion_dsheuristics.toml - rules/windows/persistence_service_windows_service_winlog.toml - rules/windows/persistence_temp_scheduled_task.toml - rules/windows/persistence_user_account_added_to_privileged_group_ad.toml - rules/windows/privilege_escalation_create_process_as_different_user.toml - rules/windows/privilege_escalation_credroaming_ldap.toml - rules/windows/privilege_escalation_group_policy_iniscript.toml - rules/windows/privilege_escalation_group_policy_privileged_groups.toml - rules/windows/privilege_escalation_group_policy_scheduled_task.toml - rules/windows/privilege_escalation_krbrelayup_service_creation.toml - rules/windows/privilege_escalation_samaccountname_spoofing_attack.toml - rules/windows/privilege_escalation_suspicious_dnshostname_update.toml - rules/windows/privilege_escalation_windows_service_via_unusual_client.toml (selectively cherry picked from commit 1784429)
Removed changes from: - rules/integrations/azure/initial_access_consent_grant_attack_via_azure_registered_application.toml - rules/linux/credential_access_bruteforce_password_guessing.toml - rules/linux/credential_access_potential_linux_ssh_bruteforce.toml - rules/linux/credential_access_potential_linux_ssh_bruteforce_root.toml - rules/windows/collection_email_outlook_mailbox_via_com.toml - rules/windows/credential_access_bruteforce_admin_account.toml - rules/windows/credential_access_bruteforce_multiple_logon_failure_followed_by_success.toml - rules/windows/credential_access_bruteforce_multiple_logon_failure_same_srcip.toml - rules/windows/credential_access_dcsync_replication_rights.toml - rules/windows/credential_access_disable_kerberos_preauth.toml - rules/windows/credential_access_ldap_attributes.toml - rules/windows/credential_access_lsass_memdump_handle_access.toml - rules/windows/credential_access_remote_sam_secretsdump.toml - rules/windows/credential_access_saved_creds_vault_winlog.toml - rules/windows/credential_access_seenabledelegationprivilege_assigned_to_user.toml - rules/windows/credential_access_shadow_credentials.toml - rules/windows/credential_access_spn_attribute_modified.toml - rules/windows/credential_access_suspicious_winreg_access_via_sebackup_priv.toml - rules/windows/defense_evasion_clearing_windows_security_logs.toml - rules/windows/discovery_privileged_localgroup_membership.toml - rules/windows/discovery_whoami_command_activity.toml - rules/windows/lateral_movement_remote_service_installed_winlog.toml - rules/windows/lateral_movement_remote_task_creation_winlog.toml - rules/windows/lateral_movement_service_control_spawned_script_int.toml - rules/windows/persistence_ad_adminsdholder.toml - rules/windows/persistence_dontexpirepasswd_account.toml - rules/windows/persistence_msds_alloweddelegateto_krbtgt.toml - rules/windows/persistence_remote_password_reset.toml - rules/windows/persistence_scheduled_task_creation_winlog.toml - rules/windows/persistence_scheduled_task_updated.toml - rules/windows/persistence_sdprop_exclusion_dsheuristics.toml - rules/windows/persistence_service_windows_service_winlog.toml - rules/windows/persistence_temp_scheduled_task.toml - rules/windows/persistence_user_account_added_to_privileged_group_ad.toml - rules/windows/privilege_escalation_create_process_as_different_user.toml - rules/windows/privilege_escalation_credroaming_ldap.toml - rules/windows/privilege_escalation_group_policy_iniscript.toml - rules/windows/privilege_escalation_group_policy_privileged_groups.toml - rules/windows/privilege_escalation_group_policy_scheduled_task.toml - rules/windows/privilege_escalation_krbrelayup_service_creation.toml - rules/windows/privilege_escalation_samaccountname_spoofing_attack.toml - rules/windows/privilege_escalation_suspicious_dnshostname_update.toml - rules/windows/privilege_escalation_windows_service_via_unusual_client.toml (selectively cherry picked from commit 1784429)
Removed changes from: - rules/integrations/azure/initial_access_consent_grant_attack_via_azure_registered_application.toml - rules/linux/credential_access_bruteforce_password_guessing.toml - rules/linux/credential_access_potential_linux_ssh_bruteforce.toml - rules/linux/credential_access_potential_linux_ssh_bruteforce_root.toml - rules/windows/collection_email_outlook_mailbox_via_com.toml - rules/windows/credential_access_bruteforce_admin_account.toml - rules/windows/credential_access_bruteforce_multiple_logon_failure_followed_by_success.toml - rules/windows/credential_access_bruteforce_multiple_logon_failure_same_srcip.toml - rules/windows/credential_access_dcsync_replication_rights.toml - rules/windows/credential_access_disable_kerberos_preauth.toml - rules/windows/credential_access_ldap_attributes.toml - rules/windows/credential_access_lsass_memdump_handle_access.toml - rules/windows/credential_access_remote_sam_secretsdump.toml - rules/windows/credential_access_saved_creds_vault_winlog.toml - rules/windows/credential_access_seenabledelegationprivilege_assigned_to_user.toml - rules/windows/credential_access_shadow_credentials.toml - rules/windows/credential_access_spn_attribute_modified.toml - rules/windows/credential_access_suspicious_winreg_access_via_sebackup_priv.toml - rules/windows/defense_evasion_clearing_windows_security_logs.toml - rules/windows/discovery_privileged_localgroup_membership.toml - rules/windows/discovery_whoami_command_activity.toml - rules/windows/lateral_movement_remote_service_installed_winlog.toml - rules/windows/lateral_movement_remote_task_creation_winlog.toml - rules/windows/lateral_movement_service_control_spawned_script_int.toml - rules/windows/persistence_ad_adminsdholder.toml - rules/windows/persistence_dontexpirepasswd_account.toml - rules/windows/persistence_msds_alloweddelegateto_krbtgt.toml - rules/windows/persistence_remote_password_reset.toml - rules/windows/persistence_scheduled_task_creation_winlog.toml - rules/windows/persistence_scheduled_task_updated.toml - rules/windows/persistence_sdprop_exclusion_dsheuristics.toml - rules/windows/persistence_service_windows_service_winlog.toml - rules/windows/persistence_temp_scheduled_task.toml - rules/windows/persistence_user_account_added_to_privileged_group_ad.toml - rules/windows/privilege_escalation_create_process_as_different_user.toml - rules/windows/privilege_escalation_credroaming_ldap.toml - rules/windows/privilege_escalation_group_policy_iniscript.toml - rules/windows/privilege_escalation_group_policy_privileged_groups.toml - rules/windows/privilege_escalation_group_policy_scheduled_task.toml - rules/windows/privilege_escalation_krbrelayup_service_creation.toml - rules/windows/privilege_escalation_samaccountname_spoofing_attack.toml - rules/windows/privilege_escalation_suspicious_dnshostname_update.toml - rules/windows/privilege_escalation_windows_service_via_unusual_client.toml (selectively cherry picked from commit 1784429)
Removed changes from: - rules/windows/collection_email_outlook_mailbox_via_com.toml (selectively cherry picked from commit 1784429)
(cherry picked from commit 1784429)
(cherry picked from commit 1784429)
(cherry picked from commit 1784429)
Issues
#1994
Summary
find_latest_compatible_version
that scans all integration versions to determine the compatibility window to validate the rule with the integrations.show-latest-compatible
that prints the latest compatible integration version given a package and stack version.build_integration_manifests
method that was introduced when theintegration
field schema changed to support lists.IntegrationManifestSchema
schema to include thedownload
field that is used to pull the schemas.test_integration_tag
unit test to catch integrations that are missing based on rule index.Limit backports to 8.3+ #2450[FR] Recommend Latest Compatible Integration Versions #2495Manual reconciliation of the lock fileRelated Integrations
logic to install most recent compatible version kibana#149606Testing
view-rule
on several different integrations and try with multiplemin_stack
versions.python -m detection_rules view-rule rules/integrations/google_workspace/collection_google_drive_ownership_transferred_via_google_workspace.toml
python -m detection_rules view-rule rules/integrations/aws/collection_cloudtrail_logging_created.toml
python -m detection_rules view-rule rules/integrations/azure/initial_access_consent_grant_attack_via_azure_registered_application.toml
python -m detection_rules view-rule rules/apm/apm_403_response_to_a_post.toml
show-latest-compatible
to verify command shows latest compatible version.python -m detection_rules dev integrations show-latest-compatible -p apm -s 8.2.0
build-schemas
andbuild-manifest
commands to test rebuilding the schemas and manifestpython -m detection_rules dev integrations build-schemas -o
python -m detection_rules dev integrations build-manifests -o
make test
to ensure all unit tests pass.