-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathaudit.go
More file actions
48 lines (38 loc) · 1.01 KB
/
audit.go
File metadata and controls
48 lines (38 loc) · 1.01 KB
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
// Copyright (c) Mondoo, Inc.
// SPDX-License-Identifier: BUSL-1.1
package resources
import (
"context"
"github.com/oracle/oci-go-sdk/v65/audit"
"github.com/oracle/oci-go-sdk/v65/common"
"go.mondoo.com/mql/v13/providers/oci/connection"
)
func (o *mqlOciAudit) id() (string, error) {
return "oci.audit", nil
}
func (o *mqlOciAudit) retentionPeriodDays() (int64, error) {
conn := o.MqlRuntime.Connection.(*connection.OciConnection)
// Audit configuration is tenancy-level; use home region
tenancy, err := conn.Tenant(context.Background())
if err != nil {
return 0, err
}
region := ""
if tenancy.HomeRegionKey != nil {
region = *tenancy.HomeRegionKey
}
client, err := conn.AuditClient(region)
if err != nil {
return 0, err
}
resp, err := client.GetConfiguration(context.Background(), audit.GetConfigurationRequest{
CompartmentId: common.String(conn.TenantID()),
})
if err != nil {
return 0, err
}
if resp.RetentionPeriodDays == nil {
return 0, nil
}
return int64(*resp.RetentionPeriodDays), nil
}