Skip to content

⭐ v13: Convert Azure Defender dict values into resources#6694

Merged
arlimus merged 6 commits intomainfrom
tas50/defender_resources
Mar 2, 2026
Merged

⭐ v13: Convert Azure Defender dict values into resources#6694
arlimus merged 6 commits intomainfrom
tas50/defender_resources

Conversation

@tas50
Copy link
Copy Markdown
Member

@tas50 tas50 commented Feb 26, 2026

This improves how these work on the shell and give LLMs the information they need to write these queries.

Note: This is a breaking change and will require updating our policies at the same time.

Closes #4499

@tas50 tas50 force-pushed the tas50/defender_resources branch from 444a335 to 01768f0 Compare February 26, 2026 15:18
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-structured refactoring; one performance consideration with lazy-loaded extensions

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 26, 2026

Test Results

5 221 tests   5 217 ✅  2m 3s ⏱️
  409 suites      4 💤
   31 files        0 ❌

Results for commit 3156644.

♻️ This comment has been updated with latest results.

@tas50 tas50 force-pushed the tas50/defender_resources branch 2 times, most recently from 3b17050 to 27b02d2 Compare February 26, 2026 16:07
@mondoo-code-review
Copy link
Copy Markdown

Unable to complete the code review. Please try again or reduce the PR size.

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.

One real bug: defenderForContainers.extensions will always return an empty/unset value at runtime.

@tas50 tas50 changed the title v13: Convert Azure Defender dict values into resources ⭐ v13: Convert Azure Defender dict values into resources Feb 28, 2026
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-structured refactoring; nil-safety gap in commonPricingArgs and minor simplification opportunity.

@tas50 tas50 added the pending-testing Waiting on manual testing label Feb 28, 2026
mondoo-code-review[bot]

This comment was marked as outdated.

@mondoo-code-review mondoo-code-review bot dismissed their stale review February 28, 2026 20:46

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.

Clean refactor from dict to typed resources with good DRY helpers; one minor __id inconsistency for existing CSPM extensions.

tas50 and others added 6 commits March 2, 2026 12:39
Replace all 10 untyped dict-returning defenderFor* fields with fully
typed MQL resources, matching the existing defenderForApis and
defenderCSPM pattern. Each resource exposes .enabled, .pricingTier,
and common pricing metadata (subPlan, enforce, deprecated,
freeTrialRemainingTime, enablementTime, inherited, inheritedFrom,
replacedBy, resourcesCoverageStatus).

Add typed extension sub-resources for both defenderCSPM and
defenderForContainers with name, isEnabled, additionalProperties,
operationStatusCode, and operationStatusMessage fields.

Add isEnabled and phone fields to securityContact.

Add unit tests for commonPricingArgs and argsFromContactProperties
helper functions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add comments to both DefenderCSPM and DefenderForContainers extensions()
methods explaining the intentional re-fetch of pricing data for lazy loading.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The extensions field was defined as a plain field instead of a computed
field (missing `()`), so the hand-written extensions() method was never
called. This matches the working defenderCSPM pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add nil check for props parameter to prevent panic if Properties is nil
- Simplify enablementTime assignment since llx.TimeDataPtr already handles nil
- Remove unused time import
- Add NilProperties test case for commonPricingArgs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Prevent nil-pointer panics when cloudPosturePricing.Properties or
containersPricing.Properties is nil in the CSPM and Containers
extensions() methods.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use "/extension/" (singular) in buildExtensionResources to maintain
backward compatibility with the pre-existing CSPM extension cache keys.

Simplify the nil-props guard in commonPricingArgs by substituting an
empty PricingProperties struct, so all nil-safe field checks handle it
uniformly without duplicating zero-value assignments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@arlimus arlimus left a comment

Choose a reason for hiding this comment

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

super helpful for all named fields in here

@arlimus arlimus merged commit bfe3d8d into main Mar 2, 2026
22 checks passed
@arlimus arlimus deleted the tas50/defender_resources branch March 2, 2026 23:56
@github-actions github-actions bot locked and limited conversation to collaborators Mar 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

pending-testing Waiting on manual testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update azure.subscription.cloudDefender.defenderForServers resource

2 participants