This is an automated email from the ASF dual-hosted git repository.
viirya pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-connect-gateway.git
The following commit(s) were added to refs/heads/main by this push:
new 4e6676d [SPARK-60370] Run cargo audit in CI on a daily schedule and
on dependency changes
4e6676d is described below
commit 4e6676dbd51f1b375f5a4c5f065d8c9533d43f0f
Author: Liang-Chi Hsieh <[email protected]>
AuthorDate: Fri Oct 23 09:29:17 2026 -0700
[SPARK-60370] Run cargo audit in CI on a daily schedule and on dependency
changes
### What changes were proposed in this pull request?
Run `cargo audit` in CI, checking `Cargo.lock` against the RustSec advisory
database.
| File | Purpose |
|---|---|
| `.github/workflows/audit.yml` | The workflow (triggers below) |
| `dev/audit-new-advisories.sh` | Pull-request check: report only
advisories the change introduces |
| `.cargo/audit.toml` | Ignores RUSTSEC-2023-0071 (`rsa`), pointing at
SPARK-60369 |
The workflow keeps two questions apart:
- **Is `main` affected by a known advisory?** A daily schedule (and
`workflow_dispatch`) runs a full `cargo audit` on `main`.
- **Does this change introduce one?** Pull requests that touch
`Cargo.lock`, a
`Cargo.toml`, `.cargo/audit.toml`, or the audit tooling run
`dev/audit-new-advisories.sh`. It audits the base revision's `Cargo.lock`
and
the pull request's against the same snapshot of the database, and fails
only
on advisory/crate pairs that the base does not have. Advisories already on
`main` are listed but not counted against the pull request.
There is **no push trigger**. A merge has already been checked as a pull
request, and a full audit on push would mark every dependency merge red
while
`main` carries any unfixed advisory, including merges that fix one.
`dev/audit-new-advisories.sh` exits 0 when nothing is introduced, 1 when
something is, and 2 when `cargo audit` cannot produce a report. `cargo
audit`
itself exits 1 on findings, so its status cannot tell a finding from a
failure
(for example, the database could not be fetched); the script requires a JSON
report and treats anything else as an error rather than a pass. Pairs are
compared without versions, so moving a crate from one affected version to
another does not count as new.
`cargo-audit` is installed with `cargo install --version 0.22.1 --locked`
instead of a third-party action, to stay within the Apache GitHub Actions
allowlist. Checkout and toolchain setup are the same pinned steps `ci.yml`
uses.
### Why are the changes needed?
Nothing in CI checked dependencies for known vulnerabilities. Three
advisories
(`h2`, `rustls`, `rsa`) sat on `main` with CI green and were found only by
running `cargo audit` by hand. The `h2` fix from SPARK-60115 is a
`--precise`
pin on a transitive dependency, which a later `cargo update` or a `hyper` /
`tonic` bump could silently undo.
The reason for not simply failing on any advisory: the database changes
daily,
so such a check would turn pull requests red for vulnerabilities they did
not
introduce -- the failure mode SPARK-59989 fixed for the floating Rust
toolchain.
While this change was being prepared, eleven new advisories affecting the
lockfile were published, so this is not hypothetical.
**The `rsa` ignore.** RUSTSEC-2023-0071 (Marvin Attack) has no fixed
release:
0.9.10 is the latest stable and 0.10 exists only as a release candidate. The
attack recovers a private key from the timing of private-key operations. The
gateway only verifies RS256 signatures with public keys through
`jsonwebtoken`;
every `EncodingKey` / `RsaPrivateKey` use is inside `#[cfg(test)]`, and the
direct `rsa` dependency is a dev-dependency. SPARK-60369 tracks removing the
ignore and lists when to revisit it.
**What to expect after merge.** The scheduled run will be red until the
advisories currently on `main` are fixed: #51 (SPARK-60371) addresses nine
of
them, and RUSTSEC-2026-0381 / -0382 (`webpki-roots`, `rustls-webpki`) will
be
handled separately. That is the intended signal. Pull requests are not
affected by it.
### Does this PR introduce _any_ user-facing change?
No. CI only.
### How was this patch tested?
`dev/audit-new-advisories.sh` was run locally against real lockfiles:
| Base | Head | Result |
|---|---|---|
| `main` | `main` | exit 0; existing advisories listed as already present |
| `main` | #51's lockfile | exit 0; nine advisories listed as resolved |
| `main` | `main` before SPARK-60115 (`h2` 0.4.15) | **exit 1**;
RUSTSEC-2026-0258 reported as introduced |
| -- | no arguments / missing file | exit 2 |
| `main` | unparseable lockfile (also tried as base) | exit 2, not a pass |
RUSTSEC-2023-0071 is absent from every report, confirming
`.cargo/audit.toml`
is honoured when a lockfile is given with `--file`.
The base-lockfile step (`git fetch --no-tags --depth=1 origin <base sha>`
with
credentials not persisted, then `git show <sha>:Cargo.lock`) was exercised
in a
fresh shallow clone of this repository that did not contain the commit.
This pull request does not change `Cargo.lock`, so its own pull-request
check
should report no introduced advisories.
### Was this patch authored or co-authored using generative AI tooling?
Yes, co-authored with Claude Code.
Closes #52 from viirya/ci-12-cargo-audit.
Authored-by: Liang-Chi Hsieh <[email protected]>
Signed-off-by: Liang-Chi Hsieh <[email protected]>
---
.cargo/audit.toml | 29 ++++++++++++
.github/workflows/audit.yml | 98 ++++++++++++++++++++++++++++++++++++++++
dev/audit-new-advisories.sh | 106 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 233 insertions(+)
diff --git a/.cargo/audit.toml b/.cargo/audit.toml
new file mode 100644
index 0000000..07c50bc
--- /dev/null
+++ b/.cargo/audit.toml
@@ -0,0 +1,29 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Configuration for `cargo audit`, run by .github/workflows/audit.yml.
+#
+# Every ignore below must name the issue that tracks removing it. An ignore
+# without one tends to outlive the reason it was added.
+
+[advisories]
+ignore = [
+ # RUSTSEC-2023-0071, rsa: Marvin Attack timing sidechannel on RSA
+ # private-key operations. No fixed release exists. The gateway only
+ # verifies RS256 signatures with public keys (via jsonwebtoken); every
+ # private-key use is test-only. Tracked by SPARK-60369, which also lists
+ # the conditions for removing this entry.
+ "RUSTSEC-2023-0071",
+]
diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml
new file mode 100644
index 0000000..caf0fcd
--- /dev/null
+++ b/.github/workflows/audit.yml
@@ -0,0 +1,98 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Checks Cargo.lock against the RustSec advisory database.
+#
+# The advisory database changes daily, so a check that fails on *any* advisory
+# would turn pull requests red for vulnerabilities they did not introduce --
+# the same failure mode as a floating toolchain. The two questions are kept
+# apart instead:
+#
+# - Is main affected by a known advisory? The daily schedule (and
+# workflow_dispatch) runs a full `cargo audit` on main.
+# - Does this change introduce one? Pull requests that touch the dependency
+# set run dev/audit-new-advisories.sh, which fails only on advisories the
+# pull request's Cargo.lock has and its base's does not. Advisories already
+# on main are listed but not counted against the pull request.
+#
+# There is no push trigger: a merge is already checked as a pull request, and a
+# full audit on push would mark every dependency merge red while main carries
+# any unfixed advisory -- including merges that fix one.
+#
+# Advisories with no fixed release are ignored in .cargo/audit.toml, each
+# naming the issue that tracks it.
+
+name: Security audit
+
+on:
+ schedule:
+ - cron: "23 4 * * *"
+ workflow_dispatch:
+ pull_request:
+ branches: [main]
+ paths:
+ - "Cargo.lock"
+ - "Cargo.toml"
+ - "crates/*/Cargo.toml"
+ - ".cargo/audit.toml"
+ - ".github/workflows/audit.yml"
+ - "dev/audit-new-advisories.sh"
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
+
+jobs:
+ audit:
+ name: cargo audit
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #
v4.2.2
+ with:
+ persist-credentials: false
+
+ - name: Setup Rust toolchain
+ uses: ./.github/actions/setup-builder
+ with:
+ rust-version: stable
+
+ # Installed from crates.io rather than through a third-party action, to
+ # stay within the Apache GitHub Actions allowlist. Pinned so a new
+ # cargo-audit release cannot change the result without a reviewed bump.
+ - name: Install cargo-audit
+ run: cargo install cargo-audit --version 0.22.1 --locked
+
+ - name: Audit main
+ if: github.event_name != 'pull_request'
+ run: cargo audit
+
+ # Only the base revision's Cargo.lock is needed; fetch that one commit
+ # rather than the full history.
+ - name: Fetch base Cargo.lock
+ if: github.event_name == 'pull_request'
+ env:
+ BASE_SHA: ${{ github.event.pull_request.base.sha }}
+ run: |
+ git fetch --no-tags --depth=1 origin "$BASE_SHA"
+ git show "$BASE_SHA:Cargo.lock" > "$RUNNER_TEMP/base.Cargo.lock"
+
+ - name: Audit for advisories introduced by this pull request
+ if: github.event_name == 'pull_request'
+ run: dev/audit-new-advisories.sh "$RUNNER_TEMP/base.Cargo.lock"
Cargo.lock
diff --git a/dev/audit-new-advisories.sh b/dev/audit-new-advisories.sh
new file mode 100755
index 0000000..2b0e73c
--- /dev/null
+++ b/dev/audit-new-advisories.sh
@@ -0,0 +1,106 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# USAGE-BEGIN
+# Report RustSec advisories that a change introduces, leaving out ones that are
+# already present on the revision it is based on.
+#
+# dev/audit-new-advisories.sh BASE_LOCKFILE [HEAD_LOCKFILE]
+#
+# HEAD_LOCKFILE defaults to ./Cargo.lock. Both lockfiles are checked with
+# `cargo audit`, which honours .cargo/audit.toml, against the same snapshot of
+# the advisory database.
+#
+# Exit status: 0 if HEAD has no advisory that BASE lacks, 1 if it does, 2 on a
+# usage error or if `cargo audit` could not produce a report.
+#
+# This is what CI runs on pull requests. Advisories already present on main are
+# reported by the scheduled run instead, so a pull request is only held
+# responsible for what it changes.
+# USAGE-END
+
+set -euo pipefail
+
+usage() {
+ sed -n '/^# USAGE-BEGIN$/,/^# USAGE-END$/{/USAGE-/d;s/^# \{0,1\}//;p;}' "$0"
+}
+
+case "${1:-}" in
+ -h|--help) usage; exit 0 ;;
+esac
+if [[ $# -lt 1 || $# -gt 2 ]]; then
+ usage >&2
+ exit 2
+fi
+base="$1"
+head="${2:-Cargo.lock}"
+for f in "$base" "$head"; do
+ if [[ ! -f "$f" ]]; then
+ echo "error: no such file: $f" >&2
+ exit 2
+ fi
+done
+
+tmp="$(mktemp -d)"
+trap 'rm -rf "$tmp"' EXIT
+
+# `cargo audit` exits 1 when it finds advisories, so its exit status cannot
tell
+# a finding from a failure (say, the advisory database could not be fetched).
+# Anything that is not a JSON report counts as a failure.
+audit() {
+ local lockfile="$1" out="$2"
+ shift 2
+ cargo audit --json --file "$lockfile" "$@" >"$out" 2>"$tmp/stderr" || true
+ if ! jq -e '.vulnerabilities.list' "$out" >/dev/null 2>&1; then
+ echo "error: cargo audit did not produce a report for $lockfile:" >&2
+ cat "$tmp/stderr" >&2
+ exit 2
+ fi
+}
+
+# One line per advisory and affected crate. Versions are left out on purpose: a
+# change that moves a crate from one affected version to another has not
+# introduced anything new.
+keys() {
+ jq -r '.vulnerabilities.list[] | "\(.advisory.id) \(.package.name)"' "$1" |
sort -u
+}
+
+# The first run fetches the advisory database; the second reuses that copy, so
+# an advisory published in between cannot show up as introduced by the change.
+audit "$head" "$tmp/head.json"
+audit "$base" "$tmp/base.json" --no-fetch
+keys "$tmp/head.json" >"$tmp/head"
+keys "$tmp/base.json" >"$tmp/base"
+
+new="$(comm -13 "$tmp/base" "$tmp/head")"
+existing="$(comm -12 "$tmp/base" "$tmp/head")"
+resolved="$(comm -23 "$tmp/base" "$tmp/head")"
+
+report() {
+ local title="$1" body="$2"
+ [[ -n "$body" ]] || return 0
+ echo "$title"
+ sed 's/^/ /' <<<"$body"
+}
+report "Resolved by this change:" "$resolved"
+report "Already present on the base revision (not counted here):" "$existing"
+
+if [[ -n "$new" ]]; then
+ report "Introduced by this change:" "$new"
+ exit 1
+fi
+echo "No advisories introduced by this change."
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]