Skip to content

rego: Upgrade to OPA v1#2815

Open
micromaomao wants to merge 25 commits into
microsoft:mainfrom
micromaomao:tingmao_github/opa
Open

rego: Upgrade to OPA v1#2815
micromaomao wants to merge 25 commits into
microsoft:mainfrom
micromaomao:tingmao_github/opa

Conversation

@micromaomao

@micromaomao micromaomao commented Jul 10, 2026

Copy link
Copy Markdown
Member
  • Bump OPA dependency
  • Change imports to use v1
  • Fix framework.rego

Depends-on: #2789
Depends-on: #2792

MahatiC and others added 14 commits May 7, 2026 22:36
Signed-off-by: Mahati Chamarthy <mahati.chamarthy@gmail.com>
This commit adds guest-side enforcement: each requested ETW provider is validated against allowed_log_providers declared in the security policy (case-insensitive match).
Providers not in the allowlist are silently dropped. The filtered config is re-encoded and forwarded to GCS with GUIDs resolved.

Also removes the hostedSystemConfig dead code path from createContainer — the sidecar only runs for confidential containers, which always use CWCOWHostedSystem.

Signed-off-by: Mahati Chamarthy <mahati.chamarthy@gmail.com>
…witch

Tightens log_provider enforcement so that, by default, the sidecar fails-close on any disallowed provider and locks down further policy calls (LockDown now installs the closed enforcer so SetConfidentialOptions cannot reinstall a permissive policy). The previous silent-drop behaviour is preserved behind a new allow_log_provider_dropping policy flag — when true, providers missing from allowed_log_providers are dropped and only the kept subset is re-encoded and forwarded to GCS.

Threads the flag through the rego framework, marshaller, and Go enforcer (EnforceLogProviderPolicy now returns the providers to keep), and adds rego + sidecar tests covering both fail-close and dropping modes.

Signed-off-by: Takuro Sato <takurosato@microsoft.com>
When allow_log_provider_dropping is enabled and the policy returns a strict subset of the requested providers, the sidecar silently rebuilt the LogSourcesInfo payload, leaving operators with no signal that any provider had been dropped — and under typical confidential setups forwardlogs itself may be off, so the trim was effectively invisible.

Emit a single Warn at the moment of trimming with the requested, kept, and dropped provider names. The log still lands inside the UVM and is reachable via shimdiag even when forwardlogs is disabled.

Signed-off-by: Takuro Sato <takurosato@microsoft.com>
Signed-off-by: Takuro Sato <takurosato@microsoft.com>
Without this, LockDown on a ClosedDoor enforcer with
PolicyEnforcerSet=false (the sidecar's boot-time state) leaves the
flag unset, and a later SetConfidentialOptions can still install a
permissive policy.

Signed-off-by: Takuro Sato <takurosato@microsoft.com>
The rego enforcer returns providers_to_keep as a set, so a request like
[A, A] against an allowlist of [A] came back as [A] and tripped a
spurious warning + re-marshal. Scan requestedNames against keepSet.

Signed-off-by: Takuro Sato <takurosato@microsoft.com>
The sidecar already decodes the base64+JSON payload to enforce
log_provider policy. Hand the parsed LogSourcesInfo to a new
UpdateLogSourcesFromInfo helper instead of re-encoding so the inbox
prep can decode it again. UpdateLogSources is reimplemented on top.

Signed-off-by: Takuro Sato <takurosato@microsoft.com>
Signed-off-by: Takuro Sato <takurosato@microsoft.com>
Signed-off-by: Takuro Sato <takurosato@microsoft.com>
Signed-off-by: Takuro Sato <takurosato@microsoft.com>
…tion

Signed-off-by: Takuro Sato <takurosato@microsoft.com>
Signed-off-by: Takuro Sato <takurosato@microsoft.com>
@micromaomao
micromaomao requested a review from a team as a code owner July 10, 2026 14:38
@jterry75

Copy link
Copy Markdown
Contributor

@micromaomao - I didn't realize you were working on this. Could we first merge my change and then we can take your updates to move to v1?

…ired rules present

This refactors rule_ok (and renames it) to fix the `some env in envList` being
applied at the wrong level.

Signed-off-by: Tingmao Wang <tingmaowang@microsoft.com>
Signed-off-by: Tingmao Wang <tingmaowang@microsoft.com>
This currently support containers[_].env_rules and containers[_].mounts.  If
multiple platform_rules are defined, a container matching either one can be
started (but in a consistent manner - e.g. if two platforms have different
environment variables or mounts, a container can't "mix and match" between
them).

In order to achieve the above consistency, we "patch" the container objects
instead of adding logic to e.g. env_rule_ok or envList_ok.  This also means that
the error_objects of a denial message will reflect the platform rules inserted.

Signed-off-by: Tingmao Wang <tingmaowang@microsoft.com>
…e field

Currently we only add input.rule to the original input, not the redacted input.
This results in the case of create_container not having the "rule" field in the
final deny message, but other enforcement points do have it since in those cases
the redactSensitiveData return the original input map.

Signed-off-by: Tingmao Wang <tingmaowang@microsoft.com>
Signed-off-by: Tingmao Wang <tingmaowang@microsoft.com>
Replacing
(^\w+(\(.+\)|\[(\w+|".+")\])?( := (\w+?|\{(.|\n)+?\}|\w+\[\w+\]))?) \{
with
$1 if {
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.

4 participants