Skip to content

always set SecurityPolicyEnabled when policy is present#2748

Open
anmaxvl wants to merge 2 commits into
microsoft:mainfrom
anmaxvl:fix-lcow-policy-plumbing
Open

always set SecurityPolicyEnabled when policy is present#2748
anmaxvl wants to merge 2 commits into
microsoft:mainfrom
anmaxvl:fix-lcow-policy-plumbing

Conversation

@anmaxvl
Copy link
Copy Markdown
Contributor

@anmaxvl anmaxvl commented May 21, 2026

Previously, SecurityPolicyEnabled was only set for LCOW when no-security-hardware was false, which meant the security policy was never plumbed to the GCS in the no-hardware dev path. This differed from the WCOW path which always sets SecurityPolicyEnabled when a policy is present.

Move SecurityPolicyEnabled assignment out of the !noSecurityHardware block so it is set whenever a security policy string is present. Gate the SNP-specific HCS document (makeLCOWSecurityDoc) on GuestStateFilePath instead, since that is only set when real SNP hardware is available.

Add AI generated unit tests.

Previously, SecurityPolicyEnabled was only set for LCOW when
no-security-hardware was false, which meant the security policy was
never plumbed to the GCS in the no-hardware dev path. This differed
from the WCOW path which always sets SecurityPolicyEnabled when a
policy is present.

Move SecurityPolicyEnabled assignment out of the !noSecurityHardware
block so it is set whenever a security policy string is present. Gate
the SNP-specific HCS document (makeLCOWSecurityDoc) on GuestStateFilePath
instead, since that is only set when real SNP hardware is available.

Add AI generated unit tests.

Signed-off-by: Maksim An <maksiman@microsoft.com>
@anmaxvl anmaxvl requested a review from a team as a code owner May 21, 2026 18:21
@rawahars
Copy link
Copy Markdown
Contributor

@anmaxvl Can you please make the verify and behaviour and make the changes in V2 shim as well-

noSecurityHardware := oci.ParseAnnotationsBool(ctx, annotations, shimannotations.NoSecurityHardware, false)

…resent

Always set ConfidentialConfig when a security policy is present.
Add NoSecurityHardware to SandboxOptions and use isConfidentialSNP
to gate SNP-specific HCS document construction (schema V25, confidential
boot options, NUMA skip, etc.) separately from policy presence.

Signed-off-by: Maksim An <maksiman@microsoft.com>
@anmaxvl anmaxvl force-pushed the fix-lcow-policy-plumbing branch from 6e7d936 to 5809d15 Compare May 22, 2026 06:45
// NoSecurityHardware indicates that SNP hardware is not available. When true,
// the security policy is still plumbed to the GCS but the HCS document uses the
// standard (non-SNP) format.
NoSecurityHardware bool
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.

Since NoSecurityHardware is used locally within lcow builder, can we avoid adding it to SandboxOptions?

SandboxOptions are used outside the package and usually contain the fields which are used later in the workflow.

// isConfidentialSNP is true when we have a security policy AND real SNP hardware.
// This gates SNP-specific HCS document construction (schema V25, confidential boot, etc.).
// When no-security-hardware is set, we still plumb the policy but use the standard HCS doc.
isConfidentialSNP := sandboxOptions.ConfidentialConfig != nil && !sandboxOptions.NoSecurityHardware
Copy link
Copy Markdown
Contributor

@rawahars rawahars May 25, 2026

Choose a reason for hiding this comment

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

Maybe move NoSecurityHardware parsing here. It serves no purpose inside parseSandboxOptions.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants