Skip to content

Commit 8def4bd

Browse files
authored
Merge pull request #268614 from dcurwin/wi-214914-custom-recommendations-march11-2024
Custom recommendations
2 parents f21bce0 + eb3f231 commit 8def4bd

8 files changed

+192
-260
lines changed

.openpublishing.redirection.defender-for-cloud.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,11 @@
940940
"redirect_url": "/azure/defender-for-cloud/agentless-vulnerability-assessment-aws",
941941
"redirect_document_id": true
942942
},
943+
{
944+
"source_path_from_root": "/articles/defender-for-cloud/custom-security-policies.md",
945+
"redirect_url": "/azure/defender-for-cloud/create-custom-recommendations",
946+
"redirect_document_id": false
947+
},
943948
{
944949
"source_path_from_root": "/articles/defender-for-cloud/how-to-migrate-to-built-in.md",
945950
"redirect_url": "/azure/defender-for-cloud/how-to-transition-to-built-in",

articles/defender-for-cloud/TOC.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,7 @@
324324
items:
325325
- name: Choose standards for your compliance dashboard
326326
href: update-regulatory-compliance-packages.md
327-
- name: Create custom standards/recommendations (Azure)
328-
displayName: initiatives, custom, policies
329-
href: custom-security-policies.md
330-
- name: Create custom standards/recommendations (AWS/GCP)
327+
- name: Create custom standards/recommendations
331328
href: create-custom-recommendations.md
332329
- name: Manage MCSB recommendations
333330
href: manage-mcsb.md

articles/defender-for-cloud/create-custom-recommendations.md

Lines changed: 168 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
---
2-
title: Create custom security standards and recommendations for AWS/GCP resources in Microsoft Defender for Cloud
3-
description: Learn how to create custom security standards and recommendations for AWS/GCP resources in Microsoft Defender for Cloud
2+
title: Create custom security standards and recommendations
3+
description: Learn how to create custom security standards and recommendations for all clouds in Microsoft Defender for Cloud.
44
ms.topic: how-to
55
ms.date: 03/26/2023
66
---
77

8-
# Create custom security standards and recommendations (AWS/GCP)
8+
# Create custom security standards and recommendations in Microsoft Defender for Cloud
99

1010
[Security recommendations](security-policy-concept.md) in Microsoft Defender for Cloud help you to improve and harden your security posture. Recommendations are based on assessments against [security standards](security-policy-concept.md) defined for Azure subscriptions, AWS accounts, and GCP projects that have Defender for Cloud enabled.
1111

1212
This article describes how to:
1313

14-
- Create custom recommendations for AWS accounts and GCP projects with a KQL query.
14+
- Create custom recommendations for all clouds (Azure, AWS, and GCP) with a KQL query.
1515
- Assign custom recommendations to a custom security standard.
1616

1717
## Before you start
1818

19-
- Defender for Cloud currently supports creating custom recommendations for AWS accounts and GCP projects only.
2019
- You need Owner permissions on the subscription to create a new security standard.
21-
- You need Security Admin permissions to create custom recommendations
22-
- To create custom recommendations, you must have the [Defender CSPM plan](concept-cloud-security-posture-management.md) enabled.
20+
- You need Security Admin permissions to create custom recommendations.
21+
- To create custom recommendations based on KQL, you must have the [Defender CSPM plan](concept-cloud-security-posture-management.md) enabled. All customers can create custom recommendations based on Azure Policy.
2322
- [Review support in Azure clouds](support-matrix-cloud-environment.md) for custom recommendations.
2423

2524
We recommend watching this episode of [Defender for Cloud in the field](https://techcommunity.microsoft.com/t5/microsoft-defender-for-cloud/creating-custom-recommendations-amp-standards-for-aws-gcp/ba-p/3810248) to learn more about the feature, and dig into creating KQL queries.
@@ -30,7 +29,7 @@ Watch this episode of [Defender for Cloud in the field](https://techcommunity.mi
3029

3130
Create custom recommendations, including steps for remediation, severity, and the standards to which the recommendation should be assigned. You add recommendation logic with KQL. You can use a simple query editor with built-in query templated that you can tweak as needed, or you can write your KQL query from scratch.
3231

33-
1. In the Defender for Cloud portal > **Environment settings**, select the relevant AWS account or GCP project.
32+
1. In the Defender for Cloud portal > **Environment settings**, select the relevant scope.
3433

3534
1. Select **Security policies** > **+ Create** > **Custom recommendation**.
3635

@@ -59,7 +58,7 @@ We recommend using the query editor to create a recommendation query.
5958

6059
:::image type="content" source="./media/create-custom-recommendations/query-editor.png" alt-text="Screenshot showing how to use the query editor." lightbox="./media/create-custom-recommendations/query-editor.png":::
6160

62-
1. Select **Run query** to test the query you've created.
61+
1. Select **Run query** to test the query you created.
6362
1. When the query is ready, cut and paste it from the editor into the **Recommendations query** pane.
6463

6564
## Create a custom standard
@@ -70,17 +69,173 @@ Custom recommendations can be assigned to one or more custom standards.
7069

7170
1. Navigate to **Microsoft Defender for Cloud** > **Environment settings**.
7271

73-
1. Select the relevant AWS account.
72+
1. Select the relevant scope.
7473

7574
1. Select **Security policies** > **+ Create** > **Standard**.
7675

77-
1. In **Create new standard**, enter a name, description and select recommendations from the drop-down menu.
76+
1. In **Recommendations**, select the recommendations that you want to add to the custom standard. For Azure subscriptions, you can see the source as well.
7877

79-
:::image type="content" source="media/create-custom-recommendations/create-standard-aws.png" alt-text="Screenshot of the window for creating a new standard.":::
78+
:::image type="content" source="media/custom-security-policies/select-recommendations.png" alt-text="Screenshot that shows the list of all of the recommendations that are available to select for the custom standard." lightbox="media/custom-security-policies/select-recommendations.png":::
8079

8180
1. Select **Create**.
8281

83-
## Next steps
82+
## Create and enhance custom recommendations with Azure Policy (legacy)
83+
84+
For Azure subscriptions, you can create custom recommendations and standards, and enhance them, using Azure Policy. This is a legacy feature, and we recommend using the new custom recommendations feature.
85+
86+
### Create a custom recommendation/standard (legacy)
87+
88+
You can create custom recommendations and standards in Defender for cloud by creating policy definitions and initiatives in Azure Policy, and onboarding them in Defender for Cloud.
89+
90+
Here's how you do that:
91+
92+
1. Create one or more policy definitions in the [Azure Policy portal](../governance/policy/tutorials/create-custom-policy-definition.md), or [programatically](../governance/policy/how-to/programmatically-create.md).
93+
1. [Create a policy initiative](../governance/policy/concepts/initiative-definition-structure.md) that contains the custom policy definitions.
94+
95+
### Onboard the initiative as a custom standard (legacy)
96+
97+
[Policy assignments](../governance/policy/concepts/assignment-structure.md) are used by Azure Policy to assign Azure resources to a policy or initiative.
98+
99+
To onboard an initiative to a custom security standard in Defender for you, you need to include `"ASC":"true"` in the request body as shown here. The `ASC` field onboards the initiative to Microsoft Defender for Cloud.
100+
101+
Here's an example of how to do that.
102+
103+
#### Example to onboard a custom initiative
104+
105+
```json
106+
PUT
107+
PUT https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policySetDefinitions/{policySetDefinitionName}?api-version=2021-06-01
108+
109+
Request Body (JSON)
110+
111+
{
112+
"properties": {
113+
"displayName": "Cost Management",
114+
"description": "Policies to enforce low cost storage SKUs",
115+
"metadata": {
116+
"category": "Cost Management"
117+
"ASC":"true"
118+
},
119+
"parameters": {
120+
"namePrefix": {
121+
"type": "String",
122+
"defaultValue": "myPrefix",
123+
"metadata": {
124+
"displayName": "Prefix to enforce on resource names"
125+
}
126+
}
127+
},
128+
"policyDefinitions": [
129+
{
130+
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1",
131+
"policyDefinitionReferenceId": "Limit_Skus",
132+
"parameters": {
133+
"listOfAllowedSKUs": {
134+
"value": [
135+
"Standard_GRS",
136+
"Standard_LRS"
137+
]
138+
}
139+
}
140+
},
141+
{
142+
"policyDefinitionId": "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming",
143+
"policyDefinitionReferenceId": "Resource_Naming",
144+
"parameters": {
145+
"prefix": {
146+
"value": "[parameters('namePrefix')]"
147+
},
148+
"suffix": {
149+
"value": "-LC"
150+
}
151+
}
152+
}
153+
]
154+
}
155+
}
156+
```
157+
158+
#### Example to remove an assignment
159+
160+
This example shows you how to remove an assignment:
161+
162+
```json
163+
DELETE
164+
https://management.azure.com/{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}?api-version=2018-05-01
165+
```
166+
167+
::: zone-end
168+
169+
### Enhance custom recommendations (legacy)
170+
171+
The built-in recommendations supplied with Microsoft Defender for Cloud include details such as severity levels and remediation instructions. If you want to add this type of information to custom recommendations for Azure, use the REST API.
172+
173+
The two types of information you can add are:
174+
175+
- **RemediationDescription** – String
176+
- **Severity** – Enum [Low, Medium, High]
177+
178+
The metadata should be added to the policy definition for a policy that is part of the custom initiative. It should be in the 'securityCenter' property, as shown:
179+
180+
```json
181+
"metadata": {
182+
"securityCenter": {
183+
"RemediationDescription": "Custom description goes here",
184+
"Severity": "High"
185+
},
186+
```
187+
188+
Here's another example of a custom policy including the metadata/securityCenter property:
189+
190+
```json
191+
{
192+
"properties": {
193+
"displayName": "Security - ERvNet - AuditRGLock",
194+
"policyType": "Custom",
195+
"mode": "All",
196+
"description": "Audit required resource groups lock",
197+
"metadata": {
198+
"securityCenter": {
199+
"RemediationDescription": "Resource Group locks can be set via Azure Portal -> Resource Group -> Locks",
200+
"Severity": "High"
201+
}
202+
},
203+
"parameters": {
204+
"expressRouteLockLevel": {
205+
"type": "String",
206+
"metadata": {
207+
"displayName": "Lock level",
208+
"description": "Required lock level for ExpressRoute resource groups."
209+
},
210+
"allowedValues": [
211+
"CanNotDelete",
212+
"ReadOnly"
213+
]
214+
}
215+
},
216+
"policyRule": {
217+
"if": {
218+
"field": "type",
219+
"equals": "Microsoft.Resources/subscriptions/resourceGroups"
220+
},
221+
"then": {
222+
"effect": "auditIfNotExists",
223+
"details": {
224+
"type": "Microsoft.Authorization/locks",
225+
"existenceCondition": {
226+
"field": "Microsoft.Authorization/locks/level",
227+
"equals": "[parameters('expressRouteLockLevel')]"
228+
}
229+
}
230+
}
231+
}
232+
}
233+
}
234+
```
235+
236+
For another example for using the securityCenter property, see [this section of the REST API documentation](/rest/api/defenderforcloud/assessments-metadata/create-in-subscription#examples).
237+
238+
## Related content
84239

85240
You can use the following links to learn more about Kusto queries:
86241

0 commit comments

Comments
 (0)