Skip to content

fix(Bicep): Remove existing resources from bicep payload#7915

Merged
cx-artur-ribeiro merged 8 commits into
masterfrom
remove-existing-resources-from-bicep-payload
Dec 23, 2025
Merged

fix(Bicep): Remove existing resources from bicep payload#7915
cx-artur-ribeiro merged 8 commits into
masterfrom
remove-existing-resources-from-bicep-payload

Conversation

@cx-rui-araujo

@cx-rui-araujo cx-rui-araujo commented Dec 18, 2025

Copy link
Copy Markdown
Contributor

Reason for Proposed Changes

  • Resources declared with the existing keyword must already be deployed in the environment. Otherwise, a Not Found error is returned at deployment time. The existing keyword is intended to reference (or "select") an already deployed resource, not to create or update it.
  • Currently, KICS treats existing resources the same as regular resources during the parser stage. As a result, KICS evaluates these resources against security queries that rely on properties which are not defined in the existing resources declaration. This often leads to false positives, since existing resource declarations do not include all the properties required by the queries, and their actual configuration is unknown from static analysis alone.
  • Documentation: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/existing-resource

Proposed Changes

  • Exclude resources declared with the existing keyword from the payload. This prevents KICS from flagging vulnerabilities on resources whose real properties cannot be determined through static analysis. Since KICS does not have access to the runtime state of existing resources, analyzing them as fully defined resources produces inaccurate results in most cases.

I submit this contribution under the Apache-2.0 license.

@github-actions

github-actions Bot commented Dec 18, 2025

Copy link
Copy Markdown
Contributor

kics-logo

KICS version: v2.1.18

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 1
Files parsed placeholder 1
Files failed to scan placeholder 0
Total executed queries placeholder 47
Queries failed to execute placeholder 0
Execution time placeholder 0

@cx-rui-araujo cx-rui-araujo self-assigned this Dec 18, 2025
@cx-rui-araujo cx-rui-araujo marked this pull request as ready for review December 19, 2025 16:15
@cx-rui-araujo cx-rui-araujo requested a review from a team as a code owner December 19, 2025 16:15
@github-actions github-actions Bot added query New query feature azure PR related with Azure Cloud labels Dec 19, 2025

@cx-bruno-silva cx-bruno-silva left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@cx-artur-ribeiro cx-artur-ribeiro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, the payload no longer contains the parent resource if it contains the "existing" keyword and the same happens for the child resource as well.

Well done Rui!

@cx-artur-ribeiro cx-artur-ribeiro merged commit f8979be into master Dec 23, 2025
36 checks passed
@cx-artur-ribeiro cx-artur-ribeiro deleted the remove-existing-resources-from-bicep-payload branch December 23, 2025 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure PR related with Azure Cloud query New query feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants