Skip to content

Commit 56ea8f6

Browse files
committed
fix(docker): pre-create /db directory and fix parent dir creation in download()
- Set GEM_AUDIT_DB=/db with a pre-created /db directory in the image, replacing the previous default of ~/.local/share/ruby-advisory-db which does not exist in distroless containers - download() now calls create_dir_all on the parent path before cloning to prevent gix failures when parent directories are absent - Bump version to 2.3.3
1 parent 886bc81 commit 56ea8f6

5 files changed

Lines changed: 25 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
### 2.3.3 / 2026-03-01
2+
3+
#### Fixed
4+
5+
* `download()` now calls `create_dir_all` on the parent directory before
6+
cloning, preventing failures when the default path (`/root/.local/share/`)
7+
does not exist in the container.
8+
* Docker image default `GEM_AUDIT_DB` changed from `~/.local/share/ruby-advisory-db`
9+
to `/db`, a pre-created writable directory in the image that works without
10+
any volume mount or environment override.
11+
12+
---
13+
114
### 2.3.2 / 2026-03-01
215

316
#### Fixed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "gem-audit"
3-
version = "2.3.2"
3+
version = "2.3.3"
44
edition = "2024"
55
description = "Fast, standalone security auditor for Gemfile.lock"
66
license = "MIT"

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ FROM gcr.io/distroless/cc-debian13:debug
1212

1313
COPY --from=builder /build/target/release/gem-audit /usr/local/bin/gem-audit
1414

15+
# Pre-create a writable directory for the advisory database.
16+
# Override with GEM_AUDIT_DB (e.g. in GitLab CI point to $CI_PROJECT_DIR).
17+
RUN ["/busybox/mkdir", "-p", "/db"]
18+
ENV GEM_AUDIT_DB=/db
19+
1520
WORKDIR /workspace
1621

1722
ENTRYPOINT ["gem-audit"]

src/advisory/database.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ impl Database {
5151

5252
/// Download the ruby-advisory-db to the given path.
5353
pub fn download(path: &Path, _quiet: bool) -> Result<Self, DatabaseError> {
54+
// Ensure the parent directory exists; gix does not create it automatically.
55+
if let Some(parent) = path.parent() {
56+
std::fs::create_dir_all(parent).map_err(DatabaseError::Io)?;
57+
}
58+
5459
let (mut checkout, _outcome) = gix::prepare_clone(ADVISORY_DB_URL, path)
5560
.map_err(|e| DatabaseError::DownloadFailed(e.to_string()))?
5661
.fetch_then_checkout(gix::progress::Discard, &gix::interrupt::IS_INTERRUPTED)

0 commit comments

Comments
 (0)