Skip to main content

azure_sentinel_alert_rule Resource

[edit on GitHub]

Use the azure_sentinel_alert_rule InSpec audit resource to test the properties of an Azure Sentinel alert rule for a resource group or the entire subscription.

For additional information, see the Azure Sentinel Alert Rules API documentation.

Azure REST API Version, Endpoint, and HTTP Client Parameters

This resource interacts with API versions supported by the resource provider. The api_version can be defined as a resource parameter. If not provided, this resource uses the latest version. For more information, refer to the azure_generic_resource document.

Unless defined, this resource uses the azure_cloud global endpoint and default values for the HTTP client. For more information, refer to the resource pack README.

Installation

This resource is available in the Chef InSpec Azure resource pack.

See the Chef InSpec documentation on cloud platforms for information on configuring your Azure environment for InSpec and creating an InSpec profile that uses the InSpec Azure resource pack.

Syntax

An azure_sentinel_alert_rule resource block returns all Azure alert_rule, either within a resource group (if provided) or an entire Subscription.

describe azure_sentinel_alert_rule(resource_group: 'RESOURCE_GROUP', workspace_name: 'WORKSPACE_NAME', rule_id: 'RULE_ID') do
  it { should exit }
end

Parameters

resource_group (required)

Azure resource group where the targeted resource resides.

workspace_name (required)

Azure workspace Name for which alert rule is retrieved.

rule_id (required)

Alert rule ID.

Properties

id
The ID of the alert rule.
name
The name of the alert rule.
type
The alert rule type.
kind
The kind of the alert rule.
etag
The etag of the alert rule.
properties
The properties of the alert rule.

Examples

Tests if the rule ID exists

describe azure_sentinel_alert_rule(resource_group: 'RESOURCE_GROUP', workspace_name: 'WORKSPACE_NAME', rule_id: 'RULE_ID') do
  its('id') { should eq 'ALERT_RULE_ID' }
end

Tests if the rule name exists

describe azure_sentinel_alert_rule(resource_group: 'RESOURCE_GROUP', workspace_name: 'WORKSPACE_NAME', rule_id: 'RULE_ID') do
  its('name') { should eq 'ALERT_RULE_NAME' }
end

Tests if the rule kind is ‘Scheduled’

describe azure_sentinel_alert_rule(resource_group: 'RESOURCE_GROUP', workspace_name: 'WORKSPACE_NAME', rule_id: 'RULE_ID') do
  its('kind') { should eq 'Scheduled' }
end

Test if the rule type is ‘Microsoft.SecurityInsights/alertRules’

describe azure_sentinel_alert_rule(resource_group: 'RESOURCE_GROUP', workspace_name: 'WORKSPACE_NAME', rule_id: 'RULE_ID') do
  its('type') { should eq 'Microsoft.SecurityInsights/alertRules' }
end

Test if the display name is present or not

describe azure_sentinel_alert_rule(resource_group: 'RESOURCE_GROUP', workspace_name: 'WORKSPACE_NAME', rule_id: 'RULE_ID') do
  its('properties.displayName') { should eq "DISPLAY_NAME" }
end

Matchers

This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our Universal Matchers page.

exists

# If we expect a resource to always exist.

describe azure_sentinel_alert_rule(resource_group: 'RESOURCE_GROUP', workspace_name: 'WORKSPACE_NAME', rule_id: 'RULE_ID') do
  it { should exist }
end

not_exists

# If we expect a resource to never exist.

describe azure_sentinel_alert_rule(resource_group: 'RESOURCE_GROUP', workspace_name: 'WORKSPACE_NAME', rule_id: 'RULE_ID') do
  it { should_not exist }
end

Azure Permissions

Your Service Principal must be set up with at least a contributor role on the subscription you wish to test.

Was this page helpful?

×









Search Results