fix(dns): enforce TLSA/CAA required fields for lower-case --type - #256
Open
AshutoshMore142k4 wants to merge 1 commit into
Open
fix(dns): enforce TLSA/CAA required fields for lower-case --type#256AshutoshMore142k4 wants to merge 1 commit into
AshutoshMore142k4 wants to merge 1 commit into
Conversation
`--type` is parsed with a value_parser that upper-cases the value, but clap matches `required_if_eq` against the raw argument. So `--type tlsa` never triggered the --usage/--selector/--matching-type requirement that `--type TLSA` enforces, and the record was built with certificateData but no usage/selector/matchingType and sent to the API. `--type caa` slipped past --tag the same way, falling through to validate_caa_fields, which only runs after auth. Set ignore_case on the --type arg, which is what clap documents for this case. All four required_if_eq predicates in the crate key off this one argument, so it covers both record types and keeps the rejection at parse time.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved blocking issues were identified.
Pull request overview
Fixes case-insensitive enforcement of required TLSA and CAA fields during DNS CLI parsing.
Changes:
- Enables case-insensitive
--typerequirements. - Adds lowercase TLSA and CAA regression tests.
- Updates validation comments.
File summaries
| File | Description |
|---|---|
rust/src/dns/records.rs |
Enables case-insensitive conditional requirements. |
rust/src/dns/mod.rs |
Adds lowercase TLSA and CAA validation tests. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--typeis parsed with avalue_parserthat upper-cases the value, but clap matchesrequired_if_eqagainst the raw argument (MatchedArg::check_explicitreadsraw_vals_flatten()). Sogddy dns add example.com --type tlsa …never triggered the--usage/--selector/--matching-typerequirement that--type TLSAenforces — the record was built withcertificateDatabut nousage/selector/matchingTypeand sent to the API, which the v3 schema requires all four for.--type caaslipped past the--tagrequirement the same way. That one is caught byvalidate_caa_fields, but only in the handler — so for anyone not already authenticated it surfaces as an auth error rather than a validation error.ignore_caseon the--typearg, which is what clap documents for exactly this case ("the equality check done byrequired_if_eq… is case-insensitive"). All fourrequired_if_eqpredicates in the crate key off this one argument, so a single flag covers both record types and keeps the rejection at parse time, before auth.Test plan
cargo check --workspacecargo fmt --checkcargo test --workspace— 776 passed./rust/scripts/check-module-size.shcargo clippy --workspace --all-targets -- -D warnings— clean for this change. (Heads-up unrelated to this PR: on a Windows host it errors on a pre-existing unuseduse super::*inextension/security/file_discovery.rs, whose only two tests are#[cfg(unix)], so the test module compiles empty there. CI on ubuntu is unaffected.)invalid_dns_input_is_rejected_before_auth_or_dry_runtable for lower-casetlsaandcaa. Confirmed they fail without the fix — thetlsarow gets as far as auth resolution instead of being rejected at parse:expected "--usage", got: {"error": {"code": "ERROR", "message": "auth: no provider registered ...gddy dns add example.com --type tlsa --name www --data d2ab…e971now fails at parse with the identical error--type TLSAgives (--usage <N>,--selector <N>,--matching-type <N>); mixed caseTlSatoogddy dns set example.com --type caa --name @ --data letsencrypt.orgnow fails at parse asking for--tag--type TLSAunchanged; lower-casetlsawith all three fields supplied parses and proceeds;--type astill works;--type bogusand--type nsstill rejected with their existing messages