diff --git a/.cargo/audit.toml b/.cargo/audit.toml new file mode 100644 index 000000000..fea5c837d --- /dev/null +++ b/.cargo/audit.toml @@ -0,0 +1,12 @@ +[advisories] +ignore = [ + # Ignoring unmaintained 'paste' advisory as it is a widely used, low-risk build dependency. + "RUSTSEC-2024-0436", +] + +[output] +# Deny advisories that are warnings by default. +# At the moment this works if we allow paste, we might want to disable this in the future if it +# becomes too tedious +deny = ["warnings"] +quiet = false diff --git a/.github/workflows/cargo_audit.yml b/.github/workflows/cargo_audit.yml new file mode 100644 index 000000000..14836f63e --- /dev/null +++ b/.github/workflows/cargo_audit.yml @@ -0,0 +1,40 @@ +# Run cargo audit +on: + workflow_dispatch: + schedule: + # runs every day at 4am UTC + - cron: '0 4 * * *' + +env: + CARGO_TERM_COLOR: always + ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + CHECKOUT_TOKEN: ${{ secrets.REPO_CHECKOUT_TOKEN || secrets.GITHUB_TOKEN }} + SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }} + SLACK_ICON: https://pbs.twimg.com/profile_images/1274014582265298945/OjBKP9kn_400x400.png + SLACK_USERNAME: ${{ secrets.BOT_USERNAME }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACKIFY_MARKDOWN: true + +permissions: {} + +jobs: + audit: + name: cargo_audit/audit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 + with: + persist-credentials: 'false' + token: ${{ env.CHECKOUT_TOKEN }} + + - name: Audit dependencies + run: | + make audit_dependencies + + - name: Slack Notification + if: ${{ failure() }} + continue-on-error: true + uses: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 + env: + SLACK_COLOR: ${{ job.status }} + SLACK_MESSAGE: "cargo-audit finished with status: ${{ job.status }}. ([action run](${{ env.ACTION_RUN_URL }}))" diff --git a/Makefile b/Makefile index 59ee47c05..65f5c7a2f 100644 --- a/Makefile +++ b/Makefile @@ -160,9 +160,13 @@ install_tarpaulin: install_rs_build_toolchain ( echo "Unable to install cargo tarpaulin, unknown error." && exit 1 ) .PHONY: install_cargo_dylint # Install custom tfhe-rs lints -install_cargo_dylint: +install_cargo_dylint: install_rs_build_toolchain cargo install --locked cargo-dylint dylint-link +.PHONY: install_cargo_audit # Check dependencies +install_cargo_audit: install_rs_build_toolchain + cargo install --locked cargo-audit + .PHONY: install_typos_checker # Install typos checker install_typos_checker: install_rs_build_toolchain @typos --version > /dev/null 2>&1 || \ @@ -545,6 +549,10 @@ tfhe_lints: install_cargo_dylint RUSTFLAGS="$(RUSTFLAGS)" cargo dylint --all -p tfhe-zk-pok --no-deps -- \ --features=experimental +.PHONY: audit_dependencies # Run cargo audit to check vulnerable dependencies +audit_dependencies: install_rs_build_toolchain install_cargo_audit + cargo audit + .PHONY: build_core # Build core_crypto without experimental features build_core: install_rs_build_toolchain install_rs_check_toolchain