LeoYeAI/agent-master-skills / skills/agentaudit
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 | 631 B |
| config/credentials.json | config | 89 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.1 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.sh
View on GitHub#!/usr/bin/env bash
# gate.sh — AgentAudit Security Gate
# Usage: bash gate.sh <package-manager> <package-name> [extra-args...]
set -euo pipefail
API_URL="https://www.agentaudit.dev"
SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
# --- Dependency Check ---
for cmd in jq curl; do
if ! command -v "$cmd" &>/dev/null; then
echo "{\"error\":\"Required dependency missing: ${cmd}. Install it first.\",\"exit_code\":1}" >&2
exit 1
fi
done
# --- Args ---
if [[ $# -lt 2 ]]; then
echo '{"error":"Usage: gate.sh <npm|pip|clawhub> <package> [args...]","exit_code":1}' >&2
exit 1
fi
PM="$1"; PKG="$2"; shift 2; EXTRA_ARGS=("$@")
# --- Validate Package Name ---
if [[ -z "$PKG" || "$PKG" =~ ^[[:space:]]*$ ]]; then
echo '{"error":"Package name must not be empty.","exit_code":1}' >&2
exit 1
fi
# --- URL-encode package name (handles @scoped/packages) ---
url_encode() {
local string="$1"
printf '%s' "$string" | python3 -c "import sys, urllib.parse; print(urllib.parse.quote(sys.stdin.read(), safe=''))" 2>/dev/null \
|| printf '%s' "$string" | jq -sRr @uri 2>/dev/null \
|| printf '%s' "$string" | sed 's/@/%40/g; s/\//%2F/g; s/ /%20/g'
}
PKG_ENCODED="$(url_encode "$PKG")"
# --- API Key (shared loader: env var > skill-local > user-level config) ---
GATE_SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
source "$GATE_SCRIPT_DIR/_load-key.sh"
source "$GATE_SCRIPT_DIR/_curl-retry.sh"
API_KEY="$(load_api_key)"
# --- Query /api/check (authoritative trust score, handles 0-finding packages) ---
CHECK_ARGS=(-sL -f --max-time 15 "${API_URL}/api/check?package=${PKG_ENCODED}")
[[ -n "$API_KEY" ]] && CHECK_ARGS+=(-H "Authorization: Bearer ${API_KEY}")
CHECK_RESPONSE="$(curl_retry "${CHECK_ARGS[@]}")" || {
echo "{\"gate\":\"warn\",\"package\":\"${PKG}\",\"score\":null,\"message\":\"⚠️ Registry unreachable (timeout or down). Proceeding in WARN mode — package is UNVERIFIED. Consider running a local audit or waiting until the registry is back.\",\"exit_code\":2}"
exit 2
}
# --- Check if package has been audited ---
EXISTS=$(echo "$CHECK_RESPONSE" | jq -r '.exists // false')
if [[ "$EXISTS" != "true" ]]; then
cat <<EOF
{
"gate": "unknown",
"package": "${PKG}",
"score": null,
"total": 0,
"message": "🔍 Package not yet audited in registry",
"info": "This package hasn't been scanned yet. You can be the first to audit it and contribute to the community!",
"next_steps": {
"option_1": "Run a security audit now and submit findings to the registry",
"option_2": "Proceed with caution after manual verification",
"option_3": "Choose a different, already-audited package"
},
"how_to_audit": {
"step_1": "Read the audit prompt: cat $SCRIPT_DIR/prompts/audit-prompt.md",
"step_2": "Analyze the package source code against the security checklist",
"step_3": "Build a JSON report with findings (see SKILL.md for format)",
"step_4": "Submit: bash $SCRIPT_DIR/scripts/upload.sh report.json"
},
"risk_checks": [
"Is this package < 30 days old? (higher risk)",
"Does it have < 100 weekly downloads? (higher risk)",
"Is the author new with no other packages? (higher risk)",
"Is the name similar to a popular package (typosquat)?"
],
"recommendation": "Do NOT auto-install unaudited packages. Audit first, then proceed with informed decision.",
"exit_code": 3
}
EOF
exit 3
fi
# --- Use authoritative trust_score from /api/check ---
SCORE=$(echo "$CHECK_RESPONSE" | jq '.trust_score // 100')
TOTAL=$(echo "$CHECK_RESPONSE" | jq '.total_findings // 0')
# Build findings summary from /api/check response
FINDINGS_SUMMARY=$(echo "$CHECK_RESPONSE" | jq -c '{
critical: (.critical // 0),
high: (.high // 0),
medium: (.medium // 0),
low: (.low // 0),
by_design:(.by_design_count // 0)
}')
# --- Decision ---
build_output() {
jq -nc --arg gate "$1" --arg pkg "$PKG" --argjson score "$SCORE" \
--argjson total "$TOTAL" --argjson findings "$FINDINGS_SUMMARY" \
--arg msg "$2" --argjson ec "$3" \
'{gate:$gate,package:$pkg,score:$score,total:$total,findings:$findings,message:$msg,exit_code:$ec}'
}
if [[ "$SCORE" -ge 70 ]]; then
# PASS — safe to install (gate only checks, never installs)
build_output "pass" "Score ${SCORE}/100 — safe to install" 0
exit 0
elif [[ "$SCORE" -ge 40 ]]; then
build_output "warning" "Score ${SCORE}/100 — review findings before installing" 2
# Fetch detailed findings for top findings display
FIND_ARGS=(-sL -f --max-time 10 "${API_URL}/api/findings?package=${PKG_ENCODED}")
[[ -n "$API_KEY" ]] && FIND_ARGS+=(-H "Authorization: Bearer ${API_KEY}")
FIND_RESPONSE="$(curl_retry "${FIND_ARGS[@]}" 2>/dev/null)" || true
if [[ -n "$FIND_RESPONSE" ]]; then
echo "$FIND_RESPONSE" | jq -c '[.findings[]|select(.by_design!=true and .by_design!="true")|{severity,title,by_design}][:5]' >&2
fi
exit 2
else
build_output "block" "Score ${SCORE}/100 — too risky, installation blocked" 1
exit 1
fi
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: 471k | 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: 471k | 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: 471k | 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 |