-
Notifications
You must be signed in to change notification settings - Fork 11
/
GetAlertsResourceGroup_example.go
176 lines (173 loc) · 7.67 KB
/
GetAlertsResourceGroup_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
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/GetAlertsResourceGroup_example.json
func ExampleAlertsClient_NewListByResourceGroupPager() {
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().NewListByResourceGroupPager("myRg1", 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{
// "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, "2020-02-23T13:47:58.0000000Z"); return t}()),
// VendorName: to.Ptr("Microsoft"),
// Version: to.Ptr("2022-01-01"),
// },
// }},
// }
}
}