Deny network access when an allow amendment fails (#36037)

## Why

A failed network policy amendment must not grant access to the requested host or approve it for the rest of the session.

## What changed

- Only approve the host for the session after the allow amendment is applied successfully.
- Otherwise deny the pending request and record a policy-denial outcome for its owning call.

## Testing

Added a managed-network regression test that submits an invalid allow amendment, verifies that the request is blocked, and confirms that retrying the host prompts for approval again.

GitOrigin-RevId: b2014d19128133abd5e19b8a7e4eb27810a45306
This commit is contained in:
jif
2026-07-29 22:29:36 +00:00
committed by copyberry
parent a1286d12a2
commit 3834c47ccb
2 changed files with 97 additions and 5 deletions
+18 -5
View File
@@ -920,12 +920,25 @@ impl NetworkApprovalService {
.await;
}
}
{
let mut denied_hosts = self.session_denied_hosts.lock().await;
denied_hosts.remove(&key);
if pending_owner.decision_on_drop == PendingApprovalDecision::AllowForSession {
{
let mut denied_hosts = self.session_denied_hosts.lock().await;
denied_hosts.remove(&key);
}
self.session_approved_hosts.lock().await.insert(key.clone());
PendingApprovalDecision::AllowForSession
} else {
if let Some(owner_call) = owner_call.as_ref() {
self.record_call_outcome(
&owner_call.registration_id,
NetworkApprovalOutcome::DeniedByPolicy(
policy_denial_message.clone(),
),
)
.await;
}
PendingApprovalDecision::Deny
}
self.session_approved_hosts.lock().await.insert(key.clone());
PendingApprovalDecision::AllowForSession
}
NetworkPolicyRuleAction::Deny => {
match session