Skip to content

⭐ Expand OCI provider with new resources for CIS benchmark coverage#6623

Open
tas50 wants to merge 13 commits intomainfrom
tas50/oci_mega_add
Open

⭐ Expand OCI provider with new resources for CIS benchmark coverage#6623
tas50 wants to merge 13 commits intomainfrom
tas50/oci_mega_add

Conversation

@tas50
Copy link
Copy Markdown
Member

@tas50 tas50 commented Feb 13, 2026

Summary

Major expansion of the OCI provider with new resources for CIS benchmark coverage and security auditing.

New resource services

  • Audit: oci.audit — tenancy-level audit log retention configuration
  • Bastion: oci.bastion — bastion instances with typed VCN and subnet references
  • Cloud Guard: oci.cloudGuard — targets and detector recipes
  • Events: oci.events — event rules with actions
  • File Storage: oci.fileStorage — file systems with KMS key references
  • KMS: oci.kms — vaults and keys
  • Load Balancer: oci.loadBalancer — load balancers with listeners (SSL/TLS protocols, cipher suites, peer cert verification) and backend sets
  • Logging: oci.logging — log groups and logs with typed log group references
  • Monitoring: oci.monitoring — alarm definitions with severity, query, and notification destinations
  • Network Firewall: oci.networkFirewall — firewalls with typed subnet/policy references, and policies with lazy-loaded details
  • ONS (Notifications): oci.ons — topics and subscriptions with typed topic references
  • OKE: oci.oke — clusters with K8s version, public/private endpoint config, image policy, pod security policy, typed VCN/KMS references, and lazy-loaded node pools
  • Vault Secrets: oci.vault — secrets with rotation status and typed KMS key/vault references
  • Network Subnets: oci.network.subnet — subnets with VCN references, CIDR, DNS, public IP/ingress controls
  • Network Security Groups: oci.network.networkSecurityGroup — NSGs with ingress/egress security rules and VCN references

Enhancements to existing resources

  • Compute instances: block volumes, boot volumes, and new fields (platformConfig, launchOptions, instanceOptions, shapeConfig, sourceDetails, metadata, timeMaintenanceRebootDue)
  • Buckets: additional fields (objectLifecyclePolicyEtag)

Typed resource references (instead of raw ID strings)

Resource Field References
oci.network.securityList vcn() oci.network.vcn
oci.network.networkSecurityGroup vcn() oci.network.vcn
oci.network.subnet vcn() oci.network.vcn
oci.bastion.instance targetVcn() oci.network.vcn
oci.bastion.instance targetSubnet() oci.network.subnet
oci.compute.blockVolume kmsKey() oci.kms.key
oci.compute.bootVolume kmsKey() oci.kms.key
oci.fileStorage.fileSystem kmsKey() oci.kms.key
oci.vault.secret kmsKey() oci.kms.key
oci.vault.secret kmsVault() oci.kms.vault
oci.ons.subscription topic() oci.ons.topic
oci.logging.log logGroup() oci.logging.logGroup
oci.networkFirewall.firewall subnet() oci.network.subnet
oci.networkFirewall.firewall policy() oci.networkFirewall.policy
oci.oke.cluster vcn() oci.network.vcn
oci.oke.cluster kmsKey() oci.kms.key

New fields on existing resources

  • oci.kms.key: isAutoRotationEnabled
  • oci.compute.instance: timeMaintenanceRebootDue
  • oci.logging.log: created, timeLastModified

Also fixed

  • Pre-sized map allocations in compute resource creation
  • v12→v13 import fixes, nil safety, dead code cleanup
  • NSG DestType renamed to DestinationType for clarity
  • NSG security rules fetch uses double-check locking for thread safety
  • Network firewall policy description/attachedFirewallCount lazy-loaded instead of hardcoded
  • Added computeagent, Vnic to spelling expect.txt

Fixes

Test plan

  • make test/lint passes
  • make providers/build/oci && make providers/install/oci
  • Interactive verification with mql shell oci:
    • oci.audit.retentionPeriodDays
    • oci.bastion.bastions { name targetVcn targetSubnet state }
    • oci.monitoring.alarms { name isEnabled severity query destinations }
    • oci.vault.secrets { name kmsVault kmsKey rotationStatus state }
    • oci.network.subnets { name vcn cidrBlock prohibitPublicIpOnVnic }
    • oci.cloudGuard.targets { name state recipeCount }
    • oci.events.rules { name isEnabled state }
    • oci.kms.vaults { name keys { name isAutoRotationEnabled } }
    • oci.logging.logGroups { logs { name logGroup created timeLastModified } }
    • oci.ons.topics { name subscriptions { topic protocol } }
    • oci.compute.blockVolumes { name kmsKey state }
    • oci.compute.bootVolumes { name kmsKey state }
    • oci.fileStorage.fileSystems { name kmsKey state }
    • oci.loadBalancer.loadBalancers { name isPrivate listeners { protocol sslProtocols } }
    • oci.networkFirewall.firewalls { name subnet policy state }
    • oci.networkFirewall.policies { name description attachedFirewallCount }
    • oci.oke.clusters { name kubernetesVersion isPublicEndpointEnabled isImagePolicyEnabled kmsKey }
    • oci.oke.clusters { nodePools { name kubernetesVersion nodeShape sshPublicKey } }

🤖 Generated with Claude Code

@tas50 tas50 requested a review from syrull February 13, 2026 23:16
@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 13, 2026

Test Results

5 753 tests  +21   5 749 ✅ +21   2m 0s ⏱️ -13s
  425 suites ± 0       4 💤 ± 0 
   33 files   ± 0       0 ❌ ± 0 

Results for commit 9bd1ad9. ± Comparison against base commit cfa665f.

♻️ This comment has been updated with latest results.

@github-actions

This comment has been minimized.

@tas50 tas50 force-pushed the tas50/oci_mega_add branch 3 times, most recently from 5f643f6 to 57ec08a Compare February 18, 2026 23:20
@github-actions

This comment has been minimized.

@tas50 tas50 force-pushed the tas50/oci_mega_add branch 7 times, most recently from 69d88fb to 96ee221 Compare February 25, 2026 17:07
Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-implemented expansion of OCI provider with proper pagination, nil handling, and caching patterns

@tas50 tas50 force-pushed the tas50/oci_mega_add branch from 96ee221 to 4490054 Compare February 28, 2026 13:37
Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
  "summary": "Good overall structure and consistent patterns, but boot volume listing will fail at runtime due to a missing required API parameter, and two schema inconsistencies need addressing.",
  "verdict": "REQUEST_CHANGES",
  "findings": [
    {
      "path": "providers/oci/resources/compute.go",
      "line": 478,
      "endLine": 481,
      "severity": "critical",
      "body": "`getBootVolumesForRegion` constructs `ListBootVolumesRequest` without `AvailabilityDomain`, which is a **required** parameter in the OCI REST API (unlike `ListVolumes` for block volumes, which only needs `compartmentId`). This will produce a 400 error at runtime.\n\nCompare with `filestorage.go:51-76`, which correctly iterates availability domains per region:\n```go\nadResponse, err := identityClient.ListAvailabilityDomains(ctx, identity.ListAvailabilityDomainsRequest{\n    CompartmentId: common.String(conn.TenantID()),\n})\n// ... then per AD:\nrequest := filestorage.ListFileSystemsRequest{\n    CompartmentId:      common.String(compartmentID),\n    AvailabilityDomain: common.String(*ad.Name),\n    Page:               page,\n}\n```\n`getBootVolumesForRegion` needs the same AD-iteration pattern."
    },
    {
      "path": "providers/oci/resources/oci.lr",
      "line": 274,
      "endLine": 300,
      "severity": "warning",
      "body": "`oci.compute.blockVolume` and `oci.compute.bootVolume` define `compartmentID string` instead of `compartment oci.compartment`, inconsistent with the existing `oci.compute.instance` and `oci.compute.image` resources which use a typed resource reference. Per the project guidelines: *"Prefer typed resource references over raw ID strings."*\n\nChange to:\n```\ncompartment oci.compartment\n```\nand populate it the same way `oci.compute.instance` does (via `CreateResource(\"oci.compartment\", ...)`). The same inconsistency exists on `oci.network.networkSecurityGroup.vcnId string` (line 387) — that should be `vcn oci.network.vcn`."
    },
    {
      "path": "providers/oci/resources/oci.lr",
      "line": 430,
      "endLine": 447,
      "severity": "warning",
      "body": "`oci.logging.log` is missing a `created time` field. Every other new resource in this PR exposes creation time (`logGroup`, `kmsVault`, `kmsKey`, `eventsRule`, `fileSystem`, `blockVolume`, `bootVolume`, etc.), and `logging.LogSummary.TimeCreated` is available in the SDK.\n\nAdd to the schema:\n```\n// Log creation time\ncreated time\n```\nAnd in `logging.go`'s `logs()` method, populate it the same way `logGroups()` does with `llx.TimeDataPtr(created)`."
    }
  ]
}

@tas50 tas50 added the pending-testing Waiting on manual testing label Feb 28, 2026
@tas50
Copy link
Copy Markdown
Member Author

tas50 commented Mar 3, 2026

/review

Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Querying OCI boot volumes will likely fail at runtime due to missing required API parameter.

@tas50 tas50 force-pushed the tas50/oci_mega_add branch from 4490054 to 3958399 Compare March 5, 2026 21:21
@mondoo-code-review mondoo-code-review bot dismissed their stale review March 5, 2026 21:22

Superseded by new review

Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New OCI resources for CIS benchmark coverage are well-implemented and follow existing patterns consistently.

tas50 added 2 commits March 27, 2026 13:41
New resource services:
- Cloud Guard: oci.cloudGuard, targets, and detector recipes
- Events: oci.events and event rules
- File Storage: oci.fileStorage and file systems
- KMS: oci.kms, vaults, and keys
- Logging: oci.logging, log groups, and logs
- ONS (Notifications): oci.ons, topics, and subscriptions
- Network Security Groups: oci.network.networkSecurityGroup with ingress/egress security rules

Enhancements to existing resources:

- Compute: block volumes, boot volumes, and new instance fields (platformConfig, launchOptions, instanceOptions, shapeConfig, sourceDetails, metadata)
- Buckets: additional fields
- Networking: NSG support with lazy-loaded security rules

Signed-off-by: Tim Smith <tsmith84@gmail.com>
Signed-off-by: Tim Smith <tsmith84@gmail.com>
@tas50 tas50 force-pushed the tas50/oci_mega_add branch from 3958399 to e1018d0 Compare March 27, 2026 20:41
Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New OCI resources for CIS benchmarks are well-structured but missing version entries for all new resources and fields

Additional findings (file/line not in diff):

  • 🔵 providers/oci/resources/oci.lr:501oci.logging.log has retentionDuration int but the OCI SDK's RetentionDuration field is *int32. While llx.IntDataPtr handles *int32 via generics, double-check that the OCI SDK type for this field is numeric and not a duration enum. If it is indeed *int32, the current code is correct.

- 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>
@tas50 tas50 force-pushed the tas50/oci_mega_add branch from e1018d0 to d229cda Compare March 27, 2026 23:10
@mondoo-code-review mondoo-code-review bot dismissed their stale review March 27, 2026 23:11

Superseded by new review

Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New OCI resources for CIS benchmark coverage are well-structured and follow existing patterns.

tas50 and others added 3 commits March 27, 2026 16:14
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- oci.kms.key: isAutoRotationEnabled
- oci.compute.instance: timeMaintenanceRebootDue
- oci.logging.log: created, timeLastModified

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…lt secrets

New service resources:
- oci.audit: tenancy-level audit log retention configuration
- oci.bastion: bastion instances with typed VCN references
- oci.monitoring: alarm definitions with severity, query, destinations
- oci.vault: secrets with rotation status, typed KMS key/vault references

Also converts existing ID fields to typed resource references:
- securityList.vcnId → securityList.vcn() oci.network.vcn
- networkSecurityGroup.vcnId → networkSecurityGroup.vcn() oci.network.vcn
- vault.secret.vaultId → vault.secret.kmsVault() oci.kms.vault
- vault.secret.keyId → vault.secret.kmsKey() oci.kms.key

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

This comment has been minimized.

New resource:
- oci.network.subnet: subnets with VCN reference, CIDR, DNS, public IP/ingress controls

Converted ID fields to typed resource references:
- bastion.instance.targetSubnetId → targetSubnet() oci.network.subnet
- blockVolume.kmsKeyId → kmsKey() oci.kms.key
- bootVolume.kmsKeyId → kmsKey() oci.kms.key
- fileStorage.fileSystem.kmsKeyId → kmsKey() oci.kms.key
- ons.subscription.topicId → topic() oci.ons.topic

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

This comment has been minimized.

tas50 and others added 4 commits March 27, 2026 16:50
- Keep vcnId on securityList and NSG as deprecated (use vcn() instead)
- Add computeagent, Vnic to spelling expect.txt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… needed)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…gging.log

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New service resources:
- oci.loadBalancer: load balancers with lazy-loaded listeners (SSL/TLS
  config, protocols, cipher suites) and backend sets
- oci.networkFirewall: firewalls with typed subnet/policy references,
  and firewall policies
- oci.oke: OKE clusters with K8s version, public/private endpoint
  config, image policy, pod security policy, typed VCN/KMS references,
  and lazy-loaded node pools

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New OCI resources for Load Balancer, Network Firewall, and OKE are well-structured but have two data-correctness issues.

- oke: Remove hardcoded zero time for nodePool.created (not on summary)
- networkfirewall: Lazy-load policy description/attachedFirewallCount
  via GetNetworkFirewallPolicy instead of hardcoding defaults
- network: Rename DestType → DestinationType for clarity
- network: Add sync.Mutex double-check locking to NSG fetchSecurityRules
- cloudguard: Add comment about HomeRegionKey short key format

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mondoo-code-review mondoo-code-review bot dismissed their stale review March 28, 2026 00:12

Superseded by new review

Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous findings (hardcoded defaults, zero-time field) are properly addressed; new lazy-loader has a data-race risk.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tas50
Copy link
Copy Markdown
Member Author

tas50 commented Mar 28, 2026

/review

Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New OCI resources for CIS benchmarks are well-structured, but KMS key cross-references will return empty fields beyond id due to missing init/resolution logic.

Comment on lines +462 to +468
}
mqlKey, err := NewResource(o.MqlRuntime, "oci.kms.key", map[string]*llx.RawData{
"id": llx.StringData(o.cacheKmsKeyId),
})
if err != nil {
return nil, err
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 warningNewResource("oci.kms.key", {"id": ...}) creates a stub with only the id field populated. There is no initOciKmsKey function to lazily resolve the remaining fields (name, algorithm, protectionMode, state, etc.) from the API. Any MQL query like blockVolume.kmsKey.name will return an empty string.

The same pattern affects bootVolume.kmsKey(), fileSystem.kmsKey(), secret.kmsKey(), and cluster.kmsKey(). Consider either:

  • Adding an initOciKmsKey that fetches the key detail (requires caching the vault's management endpoint and region), or
  • Documenting that .kmsKey is currently ID-only and deferring full resolution to a follow-up.

Comment on lines +24 to +37
func int64Value(i *int64) int64 {
if i == nil {
return 0
}
return *i
}

func intValue(i *int) int64 {
if i == nil {
return 0
}
return int64(*i)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 suggestionint64Value and intValue are added but have no callers outside their unit tests. If they're for future use that's fine, but if not, consider removing dead code to keep the surface small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-testing Waiting on manual testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant