-
Notifications
You must be signed in to change notification settings - Fork 11
/
GetAlertsSubscription_example.go
335 lines (332 loc) · 15.9 KB
/
GetAlertsSubscription_example.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
package armsecurity_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/security/armsecurity"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/e716082ac474f182e2220e4f38f1d6191e7636cf/specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertsSubscription_example.json
func ExampleAlertsClient_NewListPager() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armsecurity.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewAlertsClient().NewListPager(nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.AlertList = armsecurity.AlertList{
// Value: []*armsecurity.Alert{
// {
// Name: to.Ptr("2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a"),
// Type: to.Ptr("Microsoft.Security/Locations/alerts"),
// ID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Security/locations/westeurope/alerts/2518770965529163669_F144EE95-A3E5-42DA-A279-967D115809AA"),
// Properties: &armsecurity.AlertProperties{
// Description: to.Ptr("This is a test alert generated by Azure Security Center. No further action is needed."),
// AlertDisplayName: to.Ptr("Azure Security Center test alert (not a threat)"),
// AlertType: to.Ptr("VM_EICAR"),
// AlertURI: to.Ptr("https://portal.azure.com/#blade/Microsoft_Azure_Security/AlertBlade/alertId/2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a/subscriptionId/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroup/myRg1/referencedFrom/alertDeepLink/location/westeurope"),
// CompromisedEntity: to.Ptr("vm1"),
// CorrelationKey: to.Ptr("kso0LFWxzCll5tqrk5hmrBJ+MY1BX806W6q6+0s9Lk="),
// EndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-22T00:00:00.0000000Z"); return t}()),
// Entities: []*armsecurity.AlertEntity{
// {
// AdditionalProperties: map[string]any{
// "address": "192.0.2.1",
// "location": map[string]any{
// "asn": float64(6584),
// "city": "sonning",
// "countryCode": "gb",
// "latitude": float64(51.468),
// "longitude": float64(-0.909),
// "state": "wokingham",
// },
// },
// Type: to.Ptr("ip"),
// }},
// ExtendedLinks: []map[string]*string{
// map[string]*string{
// "Category": to.Ptr("threat_reports"),
// "Href": to.Ptr("https://contoso.com/reports/DisplayReport"),
// "Label": to.Ptr("Report: RDP Brute Forcing"),
// "Type": to.Ptr("webLink"),
// }},
// ExtendedProperties: map[string]*string{
// "Property1": to.Ptr("Property1 information"),
// },
// Intent: to.Ptr(armsecurity.IntentExecution),
// IsIncident: to.Ptr(true),
// ProcessingEndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-23T13:47:58.9205584Z"); return t}()),
// ProductComponentName: to.Ptr("testName"),
// ProductName: to.Ptr("Azure Security Center"),
// RemediationSteps: []*string{
// to.Ptr("No further action is needed.")},
// ResourceIdentifiers: []armsecurity.ResourceIdentifierClassification{
// &armsecurity.AzureResourceIdentifier{
// Type: to.Ptr(armsecurity.ResourceIdentifierTypeAzureResource),
// AzureResourceID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"),
// },
// &armsecurity.LogAnalyticsIdentifier{
// Type: to.Ptr(armsecurity.ResourceIdentifierTypeLogAnalytics),
// AgentID: to.Ptr("75724a01-f021-4aa8-9ec2-329792373e6e"),
// WorkspaceID: to.Ptr("f419f624-acad-4d89-b86d-f62fa387f019"),
// WorkspaceResourceGroup: to.Ptr("myRg1"),
// WorkspaceSubscriptionID: to.Ptr("20ff7fc3-e762-44dd-bd96-b71116dcdc23"),
// }},
// Severity: to.Ptr(armsecurity.AlertSeverityHigh),
// StartTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-22T00:00:00.0000000Z"); return t}()),
// Status: to.Ptr(armsecurity.AlertStatusActive),
// SubTechniques: []*string{
// to.Ptr("T1059.001"),
// to.Ptr("T1059.006"),
// to.Ptr("T1053.002")},
// SupportingEvidence: &armsecurity.AlertPropertiesSupportingEvidence{
// AdditionalProperties: map[string]any{
// "columns": []any{
// "Date",
// "Activity",
// "User",
// "TestedText",
// "TestedValue",
// },
// "rows": []any{
// []any{
// "2022-01-17T07:03:52.034Z",
// "Log on",
// "testUser",
// "false",
// false,
// },
// []any{
// "2022-01-17T07:03:52.034Z",
// "Log on",
// "testUser2",
// "false",
// false,
// },
// []any{
// "2022-01-17T07:03:52.034Z",
// "Log on",
// "testUser3",
// "true",
// true,
// },
// },
// "title": "Investigate activity test",
// },
// Type: to.Ptr("tabularEvidences"),
// },
// SystemAlertID: to.Ptr("2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a"),
// Techniques: []*string{
// to.Ptr("T1059"),
// to.Ptr("T1053"),
// to.Ptr("T1072")},
// TimeGeneratedUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-02-23T13:47:58.0000000Z"); return t}()),
// VendorName: to.Ptr("Microsoft"),
// Version: to.Ptr("2022-01-01"),
// },
// },
// {
// Name: to.Ptr("2518765996949954086_2325cf9e-42a2-4f72-ae7f-9b863cba2d22"),
// Type: to.Ptr("Microsoft.Security/Locations/alerts"),
// ID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg2/providers/Microsoft.Security/locations/westeurope/alerts/2518765996949954086_2325cf9e-42a2-4f72-ae7f-9b863cba2d22"),
// Properties: &armsecurity.AlertProperties{
// Description: to.Ptr("The process ‘c:\\users\\contosoUser\\scrsave.scr’ was observed executing from an uncommon location. Files with the .scr extensions are screen saver files and are normally reside and execute from the Windows system directory."),
// AlertDisplayName: to.Ptr("Suspicious Screensaver process executed"),
// AlertType: to.Ptr("VM_SuspiciousScreenSaver"),
// AlertURI: to.Ptr("https://portal.azure.com/#blade/Microsoft_Azure_Security/AlertBlade/alertId/2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a/subscriptionId/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroup/myRg1/referencedFrom/alertDeepLink/location/westeurope"),
// CompromisedEntity: to.Ptr("vm2"),
// CorrelationKey: to.Ptr("4hno6LF0xzCl5tqrk4nrBW+MY1BX816W6q6+0srk4"),
// EndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-07T13:51:45.0045913Z"); return t}()),
// Entities: []*armsecurity.AlertEntity{
// {
// AdditionalProperties: map[string]any{
// "OsVersion": nil,
// "azureID": "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourcegroups/myRg2/providers/microsoft.compute/virtualmachines/vm2",
// "dnsDomain": "",
// "hostName": "vm2",
// "netBiosName": "vm2",
// "ntDomain": "",
// "omsAgentID": "45b44640-3b94-4892-a28c-4a5cae27065a",
// "operatingSystem": "Unknown",
// },
// Type: to.Ptr("host"),
// },
// {
// AdditionalProperties: map[string]any{
// "name": "contosoUser",
// "logonId": "0x61450d87",
// "ntDomain": "vm2",
// "sid": "S-1-5-21-2144575486-8928446540-5163864319-500",
// },
// Type: to.Ptr("account"),
// },
// {
// AdditionalProperties: map[string]any{
// "name": "cmd.exe",
// "directory": "c:\\windows\\system32",
// },
// Type: to.Ptr("file"),
// },
// {
// AdditionalProperties: map[string]any{
// "processId": "0x3c44",
// },
// Type: to.Ptr("process"),
// },
// {
// AdditionalProperties: map[string]any{
// "name": "scrsave.scr",
// "directory": "c:\\users\\contosoUser",
// },
// Type: to.Ptr("file"),
// },
// {
// AdditionalProperties: map[string]any{
// "commandLine": "c:\\users\\contosoUser\\scrsave.scr",
// "creationTimeUtc": "2018-05-07T13:51:45.0045913Z",
// "processId": "0x4aec",
// },
// Type: to.Ptr("process"),
// }},
// ExtendedLinks: []map[string]*string{
// map[string]*string{
// "Category": to.Ptr("threat_reports"),
// "Href": to.Ptr("https://contoso.com/reports/DisplayReport"),
// "Label": to.Ptr("Report: RDP Brute Forcing"),
// "Type": to.Ptr("webLink"),
// }},
// ExtendedProperties: map[string]*string{
// "account logon id": to.Ptr("0x61450d87"),
// "command line": to.Ptr("c:\\users\\contosoUser\\scrsave.scr"),
// "domain name": to.Ptr("vm2"),
// "parent process": to.Ptr("cmd.exe"),
// "parent process id": to.Ptr("0x3c44"),
// "process id": to.Ptr("0x4aec"),
// "process name": to.Ptr("c:\\users\\contosoUser\\scrsave.scr"),
// "resourceType": to.Ptr("Virtual Machine"),
// "user SID": to.Ptr("S-1-5-21-2144575486-8928446540-5163864319-500"),
// "user name": to.Ptr("vm2\\contosoUser"),
// },
// Intent: to.Ptr(armsecurity.IntentExecution),
// IsIncident: to.Ptr(true),
// ProcessingEndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-07T13:51:48.9810457Z"); return t}()),
// ProductComponentName: to.Ptr("testName2"),
// ProductName: to.Ptr("Azure Security Center"),
// RemediationSteps: []*string{
// to.Ptr("1. Run Process Explorer and try to identify unknown running processes (see https://technet.microsoft.com/en-us/sysinternals/bb896653.aspx)"),
// to.Ptr("2. Make sure the machine is completely updated and has an updated anti-malware application installed"),
// to.Ptr("3. Run a full anti-malware scan and verify that the threat was removed"),
// to.Ptr("4. Install and run Microsoft’s Malicious Software Removal Tool (see https://www.microsoft.com/en-us/download/malicious-software-removal-tool-details.aspx)"),
// to.Ptr("5. Run Microsoft’s Autoruns utility and try to identify unknown applications that are configured to run at login (see https://technet.microsoft.com/en-us/sysinternals/bb963902.aspx)"),
// to.Ptr("6. Escalate the alert to the information security team")},
// ResourceIdentifiers: []armsecurity.ResourceIdentifierClassification{
// &armsecurity.AzureResourceIdentifier{
// Type: to.Ptr(armsecurity.ResourceIdentifierTypeAzureResource),
// AzureResourceID: to.Ptr("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"),
// },
// &armsecurity.LogAnalyticsIdentifier{
// Type: to.Ptr(armsecurity.ResourceIdentifierTypeLogAnalytics),
// AgentID: to.Ptr("75724a01-f021-4aa8-9ec2-329792373e6e"),
// WorkspaceID: to.Ptr("f419f624-acad-4d89-b86d-f62fa387f019"),
// WorkspaceResourceGroup: to.Ptr("myRg1"),
// WorkspaceSubscriptionID: to.Ptr("20ff7fc3-e762-44dd-bd96-b71116dcdc23"),
// }},
// Severity: to.Ptr(armsecurity.AlertSeverityMedium),
// StartTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-07T13:51:45.0045913Z"); return t}()),
// Status: to.Ptr(armsecurity.AlertStatusActive),
// SubTechniques: []*string{
// to.Ptr("T1059.001"),
// to.Ptr("T1059.006"),
// to.Ptr("T1053.002")},
// SupportingEvidence: &armsecurity.AlertPropertiesSupportingEvidence{
// AdditionalProperties: map[string]any{
// "supportingEvidenceList": []any{
// map[string]any{
// "type": "nestedList",
// "evidenceElements":[]any{
// map[string]any{
// "type": "evidenceElement",
// "innerElements": nil,
// "text":map[string]any{
// "arguments":map[string]any{
// "domainName":map[string]any{
// "type": "string",
// "value": "domainName",
// },
// "sensitiveEnumerationTypes":map[string]any{
// "type": "string[]",
// "value":[]any{
// "UseDesKey",
// },
// },
// },
// "fallback": "Actor enumerated UseDesKey on domain1.test.local",
// "localizationKey": "AATP_ALERTS_LDAP_SENSITIVE_ATTRIBUTE_RECONNAISSANCE_SECURITY_ALERT_EVIDENCE_ENUMERATION_DETAIL_A7C00BD7",
// },
// },
// },
// },
// map[string]any{
// "type": "tabularEvidences",
// "columns":[]any{
// "Date",
// "Activity",
// "User",
// "TestedText",
// "TestedValue",
// },
// "rows":[]any{
// []any{
// "2022-01-17T07:03:52.034Z",
// "Log on",
// "testUser",
// "false",
// false,
// },
// []any{
// "2022-01-17T07:03:52.034Z",
// "Log on",
// "testUser2",
// "false",
// false,
// },
// []any{
// "2022-01-17T07:03:52.034Z",
// "Log on",
// "testUser3",
// "true",
// true,
// },
// },
// "title": "Investigate activity test",
// },
// },
// },
// Type: to.Ptr("supportingEvidenceList"),
// },
// SystemAlertID: to.Ptr("2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a"),
// Techniques: []*string{
// to.Ptr("T1059"),
// to.Ptr("T1053"),
// to.Ptr("T1072")},
// TimeGeneratedUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-05-07T13:51:48.3810457Z"); return t}()),
// VendorName: to.Ptr("Microsoft"),
// Version: to.Ptr("2022-01-01"),
// },
// }},
// }
}
}