feat(query): implements "Beta - Activity Log Alert For Service Health Not Configured"#7821
Merged
cx-andre-pereira merged 18 commits intoDec 9, 2025
Conversation
Contributor
…_alert_for_service_health
…rvice_health' of https://github.com/Checkmarx/kics into AST-116647_40_6.1.2.11_ensure_activity_log_alert_for_service_health
…_alert_for_service_health
…_alert_for_service_health
…_alert_for_service_health
…_alert_for_service_health
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








Reason for Proposed Changes
Currently there is no query to ensure that there is a "azurerm_monitor_activity_log_alert" resource configured to capture "Service Health" events.
Quoting CIS_Microsoft_Azure_Foundations_Benchmark_v5.0.0 page 267: "
Monitoring for Service Health events provides insight into service issues, planned maintenance, security advisories, and other changes that may affect the Azure services and regions in use."Through the CIS benchmark we can also determine that detecting the target configuration boils down to checking 4 conditions :
categoryfield should be set to "ServiceHealth"It is expected that all "subscriptions" are associated in this manner, the data block "azurerm_subscription" allows defining these subscriptions, and so the query should iteratively check all associated alert logs for each subscription.
Proposed Changes
Implemented the missing query.
The query will start by collecting all log alert type resources as well as all subscriptions defined through data azurerm_subscription blocks.
Then, for each subscription, the log alerts are scrubbed to search for at least one that fulfills requisites 2, 3 and 4 and references the specific subscription the auxiliary function "at_least_one_valid_log_alert" got called for.
The query will trigger differently depending on the log_alerts found, with the following priority :
These priorities are demonstrated through the positive4 and positive5 tests and their results.
I submit this contribution under the Apache-2.0 license.