Skip to content

fix(diff-logs): ignore OCSF network Refuse (policy DNS) records - #72

Merged
ilanh merged 1 commit into
mainfrom
fix/69-diff-logs-dns-refuse
Nov 9, 2026
Merged

ilanh merged 1 commit into
mainfrom
fix/69-diff-logs-dns-refuse

Conversation

@ilanh

@ilanh ilanh commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Closes #69

OpenShell logs a Network Activity "Refuse" record (class_uid 4001, activity_id 5, status_detail: policy_dns_ineligible) when policy DNS refuses a name the policy doesn't allow. The record has no port and no actor. The connection attempt that follows gets its own record: a denied Open with host, port and binary.

parse_json_line counted the Refuse record as a second denial and added a bogus manual review: <host>:? (denied connection without a port) item. It now skips 4001 records with activity_id 5 or status_detail == "policy_dns_ineligible". The shorthand parser already ignores NET:REFUSE, so JSON and shorthand logs now give the same results.

  • Unit test skips_ocsf_network_refuse_records uses a record shaped like the real OpenShell v0.1.7 (OCSF 1.8.0) Refuse record.
  • Tested against the real v0.1.7 capture behind test: add real OpenShell v0.1.7 OCSF 1.8.0 log fixtures #70, using the playground repo:
    • Before: 12 events: 5 denied, 7 allowed, plus two manual review: example.com:? / pypi.org:? items.
    • After: 10 events: 3 denied, 7 allowed, the same as the shorthand log from the same run.
  • CHANGELOG: added an Unreleased entry.

Ran locally: fmt, clippy -D warnings, cargo test --locked, --test gateway_policies and gen-docs.sh --check all pass.

OpenShell logs a class 4001 / activity 5 "Refuse" record (status_detail policy_dns_ineligible) when policy DNS refuses a name. It has no port or actor, and the connection attempt that follows is logged separately as a denied Open. parse_json_line counted it as a second denial and produced a bogus "manual review: host:?" item. Skip it, matching the shorthand parser, which ignores NET:REFUSE.

Closes #69

Signed-off-by: Ilan Harel <ilan@Ilans-MacBook-Pro.local>
@ilanh
ilanh force-pushed the fix/69-diff-logs-dns-refuse branch from 7ca5d93 to 401eda6 Compare November 9, 2026 07:36
@ilanh
ilanh merged commit 5a1ec7c into main Nov 9, 2026
2 checks passed
@ilanh
ilanh deleted the fix/69-diff-logs-dns-refuse branch November 9, 2026 07:40
ilanh added a commit that referenced this pull request Nov 9, 2026
Closes #70

Rebased onto main after #71 and #72 merged. The golden note now says
OpenShell 0.1.7.

Adds a log fixture captured from a real OpenShell v0.1.7 sandbox: the
playground image and policy, with `ocsf_json_enabled=true`.

- `tests/fixtures/logs/ocsf-1.8.0.jsonl`: 17 native OCSF 1.8.0 records
(`metadata.version` is `1.8.0` on every line):
  - 4001 Open, allowed and denied
  - two 4001 Refuse records with `policy_dns_ineligible`
  - 4002 L7 allow and deny
- one record each of 0 (relay open/close), 4007 (SSH) and 5019 (policy
DNS mapped/staged), which `diff-logs` ignores
- Scrubbed:
  - Device hostname → `sandbox`.
  - Container → `fixture` with an all-zero UUID.
- `metadata.uid`, SSH channel ids and DNS mapping ids → fixed fake
UUIDs.
  - Real resolved IPs → 203.0.113.x (TEST-NET-3).
- The 198.18.x synthetic IPs, the proxy loopback address and the public
test hostnames are unchanged.
  - Timestamps rebased.
  - No usernames or tokens.
- `tests/fixtures/ocsf-1.8.0-app/`: a minimal annotated app that matches
the captured run.
- `tests/cli.rs` `diff_logs_reads_openshell_0_1_7_ocsf_1_8_0_records`:
  - Checks `10 events: 3 denied, 7 allowed`.
- Expects `missing_egress` for example.com (curl) and pypi.org
(python3.12), and `l7_allow` for httpbin.org POST /post.
  - Expects no `manual` items.
- Adds the plain human golden
`tests/golden/diff_logs_ocsf_1_8_0_plain.txt`.

Filesystem denials (two in the run) were not logged at all, which
matches NVIDIA/OpenShell#4270 (still open).

Ran locally: fmt, clippy `-D warnings`, `cargo test --locked`, `--test
gateway_policies` and `gen-docs.sh --check` all pass.

Signed-off-by: Ilan Harel <ilan@Ilans-MacBook-Pro.local>
Co-authored-by: Ilan Harel <ilan@Ilans-MacBook-Pro.local>
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.

diff-logs: ignore OCSF Network Activity Refuse (policy DNS) records that have no port

1 participant