Skip to content

Commit 3958399

Browse files
tas50claude
andcommitted
🐛 Fix OCI provider build: v12→v13 imports, nil safety, dead code
- Fix stale cnquery/v12 imports in 6 new resource files (cloudguard, events, filestorage, kms, logging, ons) and regenerated oci.lr.go - Add nil checks for ObjectEventsEnabled and ReplicationEnabled pointer dereferences in buckets.go to prevent runtime panics - Remove unused parseTime helper and its tests - Add region tracking to KMS vault resources for future extensibility - Add clarifying comment on CloudGuard's home-region-only strategy Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent af07b29 commit 3958399

File tree

12 files changed

+42
-64
lines changed

12 files changed

+42
-64
lines changed

providers/oci/resources/buckets.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,11 @@ func (o *mqlOciObjectStorage) getBuckets(conn *connection.OciConnection, namespa
143143
}
144144

145145
mqlInstance, err := CreateResource(o.MqlRuntime, "oci.objectStorage.bucket", map[string]*llx.RawData{
146-
"namespace": llx.StringDataPtr(bucket.Namespace),
147-
"name": llx.StringDataPtr(bucket.Name),
148-
"region": llx.ResourceData(regionResource, "oci.region"),
149-
"created": llx.TimeDataPtr(created),
146+
"namespace": llx.StringDataPtr(bucket.Namespace),
147+
"name": llx.StringDataPtr(bucket.Name),
148+
"compartmentID": llx.StringDataPtr(bucket.CompartmentId),
149+
"region": llx.ResourceData(regionResource, "oci.region"),
150+
"created": llx.TimeDataPtr(created),
150151
})
151152
if err != nil {
152153
return nil, err
@@ -278,6 +279,9 @@ func (o *mqlOciObjectStorageBucket) objectEventsEnabled() (bool, error) {
278279
if err != nil {
279280
return false, err
280281
}
282+
if bucketInfo.ObjectEventsEnabled == nil {
283+
return false, nil
284+
}
281285
return *bucketInfo.ObjectEventsEnabled, nil
282286
}
283287

@@ -286,6 +290,9 @@ func (o *mqlOciObjectStorageBucket) replicationEnabled() (bool, error) {
286290
if err != nil {
287291
return false, err
288292
}
293+
if bucketInfo.ReplicationEnabled == nil {
294+
return false, nil
295+
}
289296
return *bucketInfo.ReplicationEnabled, nil
290297
}
291298

providers/oci/resources/cloudguard.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import (
1010

1111
"github.com/oracle/oci-go-sdk/v65/cloudguard"
1212
"github.com/oracle/oci-go-sdk/v65/common"
13-
"go.mondoo.com/cnquery/v12/llx"
14-
"go.mondoo.com/cnquery/v12/providers/oci/connection"
13+
"go.mondoo.com/mql/v13/llx"
14+
"go.mondoo.com/mql/v13/providers/oci/connection"
1515
)
1616

17+
// CloudGuard is a tenancy-level service that only operates in the home region,
18+
// unlike other OCI services that require per-region iteration.
1719
type mqlOciCloudGuardInternal struct {
1820
config *cloudguard.Configuration
1921
homeRegion string

providers/oci/resources/compute.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,6 @@ func (o *mqlOciCompute) getComputeImage(conn *connection.OciConnection, regions
293293
definedTags[k] = v
294294
}
295295

296-
var sizeInMBs int64
297-
if image.SizeInMBs != nil {
298-
sizeInMBs = *image.SizeInMBs
299-
}
300-
301296
// Create compartment resource reference
302297
compartment, err := CreateResource(o.MqlRuntime, "oci.compartment", map[string]*llx.RawData{
303298
"id": llx.StringDataPtr(image.CompartmentId),
@@ -315,7 +310,7 @@ func (o *mqlOciCompute) getComputeImage(conn *connection.OciConnection, regions
315310
"compartment": llx.ResourceData(compartment, "oci.compartment"),
316311
"operatingSystem": llx.StringDataPtr(image.OperatingSystem),
317312
"operatingSystemVersion": llx.StringDataPtr(image.OperatingSystemVersion),
318-
"sizeInMBs": llx.IntData(sizeInMBs),
313+
"sizeInMBs": llx.IntDataPtr(image.SizeInMBs),
319314
"freeformTags": llx.MapData(freeformTags, types.String),
320315
"definedTags": llx.MapData(definedTags, types.Any),
321316
})

providers/oci/resources/conversion.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,9 @@
44
package resources
55

66
import (
7-
"time"
8-
97
"go.mondoo.com/mql/v13/providers-sdk/v1/util/jobpool"
108
)
119

12-
// parseTime parses RFC 3389 timestamps "2019-06-12T21:14:13.190Z"
13-
func parseTime(timestamp string) *time.Time {
14-
parsedCreated, err := time.Parse(time.RFC3339, timestamp)
15-
if err != nil {
16-
return nil
17-
}
18-
return &parsedCreated
19-
}
20-
2110
func stringValue(s *string) string {
2211
if s == nil {
2312
return ""

providers/oci/resources/conversion_test.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ package resources
55

66
import (
77
"testing"
8-
"time"
98

109
"github.com/stretchr/testify/assert"
11-
"github.com/stretchr/testify/require"
1210
)
1311

1412
func TestStringValue(t *testing.T) {
@@ -69,21 +67,3 @@ func TestIntValue(t *testing.T) {
6967
assert.Equal(t, int64(42), intValue(&i))
7068
})
7169
}
72-
73-
func TestParseTime(t *testing.T) {
74-
t.Run("valid RFC3339 timestamp", func(t *testing.T) {
75-
result := parseTime("2019-06-12T21:14:13.190Z")
76-
require.NotNil(t, result)
77-
assert.Equal(t, 2019, result.Year())
78-
assert.Equal(t, time.June, result.Month())
79-
assert.Equal(t, 12, result.Day())
80-
})
81-
82-
t.Run("invalid timestamp returns nil", func(t *testing.T) {
83-
assert.Nil(t, parseTime("not-a-timestamp"))
84-
})
85-
86-
t.Run("empty string returns nil", func(t *testing.T) {
87-
assert.Nil(t, parseTime(""))
88-
})
89-
}

providers/oci/resources/events.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"github.com/oracle/oci-go-sdk/v65/common"
1212
"github.com/oracle/oci-go-sdk/v65/events"
1313
"github.com/rs/zerolog/log"
14-
"go.mondoo.com/cnquery/v12/llx"
15-
"go.mondoo.com/cnquery/v12/providers-sdk/v1/util/jobpool"
16-
"go.mondoo.com/cnquery/v12/providers/oci/connection"
14+
"go.mondoo.com/mql/v13/llx"
15+
"go.mondoo.com/mql/v13/providers-sdk/v1/util/jobpool"
16+
"go.mondoo.com/mql/v13/providers/oci/connection"
1717
)
1818

1919
func (o *mqlOciEvents) id() (string, error) {

providers/oci/resources/filestorage.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
"github.com/oracle/oci-go-sdk/v65/filestorage"
1313
"github.com/oracle/oci-go-sdk/v65/identity"
1414
"github.com/rs/zerolog/log"
15-
"go.mondoo.com/cnquery/v12/llx"
16-
"go.mondoo.com/cnquery/v12/providers-sdk/v1/util/jobpool"
17-
"go.mondoo.com/cnquery/v12/providers/oci/connection"
15+
"go.mondoo.com/mql/v13/llx"
16+
"go.mondoo.com/mql/v13/providers-sdk/v1/util/jobpool"
17+
"go.mondoo.com/mql/v13/providers/oci/connection"
1818
)
1919

2020
func (o *mqlOciFileStorage) id() (string, error) {

providers/oci/resources/kms.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"github.com/oracle/oci-go-sdk/v65/common"
1212
"github.com/oracle/oci-go-sdk/v65/keymanagement"
1313
"github.com/rs/zerolog/log"
14-
"go.mondoo.com/cnquery/v12/llx"
15-
"go.mondoo.com/cnquery/v12/providers-sdk/v1/util/jobpool"
16-
"go.mondoo.com/cnquery/v12/providers/oci/connection"
14+
"go.mondoo.com/mql/v13/llx"
15+
"go.mondoo.com/mql/v13/providers-sdk/v1/util/jobpool"
16+
"go.mondoo.com/mql/v13/providers/oci/connection"
1717
)
1818

1919
func (o *mqlOciKms) id() (string, error) {
@@ -114,6 +114,7 @@ func (o *mqlOciKms) getVaults(conn *connection.OciConnection, regions []any) []*
114114
if err != nil {
115115
return nil, err
116116
}
117+
mqlInstance.(*mqlOciKmsVault).region = regionResource.Id.Data
117118
res = append(res, mqlInstance)
118119
}
119120

@@ -124,6 +125,10 @@ func (o *mqlOciKms) getVaults(conn *connection.OciConnection, regions []any) []*
124125
return tasks
125126
}
126127

128+
type mqlOciKmsVaultInternal struct {
129+
region string
130+
}
131+
127132
func (o *mqlOciKmsVault) id() (string, error) {
128133
return "oci.kms.vault/" + o.Id.Data, nil
129134
}

providers/oci/resources/logging.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
"github.com/oracle/oci-go-sdk/v65/common"
1212
"github.com/oracle/oci-go-sdk/v65/logging"
1313
"github.com/rs/zerolog/log"
14-
"go.mondoo.com/cnquery/v12/llx"
15-
"go.mondoo.com/cnquery/v12/providers-sdk/v1/util/convert"
16-
"go.mondoo.com/cnquery/v12/providers-sdk/v1/util/jobpool"
17-
"go.mondoo.com/cnquery/v12/providers/oci/connection"
14+
"go.mondoo.com/mql/v13/llx"
15+
"go.mondoo.com/mql/v13/providers-sdk/v1/util/convert"
16+
"go.mondoo.com/mql/v13/providers-sdk/v1/util/jobpool"
17+
"go.mondoo.com/mql/v13/providers/oci/connection"
1818
)
1919

2020
func (o *mqlOciLogging) id() (string, error) {

providers/oci/resources/oci.lr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private oci.compute.instance @defaults("name") {
206206
region oci.region
207207
// Instance creation time
208208
created time
209-
// Instance lifecycle state (MOVING, PROVISIONING, RUNNING, STARTING, STOPPING, STOPPED, CREATING_IMAGE, TERMINATING, TERMINATED)
209+
// Instance lifecycle state (e.g., MOVING, PROVISIONING, RUNNING, STARTING, STOPPING, STOPPED, CREATING_IMAGE, TERMINATING, TERMINATED)
210210
state string
211211
// Compute shape determining CPU and memory (e.g., VM.Standard2.1)
212212
shape string
@@ -248,7 +248,7 @@ private oci.compute.image @defaults("name") {
248248
region oci.region
249249
// Image creation time
250250
created time
251-
// Image lifecycle state (PROVISIONING, IMPORTING, AVAILABLE, EXPORTING, DISABLED, DELETED)
251+
// Image lifecycle state (e.g., PROVISIONING, IMPORTING, AVAILABLE, EXPORTING, DISABLED, DELETED)
252252
state string
253253
// Compartment containing the image
254254
compartment oci.compartment
@@ -332,7 +332,7 @@ private oci.network.vcn @defaults("name") {
332332
name string
333333
// VCN creation time
334334
created time
335-
// VCN lifecycle state (PROVISIONING, AVAILABLE, UPDATING, TERMINATING, TERMINATED)
335+
// VCN lifecycle state (e.g., PROVISIONING, AVAILABLE, TERMINATING, TERMINATED, UPDATING)
336336
state string
337337
// Deprecated: Use cidrBlocks instead
338338
cidrBlock string
@@ -364,7 +364,7 @@ private oci.network.securityList @defaults("name") {
364364
name string
365365
// Security list creation time
366366
created time
367-
// Security list lifecycle state (PROVISIONING, AVAILABLE, TERMINATING, TERMINATED)
367+
// Security list lifecycle state (e.g., PROVISIONING, AVAILABLE, TERMINATING, TERMINATED)
368368
state string
369369
// Egress security rules for outbound traffic
370370
egressSecurityRules []dict

0 commit comments

Comments
 (0)