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
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,21 @@ Status Bar: $(shield) AgentShield: Seatbelt | $(database) DBShield: Balanced (1
* **Interactive Playground**: Test any tool or endpoint inside an isolated sandbox runner directly in the side panel before installing.
* **1-Click Installer**: Click **"⚡ Add to Cursor / Claude"** to automatically configure `.cursor/mcp.json` or `claude_desktop_config.json`.

### 5. 🩺 Agent Mesh & Sandbox Health Tree
* Live diagnostic tree monitoring all 4 security and governance tiers:
* **AgentShield**: Active micro-jails, syscall filters, egress CIDR boundaries.
* **DBShield**: PostgreSQL/MySQL wire proxies, virtual schema masking, PII redactor.
* **SkillPrism**: Federated Redis cache status, semantic search index health.
* **WebSecAuditor**: Inter-file AST taint tracker, live AI secret scanner.
### 6. 🛡️ AgentShield Zero-Leak DLP Linter & 1-Click Redactor
* **Real-time ReDoS-Safe Secret Scanning**: Scans active documents on open and change for unmasked OpenAI keys, AWS access keys, GitHub PATs, Anthropic tokens, and `/proc/self/environ` reads.
* **1-Click Quick-Fix**: Click the lightbulb on any detected credential leak to instantly execute **"🛡️ Redact Secret with AgentShield"**, replacing the sensitive value with `[AGENTSHIELD_REDACTED:<ID>:<SALT>]`.
* **Kernel Sandbox Profile Switcher**: Toggle between `Strict` (zero-network air-gapped jail), `Standard` (Git-only egress), and `Permissive` (localhost IPC).

### 7. ⚡ Poly Monorepo & Task Graph Runner
* **Polyglot Workspace Discovery**: Tree view scanning npm, PyPI/uv, Cargo, and Go workspace members and dependencies.
* **1-Click Poly Runner**: Execute `poly install`, `poly audit`, `poly fix`, `poly doctor`, `poly graph`, and `poly docker` directly from the editor.
* **Cryptographic Lockfile Verification**: Validates `poly.lock` integrity and reports drift.
* **Remote Cache Telemetry**: Live status check and branch-level remote cache invalidation.

### 8. 💬 GitWhisper AI Conventional Commit Intelligence
* **SCM Integration**: Click the Sparkle icon in the Source Control title or input box to generate conventional commit messages (`feat`, `fix`, `refactor`, `perf`).
* **Zero-Egress Privacy**: Automatic secret redaction and `[Local-Only]` privacy badge assurance before committing.
* **Quality & Formatting Linter**: Evaluates staged commit messages against the Conventional Commits specification with a 0–100 score.

---

Expand Down
131 changes: 130 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ritual-agent-defense",
"displayName": "Ritual Agent Defense",
"description": "Unified AI Agent Runtime Defense, Kernel Sandboxing, Database Guardrails & Context Optimizer for Cursor, VS Code, and Windsurf",
"version": "0.2.0",
"version": "0.3.0",
"publisher": "ritualdev-lab",
"repository": {
"type": "git",
Expand Down Expand Up @@ -74,6 +74,16 @@
"id": "ritual.meshStatusView",
"name": "Agent Mesh & Sandbox Health",
"icon": "$(pulse)"
},
{
"id": "ritual.polyWorkspaceView",
"name": "Poly Monorepo & Task Graph",
"icon": "$(project)"
},
{
"id": "ritual.polyHealthView",
"name": "Poly Ecosystem Health",
"icon": "$(heart)"
}
]
},
Expand Down Expand Up @@ -128,15 +138,114 @@
"command": "ritual.dbshield.configureMcp",
"title": "DBShield: 1-Click Configure Cursor / Antigravity MCP",
"icon": "$(tools)"
},
{
"command": "ritual.agentshield.scanActiveFile",
"title": "AgentShield: Scan Active File for Secrets & DLP Leaks",
"icon": "$(shield)"
},
{
"command": "ritual.agentshield.auditWorkspace",
"title": "AgentShield: Audit Entire Workspace with Security Enforcer",
"icon": "$(search)"
},
{
"command": "ritual.agentshield.switchSandboxProfile",
"title": "AgentShield: Switch OS Kernel Sandbox Profile",
"icon": "$(lock)"
},
{
"command": "ritual.agentshield.showStatusMenu",
"title": "AgentShield: Show Zero-Leak Defense Status & Actions"
},
{
"command": "ritual.poly.refresh",
"title": "Poly: Refresh Workspace & Ecosystem Health",
"icon": "$(refresh)"
},
{
"command": "ritual.poly.install",
"title": "Poly: Install & Synchronize Polyglot Dependencies",
"icon": "$(cloud-download)"
},
{
"command": "ritual.poly.audit",
"title": "Poly: Audit Monorepo Security Vulnerabilities",
"icon": "$(shield)"
},
{
"command": "ritual.poly.fix",
"title": "Poly: Auto-Heal Vulnerabilities & Regenerate Lockfile",
"icon": "$(wrench)"
},
{
"command": "ritual.poly.doctor",
"title": "Poly: Run Multi-Ecosystem System Diagnostics",
"icon": "$(pulse)"
},
{
"command": "ritual.poly.graph",
"title": "Poly: Visualize Monorepo Task Dependency Graph",
"icon": "$(type-hierarchy)"
},
{
"command": "ritual.poly.docker",
"title": "Poly: Generate Multi-Stage Container & DevContainer",
"icon": "$(package)"
},
{
"command": "ritual.poly.addDependency",
"title": "Poly: Add Polyglot Dependency via PURL"
},
{
"command": "ritual.poly.verifyLockfile",
"title": "Poly: Verify poly.lock Cryptographic Integrity"
},
{
"command": "ritual.poly.cacheStatus",
"title": "Poly: Inspect Live Remote Cache Cluster Status"
},
{
"command": "ritual.poly.cachePurge",
"title": "Poly: Purge Remote Cache for Current Monorepo Branch"
},
{
"command": "ritual.gitwhisper.generateCommit",
"title": "GitWhisper: Generate AI Conventional Commit Message",
"icon": "$(sparkle)"
},
{
"command": "ritual.gitwhisper.checkQuality",
"title": "GitWhisper: Check Staged Commit Quality & Formatting",
"icon": "$(check)"
}
],
"menus": {
"scm/title": [
{
"command": "ritual.gitwhisper.generateCommit",
"group": "navigation@1",
"when": "scmRepositoryCount > 0"
}
],
"scm/inputBox": [
{
"command": "ritual.gitwhisper.generateCommit",
"group": "inline",
"when": "scmRepositoryCount > 0"
}
],
"view/title": [
{
"command": "ritual.refreshAll",
"when": "view == ritual.approvalsView || view == ritual.meshStatusView || view == ritual.tokenVisualizerView",
"group": "navigation"
},
{
"command": "ritual.poly.refresh",
"when": "view == ritual.polyWorkspaceView || view == ritual.polyHealthView",
"group": "navigation"
},
{
"command": "ritual.openDashboard",
"when": "view == ritual.approvalsView",
Expand Down Expand Up @@ -177,6 +286,26 @@
"type": "boolean",
"default": true,
"description": "Show system pop-up notifications when agents request mutation approvals."
},
"poly.executablePath": {
"type": "string",
"default": "poly",
"description": "Path to poly CLI binary or global executable."
},
"poly.remoteCacheUrl": {
"type": "string",
"default": "https://api.poly.build",
"description": "Hosted or enterprise self-hosted Poly remote cache cluster URL."
},
"gitwhisper.model": {
"type": "string",
"default": "local-deterministic",
"description": "Model engine used for conventional commit message synthesis."
},
"gitwhisper.redactSecrets": {
"type": "boolean",
"default": true,
"description": "Automatically redact API keys, tokens, and PII from generated commit messages."
}
}
}
Expand Down
122 changes: 122 additions & 0 deletions src/dlp/secret-detector.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import * as vscode from "vscode";
import {
generateRedactedMask,
scanTextForSecrets,
} from "./secret-patterns.js";

export * from "./secret-patterns.js";

export class SecretDiagnosticsManager {
private diagnosticCollection: vscode.DiagnosticCollection;
private statusBarItem: vscode.StatusBarItem;
private totalLeakCount = 0;

constructor(context: vscode.ExtensionContext) {
this.diagnosticCollection = vscode.languages.createDiagnosticCollection("agentshield");
this.statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 102);
this.statusBarItem.command = "ritual.agentshield.showStatusMenu";
this.updateStatusBar(0);
this.statusBarItem.show();

context.subscriptions.push(this.diagnosticCollection, this.statusBarItem);

if (vscode.window.activeTextEditor) {
this.scanDocument(vscode.window.activeTextEditor.document);
}

context.subscriptions.push(
vscode.workspace.onDidChangeTextDocument((event) => this.scanDocument(event.document)),
vscode.workspace.onDidOpenTextDocument((doc) => this.scanDocument(doc)),
vscode.workspace.onDidCloseTextDocument((doc) => this.diagnosticCollection.delete(doc.uri)),
);

// Register 1-Click Redact Quick-Fix Provider
context.subscriptions.push(
vscode.languages.registerCodeActionsProvider(
{ scheme: "file" },
new SecretRedactionActionProvider(),
{ providedCodeActionKinds: [vscode.CodeActionKind.QuickFix] },
),
);
}

public scanDocument(document: vscode.TextDocument): number {
if (document.uri.scheme !== "file" && document.uri.scheme !== "untitled") {
return 0;
}

const text = document.getText();
const matches = scanTextForSecrets(text);
const diagnostics: vscode.Diagnostic[] = [];

for (const match of matches) {
const startPos = document.positionAt(match.start);
const endPos = document.positionAt(match.end);
const range = new vscode.Range(startPos, endPos);

const diagnostic = new vscode.Diagnostic(
range,
`[AgentShield Zero-Leak Guard] Unmasked ${match.name} detected. Avoid committing or passing raw credentials to AI coding agents.`,
vscode.DiagnosticSeverity.Warning,
);
diagnostic.source = "AgentShield";
diagnostic.code = match.id;
diagnostics.push(diagnostic);
}

this.diagnosticCollection.set(document.uri, diagnostics);
this.updateStatusBar(diagnostics.length);
return diagnostics.length;
}

public updateStatusBar(count: number): void {
this.totalLeakCount = count;
if (count === 0) {
this.statusBarItem.text = "$(shield) AgentShield: Guarded";
this.statusBarItem.tooltip = "AgentShield: Zero-leak secret defense active. Workspace safe.";
this.statusBarItem.backgroundColor = undefined;
} else {
this.statusBarItem.text = `$(alert) AgentShield: ${count} Leaks!`;
this.statusBarItem.tooltip = `AgentShield: Detected ${count} unredacted secret(s)! Click to review findings.`;
this.statusBarItem.backgroundColor = new vscode.ThemeColor("statusBarItem.errorBackground");
}
}

public getLeakCount(): number {
return this.totalLeakCount;
}

public dispose(): void {
this.diagnosticCollection.clear();
this.diagnosticCollection.dispose();
this.statusBarItem.dispose();
}
}

export class SecretRedactionActionProvider implements vscode.CodeActionProvider {
provideCodeActions(
document: vscode.TextDocument,
_range: vscode.Range | vscode.Selection,
context: vscode.CodeActionContext,
): vscode.CodeAction[] {
const actions: vscode.CodeAction[] = [];

for (const diagnostic of context.diagnostics) {
if (diagnostic.source === "AgentShield") {
const action = new vscode.CodeAction(
"🛡️ Redact Secret with AgentShield",
vscode.CodeActionKind.QuickFix,
);
action.isPreferred = true;
action.diagnostics = [diagnostic];
const edit = new vscode.WorkspaceEdit();
const mask = generateRedactedMask(String(diagnostic.code || "SECRET"));
edit.replace(document.uri, diagnostic.range, mask);
action.edit = edit;
actions.push(action);
}
}

return actions;
}
}
67 changes: 67 additions & 0 deletions src/dlp/secret-patterns.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
export interface SecretDetectorPattern {
id: string;
name: string;
regex: RegExp;
}

export interface DetectedSecretMatch {
id: string;
name: string;
value: string;
start: number;
end: number;
}

export const SECRET_DETECTORS: SecretDetectorPattern[] = [
{ id: "OPENAI_KEY", name: "OpenAI Secret Key", regex: /\b(sk-[a-zA-Z0-9_\-]{20,80})\b/g },
{ id: "AWS_ACCESS_KEY", name: "AWS Access Key", regex: /\b(AKIA[0-9A-Z]{16})\b/g },
{
id: "ANTHROPIC_KEY",
name: "Anthropic API Key",
regex: /\b(sk-ant-[a-zA-Z0-9_\-]{20,80})\b/g,
},
{
id: "GITHUB_PAT",
name: "GitHub Personal Access Token",
regex: /\b(ghp_[a-zA-Z0-9]{36}|github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59})\b/g,
},
{ id: "SLACK_TOKEN", name: "Slack Bot Token", regex: /\b(xox[baprs]-[0-9a-zA-Z]{10,48})\b/g },
{ id: "STRIPE_KEY", name: "Stripe Live Secret Key", regex: /\b(sk_live_[0-9a-zA-Z]{24,34})\b/g },
{ id: "GOOGLE_API_KEY", name: "Google API Key", regex: /\b(AIza[0-9A-Za-z-_]{35})\b/g },
{
id: "PRIVATE_KEY_HEADER",
name: "Private Cryptographic Key",
regex: /-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----/g,
},
{
id: "PROC_ENVIRON",
name: "/proc/self/environ Inspection",
regex: /(?:\/proc\/(?:self|\d+)\/environ|\.e["']?n["']?v)/gi,
},
];

export function scanTextForSecrets(text: string): DetectedSecretMatch[] {
const matches: DetectedSecretMatch[] = [];

for (const detector of SECRET_DETECTORS) {
detector.regex.lastIndex = 0;
let match: RegExpExecArray | null;

while ((match = detector.regex.exec(text)) !== null) {
matches.push({
id: detector.id,
name: detector.name,
value: match[0],
start: match.index,
end: match.index + match[0].length,
});
}
}

return matches;
}

export function generateRedactedMask(detectorId: string): string {
const salt = Math.random().toString(36).substring(2, 8);
return `[AGENTSHIELD_REDACTED:${detectorId}:${salt}]`;
}
Loading
Loading