Repository navigation
refactor(security)!: qualify orchestration lint - #294
Conversation
- Add scripts/check-security.mjs on the shared diagnostic gate: pedantic clippy over five entry graphs (workspace all/default features, minimal XMLDSig, minimal XMLEnc, XAdES adapter), filtered to policy, providers, key inventory/import, XMLDSig/XMLEnc operations, operation/evidence API, transforms and XAdES, including their tests; wired into the hardening job - Make every owned diagnostic pass without suppressions: split long orchestration functions into named stages, add Errors/must_use docs, replace lossy casts with checked conversions, take Copy policy values by value and move unit tests into sibling files - Replace the six KeySourcePolicy booleans with a typed KeySourceKind set - Take the authorization of PolicyCompiler::authorize_replacement by reference, since it is only validated and copied into the policies - Gate cfg-only paths at their source: ML-KEM usage validation and the XSLT transform parser exist only with their features, and one certificate-to-XMLDSig algorithm mapping serves RSA PKCS#1 and ECDSA - Update the structured-* primitives to 0.15.1 and parse certificates through structured-pkix; x509-cert remains a test-only dependency BREAKING CHANGE: KeySourcePolicy is a typed set of KeySourceKind values instead of six public bool fields, and PolicyCompiler::authorize_replacement takes &PolicyValidity. Closes #276
|
Important Review skippedToo many files! This PR contains 174 files, which is 74 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Clippy 1.92 rejects find(..).is_none() and asks for any(), while pedantic clippy rejects the closure any() needs because Node::is_element takes a reference. all() with a negated closure satisfies both toolchains with identical semantics. Part of #276
The PR smoke replays every retained corpus input under ASan before its new mutations. With the unoptimized --dev build the replay ran at 1-60 executions per second and the evolving corpora outgrew the 35 minute job budget. An optimized build with debug assertions keeps overflow checks and debug_assert coverage; the security_roundtrip corpus (893 inputs) replays in 12 s instead of 271 s. Part of #276
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4707d509de
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Public-key adapters on the shared PKIX reader created a fresh default-policy account per read. Inside a verification operation that ignored the configured max_x509_work and workspace limits, left the work out of aggregate usage, and reported exhaustion as a malformed key. - VerifyingKey policy hooks receive a VerificationScope (operation policy plus its certificate account) instead of a bare policy; verify_with_policy also carries the SignatureContext - built-in keys, resolver-bound keys and trusted keys read their SPKI under that account; exhaustion surfaces as a typed KeyPolicy(ResourceLimitExceeded) refusal - InspectedKeyCandidateBudget::verification_scope lets resolvers that pre-check candidates use the same account - SignatureVerificationInput is non_exhaustive with a new() constructor; the native provider reads SPKI under the operation account it carries - issuer SPKI strength checks read under the chain session - standalone entry points (bare provider calls, key import, direct helpers) read under an explicit standalone account - the recipient RSA key and the software RSA verifier are built from the already admitted SPKI components instead of a second parse Regression test: preset_verification_keys_charge_the_operation_certificate_account BREAKING CHANGE: VerifyingKey::validate_policy, validate_signature_value_with_policy and verify_with_policy take &VerificationScope; verify_with_policy also takes &SignatureContext. SignatureVerificationInput is non_exhaustive and built with new().
- dispatch public-key verification by algorithm family instead of enumerating every method, which kept the helper over the length limit - declare the resource-limit imports before the early return - bind the expected EC key info with let-else in the regression test
Summary
Qualifies the security orchestration layer under scoped pedantic clippy, with no suppressions and no policy relaxation.
scripts/check-security.mjsruns on the shared diagnostic gate with--force-warn clippy::pedantic(soallowcannot hide a finding). It covers five entry graphs: workspace with all features, workspace with default features, minimal XMLDSig, minimal XMLEnc and the XAdES adapter. Findings are filtered to policy, provider adapters, key inventory and import, XMLDSig/XMLEnc operations, the authenticated operation/evidence API, reference/transform orchestration, the XAdES adapter and their tests. The script and itsnode --testsuite run in the existing hardening job.# Errors, and pure accessors are#[must_use].Copypolicy values are taken by value.KeySourcePolicyis aKeySourceKindset (ALL,NONE,contains,insert,remove,set,intersection,From<[KeySourceKind; N]>) instead of six public booleans. Profiles andxml-sec-configbuild it from explicit source kinds.structured-asn1,structured-pkix,structured-cms,structured-ltvandstructured-xadesare now 0.15.1.structured-pkix;x509-certis a dev-dependency only.max_x509_workand workspace limits apply, the work counts toward aggregate usage, and exhaustion surfaces as a typedResourceLimitExceededrefusal instead of a malformed key;VerifyingKeypolicy hooks receive aVerificationScope(operation policy plus account), andInspectedKeyCandidateBudget::verification_scopegives resolvers that pre-check candidates the same scope;Breaking changes
KeySourcePolicyfields are replaced by theKeySourceKindset API.PolicyCompiler::authorize_replacementtakes&PolicyValidity.VerifyingKey::validate_policy,validate_signature_value_with_policyandverify_with_policytake&VerificationScopeinstead of&VerificationPolicy;verify_with_policyalso takes the&SignatureContext.SignatureVerificationInputis#[non_exhaustive]and is built withSignatureVerificationInput::new.Testing
node scripts/check-security.mjs: all five entry graphs pass.node --test scripts/check-security.test.mjspasses.cargo fmt --all --checkandcargo clippy --workspace --all-targets --all-features -- -D warningsare clean on stable and 1.92.0; the minimal feature profiles ofscripts/check-features.sh(dsig, xmlenc, legacy, experimental, pkcs11, fips-dsig) lint clean.cargo nextest run --workspace --all-features -E 'not binary(libxslt_oracle)'with the xmlsec1 1.3.13 oracle and SoftHSM (scripts/test-pkcs11.sh): 5604 passed. Thefips-dsigprofile tests: 2282 passed.preset_verification_keys_charge_the_operation_certificate_account: RSA and P-256 pre-set keys verify under the default policy and are refused withResourceLimitExceededundermax_x509_work = 1.cargo test --doc --workspace --all-featurespasses.RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features -p xml-secis clean.BREAKING CHANGE: KeySourcePolicy is a typed set of KeySourceKind values instead of six public bool fields, PolicyCompiler::authorize_replacement takes &PolicyValidity, the VerifyingKey policy hooks take &VerificationScope (verify_with_policy also takes &SignatureContext), and SignatureVerificationInput is non_exhaustive with a new() constructor.
Closes #276