Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/vulnerability-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Vulnerability scan
on:
schedule:
- cron: "0 0 * * *"

@Mshehu5 Mshehu5 Jul 23, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CACK code looks good ran nix build '.#checks.x86_64-linux.cargo-audit' no error outputs was shown.

The PR description says this scan should run weekly but 0 0 * * * runs every day.
A comment will also help readabilty

Suggested change
- cron: "0 0 * * *"
schedule:
# Run weekly on Sunday at 00:00 UTC.
- cron: "0 0 * * 0"

workflow_dispatch:
permissions:
contents: read
id-token: write
concurrency:
group: vulnerability-scan
cancel-in-progress: false
jobs:
scan:
name: Scan dependencies
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Update vulnerability databases
run: nix flake update

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be nix flake update rustsec-advisory-db? a bare update refreshes everything, so vulnix scans the updated closure rather than the pinned one

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

- name: Audit Cargo dependencies
run: nix build '.#checks.x86_64-linux.cargo-audit'
- name: Build development shell closure
run: nix build --out-link result-vulnerability-scan-devshell '.#devShells.x86_64-linux.default'
- name: Build package closures
run: |
nix build --out-link result-vulnerability-scan-default '.#packages.x86_64-linux.default'
nix build --out-link result-vulnerability-scan-validate-commits '.#packages.x86_64-linux.validate-commits'
- name: Cache NVD database
uses: actions/cache@v4
with:
path: ~/.cache/vulnix
key: vulnix-nvd-${{ github.run_id }}
restore-keys: |
vulnix-nvd-
- name: Scan Nix closure
run: |
nix develop -c vulnix --closure \
"$(readlink -f result-vulnerability-scan-devshell)" \
"$(readlink -f result-vulnerability-scan-default)" \
"$(readlink -f result-vulnerability-scan-validate-commits)"
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
rustsec-advisory-db = {
url = "github:RustSec/advisory-db";
flake = false;
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
Expand Down
14 changes: 14 additions & 0 deletions nix/checks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@
checks = testChecks // {
build = toolchains.nightly.buildPackage (checkArgs // { cargoArtifacts = cargoArtifactsRelease; });

cargo-audit =
pkgs.runCommand "cargo-audit-${rev}"
{
inherit src;
nativeBuildInputs = [ pkgs.cargo-audit ];
}
''
cargo-audit audit \
--no-fetch \
--db ${inputs.rustsec-advisory-db} \
--file "$src/Cargo.lock"
mkdir -p $out
'';

mutants = toolchains.nightly.mkCargoDerivation (
checkArgs
// {
Expand Down
2 changes: 2 additions & 0 deletions nix/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
craneLib:
craneLib.devShell {
packages = with pkgs; [
cargo-audit
cargo-llvm-cov
cargo-nextest
cargo-sort
config.packages.validate-commits
config.treefmt.build.wrapper
just
rust-analyzer
vulnix
];
};
in
Expand Down
Loading