From a704ff069fb4765db80a16fcf08e68cbe8f21d97 Mon Sep 17 00:00:00 2001 From: Manuel Weber Date: Tue, 14 Jan 2025 15:29:58 +0100 Subject: [PATCH] add security settings++ Signed-off-by: Manuel Weber --- providers/azure/resources/armsecurity.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/providers/azure/resources/armsecurity.go b/providers/azure/resources/armsecurity.go index a53c4f73f3..4599094316 100644 --- a/providers/azure/resources/armsecurity.go +++ b/providers/azure/resources/armsecurity.go @@ -81,7 +81,7 @@ func getPolicyAssignments(ctx context.Context, conn armSecurityConn) (PolicyAssi // the armsecurity.NewListPager is broken, see https://github.com/Azure/azure-sdk-for-go/issues/19740. // until it's fixed, we can fetch them manually -func getSecurityContacts(ctx context.Context, conn armSecurityConn) ([]security.Contact, error) { +func getSecurityContacts(ctx context.Context, conn armSecurityConn) ([], error) { token, err := conn.GetToken() if err != nil { return []security.Contact{}, err @@ -133,10 +133,10 @@ func getSecurityContacts(ctx context.Context, conn armSecurityConn) ([]security. return result, err } -func getMCAS(ctx context.Context, conn armSecurityConn) ([]security.Contact, error) { +func getSettingsClient(ctx context.Context, conn armSecurityConn) ([]security.SettingsClient, error) { token, err := conn.GetToken() if err != nil { - return []security.Contact{}, err + return []security.SettingsClient{}, err } urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings" urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(conn.subscriptionId)) @@ -144,7 +144,7 @@ func getMCAS(ctx context.Context, conn armSecurityConn) ([]security.Contact, err client := http.Client{} req, err := http.NewRequest("GET", urlPath, nil) if err != nil { - return []security.Contact{}, err + return []security.SettingsClient{}, err } q := req.URL.Query() q.Set("api-version", "2021-06-01") @@ -154,23 +154,23 @@ func getMCAS(ctx context.Context, conn armSecurityConn) ([]security.Contact, err resp, err := client.Do(req) if err != nil { - return []security.Contact{}, err + return []security.SettingsClient{}, err } defer resp.Body.Close() if resp.StatusCode != 200 { - return []security.Contact{}, errors.New("failed to fetch security contacts from " + urlPath + ": " + resp.Status) + return [][]security.SettingsClient{}, errors.New("failed to fetch security contacts from " + urlPath + ": " + resp.Status) } raw, err := io.ReadAll(resp.Body) if err != nil { - return []security.Contact{}, err + return [][]security.SettingsClient{}, err } - result := []security.Contact{} + result := [][]security.SettingsClient{} err = json.Unmarshal(raw, &result) if err != nil { // fallback, try to unmarshal to ContactList - contactList := &security.ContactList{} + contactList := &security.SettingsList{} err = json.Unmarshal(raw, contactList) if err != nil { return nil, err