diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml new file mode 100644 index 000000000..0842732f5 --- /dev/null +++ b/.github/workflows/typos.yml @@ -0,0 +1,26 @@ +on: + push: + pull_request: + merge_group: + schedule: # Trigger a job on default branch at 4AM PST everyday + - cron: "0 11 * * *" + +name: Typos + +jobs: + typos: + name: Spell check + runs-on: windows-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + # We explicitly install typos instead the typos GitHub Action due to: + # https://github.com/crate-ci/typos/issues/1191 + - name: Install typos (taiki-e/install-action) + uses: taiki-e/install-action@v2 + with: + tool: typos + + - name: Run typos (check) + run: typos diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 000000000..ba5ce2e72 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,16 @@ +[files] +extend-exclude = ["**/target/**", "**/Cargo.lock"] + +# Allow specific identifiers in code derived from WDK +[default.extend-identifiers] +STATUS_FVE_MOR_FAILED = "STATUS_FVE_MOR_FAILED" +STATUS_MCA_OCCURED = "STATUS_MCA_OCCURED" +STATUS_ND_QUEUE_OVERFLOW = "STATUS_ND_QUEUE_OVERFLOW" +STATUS_TPM_DAA_INPUT_DATA0 = "STATUS_TPM_DAA_INPUT_DATA0" +STATUS_TPM_DAA_INPUT_DATA1 = "STATUS_TPM_DAA_INPUT_DATA1" +STATUS_TPM_DAA_ISSUER_SETTINGS = "STATUS_TPM_DAA_ISSUER_SETTINGS" +STATUS_TPM_DAA_ISSUER_VALIDITY = "STATUS_TPM_DAA_ISSUER_VALIDITY" +STATUS_TPM_DAA_RESOURCES = "STATUS_TPM_DAA_RESOURCES" +STATUS_TPM_DAA_STAGE = "STATUS_TPM_DAA_STAGE" +STATUS_TPM_DAA_TPM_SETTINGS = "STATUS_TPM_DAA_TPM_SETTINGS" +STATUS_TPM_DAA_WRONG_W = "STATUS_TPM_DAA_WRONG_W" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 69d4337e4..f2e425ae2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -91,6 +91,7 @@ The following tools should be installed as a part of the `windows-drivers-rs` de * `cargo-audit`: `cargo install --locked cargo-audit` * `cargo-machete`: `cargo install --locked cargo-machete` * `taplo-cli`: `cargo install --locked taplo-cli` +* `typos-cli`: `cargo install --locked typos-cli` **Note on arm64:** ARM64 support for ring is [not released yet](https://github.com/briansmith/ring/issues/1167), so TLS features must be disabled until arm64 is officially supported by ring (probably in 0.17.0 release) @@ -140,6 +141,13 @@ To maintain the quality of code, tests and tools are required to pass before con * Check for sorted sections and dependencies listed in the `Cargo.toml` files: `cargo sort -w -g -n --check` * Running `cargo sort -w -g -n` resolves any formatting inconsistencies. +**_Spelling (typos-cli):_** + +* Check spelling with typos-cli: `typos` + * Auto-fix locally before committing: `typos --write-changes` + * CI runs `typos` on every PR to `main` and will fail on finding any typos + * Configuration lives in `.typos.toml`; we allowlist specific Windows API identifiers flagged by typos to preserve upstream names and binding compatibility (no file-level excludes) + **_Dependency Analysis:_** * Scan for security advisories in dependent crates: `cargo audit --deny warnings` diff --git a/README.md b/README.md index b936e77dd..24e871563 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ This project was built with support of WDM, KMDF, and UMDF drivers in mind, as w * [crates](./crates): Contains all the main crates that are a part of the Cargo workspace. * [examples](./examples): Contains workspace-level examples. These examples consist of different types of minimal Windows drivers (ie. WDM, KMDF, UMDF). -* [tests](./tests): Contains workspace-level tests, inlcuding tests for metadata-based wdk configuration in packages and workspaces. +* [tests](./tests): Contains workspace-level tests, including tests for metadata-based wdk configuration in packages and workspaces. **Note:**: Since the workspace level examples and tests use different WDK configurations, and WDR only supports one WDK configuration per workspace, the workspace-level examples and tests folder are excluded from the [repository root's Cargo manifest](./Cargo.toml). diff --git a/crates/cargo-wdk/src/actions/build/package_task.rs b/crates/cargo-wdk/src/actions/build/package_task.rs index 481ecf8f6..a727ae508 100644 --- a/crates/cargo-wdk/src/actions/build/package_task.rs +++ b/crates/cargo-wdk/src/actions/build/package_task.rs @@ -38,7 +38,7 @@ pub struct PackageTaskParams<'a> { pub driver_model: DriverConfig, } -/// Suports low level driver packaging operations +/// Supports low level driver packaging operations pub struct PackageTask<'a> { package_name: String, verify_signature: bool, @@ -394,7 +394,7 @@ impl<'a> PackageTask<'a> { Ok(()) } - /// Signs the specified file using signtool command using cerificate from + /// Signs the specified file using signtool command using certificate from /// certificate store. /// /// # Arguments diff --git a/crates/cargo-wdk/src/actions/new/mod.rs b/crates/cargo-wdk/src/actions/new/mod.rs index 9ca7fdb7d..4613a3c1b 100644 --- a/crates/cargo-wdk/src/actions/new/mod.rs +++ b/crates/cargo-wdk/src/actions/new/mod.rs @@ -45,7 +45,7 @@ impl<'a> NewAction<'a> { /// is used as the package name. /// * `driver_type` - The type of the driver project to be created. /// * `verbosity_level` - The verbosity level for logging. - /// * `command_exec` - The provider for command exection. + /// * `command_exec` - The provider for command execution. /// * `fs` - The provider for file system operations. /// /// # Returns diff --git a/crates/wdk-alloc/src/lib.rs b/crates/wdk-alloc/src/lib.rs index 1a8b72829..b5abb5a78 100644 --- a/crates/wdk-alloc/src/lib.rs +++ b/crates/wdk-alloc/src/lib.rs @@ -52,7 +52,7 @@ mod kernel_mode { // SAFETY: This is safe because the Wdk allocator: // 1. can never unwind since it can never panic // 2. has implementations of alloc and dealloc that maintain layout - // constraints (FIXME: Alignment of the layout is currenty not + // constraints (FIXME: Alignment of the layout is currently not // supported) unsafe impl GlobalAlloc for WdkAllocator { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { diff --git a/crates/wdk-build/CHANGELOG.md b/crates/wdk-build/CHANGELOG.md index daa46b917..83a83d6e0 100644 --- a/crates/wdk-build/CHANGELOG.md +++ b/crates/wdk-build/CHANGELOG.md @@ -85,7 +85,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - resolve warnings in rust-script blocks and only fail warnings in CI ([#87](https://github/microsoft/windows-drivers-rs/pull/87)) -- add missing cpu-arch macro defintions +- add missing cpu-arch macro definitions - fix wdk path regkey detection ### Other diff --git a/crates/wdk-build/rust-driver-makefile.toml b/crates/wdk-build/rust-driver-makefile.toml index 6b8009395..a6e6fc0dc 100644 --- a/crates/wdk-build/rust-driver-makefile.toml +++ b/crates/wdk-build/rust-driver-makefile.toml @@ -136,7 +136,7 @@ wdk_build::cargo_make::forward_printed_env_vars( ''' [tasks.setup-wdk-config-env-vars] -# This exists as a seperate task outside of `wdk-build-init` so that any wdk-metadata-detection errors can be a hard error, without failing every task flow that executes on non-driver crates in the workspace. +# This exists as a separate task outside of `wdk-build-init` so that any wdk-metadata-detection errors can be a hard error, without failing every task flow that executes on non-driver crates in the workspace. private = true install_crate = { crate_name = "rust-script", min_version = "0.30.0" } plugin = "rust-env-update" diff --git a/crates/wdk-build/src/cargo_make.rs b/crates/wdk-build/src/cargo_make.rs index ceb3dcaac..86fd40de9 100644 --- a/crates/wdk-build/src/cargo_make.rs +++ b/crates/wdk-build/src/cargo_make.rs @@ -714,7 +714,7 @@ pub fn get_current_package_name() -> String { /// /// # Errors /// -/// This function returns a [`ConfigError::IoError`] if the it encouters IO +/// This function returns a [`ConfigError::IoError`] if the it encounters IO /// errors while copying the file or creating the directory /// /// # Panics diff --git a/crates/wdk-build/src/lib.rs b/crates/wdk-build/src/lib.rs index 090a3e5cf..61d412826 100644 --- a/crates/wdk-build/src/lib.rs +++ b/crates/wdk-build/src/lib.rs @@ -912,12 +912,12 @@ impl Config { /// where the issue was fixed. See /// for details. fn should_include_ufxclient() -> bool { - const MINIMUM_CLANG_MAJOR_VERISON_WITH_INVALID_INLINE_FIX: u32 = 20; + const MINIMUM_CLANG_MAJOR_VERSION_WITH_INVALID_INLINE_FIX: u32 = 20; let clang_version = ::bindgen::clang_version(); match clang_version.parsed { Some((major, _minor)) - if major >= MINIMUM_CLANG_MAJOR_VERISON_WITH_INVALID_INLINE_FIX => + if major >= MINIMUM_CLANG_MAJOR_VERSION_WITH_INVALID_INLINE_FIX => { true } diff --git a/crates/wdk-build/src/metadata/ser.rs b/crates/wdk-build/src/metadata/ser.rs index fd4f18948..39b018b29 100644 --- a/crates/wdk-build/src/metadata/ser.rs +++ b/crates/wdk-build/src/metadata/ser.rs @@ -17,7 +17,7 @@ use super::{ pub const KEY_NAME_SEPARATOR: char = '-'; /// Serialize a value into a [`Map`] where the keys represent a -/// `KEY_NAME_SEPARATOR`-seperated list of field names. +/// `KEY_NAME_SEPARATOR`-separated list of field names. /// /// # Errors /// @@ -63,7 +63,7 @@ where } /// Serialize a value into a [`Map`] where the keys represent a -/// `KEY_NAME_SEPARATOR`-seperated list of field names prepended with a +/// `KEY_NAME_SEPARATOR`-separated list of field names prepended with a /// prefix. /// /// # Errors diff --git a/crates/wdk-macros/src/lib.rs b/crates/wdk-macros/src/lib.rs index 67e735602..dd99d812d 100644 --- a/crates/wdk-macros/src/lib.rs +++ b/crates/wdk-macros/src/lib.rs @@ -112,7 +112,7 @@ struct DerivedASTFragments { struct IntermediateOutputASTFragments { must_use_attribute: Option, inline_wdf_fn_signature: Signature, - inline_wdf_fn_body_statments: Vec, + inline_wdf_fn_body_statements: Vec, inline_wdf_fn_invocation: ExprCall, } @@ -299,7 +299,7 @@ impl DerivedASTFragments { unsafe fn #inline_wdf_fn_name(#parameters) #return_type }; - let inline_wdf_fn_body_statments = parse_quote! { + let inline_wdf_fn_body_statements = parse_quote! { // Get handle to WDF function from the function table let wdf_function: wdk_sys::#function_pointer_type = Some( // SAFETY: This `transmute` from a no-argument function pointer to a function pointer with the correct @@ -353,7 +353,7 @@ impl DerivedASTFragments { IntermediateOutputASTFragments { must_use_attribute, inline_wdf_fn_signature, - inline_wdf_fn_body_statments, + inline_wdf_fn_body_statements, inline_wdf_fn_invocation, } } @@ -364,7 +364,7 @@ impl IntermediateOutputASTFragments { let Self { must_use_attribute, inline_wdf_fn_signature, - inline_wdf_fn_body_statments, + inline_wdf_fn_body_statements, inline_wdf_fn_invocation, } = self; @@ -376,7 +376,7 @@ impl IntermediateOutputASTFragments { // Use a private module to prevent leaking of glob import into inline_wdf_fn_invocation's parameters mod private__ { // Glob import types from wdk_sys. glob importing is done instead of blindly prepending the - // paramters types with wdk_sys:: because bindgen generates some paramters as native rust types + // parameters types with wdk_sys:: because bindgen generates some parameters as native rust types use wdk_sys::*; // If the function returns a value, add a `#[must_use]` attribute to the function @@ -385,7 +385,7 @@ impl IntermediateOutputASTFragments { // core::hint::must_use is not stable yet: https://github.com/rust-lang/rust/issues/94745 #[inline(always)] pub #inline_wdf_fn_signature { - #(#inline_wdf_fn_body_statments)* + #(#inline_wdf_fn_body_statements)* } } @@ -928,7 +928,7 @@ fn compute_fn_parameters( .collect()) } -/// Compute the return type based on the function defintion +/// Compute the return type based on the function definition /// /// # Examples /// diff --git a/crates/wdk/src/wdf/spinlock.rs b/crates/wdk/src/wdf/spinlock.rs index 0edd567ee..01785ff79 100644 --- a/crates/wdk/src/wdf/spinlock.rs +++ b/crates/wdk/src/wdf/spinlock.rs @@ -26,7 +26,9 @@ impl SpinLock { /// /// # Errors /// - /// This function will return an error if WDF fails to contruct a timer. The error variant will contain a [`NTSTATUS`] of the failure. Full error documentation is available in the [WDFSpinLock Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdfsync/nf-wdfsync-wdfspinlockcreate#return-value) + /// This function will return an error if WDF fails to construct a spinlock. + /// The error variant will contain a [`NTSTATUS`] of the failure. Full error + /// documentation is available in the [WDFSpinLock Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdfsync/nf-wdfsync-wdfspinlockcreate#return-value) pub fn try_new(attributes: &mut WDF_OBJECT_ATTRIBUTES) -> Result { let mut spin_lock = Self { wdf_spin_lock: core::ptr::null_mut(), @@ -51,7 +53,9 @@ impl SpinLock { /// /// # Errors /// - /// This function will return an error if WDF fails to contruct a timer. The error variant will contain a [`NTSTATUS`] of the failure. Full error documentation is available in the [WDFSpinLock Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdfsync/nf-wdfsync-wdfspinlockcreate#return-value) + /// This function will return an error if WDF fails to construct a spinlock. + /// The error variant will contain a [`NTSTATUS`] of the failure. Full error + /// documentation is available in the [WDFSpinLock Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdfsync/nf-wdfsync-wdfspinlockcreate#return-value) pub fn create(attributes: &mut WDF_OBJECT_ATTRIBUTES) -> Result { Self::try_new(attributes) } diff --git a/crates/wdk/src/wdf/timer.rs b/crates/wdk/src/wdf/timer.rs index 7535ca027..83acaddc0 100644 --- a/crates/wdk/src/wdf/timer.rs +++ b/crates/wdk/src/wdf/timer.rs @@ -20,7 +20,9 @@ impl Timer { /// /// # Errors /// - /// This function will return an error if WDF fails to contruct a timer. The error variant will contain a [`NTSTATUS`] of the failure. Full error documentation is available in the [WDFTimer Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdftimer/nf-wdftimer-wdftimercreate#return-value) + /// This function will return an error if WDF fails to construct a timer. + /// The error variant will contain a [`NTSTATUS`] of the failure. Full error + /// documentation is available in the [WDFTimer Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdftimer/nf-wdftimer-wdftimercreate#return-value) pub fn try_new( timer_config: &mut WDF_TIMER_CONFIG, attributes: &mut WDF_OBJECT_ATTRIBUTES, @@ -48,7 +50,9 @@ impl Timer { /// /// # Errors /// - /// This function will return an error if WDF fails to contruct a timer. The error variant will contain a [`NTSTATUS`] of the failure. Full error documentation is available in the [WDFTimer Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdftimer/nf-wdftimer-wdftimercreate#return-value) + /// This function will return an error if WDF fails to construct a timer. + /// The error variant will contain a [`NTSTATUS`] of the failure. Full error + /// documentation is available in the [WDFTimer Documentation](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdftimer/nf-wdftimer-wdftimercreate#return-value) pub fn create( timer_config: &mut WDF_TIMER_CONFIG, attributes: &mut WDF_OBJECT_ATTRIBUTES, diff --git a/examples/sample-kmdf-driver/README.md b/examples/sample-kmdf-driver/README.md index 3c068639b..0b20e2a15 100644 --- a/examples/sample-kmdf-driver/README.md +++ b/examples/sample-kmdf-driver/README.md @@ -16,7 +16,7 @@ * Ex. `\target\x86_64-pc-windows-msvc\debug\package`, `\target\x86_64-pc-windows-msvc\release\package`, `\target\aarch64-pc-windows-msvc\debug\package`, `\target\aarch64-pc-windows-msvc\release\package`, `\target\debug\package`, `\target\release\package` - 2. The version of `devgen.exe` from the WDK Developer Tools that matches the archtecture of your DUT + 2. The version of `devgen.exe` from the WDK Developer Tools that matches the architecture of your DUT * Ex. `C:\Program Files\Windows Kits\10\Tools\10.0.22621.0\x64\devgen.exe`. Note: This path will vary based off your WDK environment 2. Install the Certificate on the DUT: 1. Double click the certificate diff --git a/examples/sample-umdf-driver/README.md b/examples/sample-umdf-driver/README.md index a0fa1a98c..45506a2ac 100644 --- a/examples/sample-umdf-driver/README.md +++ b/examples/sample-umdf-driver/README.md @@ -16,7 +16,7 @@ * Ex. `\target\x86_64-pc-windows-msvc\debug\package`, `\target\x86_64-pc-windows-msvc\release\package`, `\target\aarch64-pc-windows-msvc\debug\package`, `\target\aarch64-pc-windows-msvc\release\package`, `\target\debug\package`, `\target\release\package` - 2. The version of `devgen.exe` from the WDK Developer Tools that matches the archtecture of your DUT + 2. The version of `devgen.exe` from the WDK Developer Tools that matches the architecture of your DUT * Ex. `C:\Program Files\Windows Kits\10\Tools\10.0.22621.0\x64\devgen.exe`. Note: This path will vary based off your WDK environment 2. Install the Certificate on the DUT: 1. Double click the certificate diff --git a/examples/sample-wdm-driver/README.md b/examples/sample-wdm-driver/README.md index 49f218eb2..1ed85cc67 100644 --- a/examples/sample-wdm-driver/README.md +++ b/examples/sample-wdm-driver/README.md @@ -16,7 +16,7 @@ * Ex. `\target\x86_64-pc-windows-msvc\debug\package`, `\target\x86_64-pc-windows-msvc\release\package`, `\target\aarch64-pc-windows-msvc\debug\package`, `\target\aarch64-pc-windows-msvc\release\package`, `\target\debug\package`, `\target\release\package` - 2. The version of `devgen.exe` from the WDK Developer Tools that matches the archtecture of your DUT + 2. The version of `devgen.exe` from the WDK Developer Tools that matches the architecture of your DUT * Ex. `C:\Program Files\Windows Kits\10\Tools\10.0.22621.0\x64\devgen.exe`. Note: This path will vary based off your WDK environment 2. Install the Certificate on the DUT: 1. Double click the certificate diff --git a/tests/wdk-macros-tests/src/lib.rs b/tests/wdk-macros-tests/src/lib.rs index 8d9a46b26..a0946713d 100644 --- a/tests/wdk-macros-tests/src/lib.rs +++ b/tests/wdk-macros-tests/src/lib.rs @@ -41,7 +41,7 @@ pub static TRYBUILD_OUTPUT_FOLDER_PATH: LazyLock = /// reside in the `tests/inputs/macrotest` folder, and may be a path to /// a file relative to the `tests/inputs/macrotest` folder. This macro is /// designed to use one test file per generated test to fully take advantage of -/// parallization of tests in cargo. +/// parallelization of tests in cargo. /// /// Note: Due to limitations in `trybuild`, a successful compilation /// test will include output that looks similar to the following: