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
4 changes: 4 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ jobs:
context: .
platforms: linux/amd64,linux/arm64
push: true
provenance: true
sbom: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Sign Container Image with Cosign (Keyless Sigstore)
if: steps.build-and-push.outputs.digest != ''
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
Expand All @@ -73,6 +76,7 @@ jobs:
cosign sign --yes "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${DIGEST}"

- name: Verify Cosign Signature
if: steps.build-and-push.outputs.digest != ''
run: |
cosign verify "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }}" \
--certificate-identity-regexp="https://github.com/RitualDev-Lab/" \
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Publish Package & Sigstore Provenance
name: Manual Publish Package & Sigstore Provenance

on:
release:
types: [published]
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
workflow_dispatch:

permissions: read-all
Expand Down Expand Up @@ -42,11 +37,16 @@ jobs:
- name: Build AgentShield
run: pnpm run build

- name: Pack Release Tarball
run: |
mkdir -p release-artifacts
pnpm pack --pack-destination release-artifacts

- name: Publish to GitHub Packages
run: |
echo "@ritualdev-lab:registry=https://npm.pkg.github.com" > .npmrc
echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> .npmrc
npm publish --provenance=false
npm publish release-artifacts/*.tgz --provenance=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -83,12 +83,17 @@ jobs:
- name: Build AgentShield
run: pnpm run build

- name: Pack Release Tarball
run: |
mkdir -p release-artifacts
pnpm pack --pack-destination release-artifacts

- name: Generate SLSA Build Provenance Attestation
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: 'dist/**'
subject-path: 'release-artifacts/*.tgz'

- name: Publish to npm with Sigstore Provenance
run: npm publish --access public --provenance
run: npm publish release-artifacts/*.tgz --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
23 changes: 21 additions & 2 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
permissions:
id-token: write
contents: read
attestations: write

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand All @@ -41,9 +42,27 @@ jobs:
run: |
cd sdks/python
python -m build
python -m twine check dist/*

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
- name: Attest Python Distribution Provenance
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: 'sdks/python/dist/*'

- name: Publish to PyPI (OIDC Trusted Publishing)
if: env.HAS_PYPI_TOKEN != 'true'
env:
HAS_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN != '' }}
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
packages-dir: sdks/python/dist/
skip-existing: true

- name: Publish to PyPI (API Token fallback)
if: env.HAS_PYPI_TOKEN == 'true'
env:
HAS_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN != '' }}
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
with:
packages-dir: sdks/python/dist/
password: ${{ secrets.PYPI_API_TOKEN }}
Expand Down
37 changes: 28 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,22 @@ jobs:
- name: Build Package
run: pnpm run build

- name: Pack Release Tarball
run: |
mkdir -p release-artifacts sboms
pnpm pack --pack-destination release-artifacts

- name: Generate SLSA Build Provenance Attestation
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
with:
subject-path: 'dist/**'
subject-path: 'release-artifacts/*.tgz'

- name: Generate CycloneDX SBOM
uses: anchore/sbom-action@dfcb83b97731532d72be422cbc51ee64adb6fd56 # v0.24.4
with:
path: ./
format: 'cyclonedx-json'
output-file: 'dist/agentshield-cyclonedx.sbom.json'
output-file: 'sboms/agentshield-cyclonedx.sbom.json'
artifact-name: 'agentshield-cyclonedx.sbom.json'
upload-artifact: true
upload-release-assets: false
Expand All @@ -86,7 +91,7 @@ jobs:
with:
path: ./
format: 'spdx-json'
output-file: 'dist/agentshield-spdx.sbom.json'
output-file: 'sboms/agentshield-spdx.sbom.json'
artifact-name: 'agentshield-spdx.sbom.json'
upload-artifact: true
upload-release-assets: false
Expand All @@ -95,15 +100,17 @@ jobs:
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist-artifacts
path: dist/
path: |
release-artifacts/*.tgz
sboms/*.sbom.json
retention-days: 30

dual-publish:
name: Dual-Publish to npm & GitHub Packages
needs: [build-and-attest]
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
packages: write
id-token: write
attestations: write
Expand All @@ -120,17 +127,29 @@ jobs:
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist-artifacts
path: dist/
path: release-bundle/

- name: Publish to public npm Registry with Sigstore Provenance
run: npm publish --access public --provenance
run: npm publish release-bundle/release-artifacts/*.tgz --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Reconfigure for GitHub Packages
- name: Publish to GitHub Packages
run: |
echo "@ritualdev-lab:registry=https://npm.pkg.github.com" > .npmrc
echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> .npmrc
npm publish --provenance=false
npm publish release-bundle/release-artifacts/*.tgz --provenance=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release with Tarball & SBOMs
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@c95fe1489396fe8a9ec87454c605fbb0b60764ab # v2.2.1
with:
generate_release_notes: true
files: |
release-bundle/release-artifacts/*.tgz
release-bundle/sboms/*.sbom.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113 changes: 112 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ jobs:
python-version: "3.11"

- name: Run Python SDK Tests
run: python -m unittest discover -s sdks/python/tests
env:
PYTHONPATH: sdks/python
run: |
python -m pip install --quiet pytest || true
python -m pytest sdks/python/tests -q || python -B -m unittest discover -s sdks/python/tests

- name: Run Performance Benchmark
run: pnpm run benchmark
Expand All @@ -68,3 +72,110 @@ jobs:
- name: Dogfood AgentShield CI Security Gate
if: runner.os == 'Linux'
run: npx tsx src/cli.ts ci --base HEAD~1

native-sdks:
name: Go & Rust SDK Tests
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Go
uses: actions/setup-go@d8cbb8045d7f43706b9177cceb36c1f91a6644d5 # v7.1.0
with:
go-version: '1.24'

- name: Run Go SDK Tests
working-directory: sdks/go
run: go test -v ./...

- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master
with:
toolchain: stable

- name: Run Rust SDK Tests
working-directory: sdks/rust
run: cargo test

live-mcp-and-coverage:
name: Live MCP Server, Extension & Coverage Gate
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Install pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
with:
version: 9

- name: Setup Node.js 22
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "22"
cache: "pnpm"

- name: Install Dependencies
run: pnpm install --frozen-lockfile

- name: Build Bundles
run: pnpm run build

- name: Run Test Suite with Coverage Threshold
run: >-
npx tsx --test --experimental-test-coverage
--test-coverage-lines=45 --test-coverage-exclude="tests/**"

- name: Verify Live MCP Server & Proxy Tests
run: npx tsx --test tests/mcp-server.test.ts tests/mcp-proxy.test.ts tests/mcp-wrapper.test.ts

- name: Verify Live MCP Stdio Handshake
run: |
node --input-type=module -e '
import assert from "node:assert/strict";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
const transport = new StdioClientTransport({ command: "node", args: ["bin/mcp.js"] });
const client = new Client({ name: "ci-probe", version: "1.0.0" }, { capabilities: {} });
await client.connect(transport);
const res = await client.listTools();
const names = res.tools.map((t) => t.name);
await transport.close();
assert.ok(names.includes("agentshield_scan"));
assert.ok(names.includes("agentshield_doctor"));
'

- name: Validate VS Code Extension Manifest
run: |
node -e '
const fs = require("node:fs");
const assert = require("node:assert/strict");
const ext = JSON.parse(fs.readFileSync("extension/package.json", "utf8"));
assert.equal(ext.name, "vscode-agentshield");
assert.ok(Array.isArray(ext.contributes?.commands) && ext.contributes.commands.length >= 3);
'

security:
name: Supply-Chain & Secret Scan
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0

- name: Run OSV Dependency Vulnerability Scan
run: |
curl -sSfL -o /tmp/osv-scanner https://github.com/google/osv-scanner/releases/download/v2.7.1/osv-scanner_linux_amd64
chmod +x /tmp/osv-scanner
/tmp/osv-scanner scan source -r .

- name: Run Gitleaks Secret Scan
run: |
curl -sSfL -o /tmp/gitleaks.tar.gz https://github.com/gitleaks/gitleaks/releases/download/v8.30.1/gitleaks_8.30.1_linux_x64.tar.gz
tar -xzf /tmp/gitleaks.tar.gz -C /tmp gitleaks
/tmp/gitleaks detect --source . --redact --no-banner
10 changes: 10 additions & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Historical dummy test tokens and placeholder CLI/HTML snippets
b2159abbeba0cd03444282c18d04984effcec1ea:tests/surrogate.test.ts:generic-api-key:22
b2159abbeba0cd03444282c18d04984effcec1ea:tests/surrogate.test.ts:generic-api-key:58
b2159abbeba0cd03444282c18d04984effcec1ea:tests/surrogate.test.ts:curl-auth-header:8
b88a29c46775108768c89d3bf619e0a570bb2e3a:tests/sandbox.test.ts:generic-api-key:74
09a174cc616732eb384f3b1d0c895f135bc059ba:tests/bypass.test.ts:generic-api-key:112
4844602ae5dfbc0d7ffdf1e34fa457332b38c8c6:tests/bypass.test.ts:generic-api-key:72
cfab5f8c94b6286e37fe931e3f3d4deb1c33f2d0:tests/enterprise-baseline.test.ts:generic-api-key:56
cfab5f8c94b6286e37fe931e3f3d4deb1c33f2d0:src/cli.ts:generic-api-key:388
96678e8525a670d034e278c6f78736e4939a87a7:docs/index.html:generic-api-key:721
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LABEL maintainer="RitualDev Lab <team@ritualdev.com>"
LABEL org.opencontainers.image.title="AgentShield"
LABEL org.opencontainers.image.description="AI Agent Runtime Defense & Kernel Sandbox Engine"
LABEL org.opencontainers.image.source="https://github.com/RitualDev-Lab/AgentShield"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.licenses="Apache-2.0"

WORKDIR /app

Expand All @@ -31,4 +31,4 @@ USER nonroot:nonroot
ENV NODE_ENV=production

ENTRYPOINT ["/nodejs/bin/node", "dist/cli.js"]
CMD ["start"]
CMD ["mcp"]
3 changes: 3 additions & 0 deletions examples/langgraph-starter/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
agentshield-defense>=0.2.2
langgraph>=1.2.23
langchain-core>=1.8.3
requests>=2.33.0
httpx2>=2.12.0
httpcore2>=2.10.0
pytest>=9.2.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"dev": "tsup --watch",
"test": "tsx --test",
"benchmark": "tsx src/cli.ts benchmark",
"prepublishOnly": "npm run build && npm test && npm pack --dry-run",
"verify:pack": "npm run build && npm test && npm pack --dry-run",
"lint": "biome lint .",
"format": "biome format --write .",
"wiki:sync": "node scripts/sync-wiki.cjs"
Expand Down
Loading
Loading