Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/openshell-supervisor-network/src/l7/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ fn build_request_authority_mismatch_finding(ctx: &L7EvalContext) -> openshell_oc
.build()
}

fn build_credential_resolution_event(
pub(crate) fn build_credential_resolution_event(
ctx: &L7EvalContext,
method: &str,
endpoint_mismatch: bool,
Expand Down
16 changes: 16 additions & 0 deletions crates/openshell-supervisor-network/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5554,6 +5554,21 @@ fn rewrite_forward_request_reported(
Ok((output, substitutions))
}

/// Record a forward request answered with 500 because its credential
/// placeholder could not be resolved.
fn emit_forward_credential_unavailable(
l7_ctx: &crate::l7::relay::L7EvalContext,
method: &str,
correlation: Option<&crate::l7::correlation::RequestCorrelation>,
) {
crate::l7::correlation::emit_request_events(
correlation,
[crate::l7::relay::build_credential_resolution_event(
l7_ctx, method, false,
)],
);
}

fn initial_forward_body_prefix_len(header_str: &str, overflow: &[u8]) -> usize {
match crate::l7::rest::parse_body_length(header_str) {
Ok(crate::l7::provider::BodyLength::None) => 0,
Expand Down Expand Up @@ -7185,6 +7200,7 @@ async fn handle_forward_proxy_inner(
HttpOutcome::PlatformError,
Some("credential_injection_failed"),
);
emit_forward_credential_unavailable(&l7_ctx, method, request_correlation);
respond(
client,
&build_json_error_response_with_request_id(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,10 @@ network_policies:
};
let response = String::from_utf8(response).unwrap();
let records = capture.events.json_events();
let expected_records = if policy_denied || credential_failure {
let expected_records = if policy_denied {
1
} else if credential_failure {
2
} else if upstream_failure {
3
} else {
Expand All @@ -536,7 +538,12 @@ network_policies:
assert!(record.get("status_id").is_none());
assert!(record.get("status_detail").is_none());
for (index, control) in records.iter().enumerate() {
if upstream_failure && index == 1 {
if credential_failure && index == 1 {
assert_eq!(control["status_detail"], "credential_unavailable");
assert_eq!(control["firewall_rule"]["type"], "credential-binding");
assert_eq!(control["action_id"], 2);
assert_eq!(control["http_response"]["code"], 500);
} else if upstream_failure && index == 1 {
assert_eq!(control["status_detail"], "upstream_http_transport_failure");
assert_eq!(control["status_id"], 2);
assert_eq!(control["http_request"]["http_method"], "GET");
Expand Down
Loading