-
Notifications
You must be signed in to change notification settings - Fork 82
Fix/pre commit and clippy #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
ff79a32
e826562
e48e04c
bb1de96
82306a5
1cf3ce8
f1b3633
f3087e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,21 @@ on: | |
| - cron: "0 18 * * *" | ||
|
|
||
| jobs: | ||
| pre_commit: | ||
| timeout-minutes: 5 | ||
| name: prek | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| # tools used in pre-commit hooks | ||
| - id: cargo-rdme | ||
| uses: rusticata/ci-action-rdme@v2 | ||
| with: | ||
| rdme-args: --intralinks-features validate,verify,verify-aws | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd make for a tidier commit history if this were folded into the commit that added the pre-commit config 👼
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can be done, I just thought of these commits as slightly different (one for pre-commit and one for |
||
| # /tools | ||
| - id: prek | ||
| uses: rusticata/ci-action-prek@v1 | ||
|
|
||
| check: | ||
| name: Check | ||
| runs-on: ubuntu-latest | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # See https://pre-commit.com for more information | ||
| # See https://pre-commit.com/hooks.html for more hooks | ||
| fail_fast: true | ||
|
|
||
| exclude: | | ||
| (?x)^( | ||
| .*/(assets)/.*| | ||
| )$ | ||
|
|
||
| repos: | ||
| - repo: 'https://github.com/pre-commit/pre-commit-hooks' | ||
| rev: v6.0.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| #- id: end-of-file-fixer | ||
| - id: check-yaml | ||
| - id: check-added-large-files | ||
|
|
||
| - repo: local | ||
| hooks: | ||
| - id: cargo-fmt | ||
| name: cargo fmt | ||
| entry: cargo fmt -- | ||
| language: system | ||
| types: [rust] | ||
| pass_filenames: false # This makes it a lot faster | ||
|
|
||
| - id: cargo-clippy | ||
| name: cargo clippy | ||
| language: system | ||
| types: [rust] | ||
| pass_filenames: false | ||
| entry: cargo clippy --all-targets --features validate,verify,verify-aws -- -D warnings | ||
|
|
||
| - id: cargo-rdme | ||
| name: cargo rdme | ||
| language: system | ||
| types: [rust] | ||
| pass_filenames: false | ||
| entry: cargo rdme --intralinks-features validate,verify,verify-aws -c |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,3 +58,26 @@ time = { version="0.3.41", features=["formatting"] } | |
| [dev-dependencies] | ||
| hex-literal = "0.4" | ||
|
|
||
| [lints.rust] | ||
| unsafe_code = "forbid" | ||
| #missing_docs = "warn" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same feedback to consider here RE: not adding commented out config. |
||
| unstable_features = "deny" | ||
| unused_import_braces = "deny" | ||
| unused_qualifications = "deny" | ||
| missing_debug_implementations = "warn" | ||
| unreachable_pub = "warn" | ||
|
|
||
| [lints.rustdoc] | ||
| broken_intra_doc_links = "deny" | ||
|
|
||
| [lints.clippy] | ||
| #pedantic = { level = "warn", priority = -1 } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why land commented-out config? I think it'd be tidier to remove this and the other
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the objective is to un-comment them progressively. If we activate the warnings right now, there are a lot of fixes
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand not wanting to activate it immediately, but I don't know that I see the value in leaving it commented out as some kind of reminder. Wouldn't a GitHub issue be better for tracking the work required to enable pedantic clippy if that's a goal? |
||
| unwrap_used = "warn" | ||
| expect_used = "warn" | ||
| panic = "warn" | ||
| todo = "warn" | ||
| unimplemented = "warn" | ||
| unreachable = "warn" | ||
| dbg_macro = "warn" | ||
| #print_stdout = "warn" | ||
| #print_stderr = "warn" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| allow-unwrap-in-tests = true | ||
| allow-expect-in-tests = true | ||
| allow-panic-in-tests = true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| #![allow(clippy::expect_used)] | ||
| #![allow(clippy::panic)] | ||
| use x509_parser::prelude::*; | ||
|
|
||
| #[cfg(any( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| #![allow(clippy::unreachable)] | ||
| use asn1_rs::{oid, Oid, Set}; | ||
| use oid_registry::{ | ||
| OID_PKCS1_SHA256WITHRSA, OID_PKCS9_CHALLENGE_PASSWORD, OID_PKCS9_EXTENSION_REQUEST, | ||
| OID_SIG_ECDSA_WITH_SHA256, OID_X509_COMMON_NAME, | ||
| }; | ||
| use x509_parser::prelude::*; | ||
| use x509_parser::{pem::parse_x509_pem, prelude::*}; | ||
|
|
||
| const CSR_DATA_EMPTY_ATTRIB: &[u8] = include_bytes!("../assets/csr-empty-attributes.csr"); | ||
| const CSR_DATA: &[u8] = include_bytes!("../assets/test.csr"); | ||
|
|
@@ -25,7 +26,7 @@ fn read_csr_empty_attrib() { | |
|
|
||
| #[test] | ||
| fn read_csr_with_san() { | ||
| let der = pem::parse_x509_pem(CSR_DATA).unwrap().1; | ||
| let der = parse_x509_pem(CSR_DATA).unwrap().1; | ||
| let (rem, csr) = | ||
| X509CertificationRequest::from_der(&der.contents).expect("could not parse CSR"); | ||
|
|
||
|
|
@@ -67,7 +68,7 @@ fn read_csr_with_san() { | |
|
|
||
| #[test] | ||
| fn read_csr_with_challenge_password() { | ||
| let der = pem::parse_x509_pem(CSR_CHALLENGE_PASSWORD).unwrap().1; | ||
| let der = parse_x509_pem(CSR_CHALLENGE_PASSWORD).unwrap().1; | ||
| let (rem, csr) = X509CertificationRequest::from_der(&der.contents) | ||
| .expect("Could not parse CSR with challenge password"); | ||
|
|
||
|
|
@@ -117,7 +118,7 @@ fn read_csr_with_challenge_password() { | |
|
|
||
| #[test] | ||
| fn test_iter_raw_values() { | ||
| let der = pem::parse_x509_pem(CSR_CHALLENGE_PASSWORD).unwrap().1; | ||
| let der = parse_x509_pem(CSR_CHALLENGE_PASSWORD).unwrap().1; | ||
| let (_, csr) = X509CertificationRequest::from_der(&der.contents) | ||
| .expect("Could not parse CSR with challenge password"); | ||
|
|
||
|
|
@@ -139,7 +140,7 @@ fn test_iter_raw_values() { | |
| // Verify raw DER: tag should be UTF8String (0x0C), not SET (0x31) | ||
| assert_eq!( | ||
| any_val.header.tag(), | ||
| x509_parser::asn1_rs::Tag::Utf8String, | ||
| asn1_rs::Tag::Utf8String, | ||
| "iter_raw_values should yield individual values inside the SET, not the SET itself" | ||
| ); | ||
| let s = std::str::from_utf8(any_val.data.as_bytes2()) | ||
|
|
@@ -162,7 +163,7 @@ fn test_iter_raw_values() { | |
| // Verify raw DER: tag should be SEQUENCE (0x30), not SET (0x31) | ||
| assert_eq!( | ||
| any_val.header.tag(), | ||
| x509_parser::asn1_rs::Tag::Sequence, | ||
| asn1_rs::Tag::Sequence, | ||
| "iter_raw_values should yield SET contents, not the SET envelope" | ||
| ); | ||
| } | ||
|
|
@@ -174,11 +175,11 @@ fn test_iter_raw_values() { | |
| ))] | ||
| #[test] | ||
| fn read_csr_verify() { | ||
| let pem = pem::parse_x509_pem(CSR_DATA).unwrap().1; | ||
| let pem = parse_x509_pem(CSR_DATA).unwrap().1; | ||
| let (_, csr) = X509CertificationRequest::from_der(&pem.contents).expect("could not parse CSR"); | ||
| csr.verify_signature().unwrap(); | ||
|
|
||
| let mut der = pem::parse_x509_pem(CSR_DATA).unwrap().1; | ||
| let mut der = parse_x509_pem(CSR_DATA).unwrap().1; | ||
| assert_eq!(&der.contents[28..37], b"rusticata"); | ||
| for (i, b) in b"foobarbaz".iter().enumerate() { | ||
| der.contents[28 + i] = *b; | ||
|
|
@@ -192,14 +193,15 @@ fn read_csr_verify() { | |
| assert_eq!(csr.as_raw(), &der.contents); | ||
| } | ||
|
|
||
| #[expect(clippy::unreachable)] | ||
| #[test] | ||
| fn read_csr_with_custom_extension() { | ||
| let der = pem::parse_x509_pem(CSR_CUSTOM_EXTENSION).unwrap().1; | ||
| let der = parse_x509_pem(CSR_CUSTOM_EXTENSION).unwrap().1; | ||
| let (rem, csr) = X509CertificationRequest::from_der(&der.contents) | ||
| .expect("Could not parse CSR with custom extension"); | ||
|
|
||
| assert!(rem.is_empty()); | ||
| dbg!(csr.certification_request_info.attributes()); | ||
| //dbg!(csr.certification_request_info.attributes()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would vote to remove this line instead of commenting it out.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed, I will update |
||
| let cri = &csr.certification_request_info; | ||
| assert_eq!(cri.version, X509Version(0)); | ||
| assert_eq!(cri.attributes().len(), 1); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| #![allow(clippy::unwrap_used)] | ||
| use std::fs::{self, DirEntry}; | ||
| use x509_parser::parse_x509_certificate; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.