Skip to content

fix(ocsf): report https scheme for TLS-terminated requests - #4684

Open
ericcurtin wants to merge 2 commits into
NVIDIA:mainfrom
ericcurtin:fix/4562-https-ocsf-url-scheme/ericcurtin
Open

ericcurtin wants to merge 2 commits into
NVIDIA:mainfrom
ericcurtin:fix/4562-https-ocsf-url-scheme/ericcurtin

Conversation

@ericcurtin

Copy link
Copy Markdown
Contributor

Summary

L7 OCSF HTTP events recorded http for TLS-terminated requests. Use the transport scheme.

Related Issue

Closes #4562

Changes

  • Add L7EvalContext::ocsf_url, built from request_scheme.
  • Replace the eight hardcoded "http" URL sites with it.
  • Update sample log lines in docs.

Testing

  • Checks appropriate to the affected code and behavior pass
  • Unit tests added/updated (if applicable)
  • E2E tests added/updated (if applicable)

cargo test, cargo clippy -D warnings and cargo fmt pass for openshell-supervisor-network.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

Closes NVIDIA#4562

Signed-off-by: Eric Curtin <eric.curtin@docker.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ericcurtin

Copy link
Copy Markdown
Contributor Author

@krishicks @matthewgrossman could you please accept #4562 so the issue check can pass? @pimlock PTAL, and /ok to test aff878e3be761e8e5a8f113dabba2412ae251881 if it looks good. Thank you!

@EmilienM EmilienM 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.

Another iteration needed. The ocsf_url helper is a nice way to fix the inspected paths, but the passthrough relay still passes "http" to middleware and to the response-middleware OCSF event on TLS traffic (see inline on relay.rs). So #4562's "all L7 relay emission paths" isn't fully covered yet. Two small nits on the test and docs as well.

.http_request(HttpRequest::new(
&req.action,
OcsfUrl::new("http", &ctx.host, &redacted_target, ctx.port),
ctx.ocsf_url(&redacted_target),

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.

This event now says https, but further down the same function still hardcodes "http": apply_request(..., "http", ...) at L3611 and response_relay(&req_with_auth, ctx, "http") at L3685. This path carries TLS-terminated traffic for endpoints without L7 rules (proxy.rs:3089 sets request_default_port = Some(443) before it gets here). The second literal ends up in HttpRequestTarget.scheme, and http_response_middleware_invocation_events builds its OCSF URL from it (rest/http_response.rs:947). So with response middleware on a TLS endpoint, one request logs https on the request events and http on the response-middleware event, and the middleware itself gets http as input.

Suggest ctx.request_scheme() at both, the same way #4397 did for the inspected path (L756), plus a passthrough case in the regression test that checks the response-middleware event.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, both call sites use ctx.request_scheme(). Added a passthrough middleware test.

let ctx = L7EvalContext {
host: "api.example.test".into(),
port,
request_default_port: Some(port),

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.

Nit: port and request_default_port always match here, so this would still pass if the scheme came from ctx.port. A case where they differ (TLS on 8443 -> https with :8443 in the display, plaintext on 443 -> http) would pin down the transport-based behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Cases now cover TLS on 8443 and plaintext on 443.


```text
OCSF HTTP:POST [INFO] ALLOWED POST http://httpbin.org:443/anything [policy:httpbin engine:middleware] [failed:false transformed:true]
OCSF HTTP:POST [INFO] ALLOWED POST https://httpbin.org/anything [policy:httpbin engine:middleware] [failed:false transformed:true]

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.

Nit: a few samples for TLS traffic to api.github.com still show http://: lines 37 and 125 here, and docs/observability/accessing-logs.mdx:23. Worth switching them to https:// in the same pass.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, switched to https://.

Signed-off-by: Eric Curtin <eric.curtin@docker.com>
@ericcurtin

Copy link
Copy Markdown
Contributor Author

Addressed review feedback. @EmilienM @pimlock PTAL, and /ok to test 749337f661158ff9240738c2ac45fb189ef5007d if it looks good. Thank you!

This branch has not been deployed

No deployments
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.

bug(ocsf): HTTPS requests record an HTTP URL scheme

2 participants