Skip to content

Find the holes before someone else does. A fast, 100% Rust vulnerability scanner: XSS, SQL injection, leaked secrets, dependency CVEs and AI agent setups.

ci: checks, self-scan and release workflows

Kamc69ef8e0b4ca
diff --git a/.coderabbit.yaml b/.coderabbit.yaml
new file mode 100644
index 0000000..1fcc91e
--- /dev/null
+++ b/.coderabbit.yaml
@@ -0,0 +1,5 @@
+# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
+reviews:
+ auto_review:
+ ignore_usernames:
+ - "dependabot[bot]"
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
new file mode 100755
index 0000000..ddc8648
--- /dev/null
+++ b/.githooks/pre-commit
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec sh scripts/check-secrets.sh
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..4ed48ea
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,2 @@
+github: [erkamyaman]
+buy_me_a_coffee: erkamyaman
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..db9a65e
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,46 @@
+name: CI
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+
+permissions:
+ contents: read
+
+jobs:
+ actionlint:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+ - uses: docker://rhysd/actionlint:1.7.12
+ with:
+ args: -color
+
+ msrv:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+ - uses: dtolnay/[email protected]
+ - uses: Swatinem/rust-cache@v2
+ - run: cargo check --locked --all-targets
+
+ check:
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ubuntu-latest, macos-latest, windows-latest]
+ runs-on: ${{ matrix.os }}
+ steps:
+ - uses: actions/checkout@v7
+ - if: runner.os == 'Linux'
+ run: sh scripts/check-secrets.sh --all
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ components: rustfmt, clippy
+ - uses: Swatinem/rust-cache@v2
+ - run: cargo fmt --check
+ - run: cargo clippy --all-targets -- -D warnings
+ - run: cargo test
+ - name: Scan this repository with itself
+ run: cargo run --release --quiet -- . --offline
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..12a0bf4
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,125 @@
+name: Release
+
+on:
+ push:
+ tags: ['v*']
+
+permissions:
+ contents: read
+
+jobs:
+ build:
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - { os: ubuntu-22.04, target: x86_64-unknown-linux-gnu, npm: linux-x64 }
+ - { os: ubuntu-22.04-arm, target: aarch64-unknown-linux-gnu, npm: linux-arm64 }
+ - { os: macos-latest, target: aarch64-apple-darwin, npm: darwin-arm64 }
+ - { os: macos-latest, target: x86_64-apple-darwin, npm: darwin-x64 }
+ - { os: windows-latest, target: x86_64-pc-windows-msvc, npm: win32-x64 }
+ runs-on: ${{ matrix.os }}
+ steps:
+ - uses: actions/checkout@v7
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: ${{ matrix.target }}
+ - name: Check the tag matches Cargo.toml
+ shell: bash
+ run: |
+ version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
+ test "v$version" = "$GITHUB_REF_NAME" || { echo "tag $GITHUB_REF_NAME, Cargo.toml $version"; exit 1; }
+ - run: cargo build --release --locked --target ${{ matrix.target }}
+ - name: Package
+ shell: bash
+ run: |
+ name="safe-anything-$GITHUB_REF_NAME-${{ matrix.target }}"
+ bin="target/${{ matrix.target }}/release/safe-anything"
+ [ -f "$bin.exe" ] && bin="$bin.exe"
+ mkdir -p "dist/$name" npm-bin
+ cp "$bin" README.md LICENSE CHANGELOG.md "dist/$name/"
+ cp "$bin" npm-bin/
+ cd dist
+ if [ "$RUNNER_OS" = Windows ]; then 7z a "$name.zip" "$name" > /dev/null; else tar czf "$name.tar.gz" "$name"; fi
+ rm -rf "$name"
+ - uses: actions/upload-artifact@v4
+ with:
+ name: dist-${{ matrix.target }}
+ path: dist/*
+ if-no-files-found: error
+ - uses: actions/upload-artifact@v4
+ with:
+ name: npm-${{ matrix.npm }}
+ path: npm-bin/*
+ if-no-files-found: error
+
+ github:
+ needs: build
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ steps:
+ - uses: actions/checkout@v7
+ - uses: actions/download-artifact@v8
+ with:
+ pattern: dist-*
+ path: dist
+ merge-multiple: true
+ - name: Create the GitHub release
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ (cd dist && sha256sum -- * > SHA256SUMS)
+ version="${GITHUB_REF_NAME#v}"
+ awk -v v="$version" '/^## /{ if (on) exit; if (index($0, "## " v " ") == 1) { on = 1; next } } on' CHANGELOG.md > notes.md
+ gh release create "$GITHUB_REF_NAME" dist/* --title "$GITHUB_REF_NAME" --notes-file notes.md --verify-tag
+
+ npm:
+ needs: build
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ id-token: write
+ steps:
+ - uses: actions/checkout@v7
+ - uses: actions/setup-node@v7
+ with:
+ node-version: 24
+ registry-url: https://registry.npmjs.org
+ - run: npm install -g npm@latest
+ - uses: actions/download-artifact@v8
+ with:
+ pattern: npm-*
+ path: npm-bin
+ - name: Publish to npm (trusted publishing)
+ run: |
+ version="${GITHUB_REF_NAME#v}"
+ dir=$(node scripts/npm-packages.mjs "$version" npm-bin npm-out)
+ if npm view "safe-anything@$version" version > /dev/null 2>&1; then
+ echo "safe-anything@$version is already on npm"
+ else
+ npm publish "$dir" --access public
+ fi
+
+ crates:
+ needs: build
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ id-token: write
+ steps:
+ - uses: actions/checkout@v7
+ - uses: dtolnay/rust-toolchain@stable
+ - id: auth
+ uses: rust-lang/crates-io-auth-action@v1
+ - name: Publish to crates.io (trusted publishing)
+ env:
+ CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
+ run: |
+ version="${GITHUB_REF_NAME#v}"
+ if curl -sf -A "safe-anything-release (github.com/erkamyaman/safe-anything)" \
+ "https://crates.io/api/v1/crates/safe-anything/$version" > /dev/null; then
+ echo "safe-anything $version is already on crates.io"
+ else
+ cargo publish --locked
+ fi
diff --git a/.safe-anything-ignore b/.safe-anything-ignore
new file mode 100644
index 0000000..074209c
--- /dev/null
+++ b/.safe-anything-ignore
@@ -0,0 +1,4 @@
+# Test fixtures hold fake vulnerabilities and fake keys on purpose.
+tests/fixtures/
+# The README GIF page quotes real findings from other repositories.
+docs/assets/gif/
diff --git a/hk.pkl b/hk.pkl
new file mode 100644
index 0000000..82dcb5b
--- /dev/null
+++ b/hk.pkl
@@ -0,0 +1,16 @@
+amends "package://github.com/jdx/hk/releases/download/v2.13.0/[email protected]#/Config.pkl"
+
+steps {
+ ["secrets"] = new Step {
+ check = "sh scripts/check-secrets.sh"
+ }
+ ["cargo-fmt"] = new Step {
+ glob = List("src/**/*.rs", "tests/**/*.rs", "build.rs")
+ check = "cargo fmt --check"
+ fix = "cargo fmt"
+ }
+ ["cargo-clippy"] = new Step {
+ glob = List("src/**/*.rs", "tests/**/*.rs", "build.rs", "Cargo.toml")
+ check = "cargo clippy --all-targets --quiet -- -D warnings"
+ }
+}
diff --git a/scripts/check-secrets.sh b/scripts/check-secrets.sh
new file mode 100644
index 0000000..f6fa0ea
--- /dev/null
+++ b/scripts/check-secrets.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Refuses keys, tokens and personal home-folder paths in what git would commit.
+# Staged files by default; --all checks every tracked file.
+# Enable once per clone: git config core.hooksPath .githooks
+set -u
+
+if [ "${1:-}" = "--all" ]; then
+ files=$(git ls-files)
+ show() { cat -- "$1"; }
+else
+ files=$(git diff --cached --name-only --diff-filter=ACMR)
+ show() { git show ":$1"; }
+fi
+
+patterns='BEGIN [A-Z ]*PRIVATE KEY|AKIA[0-9A-Z]{16}|gh[pousr]_[A-Za-z0-9]{30,}|github_pat_[A-Za-z0-9_]{40,}|npm_[A-Za-z0-9]{36}|sk-(ant-|proj-)?[A-Za-z0-9_-]{24,}|xox[abpr]-[A-Za-z0-9-]{10,}|/Users/[A-Za-z0-9._-]+/|/home/[A-Za-z0-9._-]+/|[A-Za-z]:\\\\Users\\\\[A-Za-z0-9._-]+'
+placeholders='/(Users|home)/(user|u|runner|me|you|name|example|someone|USER|<[^>]*>)/|[A-Za-z]:\\\\Users\\\\(user|runneradmin|USER)'
+
+found=0
+for f in $files; do
+ case "$f" in
+ scripts/check-secrets.sh|tests/fixtures/*) continue ;;
+ esac
+ hits=$(show "$f" 2>/dev/null | grep -nIE "$patterns" | grep -vE "$placeholders")
+ if [ -n "$hits" ]; then
+ printf '%s\n' "$hits" | sed "s|^|$f:|" | cut -c1-200
+ found=1
+ fi
+done
+
+if [ "$found" -ne 0 ]; then
+ echo >&2 "check-secrets: the lines above look like a key, a token or a personal path."
+ echo >&2 "Replace them with a placeholder (sk-test, /home/user/...), or commit with --no-verify if they are fakes."
+ exit 1
+fi