8000 fix(sessions): validate egress DNS hosts and flag host-bit CIDRs by gominimal-aw-bot[bot] · Pull Request #1926 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix(sessions): validate egress DNS hosts and flag host-bit CIDRs - #1926

Merged
norrietaylor merged 7 commits into
mainfrom
inbox-patch/fix/validate-egress-dns-hosts-and-cidr-notice-96abc4a2ba633468
Oct 4, 2026
Merged

norrietaylor merged 7 commits into
mainfrom
inbox-patch/fix/validate-egress-dns-hosts-and-cidr-notice-96abc4a2ba633468

Conversation

@gominimal-aw-bot
@gominimal-aw-bot gominimal-aw-bot Bot commented Oct 4, 2026 •
Copy link
Copy Markdown
Contributor

Routing-Key: inbox-route/I_kwDOSUhdos8AAAABU21Ymg

Summary

min session activate accepted egress values that can never match anything:

  • --allow-dns-hosts 'not a host' was stored verbatim as an allow rule that admits no name.
  • --deny-subnets 10.0.0.1/8 (host bits set) was accepted without telling the user how the range is read.

Changes

  • crates/sessions/src/lib.rs
    • Add PolicyError::InvalidDnsHost { host }.
    • Add EgressPolicy::first_invalid_dns_host and wire it into validate_policy so an allow_dns_hosts entry that is not a valid DNS hostname (empty, whitespace, label >63 bytes or empty, total >253, characters outside [A-Za-z0-9-_.]) is rejected at launch on both own-address and host-address paths. One trailing dot is tolerated, matching the DNS gate's normalization.
    • Add a pure normalized_cidr helper next to is_valid_cidr that returns the masked prefix (10.0.0.1/8 → 10.0.0.0/8) or None when already normalized.
  • crates/minimal/src/cmd/session.rs
    • Print a one-line notice at activation naming the normalized network for host-bit CIDRs, e.g. --deny-subnets 10.0.0.1/8 is read as 10.0.0.0/8.

Verification

  • cargo test -p sessions --locked: 550 passed, 0 failed (includes new tests invalid_egress_dns_host_is_rejected, valid_egress_dns_hosts_are_accepted, normalized_cidr_masks_host_bits).
  • cargo build -p minimal --locked: succeeds.
  • cargo fmt --all --check: clean.

Note: cargo clippy --workspace --locked -- -D warnings fails on a pre-existing lint in crates/args/src/lib.rs (clippy::needless_borrows_for_generic_args, only present in the sandbox's clippy 1.99.0, not the pinned 1.97.0); it is unrelated to this change.

Summary by CodeRabbit

  • New Features
    • Session activation now displays notices for valid egress allow and deny subnet entries that are normalized, showing both the declared entry and the network form used.
  • Bug Fixes
    • New egress policies now reject invalid DNS hostnames. Hosts must meet length and character requirements, have valid labels, and may include one trailing dot.

Reject an allow_dns_hosts entry that is not a valid DNS hostname at
launch, naming the offending string, instead of storing it verbatim as
an allow rule that can never match the DNS gate. The check runs on both
own-address and host-address boxes.

Keep host-bit CIDRs valid, but print a one-line notice at activation
naming the normalized network so the user knows how the range is read.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@gominimal-aw-bot
gominimal-aw-bot Bot requested a review from a team as a code owner October 4, 2026 04:08
@gominimal-aw-bot gominimal-aw-bot Bot added the agent:fix Agentic fix PR eligible for review iteration; min-aw's worker-iterate gates on it. label Oct 4, 2026
@norrietaylor
Copy link
Copy Markdown
Member

/review

@minimal-foundry
minimal-foundry Bot commented Oct 4, 2026 •
Copy link
Copy Markdown
Contributor

Approved: no findings at f56b4cba8ac4.

Nothing to do.

Clobber: none: git log on all four files shows only the PR's own commits on top of the main merge; no prior fix is reverted.

@gominimal-aw-bot
Copy link
Copy Markdown
Contributor Author

[inbox-patch:clobber]

This PR would revert recently merged work

Simulating this merge shows it undoing commits that landed on the base branch within the last 3 day(s):

  • a77351901 — 100% of its 3 surviving lines in these files would be undone
    • fix(min): warn when --sync none drops the project's minimal.toml (fix(min): warn when --sync none drops the project's minimal.toml #1887)
      This is the stale-read failure, not a conflict: the agent read these files before the commits above merged, then wrote the whole region back from that stale read. Git applies it cleanly, so there is no conflict, no failing test, and nothing unusual in the diff summary — see gominimal/inbox#460.

Before merging, restore the reverted region to its state on the base branch. The rest of this PR is unaffected.

If a listed commit is one this PR intends to supersede, say so and merge — this check reports, it does not block.

@coderabbitai
coderabbitai Bot commented Oct 4, 2026 •
Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

  • Run on-demand review

This review includes 4 billable files and costs up to $1.00.

Or wait 23 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 4878be0b-28cd-4678-95ff-5ed47ffce08e
📥 Commits

Reviewing files that changed from the base of the PR and between dfb5fe4 and f56b4cb.

📒 Files selected for processing (4)
  • crates/minimal/src/cmd/session.rs
  • crates/minimal/tests/cli.rs
  • crates/minimald/src/sessions.rs
  • crates/sessions/src/lib.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 1f8a981a-7cd2-4c87-b1fc-6f3653952e62
📥 Commits

Reviewing files that changed from the base of the PR and between 3ed131b and dfb5fe4.

📒 Files selected for processing (2)
  • crates/minimald/src/sessions.rs
  • crates/sessions/src/lib.rs

Included review availability: This review used your included allowance. Your plan provides up to 5 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

New session policies validate configured egress DNS hostnames. Session activation reports declared subnet entries when IPv4 normalization masks host bits.

Changes

Egress Policy Handling

Layer / File(s) Summary
DNS hostname validation
crates/sessions/src/lib.rs, crates/minimald/src/sessions.rs
validate_new_policy checks existing policy rules and rejects the first invalid configured DNS hostname. build_record uses this method for new records. Hostname syntax checks and tests cover accepted and rejected names; validate_policy remains limited to its existing checks.
CIDR normalization notices
crates/sessions/src/lib.rs, crates/minimal/src/cmd/session.rs
normalized_cidr returns a masked IPv4 CIDR when the address has host bits set. Session activation prints the original and normalized CIDR for entries that normalize successfully.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: norrietaylor

Merge Risk: ⚪ Minimal · up to dfb5f

New sessions validate DNS hosts, while IPv4 subnet notices report masked values. No actionable merge risk remains after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: DNS-host validation and notices for IPv4 CIDRs with host bits. It follows the repository’s Conventional Commit format.
Description check ✅ Passed The description includes a clear summary, change details, and test results. It omits the template’s Checklist section and says validation is wired into validate_policy, while the change summary says…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 3 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks each hostname string,
And notes the subnet’s network ring.
New policies catch names that fail,
While normalized nets leave a trail.
Stderr prints what changed along the way,
Then hops back home to end the day.

Comment @coderabbitai help to get the list of available commands.

@minimal-foundry minimal-foundry Bot 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.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Comment thread crates/minimal/src/cmd/session.rs Resolved
The egress rules compile only IPv4 subnets, so an IPv6 entry is never
read as the masked network the notice named. normalized_cidr now
returns None for IPv6 prefixes.
@norrietaylor norrietaylor changed the title fix: fix(sessions): validate egress DNS hosts and flag host-bit CIDRs fix(sessions): validate egress DNS hosts and flag host-bit CIDRs Oct 4, 2026
@norrietaylor
Copy link
Copy Markdown
Member

/review

@minimal-foundry minimal-foundry Bot 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.

minimal-review — approved

Verdict APPROVE — No findings.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Oct 4, 2026
validate_policy re-runs on every launch, so a stored session whose
allow_dns_hosts predates the check would stop attaching after an upgrade.
The hostname check moves to validate_new_policy, which only the create
path calls. The length limit now applies after the trailing dot is
stripped, and the error says wildcards and raw IDNs are not accepted.
@norrietaylor
Copy link
Copy Markdown
Member

/review

@gominimal-aw-bot gominimal-aw-bot Bot added the agent:resolve Consent gate: pr-conflict-resolver may rewrite this branch label Oct 4, 2026
@minimal-foundry minimal-foundry Bot 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.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Comment thread crates/sessions/src/lib.rs Resolved
@minimal-foundry minimal-foundry Bot removed the review:approved minimal-review approved the current head label Oct 4, 2026
The acceptance test called validate_policy, which no longer consults
is_valid_dns_host, so it never exercised the new check's accept path.
@norrietaylor
Copy link
Copy Markdown
Member

/review

@minimal-foundry minimal-foundry Bot 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.

minimal-review — approved

Verdict APPROVE — No findings.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Oct 4, 2026
@norrietaylor
norrietaylor added this pull request to the merge queue Oct 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 4, 2026
The empty-egress-value test assumed a hostname has no syntax to check, so
an empty entry stood as typed. Hostnames are now validated when a session
is created, so the empty value is refused with a typed error naming the
entry, the same as the CIDR dimensions. It still never becomes an empty
(deny-all) list.
@norrietaylor
Copy link
Copy Markdown
Member

/review

@minimal-foundry minimal-foundry Bot 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.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Comment thread crates/sessions/src/lib.rs Resolved
@minimal-foundry minimal-foundry Bot removed the review:approved minimal-review approved the current head label Oct 4, 2026
RFC 1035 labels cannot begin or end with a hyphen, so no query name can
match such an entry; it would be stored as an allow rule that admits
nothing.
@norrietaylor
Copy link
Copy Markdown
Member

/review

@minimal-foundry minimal-foundry Bot 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.

minimal-review — approved

Verdict APPROVE — No findings.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Oct 4, 2026
@norrietaylor
norrietaylor added this pull request to the merge queue Oct 4, 2026
Merged via the queue into main with commit bf98daf Oct 4, 2026
35 checks passed
@norrietaylor
norrietaylor deleted the inbox-patch/fix/validate-egress-dns-hosts-and-cidr-notice-96abc4a2ba633468 branch October 4, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:fix Agentic fix PR eligible for review iteration; min-aw's worker-iterate gates on it. agent:resolve Consent gate: pr-conflict-resolver may rewrite this branch clobber-suspected review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0