Skip to content

Conversation

@cx-andre-pereira
Copy link
Contributor

@cx-andre-pereira cx-andre-pereira commented Nov 3, 2025

Reason for Proposed Changes

  • Currently there is no query to ensure that there is a "azurerm_monitor_activity_log_alert" resource configured to capture delete security solution events.

  • Quoting CIS_Microsoft_Azure_Foundations_Benchmark_v5.0.0 page 247: "Monitoring for Delete Security Solution events gives insight into changes to the active security solutions and may reduce the time it takes to detect suspicious activity."

  • Through the CIS benchmark we can also determine that detecting the target configuration boils down to checking 2 fields in the criteria block:

    • category should be set to "Administrative"
    • operation_name should be set to "Microsoft.Storage/storageAccounts/write"
  • Additionally we must ensure the log alert resource does not set any "filters" that act "on Level, Status or
    Caller" these can be set on the "azurerm_monitor_activity_log_alert" resource through the following fields : "caller", "level", "levels", "status", "statuses", "sub_status" or "sub_statuses". Since these could suppress or cause the log alert to miss relevant events they must not be set.

  • Finally it must be ensured that the "action_group_id" field is set (inside an "action" block).

Proposed Changes

  • Implemented the missing query.

  • The query will trigger if:

    • Both mandatory fields are correct but there is at least 1 "filter" field defined.
    • Both mandatory fields are correct and no filter is defined but the "action_group_id" field is missing.
  • Additionally the query should flag the "project" itself when there is not a single log alert with both mandatory fields correct. Currently this is not possible but the query should be reworked once it is since there are plans to implement this feature eventually.

  • In a given document if there are multiple "azurerm_monitor_activity_log_alert" and none of them fully align with the required requisites the query will prioritize flagging all the ones only missing the "action_group_id" first, then all the ones that flag due to a filter being set and, if none of the resources set the two mandatory fields to the expected values, it will flag all log alert resources. This priority is shown in the positive4 test.

I submit this contribution under the Apache-2.0 license.

@github-actions github-actions bot added feature New feature query New query feature labels Nov 3, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

kics-logo

KICS version: v2.1.13

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 1
Files parsed placeholder 1
Files failed to scan placeholder 0
Total executed queries placeholder 47
Queries failed to execute placeholder 0
Execution time placeholder 0

@github-actions github-actions bot added terraform Terraform query azure PR related with Azure Cloud labels Nov 3, 2025
@cx-andre-pereira cx-andre-pereira marked this pull request as ready for review November 3, 2025 15:40
@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner November 3, 2025 15:40
@gitguardian
Copy link

gitguardian bot commented Nov 4, 2025

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
21271469 Triggered Generic Password a9f7d86 assets/queries/terraform/azure/unrestricted_sql_server_access/test/negative5.tf View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@cx-andre-pereira cx-andre-pereira changed the title feat(query): implements "Beta - Activity Log Alert For Delete Security Solution" feat(query): implements "Beta - Activity Log Alert For Delete Security Solution Not Configured" Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure PR related with Azure Cloud feature New feature query New query feature terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant