LeoYeAI/agent-master-skills / skills/agentaudit-skill
agentaudit-skill
FlaggedAutomatic security gate that checks packages against a vulnerability database before installation. Use before any npm install, pip install, yarn add, or package manager operation.
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 33.7 KB |
| SKILL.md | skill md | 18.0 KB |
| _meta.json | config | 297 B |
| install.sh | script | 5.7 KB |
| prompts/audit-prompt.md | markdown | 36.6 KB |
| prompts/review-prompt.md | markdown | 2.8 KB |
| references/API-REFERENCE.md | markdown | 4.1 KB |
| references/AUDIT-METHODOLOGY.md | markdown | 6.8 KB |
| references/DETECTION-PATTERNS.md | markdown | 5.9 KB |
| references/REPORT-FORMAT.md | markdown | 5.0 KB |
| references/TROUBLESHOOTING.md | markdown | 4.4 KB |
| references/TRUST-SCORING.md | markdown | 2.2 KB |
| scripts/_curl-retry.sh | script | 850 B |
| scripts/_load-key.sh | script | 1.6 KB |
| scripts/check.mjs | script | 6.3 KB |
| scripts/check.sh | script | 5.7 KB |
| scripts/gate.mjs | script | 5.2 KB |
| scripts/gate.sh | script | 4.9 KB |
| scripts/register.mjs | script | 4.7 KB |
| scripts/register.sh | script | 3.4 KB |
| scripts/rotate-key.sh | script | 2.3 KB |
| scripts/upload.mjs | script | 7.3 KB |
| scripts/upload.sh | script | 8.4 KB |
| scripts/verify.sh | script | 3.6 KB |
scripts/gate.mjs
View on GitHub#!/usr/bin/env node
/**
* gate.mjs — Cross-platform security gate for AgentAudit
* Works on Windows, macOS, and Linux. No bash/jq required.
*
* Usage:
* node scripts/gate.mjs <manager> <package>
* node scripts/gate.mjs npm express
* node scripts/gate.mjs pip requests
*
* Exit codes: 0=PASS, 1=BLOCK, 2=WARN, 3=UNKNOWN
*
* Requires: Node.js 18+ (for built-in fetch)
*/
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const API_URL = 'https://www.agentaudit.dev';
const MAX_RETRIES = 3;
// ── Helpers ──────────────────────────────────────────────
function loadApiKey() {
if (process.env.AGENTAUDIT_API_KEY) return process.env.AGENTAUDIT_API_KEY;
const skillCred = process.env.AGENTAUDIT_HOME
? path.join(process.env.AGENTAUDIT_HOME, 'config', 'credentials.json')
: path.join(__dirname, '..', 'config', 'credentials.json');
if (fs.existsSync(skillCred)) {
try {
const data = JSON.parse(fs.readFileSync(skillCred, 'utf8'));
if (data.api_key) return data.api_key;
} catch {}
}
const home = process.env.HOME || process.env.USERPROFILE || '';
const xdg = process.env.XDG_CONFIG_HOME || path.join(home, '.config');
const userCred = path.join(xdg, 'agentaudit', 'credentials.json');
if (fs.existsSync(userCred)) {
try {
const data = JSON.parse(fs.readFileSync(userCred, 'utf8'));
if (data.api_key) return data.api_key;
} catch {}
}
return '';
}
async function fetchRetry(url, options = {}, retries = MAX_RETRIES) {
let lastError;
let delay = 2000;
for (let i = 0; i < retries; i++) {
try {
return await fetch(url, { ...options, signal: AbortSignal.timeout(10_000) });
} catch (err) {
lastError = err;
if (i < retries - 1) {
await new Promise(r => setTimeout(r, delay));
delay *= 2;
}
}
}
throw lastError;
}
function gateJson(gate, pkg, score, summary) {
return JSON.stringify({ gate, package: pkg, score, ...summary });
}
// ── Args ─────────────────────────────────────────────────
const manager = process.argv[2];
const pkg = process.argv[3];
if (!manager || !pkg) {
console.error('Usage: node scripts/gate.mjs <manager> <package>');
console.error(' node scripts/gate.mjs npm express');
process.exit(1);
}
const apiKey = loadApiKey();
const encoded = encodeURIComponent(pkg);
// ── Check API ────────────────────────────────────────────
let checkData;
try {
const headers = {};
if (apiKey) headers['Authorization'] = `Bearer ${apiKey}`;
const res = await fetchRetry(`${API_URL}/api/check?package=${encoded}`, { headers });
checkData = await res.json();
} catch (err) {
console.error(`Registry unreachable: ${err.message}`);
console.log(gateJson('WARN', pkg, null, { reason: 'registry_unreachable' }));
process.exit(2);
}
// Not yet audited
if (!checkData.exists) {
console.log(gateJson('UNKNOWN', pkg, null, { reason: 'not_audited' }));
process.exit(3);
}
const score = checkData.trust_score ?? 100;
const total = checkData.total_findings ?? 0;
const auditLevel = checkData.audit_level || 'unknown';
const summary = {
critical: checkData.critical ?? 0,
high: checkData.high ?? 0,
medium: checkData.medium ?? 0,
low: checkData.low ?? 0,
total_findings: total,
audit_level: auditLevel,
};
// ── Decision ─────────────────────────────────────────────
if (score >= 70) {
console.log(gateJson('PASS', pkg, score, summary));
process.exit(0);
} else if (score >= 40) {
console.log(gateJson('WARN', pkg, score, summary));
// Show top findings on stderr for the agent to read
if (total > 0) {
try {
const headers = {};
if (apiKey) headers['Authorization'] = `Bearer ${apiKey}`;
const fRes = await fetchRetry(`${API_URL}/api/findings?package=${encoded}`, { headers });
const fData = await fRes.json();
const findings = (fData.findings || [])
.filter(f => f.by_design !== true && f.by_design !== 'true')
.slice(0, 5);
console.error(JSON.stringify(findings.map(f => ({
severity: f.severity,
title: f.title,
by_design: f.by_design,
}))));
} catch {}
}
process.exit(2);
} else {
console.log(gateJson('BLOCK', pkg, score, summary));
if (total > 0) {
try {
const headers = {};
if (apiKey) headers['Authorization'] = `Bearer ${apiKey}`;
const fRes = await fetchRetry(`${API_URL}/api/findings?package=${encoded}`, { headers });
const fData = await fRes.json();
const findings = (fData.findings || [])
.filter(f => f.by_design !== true && f.by_design !== 'true')
.slice(0, 5);
console.error(JSON.stringify(findings.map(f => ({
severity: f.severity,
title: f.title,
by_design: f.by_design,
}))));
} catch {}
}
process.exit(1);
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |