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
1 change: 0 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
type=raw,value=0.2.1

- name: Build and Push Multi-Arch Image
id: build-and-push
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/go-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Go SDK (sdks/go) CI

on:
push:
branches: [main]
paths:
- "sdks/go/**"
- ".github/workflows/go-sdk.yml"
tags:
- "sdks/go/v*"
pull_request:
branches: [main]
paths:
- "sdks/go/**"
- ".github/workflows/go-sdk.yml"
workflow_dispatch:

permissions: read-all

jobs:
test-go:
name: Test Go SDK
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22"

- name: Vet & Test Go Module
working-directory: sdks/go
run: |
go vet ./...
go test -v ./...
15 changes: 12 additions & 3 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish agentshield to PyPI
name: Publish agentshield-defense to PyPI

on:
release:
Expand All @@ -7,7 +7,7 @@ on:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
- "python-v*"
- "agentshield-*"
- "agentshield-defense-*"
workflow_dispatch:

permissions: read-all
Expand All @@ -28,10 +28,19 @@ jobs:
with:
python-version: "3.11"

- name: Install build & test dependencies
run: |
python -m pip install --upgrade pip build pytest twine

- name: Run Python SDK tests
run: |
cd sdks/python
python -m pytest -q

- name: Build sdist and wheel
run: |
cd sdks/python
python setup.py sdist bdist_wheel
python -m build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/publish-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Rust SDK (agentshield-defense) CI & Crates.io Publish

on:
push:
branches: [main]
paths:
- "sdks/rust/**"
- ".github/workflows/publish-rust.yml"
tags:
- "rust-v*"
pull_request:
branches: [main]
paths:
- "sdks/rust/**"
- ".github/workflows/publish-rust.yml"
workflow_dispatch:

permissions: read-all

jobs:
test-rust:
name: Test Rust Crate (agentshield-defense)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@stable

- name: Run Cargo Tests & Package Dry-Run
working-directory: sdks/rust
run: |
cargo test --locked || cargo test
cargo package --allow-dirty --list

publish-crate:
name: Publish agentshield-defense to crates.io
needs: [test-rust]
if: startsWith(github.ref, 'refs/tags/rust-v') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: read
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@stable

- name: Publish Crate
working-directory: sdks/rust
run: |
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
echo "CARGO_REGISTRY_TOKEN secret not set; skipping crates.io upload."
exit 1
fi
cargo publish --token "$CARGO_REGISTRY_TOKEN"
6 changes: 3 additions & 3 deletions sdks/go/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🦫 AgentShield Go SDK

[![Go Reference](https://pkg.go.dev/badge/github.com/RitualDev-Lab/agentshield/sdks/go.svg)](https://pkg.go.dev/github.com/RitualDev-Lab/agentshield/sdks/go)
[![Go Reference](https://pkg.go.dev/badge/github.com/RitualDev-Lab/AgentShield/sdks/go.svg)](https://pkg.go.dev/github.com/RitualDev-Lab/AgentShield/sdks/go)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Official Go SDK for **[AgentShield](https://github.com/RitualDev-Lab/AgentShield)**: Zero-leak secret defense, in-memory surrogate token rehydration, and command sandboxing for Go AI applications and agent proxies.
Expand All @@ -10,7 +10,7 @@ Official Go SDK for **[AgentShield](https://github.com/RitualDev-Lab/AgentShield
## 📦 Installation

```bash
go get github.com/RitualDev-Lab/agentshield/sdks/go
go get github.com/RitualDev-Lab/AgentShield/sdks/go
```

Requires `agentshield` CLI or `node` on system PATH.
Expand All @@ -29,7 +29,7 @@ import (
"fmt"
"log"

"github.com/RitualDev-Lab/agentshield/sdks/go"
agentshield "github.com/RitualDev-Lab/AgentShield/sdks/go"
)

func main() {
Expand Down
43 changes: 43 additions & 0 deletions sdks/go/agentshield_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package agentshield

import (
"encoding/json"
"net/http"
"net/http/httptest"
"strings"
"testing"
)

func TestJsonUnmarshalTypes(t *testing.T) {
payload := `{"hasSecrets":true,"sanitizedText":"token=[AGENT_SHIELD:AI:1]","redactedCount":1,"findings":[{"patternId":"ai-key","severity":"high"}]}`
var res RedactResult
if err := json.Unmarshal([]byte(payload), &res); err != nil {
t.Fatalf("unexpected error: %v", err)
}
if !res.HasSecrets || res.RedactedCount != 1 || len(res.Findings) != 1 {
t.Fatalf("unexpected parsed result: %+v", res)
}
}

func TestHTTPMiddlewareAllowsSafeGet(t *testing.T) {
called := false
handler := HTTPMiddleware(nil)(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
called = true
w.WriteHeader(http.StatusOK)
}))

req := httptest.NewRequest(http.MethodGet, "/health", nil)
rec := httptest.NewRecorder()
handler.ServeHTTP(rec, req)

if !called || rec.Code != http.StatusOK {
t.Fatalf("expected GET passthrough, called=%v status=%d", called, rec.Code)
}

reqHead := httptest.NewRequest(http.MethodHead, "/health", strings.NewReader(""))
recHead := httptest.NewRecorder()
handler.ServeHTTP(recHead, reqHead)
if recHead.Code != http.StatusOK {
t.Fatalf("expected HEAD passthrough, status=%d", recHead.Code)
}
}
2 changes: 1 addition & 1 deletion sdks/go/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/RitualDev-Lab/agentshield/sdks/go
module github.com/RitualDev-Lab/AgentShield/sdks/go

go 1.21
1 change: 0 additions & 1 deletion sdks/go/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package agentshield

import (
"bytes"
"context"
"io"
"net/http"
)
Expand Down
4 changes: 3 additions & 1 deletion sdks/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ Works seamlessly with **LangChain**, **LangGraph**, **LlamaIndex**, **CrewAI**,
## 📦 Installation

```bash
pip install agentshield
pip install agentshield-defense
```

> Canonical standalone Python SDK repository: [`RitualDev-Lab/agentshield-python`](https://github.com/RitualDev-Lab/agentshield-python).

AgentShield operates in two high-performance modes:
1. **Pure Python In-Process Engine**: Zero external dependencies, pure standard library.
2. **Subprocess Sidecar Engine**: Communicates with the AgentShield Node.js daemon over JSON-RPC 2.0 stdio pipes for sub-millisecond multi-engine scanning and full ecosystem parity.
Expand Down
7 changes: 5 additions & 2 deletions sdks/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "agentshield"
version = "0.1.5"
name = "agentshield-defense"
version = "0.2.2"
description = "Zero-Leak Secret Defense & Shell Sandbox for Autonomous AI Agents in Python"
readme = "README.md"
requires-python = ">=3.9"
Expand Down Expand Up @@ -34,3 +34,6 @@ langchain = [
Homepage = "https://agentshield.ritualdev.in/"
Repository = "https://github.com/RitualDev-Lab/AgentShield"
Issues = "https://github.com/RitualDev-Lab/AgentShield/issues"

[tool.setuptools.packages.find]
include = ["agentshield*"]
9 changes: 7 additions & 2 deletions sdks/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
[package]
name = "agentshield"
version = "0.1.4"
name = "agentshield-defense"
version = "0.2.2"
edition = "2021"
description = "Zero-Leak Secret Defense & Shell Command Sandbox for Autonomous AI Agents in Rust"
readme = "README.md"
license = "MIT"
authors = ["RitualDev Lab <security@ritualdev.in>"]
repository = "https://github.com/RitualDev-Lab/AgentShield"
homepage = "https://agentshield.ritualdev.in/"
keywords = ["security", "ai-agents", "secret-scanning", "redaction", "sandbox"]
categories = ["development-tools", "command-line-utilities"]

[lib]
name = "agentshield_defense"
path = "src/lib.rs"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
8 changes: 4 additions & 4 deletions sdks/rust/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🦀 AgentShield Rust SDK
# 🦀 AgentShield Rust SDK (`agentshield-defense`)

[![Crates.io](https://img.shields.io/crates/v/agentshield.svg)](https://crates.io/crates/agentshield)
[![Crates.io](https://img.shields.io/crates/v/agentshield-defense.svg)](https://crates.io/crates/agentshield-defense)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Official Rust client for **[AgentShield](https://github.com/RitualDev-Lab/AgentShield)**: Zero-leak secret defense, in-memory surrogate token rehydration, and shell command sandboxing.
Expand All @@ -13,7 +13,7 @@ Add to your `Cargo.toml`:

```toml
[dependencies]
agentshield = "0.1.4"
agentshield-defense = "0.2.2"
```

Requires `agentshield` CLI or `npx` on PATH.
Expand All @@ -23,7 +23,7 @@ Requires `agentshield` CLI or `npx` on PATH.
## 🚀 Usage

```rust
use agentshield::AgentShieldClient;
use agentshield_defense::AgentShieldClient;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = AgentShieldClient::new()?;
Expand Down
39 changes: 39 additions & 0 deletions sdks/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,42 @@ impl Drop for AgentShieldClient {
}
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn deserializes_redact_result() {
let payload = r#"{
"hasSecrets": true,
"sanitizedText": "key=[AGENT_SHIELD:OPENAI:abc]",
"findings": [{
"patternId": "openai-key",
"patternName": "OpenAI API Key",
"category": "AI",
"severity": "critical",
"raw": "sk-proj-test",
"redacted": "[AGENT_SHIELD:OPENAI:abc]"
}],
"redactedCount": 1
}"#;
let parsed: RedactResult = serde_json::from_str(payload).expect("valid redact payload");
assert!(parsed.has_secrets);
assert_eq!(parsed.redacted_count, 1);
assert_eq!(parsed.findings[0].pattern_id, "openai-key");
}

#[test]
fn serializes_json_rpc_request() {
let req = JsonRpcRequest {
jsonrpc: "2.0",
id: 7,
method: "shield.scan",
params: serde_json::json!({ "text": "hello" }),
};
let raw = serde_json::to_string(&req).expect("serialize request");
assert!(raw.contains("\"method\":\"shield.scan\""));
assert!(raw.contains("\"id\":7"));
}
}
Loading