From 227c1c9eb253d1b09d9fdf40791315314ab5fd1c Mon Sep 17 00:00:00 2001 From: Philipp Eder Date: Mon, 11 Nov 2024 11:05:29 +0100 Subject: [PATCH 1/2] Seperates linting/Rust into linting/{Rust, Rust-Typos, Rust-Audit} Given the nature of using NASL to identify vulnerabilities we may cannot get rif of all audit findings. To indicate that the CI fails based on an audit, rather than e.g. a clippy warning, cargo audit is seperated into an own job. Since the same may be true for typos, typos are seperated into an own job as well. With that change we can immediately see if a CI of a PR failed because of audit, typos or Rust linting issues. --- .github/actions/setup-rust/action.yml | 12 +++++++++++ .github/workflows/linting.yml | 30 ++++++++++++++++++--------- 2 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 .github/actions/setup-rust/action.yml diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.yml new file mode 100644 index 000000000..be188d042 --- /dev/null +++ b/.github/actions/setup-rust/action.yml @@ -0,0 +1,12 @@ +name: "Setup Rust Environment" +description: "Install necessary dependencies and set up Rust stable" +runs: + using: "composite" + steps: + - run: sudo apt update || true + shell: bash + - run: sudo apt-get install -y libpcap-dev + shell: bash + - run: rustup update stable && rustup default stable || rustup default stable + shell: bash + diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 6b4580f66..e882f604a 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -19,15 +19,25 @@ jobs: working-directory: rust steps: - uses: actions/checkout@v4 - - run: sudo apt update || true - - run: sudo apt-get install -y libpcap-dev - - run: rustup update stable && rustup default stable || rustup default stable - - run: cargo install cargo-audit + - uses: ./.github/actions/setup-rust + - run: cargo clippy -- -D warnings + - run: cargo fmt --check + Rust-Typos: + runs-on: ubuntu-latest + defaults: + run: + working-directory: rust + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-rust - run: cargo install typos-cli - - name: Clippy - run: cargo clippy -- -D warnings - - name: Audit - run: cargo audit - run: typos - - name: Formatting - run: cargo fmt --check + Rust-Audit: + runs-on: ubuntu-latest + defaults: + run: + working-directory: rust + steps: + - uses: actions/checkout@v4 + - run: cargo install cargo-audit + - run: cargo audit From 6cedbf81a8a3615057fa5989823d2130c3cd6dbe Mon Sep 17 00:00:00 2001 From: Philipp Eder Date: Mon, 11 Nov 2024 11:18:36 +0100 Subject: [PATCH 2/2] Fixes formatting issues --- rust/src/nasl/builtin/cryptographic/tests/mod.rs | 1 - rust/src/osp/response.rs | 2 -- 2 files changed, 3 deletions(-) diff --git a/rust/src/nasl/builtin/cryptographic/tests/mod.rs b/rust/src/nasl/builtin/cryptographic/tests/mod.rs index e413d6ec0..b9ec1aca2 100644 --- a/rust/src/nasl/builtin/cryptographic/tests/mod.rs +++ b/rust/src/nasl/builtin/cryptographic/tests/mod.rs @@ -10,4 +10,3 @@ mod helper; mod hmac; mod rc4; mod rsa; - diff --git a/rust/src/osp/response.rs b/rust/src/osp/response.rs index 4eefb8c1c..bebe31137 100644 --- a/rust/src/osp/response.rs +++ b/rust/src/osp/response.rs @@ -13,7 +13,6 @@ use super::commands::Error; #[derive(Clone, Copy, Debug, Default, PartialEq)] pub struct StringU64(u64); - impl From for StringU64 { fn from(value: i64) -> Self { StringU64(value as u64) @@ -735,7 +734,6 @@ mod tests { } } - #[test] fn init_response() { let xml = r#"