Skip to content
Merged
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
155 changes: 52 additions & 103 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,117 +11,122 @@ on:
env:
REGISTRY: gcr.io
IMAGE_NAME: ${{ secrets.GCR_PROJECT_ID }}/redvector
CARGO_TERM_COLOR: always
# The root manifest has no [workspace], so `cargo test --all` only covers the
# binary crate. List the member crates explicitly so their unit tests run.
TEST_CRATES: >-
-p redvector -p parser -p response -p database -p command -p networking
-p persistence -p config -p util -p compat -p logger

jobs:
fmt:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: Check formatting
run: cargo fmt --all -- --check

test:
name: Test Suite
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [stable, nightly]
steps:
- uses: actions/checkout@v4


# `uses:` cannot contain expressions, so pick the toolchain via input.
- name: Install Rust
uses: dtolnay/rust-toolchain@${{ matrix.rust }}

uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}

- name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler

- name: Cache Cargo dependencies
uses: actions/cache@v3
uses: Swatinem/rust-cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.rust }}-

key: ${{ matrix.rust }}

# test_large_dataset takes ~15 min in a debug build; run it locally.
- name: Run tests
run: cargo test --all --verbose
run: cargo test --features full $TEST_CRATES -- --skip test_large_dataset

build:
name: Build Release
runs-on: ubuntu-latest
needs: [fmt, test]
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable


- name: Install protoc
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler

- name: Cache Cargo dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-stable-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-stable-

uses: Swatinem/rust-cache@v2

- name: Build release binary
run: cargo build --release --verbose
run: cargo build --release --features full

- name: Upload release artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: redvector-binary
path: target/release/redvector
retention-days: 30

# Publishes images only for version tags. GitHub releases for tags are
# created by build-release.yml.
docker-build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [fmt, test]
if: github.event_name == 'push'
needs: [build]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4


- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3


- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCR_SA_KEY }}

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
service_account_key: ${{ secrets.GCR_SA_KEY }}
project_id: ${{ secrets.GCR_PROJECT_ID }}

- name: Configure Docker for GCR
run: gcloud auth configure-docker ${{ env.REGISTRY }} --quiet

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}

type=raw,value=latest

- name: Build and push Docker image (Debian)
uses: docker/build-push-action@v5
with:
Expand All @@ -133,7 +138,7 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64

- name: Build and push Docker image (Distroless)
uses: docker/build-push-action@v5
with:
Expand All @@ -145,59 +150,3 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64

release:
name: Create Release
runs-on: ubuntu-latest
needs: [build, docker-build]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download release artifacts
uses: actions/download-artifact@v3
with:
name: redvector-binary
path: ./artifacts

- name: Get version from tag
id: tag
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

- name: Generate changelog
id: changelog
run: |
CHANGELOG=$(git log --pretty=format:"- %s (%h)" $(git describe --tags --abbrev=0 HEAD^)..HEAD)
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/redvector
name: Release v${{ steps.tag.outputs.VERSION }}
body: |
## Release v${{ steps.tag.outputs.VERSION }}

### Changes
${{ steps.changelog.outputs.CHANGELOG }}

### Docker Images
- `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.tag.outputs.VERSION }}`
- `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest`
- `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:distroless-v${{ steps.tag.outputs.VERSION }}`

### Installation
```bash
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.tag.outputs.VERSION }}
```
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

35 changes: 35 additions & 0 deletions .oss-scanner/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Build environment for Anthropic OSS Scanner (https://github.com/anthropics/oss-scanner).
# Built with the repository root as context; network is removed after this build,
# so every dependency is fetched here.
FROM rust:1.91-bookworm

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates pkg-config libssl-dev protobuf-compiler clang git tcl redis-tools \
&& rm -rf /var/lib/apt/lists/*

# scanner contract: the checkout lives inside the image, at /src
COPY . /src
WORKDIR /src

# Resolve and download all crates while network is still available.
RUN cargo generate-lockfile && cargo fetch

ENV CARGO_NET_OFFLINE=true \
RUSTFLAGS="-C force-frame-pointers=yes" \
CARGO_PROFILE_RELEASE_DEBUG=true \
RUST_BACKTRACE=1

# Debug build (fast to rebuild, debug assertions + overflow checks on) and a
# release build with debug info, both with every feature the server ships with.
RUN cargo build --all --features full \
&& cargo build --release --features full

# The root manifest has no [workspace]; unit tests live in the member crates.
ENV TEST_CRATES="-p redvector -p parser -p response -p database -p command -p networking -p persistence -p config -p util -p compat -p logger"

# Compile all test targets so agents can run them offline.
RUN cargo test --features full $TEST_CRATES --no-run

# Run the cheap tests (test_large_dataset takes ~15 min in debug), but do not fail the image on test failures.
RUN cargo test --features full $TEST_CRATES -- --skip test_large_dataset || echo "WARNING: cargo test reported failures"
4 changes: 4 additions & 0 deletions .oss-scanner/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used instead of the root .dockerignore when building .oss-scanner/Dockerfile:
# the scanner needs tests, docs and configs that the release image excludes.
target/
.git/
59 changes: 59 additions & 0 deletions .oss-scanner/threat_model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Threat model

## What this project does and where untrusted input enters
RedVector is an in-memory, Redis-compatible vector database written in Rust. It is a network
server; treat every byte arriving on its listeners as attacker-controlled:

- **RESP (Redis protocol), TCP 6379** — `parser/`, `networking/`, `command/`. Primary attack surface.
Assume the attacker can connect and send arbitrary commands, including before `AUTH` when a
password is configured.
- **REST API, TCP 8888** (`--features api-server`) — `src/api.rs`, `src/qdrant_api.rs` (Qdrant-compatible
JSON API, including SQL parsing via `sqlparser`).
- **gRPC API, TCP 50051** (`--features api-server`) — `proto/`, `src/api.rs`.
- **Persistence files** — RDB/AOF loading in `persistence/` and `database/rdbutil/`. Treat files on
disk as untrusted (e.g. an RDB copied from elsewhere or replicated from a malicious master).
- **Configuration** (`config/`, `redvector.conf`) is trusted operator input; out of scope unless a
client can change it remotely (e.g. `CONFIG SET`).

## Components that matter most / least
- Most: RESP parser and networking, command dispatch and argument handling, authentication/ACL
checks, vector index code (`database/`, HNSW, `redisearch-platform-core/`) reachable via `FT.*`,
REST/gRPC handlers, RDB/AOF loaders.
- Less: `benchmarks/`, `deploy/`, `docs/`, Dockerfiles, CI workflows — out of scope.
- `redisearch-platform-core` GPU / RVF2 / S3 modules are feature-gated and not enabled by `full`;
low priority.

## How to exercise it
- Build: `cargo build --features full` (already done in the image; binary at `target/debug/redvector`
and `target/release/redvector`).
- Run: `target/debug/redvector` listens on 6379 (and 8888/50051 with `full`). Talk to it with
`redis-cli` (installed) or raw TCP.
- Unit tests: `cargo test --features full $TEST_CRATES` (env var lists the member crates; the root
manifest has no `[workspace]`, so plain `cargo test` only runs the binary's tests). `tests/` holds the Tcl Redis-compat suite
(`tclsh` installed).

## How you rate severity
- **Critical**: remote code execution, or memory corruption in `unsafe` code reachable from the
network; authentication bypass giving full data access.
- **High**: pre-auth or low-privilege remote crash (panic, abort, OOM, stack overflow) from a
single request or small number of requests; reading/writing keys or vectors the client should
not access; path traversal or arbitrary file write via commands or APIs.
- **Medium**: crash or resource exhaustion that needs an authenticated client and sustained or
large traffic; unbounded allocation driven by a size field the client controls; malicious
RDB/AOF files causing a crash on load.
- **Low**: information leaks of non-sensitive internals, incorrect error handling without
security impact.
- A `panic!`/`unwrap()` that kills the whole server process from a client request is a DoS and
should be reported (rate as above), not dismissed as "just a panic".

## Reports
- Include a minimal reproducer (a `redis-cli` command sequence, raw RESP bytes, `curl`
request, or crafted file) plus the stack trace.
- A minimal patch that fixes the root cause is preferred over a large refactor.
- Deduplicate by root cause: many commands hitting the same faulty helper are one report.

## Anything to leave alone
- Differences from upstream Redis behaviour that have no security impact.
- Missing features or incomplete persistence documented in README "Current limitations".
- Vulnerabilities in third-party crates unless RedVector uses them in a way that is itself the bug.
- Lack of TLS or default no-password configuration (documented operator choice).
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Multi-stage Dockerfile for RedVector - Redis-compatible Vector Database
# Stage 1: Build
# 1.85+ required: transitive crates (e.g. getrandom 0.4) use edition2024
FROM rust:1.85-slim AS builder
# 1.88+ required: transitive crates (icu_*, idna_adapter) need rustc 1.88
FROM rust:1.91-slim AS builder

# Install build dependencies
RUN apt-get update && apt-get install -y \
Expand All @@ -14,7 +14,7 @@ RUN apt-get update && apt-get install -y \
WORKDIR /build

# Copy manifests first for better caching
COPY Cargo.toml Cargo.lock ./
COPY Cargo.toml Cargo.lock* ./
COPY build.rs ./
COPY proto/ ./proto/
COPY command/Cargo.toml ./command/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.distroless
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Multi-stage Dockerfile for redvector - Ultra-minimal distroless version
# Using Debian for build, distroless for ultra-minimal runtime (no shell, no package manager)
# Stage 1: Build dependencies
FROM rust:1.85-slim AS builder
FROM rust:1.91-slim AS builder

# Install build dependencies
RUN apt-get update && apt-get install -y \
Expand Down
20 changes: 20 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Security Policy

## Reporting a vulnerability

Please report security vulnerabilities privately by email to **rafaelescrich@gmail.com**,
or through GitHub's private vulnerability reporting
("Security" tab → "Report a vulnerability") on this repository.

Please do not open public issues for security problems. Include a description, affected
version/commit, and steps or a proof of concept to reproduce. You should get an
acknowledgement within 7 days.

## Supported versions

Only the latest release and `main` receive security fixes.

## Automated scanning

This project is enrolled in Anthropic's OSS Scanner. The build environment and threat model
used by the scanner are in [`.oss-scanner/`](.oss-scanner/).
3 changes: 1 addition & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ fn main() {
#[cfg(feature = "api-server")]
{
println!("cargo:rerun-if-changed=proto/redvector.proto");
tonic_build::compile_protos("proto/redvector.proto")
.expect("Failed to compile protobuf");
tonic_build::compile_protos("proto/redvector.proto").expect("Failed to compile protobuf");
}
}
Loading
Loading