Skip to content

chore(dkim): address Grok review feedback on PR #3877#3885

Merged
aterga merged 1 commit into
feat/dkim-verifierfrom
claude/address-grok-suggestions-9S5mB
May 12, 2026
Merged

chore(dkim): address Grok review feedback on PR #3877#3885
aterga merged 1 commit into
feat/dkim-verifierfrom
claude/address-grok-suggestions-9S5mB

Conversation

@aterga
Copy link
Copy Markdown
Collaborator

@aterga aterga commented May 12, 2026

Addresses the four "easy-to-change improvements" from Grok's review on #3877 (#3877 (review)). Targets feat/dkim-verifier so it can be merged in as a follow-up commit to that PR.

What changed

  1. types.rsNoSignature doc-comment. The distinct variant Grok asked for (NoSignaturePresent or equivalent) already exists as VerificationFailReason::NoSignature at types.rs:84 and is returned from verify() when no DKIM-Signature headers are present (verify.rs:54, verify.rs:67). The frontend can already distinguish it from a generic failure. Expanded the doc-comment to make the UX intent ("this provider doesn't use DKIM") explicit so future readers (and AI reviewers) don't re-flag this.

  2. parse.rs — explicit unknown-tag-ignored test. RFC 6376 §3.5 requires implementations to ignore unrecognised tags. The parser already does this (it's lookup-by-name in split_tag_listget(name); unknown tags pass straight through — the existing happy_value() fixture even contains an unknown q=dns/txt). Pinned the behaviour with a dedicated unknown_tags_are_ignored test covering z= and a synthetic zz=.

  3. verify.rs — SECURITY comment at the trust boundary. Added an inline // SECURITY: block at the parse_dkim_txt call site stating that dkim_txt is trusted, sourced from the DNSSEC verifier (feat(dnssec): scaffold verifier module + canister-side trust-anchor wiring #3838) or pinned-host DoH outcall (feat(doh): DoH fallback for DKIM/DMARC TXT records on unsigned domains #3879).

Not actioned

Tests

  • cargo test -p internet_identity --bin internet_identity dkim:: — 79 pass (was 78, +1 for the new unknown-tag test).
  • cargo clippy -p internet_identity --bin internet_identity --tests -- -D warnings — clean.
  • cargo check -p internet_identity --target wasm32-unknown-unknown — clean.
  • cargo fmt --check on the three modified files — clean (other pre-existing fmt drifts in dnssec/, openid/, tests/integration/ are unrelated and predate this branch).

Generated by Claude Code

- types.rs: expand `NoSignature` doc-comment to call out the frontend
  UX use case (distinct from a generic verification failure so the UI
  can render "this provider doesn't use DKIM"). The variant itself was
  already distinct — this just documents the intent.
- parse.rs: add explicit `unknown_tags_are_ignored` test asserting that
  unknown tags (z=, future extensions) pass parsing per RFC 6376 §3.5.
  Behaviour was already correct (the parser is lookup-by-name, not
  reject-on-extra); the test pins it.
- verify.rs: add SECURITY comment at the `parse_dkim_txt` call site
  making the trust boundary explicit — `dkim_txt` must come from a
  DNSSEC-validated chain (PR #3838) or a pinned-host DoH outcall
  (PR #3879).
@aterga aterga marked this pull request as ready for review May 12, 2026 13:27
@aterga aterga requested a review from a team as a code owner May 12, 2026 13:27
@aterga aterga requested a review from Copilot May 12, 2026 13:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Follow-up to the DKIM verifier work that incorporates requested review tweaks to make intent/trust boundaries clearer and to pin RFC-required behavior with a dedicated test.

Changes:

  • Clarified VerificationFailReason::NoSignature doc-comment to reflect frontend UX intent.
  • Added a unit test asserting unknown DKIM-Signature tags are ignored (RFC 6376 §3.5).
  • Added an explicit trust-boundary SECURITY: comment at the DKIM TXT parsing call site.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/internet_identity/src/dkim/verify.rs Documents the trust boundary for dkim_txt at the DNS record parsing call site.
src/internet_identity/src/dkim/types.rs Clarifies semantics/UX intent for the “no DKIM signature present” failure reason.
src/internet_identity/src/dkim/parse.rs Adds a regression test ensuring unknown DKIM tags don’t break parsing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aterga aterga merged commit 5fb9219 into feat/dkim-verifier May 12, 2026
42 of 43 checks passed
@aterga aterga deleted the claude/address-grok-suggestions-9S5mB branch May 12, 2026 13:33
aterga added a commit that referenced this pull request May 12, 2026
Addresses the two actionable "easy-to-change improvements" from Grok's
review on #3878
(#3878 (comment)).
Targets `feat/dmarc-alignment` so it can land as a follow-up commit on
that PR.

(Tried to push directly to `feat/dmarc-alignment` per the maintainer's
note from #3877 / #3885, but my account got a 403 against that branch —
falling back to a stacked draft PR.)

## What changed

1. **`dmarc/mod.rs` — consolidated `# Security model` docblock.** Calls
out the three deliberate deviations from "stock" DMARC, each with a
one-paragraph rationale:
- **No Public Suffix List** — label-anchored suffix check prevents
`evilexample.com`-style spoofs at the cost of closing multi-domain orgs
(`gmail.com` ↔ `googlemail.com`). Safe direction for a recovery surface.
Design doc §6.4.
- **No SPF** — recovery proves mailbox control, not path-of-delivery.
DKIM gives the cryptographic binding; SPF would need a source IP the
gateway payload doesn't carry. Design doc §6.5.
- **Fail-closed everywhere** — every malformed/unknown step collapses to
`Unverified`. No quarantine, no downgrade.

2. **`dmarc/test_vectors.rs` —
`verifies_end_to_end_when_dmarc_record_has_unknown_tags`.** Runs the
full `verify_email` against a DMARC record carrying `rua=`, `ruf=`,
`fo=`, and a synthetic `vendorext=` tag. Pins the ignore-unknown-tags
behaviour through the public entry point, not just the parser unit
(which already has a `unknown_tags_are_ignored` test in
`dmarc/parse.rs`).

## Not actioned

- **Grok item #1 ("parser must ignore unknown tags").** Already
implemented and unit-tested before this PR. `dmarc/parse.rs` is
lookup-by-name, so unknown tags pass through silently. The PR
description even calls this out: "ignores unknown / reporting tags". The
new end-to-end test is the explicit confirmation Grok asked for under
item #3.

The four strategic recommendations (observability metrics, frontend
error surface, SPF wiring, README) are explicitly "nice-to-have" /
"future" and belong in later PRs of the stack.

## Tests

- `cargo test -p internet_identity --bin internet_identity dmarc::` — 49
pass (was 48, +1 e2e unknown-tag test).
- `cargo clippy -p internet_identity --bin internet_identity --tests --
-D warnings` — clean.
- `cargo check -p internet_identity --target wasm32-unknown-unknown` —
clean.
- `cargo fmt --check` on the two touched files — clean (other
pre-existing fmt drifts in `dnssec/`, `openid/`, `tests/integration/`,
`types/attributes.rs` are unrelated and predate this branch).


---
_Generated by [Claude
Code](https://claude.ai/code/session_01NZmvbHgzN5NQc7Hqx9ZzpP)_

Co-authored-by: Claude <noreply@anthropic.com>
sea-snake pushed a commit that referenced this pull request May 13, 2026
Addresses the two actionable "easy-to-change improvements" from Grok's
review on #3878
(#3878 (comment)).
Targets `feat/dmarc-alignment` so it can land as a follow-up commit on
that PR.

(Tried to push directly to `feat/dmarc-alignment` per the maintainer's
note from #3877 / #3885, but my account got a 403 against that branch —
falling back to a stacked draft PR.)

## What changed

1. **`dmarc/mod.rs` — consolidated `# Security model` docblock.** Calls
out the three deliberate deviations from "stock" DMARC, each with a
one-paragraph rationale:
- **No Public Suffix List** — label-anchored suffix check prevents
`evilexample.com`-style spoofs at the cost of closing multi-domain orgs
(`gmail.com` ↔ `googlemail.com`). Safe direction for a recovery surface.
Design doc §6.4.
- **No SPF** — recovery proves mailbox control, not path-of-delivery.
DKIM gives the cryptographic binding; SPF would need a source IP the
gateway payload doesn't carry. Design doc §6.5.
- **Fail-closed everywhere** — every malformed/unknown step collapses to
`Unverified`. No quarantine, no downgrade.

2. **`dmarc/test_vectors.rs` —
`verifies_end_to_end_when_dmarc_record_has_unknown_tags`.** Runs the
full `verify_email` against a DMARC record carrying `rua=`, `ruf=`,
`fo=`, and a synthetic `vendorext=` tag. Pins the ignore-unknown-tags
behaviour through the public entry point, not just the parser unit
(which already has a `unknown_tags_are_ignored` test in
`dmarc/parse.rs`).

## Not actioned

- **Grok item #1 ("parser must ignore unknown tags").** Already
implemented and unit-tested before this PR. `dmarc/parse.rs` is
lookup-by-name, so unknown tags pass through silently. The PR
description even calls this out: "ignores unknown / reporting tags". The
new end-to-end test is the explicit confirmation Grok asked for under
item #3.

The four strategic recommendations (observability metrics, frontend
error surface, SPF wiring, README) are explicitly "nice-to-have" /
"future" and belong in later PRs of the stack.

## Tests

- `cargo test -p internet_identity --bin internet_identity dmarc::` — 49
pass (was 48, +1 e2e unknown-tag test).
- `cargo clippy -p internet_identity --bin internet_identity --tests --
-D warnings` — clean.
- `cargo check -p internet_identity --target wasm32-unknown-unknown` —
clean.
- `cargo fmt --check` on the two touched files — clean (other
pre-existing fmt drifts in `dnssec/`, `openid/`, `tests/integration/`,
`types/attributes.rs` are unrelated and predate this branch).


---
_Generated by [Claude
Code](https://claude.ai/code/session_01NZmvbHgzN5NQc7Hqx9ZzpP)_

Co-authored-by: Claude <noreply@anthropic.com>
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.

3 participants