Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bcfe832030 | |||
| e3546119ee | |||
| 11786d8b10 |
@@ -1,24 +0,0 @@
|
||||
* text=auto
|
||||
|
||||
# Keep executable/script sources LF across platforms.
|
||||
*.sh text eol=lf
|
||||
*.bash text eol=lf
|
||||
*.zsh text eol=lf
|
||||
*.mjs text eol=lf
|
||||
*.js text eol=lf
|
||||
*.ts text eol=lf
|
||||
*.tsx text eol=lf
|
||||
*.py text eol=lf
|
||||
|
||||
# Keep config/docs deterministic in CI and local tooling.
|
||||
*.md text eol=lf
|
||||
*.json text eol=lf
|
||||
*.yml text eol=lf
|
||||
*.yaml text eol=lf
|
||||
*.toml text eol=lf
|
||||
*.pem text eol=lf
|
||||
|
||||
# Binary assets.
|
||||
*.png binary
|
||||
*.ico binary
|
||||
*.ttf binary
|
||||
@@ -1,63 +0,0 @@
|
||||
---
|
||||
name: Bug Report
|
||||
about: Report a bug or unexpected behavior
|
||||
labels: bug, needs-triage
|
||||
---
|
||||
|
||||
## Opener Type
|
||||
|
||||
<!-- Check one: -->
|
||||
- [ ] Human
|
||||
- [ ] Agent (automated report)
|
||||
|
||||
---
|
||||
|
||||
## Bug Description
|
||||
|
||||
<!-- A clear and concise description of the bug -->
|
||||
|
||||
## Steps to Reproduce
|
||||
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
## Expected Behavior
|
||||
|
||||
<!-- What you expected to happen -->
|
||||
|
||||
## Actual Behavior
|
||||
|
||||
<!-- What actually happened -->
|
||||
|
||||
---
|
||||
|
||||
## Environment
|
||||
|
||||
- **OS:** <!-- e.g., macOS 14.0, Ubuntu 22.04, Windows 11 -->
|
||||
- **Version:** <!-- e.g., 1.2.3 -->
|
||||
- **Platform:** <!-- e.g., OpenClaw, Claude Code -->
|
||||
|
||||
## Logs / Error Output
|
||||
|
||||
```
|
||||
<!-- Paste relevant logs or error messages here -->
|
||||
```
|
||||
|
||||
## Screenshots
|
||||
|
||||
<!-- If applicable, add screenshots to help explain the problem -->
|
||||
|
||||
---
|
||||
|
||||
## Additional Context
|
||||
|
||||
<!-- Any other context about the problem -->
|
||||
|
||||
---
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] I have searched existing issues to ensure this is not a duplicate
|
||||
- [ ] I have included steps to reproduce the bug
|
||||
- [ ] I have included relevant environment information
|
||||
@@ -1,75 +0,0 @@
|
||||
---
|
||||
name: Feature Request
|
||||
about: Suggest a new feature or enhancement
|
||||
labels: enhancement, needs-triage
|
||||
---
|
||||
|
||||
## Opener Type
|
||||
|
||||
<!-- Check one: -->
|
||||
- [ ] Human
|
||||
- [ ] Agent (automated suggestion)
|
||||
|
||||
---
|
||||
|
||||
## Feature Summary
|
||||
|
||||
<!-- A brief, one-line summary of the feature -->
|
||||
|
||||
## Problem Statement
|
||||
|
||||
<!-- What problem does this feature solve? Why is it needed? -->
|
||||
|
||||
## Proposed Solution
|
||||
|
||||
<!-- Describe your proposed solution or implementation approach -->
|
||||
|
||||
## Alternatives Considered
|
||||
|
||||
<!-- What alternative solutions or features have you considered? -->
|
||||
|
||||
---
|
||||
|
||||
## Use Cases
|
||||
|
||||
<!-- Describe specific use cases where this feature would be beneficial -->
|
||||
|
||||
1.
|
||||
2.
|
||||
|
||||
## User Impact
|
||||
|
||||
<!-- Who benefits from this feature? How does it improve their experience? -->
|
||||
|
||||
---
|
||||
|
||||
## Implementation Notes (Optional)
|
||||
|
||||
<!-- Any technical considerations, potential approaches, or constraints -->
|
||||
|
||||
## Mockups / Examples (Optional)
|
||||
|
||||
<!-- If applicable, add mockups, diagrams, or examples -->
|
||||
|
||||
---
|
||||
|
||||
## Priority Assessment
|
||||
|
||||
<!-- Check one: -->
|
||||
- [ ] Nice to have - Would improve UX but not critical
|
||||
- [ ] Important - Addresses a common pain point
|
||||
- [ ] Critical - Blocks important workflows or use cases
|
||||
|
||||
---
|
||||
|
||||
## Additional Context
|
||||
|
||||
<!-- Any other context or information about the feature request -->
|
||||
|
||||
---
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] I have searched existing issues to ensure this is not a duplicate
|
||||
- [ ] I have clearly described the problem this feature would solve
|
||||
- [ ] I have considered alternative approaches
|
||||
@@ -1,105 +0,0 @@
|
||||
---
|
||||
name: Security Incident Report
|
||||
about: Report malicious prompts, vulnerable skills, or tampering attempts
|
||||
labels: security, needs-triage
|
||||
---
|
||||
|
||||
## Opener Type
|
||||
|
||||
<!-- Check one: -->
|
||||
- [ ] Human
|
||||
- [ ] Agent (automated report)
|
||||
|
||||
---
|
||||
|
||||
## Report Type
|
||||
|
||||
<!-- Check one: -->
|
||||
- [ ] Malicious Prompt - Detected prompt injection or social engineering attempt
|
||||
- [ ] Vulnerable Skill - Found a skill with security issues
|
||||
- [ ] Tampering Attempt - Observed attempt to disable/modify ClawSec
|
||||
|
||||
## Severity
|
||||
|
||||
<!-- Check one: -->
|
||||
- [ ] Critical - Active exploitation, data exfiltration, complete bypass
|
||||
- [ ] High - Significant security risk, potential for harm
|
||||
- [ ] Medium - Security concern that should be addressed
|
||||
- [ ] Low - Minor issue, best practice violation
|
||||
|
||||
---
|
||||
|
||||
## Title
|
||||
|
||||
<!-- Brief descriptive title of the incident -->
|
||||
|
||||
## Description
|
||||
|
||||
<!-- Detailed description of what was observed -->
|
||||
|
||||
---
|
||||
|
||||
## Evidence
|
||||
|
||||
### Observed At
|
||||
<!-- ISO 8601 timestamp: YYYY-MM-DDTHH:MM:SSZ -->
|
||||
|
||||
### Context
|
||||
<!-- What was happening when this occurred -->
|
||||
|
||||
### Payload
|
||||
<!-- The actual prompt/code/behavior observed (SANITIZED - remove any real user data, credentials, or PII) -->
|
||||
|
||||
```
|
||||
<!-- Paste sanitized payload here -->
|
||||
```
|
||||
|
||||
### Indicators
|
||||
<!-- List specific indicators that flagged this as suspicious -->
|
||||
-
|
||||
-
|
||||
-
|
||||
|
||||
---
|
||||
|
||||
## Affected
|
||||
|
||||
### Skill Name
|
||||
<!-- Name of the affected skill (if applicable) -->
|
||||
|
||||
### Skill Version
|
||||
<!-- Version number (if known) -->
|
||||
|
||||
### Platforms
|
||||
<!-- Check all that apply: -->
|
||||
- [ ] OpenClaw
|
||||
- [ ] Other: <!-- specify -->
|
||||
|
||||
---
|
||||
|
||||
## Recommended Action
|
||||
|
||||
<!-- What should users do in response to this threat? -->
|
||||
|
||||
---
|
||||
|
||||
## Reporter Information (Optional)
|
||||
|
||||
**Agent/User Name:**
|
||||
**Contact:** <!-- How to reach for follow-up -->
|
||||
|
||||
---
|
||||
|
||||
## Privacy Checklist
|
||||
|
||||
<!-- Confirm before submitting: -->
|
||||
- [ ] I have removed all real user data and PII
|
||||
- [ ] I have not included any API keys, credentials, or secrets
|
||||
- [ ] Evidence is sanitized and describes issues abstractly where needed
|
||||
- [ ] No proprietary or confidential information is included
|
||||
|
||||
---
|
||||
|
||||
## Additional Notes
|
||||
|
||||
<!-- Any other relevant information -->
|
||||
@@ -1,44 +0,0 @@
|
||||
## Opener Type
|
||||
|
||||
<!-- Check one: -->
|
||||
- [ ] Human
|
||||
- [ ] Agent (automated)
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
<!-- Brief description of changes -->
|
||||
|
||||
## Changes Made
|
||||
|
||||
-
|
||||
-
|
||||
|
||||
## Related Issues
|
||||
|
||||
<!-- Link any related issues: Fixes #123, Relates to #456 -->
|
||||
|
||||
---
|
||||
|
||||
## Type of Change
|
||||
|
||||
<!-- Check all that apply: -->
|
||||
- [ ] Bug fix (non-breaking change that fixes an issue)
|
||||
- [ ] New feature (non-breaking change that adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
|
||||
- [ ] Documentation update
|
||||
- [ ] Security incident (please open a Security Incident Report issue instead of a PR)
|
||||
|
||||
---
|
||||
|
||||
## Testing
|
||||
|
||||
<!-- Describe how you tested these changes -->
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] My code follows the project's style guidelines
|
||||
- [ ] I have performed a self-review of my changes
|
||||
- [ ] I have added tests that prove my fix/feature works
|
||||
- [ ] New and existing tests pass locally
|
||||
@@ -1,110 +0,0 @@
|
||||
name: Sign and Verify File
|
||||
description: Sign a file with the CI private key and verify the signature against one or more files.
|
||||
|
||||
inputs:
|
||||
private_key:
|
||||
description: PEM-encoded private key contents.
|
||||
required: true
|
||||
private_key_passphrase:
|
||||
description: Optional passphrase for encrypted private keys.
|
||||
required: false
|
||||
default: ""
|
||||
input_file:
|
||||
description: File to sign.
|
||||
required: true
|
||||
signature_file:
|
||||
description: Output path for base64 signature.
|
||||
required: true
|
||||
verify_files:
|
||||
description: Newline-separated list of files to verify with the generated signature. Defaults to input_file.
|
||||
required: false
|
||||
default: ""
|
||||
public_key_output:
|
||||
description: Optional output path for the derived public key.
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
outputs:
|
||||
signature_file:
|
||||
description: Signature file path.
|
||||
value: ${{ steps.sign.outputs.signature_file }}
|
||||
public_key_file:
|
||||
description: Public key file path when public_key_output is set.
|
||||
value: ${{ steps.sign.outputs.public_key_file }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- id: sign
|
||||
shell: bash
|
||||
env:
|
||||
PRIVATE_KEY: ${{ inputs.private_key }}
|
||||
PRIVATE_KEY_PASSPHRASE: ${{ inputs.private_key_passphrase }}
|
||||
INPUT_FILE: ${{ inputs.input_file }}
|
||||
SIGNATURE_FILE: ${{ inputs.signature_file }}
|
||||
VERIFY_FILES_RAW: ${{ inputs.verify_files }}
|
||||
PUBLIC_KEY_OUTPUT: ${{ inputs.public_key_output }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if [ -z "${PRIVATE_KEY:-}" ]; then
|
||||
echo "::error::Missing required private key input."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "${INPUT_FILE}" ]; then
|
||||
echo "::error file=${INPUT_FILE}::Input file not found for signing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
umask 077
|
||||
tmp_dir="$(mktemp -d)"
|
||||
cleanup() {
|
||||
rm -rf "${tmp_dir}"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
key_file="${tmp_dir}/private.pem"
|
||||
pub_file="${tmp_dir}/public.pem"
|
||||
sig_bin="${tmp_dir}/signature.bin"
|
||||
|
||||
printf '%s' "${PRIVATE_KEY}" > "${key_file}"
|
||||
|
||||
passin_args=()
|
||||
if [ -n "${PRIVATE_KEY_PASSPHRASE:-}" ]; then
|
||||
passin_args=(-passin "pass:${PRIVATE_KEY_PASSPHRASE}")
|
||||
fi
|
||||
|
||||
openssl pkey -in "${key_file}" "${passin_args[@]}" -pubout -out "${pub_file}"
|
||||
|
||||
mkdir -p "$(dirname "${SIGNATURE_FILE}")"
|
||||
# Sign with Ed25519 (requires -rawin flag for raw input)
|
||||
openssl pkeyutl -sign -rawin -inkey "${key_file}" "${passin_args[@]}" -in "${INPUT_FILE}" \
|
||||
| openssl base64 -A > "${SIGNATURE_FILE}"
|
||||
|
||||
openssl base64 -d -A -in "${SIGNATURE_FILE}" -out "${sig_bin}"
|
||||
|
||||
verify_files="${VERIFY_FILES_RAW}"
|
||||
if [ -z "${verify_files}" ]; then
|
||||
verify_files="${INPUT_FILE}"
|
||||
fi
|
||||
|
||||
while IFS= read -r verify_file; do
|
||||
[ -z "${verify_file}" ] && continue
|
||||
if [ ! -f "${verify_file}" ]; then
|
||||
echo "::error file=${verify_file}::Verification target does not exist."
|
||||
exit 1
|
||||
fi
|
||||
# Verify Ed25519 signature (requires -rawin flag for raw input)
|
||||
openssl pkeyutl -verify -rawin -pubin -inkey "${pub_file}" -sigfile "${sig_bin}" -in "${verify_file}" >/dev/null
|
||||
done <<< "${verify_files}"
|
||||
|
||||
if [ -n "${PUBLIC_KEY_OUTPUT}" ]; then
|
||||
mkdir -p "$(dirname "${PUBLIC_KEY_OUTPUT}")"
|
||||
cp "${pub_file}" "${PUBLIC_KEY_OUTPUT}"
|
||||
echo "public_key_file=${PUBLIC_KEY_OUTPUT}" >> "${GITHUB_OUTPUT}"
|
||||
else
|
||||
echo "public_key_file=" >> "${GITHUB_OUTPUT}"
|
||||
fi
|
||||
|
||||
echo "signature_file=${SIGNATURE_FILE}" >> "${GITHUB_OUTPUT}"
|
||||
@@ -1,19 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 5
|
||||
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 5
|
||||
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/.github"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 5
|
||||
@@ -1,2 +0,0 @@
|
||||
ruff==0.15.9
|
||||
bandit==1.9.4
|
||||
@@ -1,136 +0,0 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
lint-typescript:
|
||||
name: Lint TypeScript/React (${{ matrix.os }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
- name: ESLint
|
||||
run: npx eslint . --ext .ts,.tsx,.js,.jsx,.mjs --max-warnings 0
|
||||
- name: TypeScript Check
|
||||
run: npx tsc --noEmit
|
||||
- name: Build Check
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
run: npm run build
|
||||
|
||||
lint-python:
|
||||
name: Lint Python
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- name: Ruff (lint + format check)
|
||||
run: pipx run --spec "ruff==0.6.9" ruff check utils/ --output-format=github
|
||||
- name: Bandit (security)
|
||||
run: pipx run --spec "bandit==1.7.9" bandit -r utils/ -ll
|
||||
|
||||
lint-shell:
|
||||
name: Lint Shell Scripts
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: ShellCheck
|
||||
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0
|
||||
with:
|
||||
scandir: './scripts'
|
||||
severity: warning
|
||||
|
||||
security-scan:
|
||||
name: Security Scan
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Trivy FS Scan
|
||||
uses: aquasecurity/trivy-action@e368e328979b113139d6f9068e03accaed98a518 # 0.34.1
|
||||
with:
|
||||
scan-type: 'fs'
|
||||
scan-ref: '.'
|
||||
severity: 'CRITICAL,HIGH'
|
||||
exit-code: '1'
|
||||
ignore-unfixed: true
|
||||
- name: Trivy Config Scan
|
||||
uses: aquasecurity/trivy-action@e368e328979b113139d6f9068e03accaed98a518 # 0.34.1
|
||||
with:
|
||||
scan-type: 'config'
|
||||
scan-ref: '.'
|
||||
severity: 'CRITICAL,HIGH'
|
||||
exit-code: '1'
|
||||
|
||||
dependency-audit:
|
||||
name: Dependency Audit
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
- name: npm audit
|
||||
run: npm audit --audit-level=high --registry=https://registry.npmjs.org
|
||||
- name: Check for outdated deps
|
||||
run: npm outdated || true
|
||||
|
||||
clawsec-suite-tests:
|
||||
name: ClawSec Suite Verification Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
- name: Feed Verification Tests
|
||||
run: node skills/clawsec-suite/test/feed_verification.test.mjs
|
||||
- name: Guarded Install Tests
|
||||
run: node skills/clawsec-suite/test/guarded_install.test.mjs
|
||||
- name: Advisory Suppression Tests
|
||||
run: node skills/clawsec-suite/test/advisory_suppression.test.mjs
|
||||
- name: Path Resolution Tests
|
||||
run: node skills/clawsec-suite/test/path_resolution.test.mjs
|
||||
- name: Fuzz Property Tests
|
||||
run: node skills/clawsec-suite/test/fuzz_properties.test.mjs
|
||||
- name: Semver/Scope/Suppression Fuzz Tests
|
||||
run: node skills/clawsec-suite/test/fuzz_semver_scope_suppression.test.mjs
|
||||
- name: Advisory Application Scope Tests
|
||||
run: node skills/clawsec-suite/test/advisory_application_scope.test.mjs
|
||||
|
||||
openclaw-audit-watchdog-tests:
|
||||
name: OpenClaw Audit Watchdog Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
- name: Suppression Config Tests
|
||||
run: node skills/openclaw-audit-watchdog/test/suppression_config.test.mjs
|
||||
- name: Suppression Config Fuzz Tests
|
||||
run: node skills/openclaw-audit-watchdog/test/suppression_config_fuzz.test.mjs
|
||||
- name: Render Report Suppression Tests
|
||||
run: node skills/openclaw-audit-watchdog/test/render_report_suppression.test.mjs
|
||||
@@ -1,40 +0,0 @@
|
||||
name: CodeQL
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "17 3 * * 1"
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze (CodeQL)
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: ["javascript-typescript"]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # v4
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v4
|
||||
@@ -1,345 +0,0 @@
|
||||
name: Process Community Advisory
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [labeled]
|
||||
|
||||
permissions: read-all
|
||||
|
||||
concurrency:
|
||||
group: community-advisory
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
FEED_PATH: advisories/feed.json
|
||||
FEED_SIG_PATH: advisories/feed.json.sig
|
||||
SKILL_FEED_PATH: skills/clawsec-feed/advisories/feed.json
|
||||
SKILL_FEED_SIG_PATH: skills/clawsec-feed/advisories/feed.json.sig
|
||||
|
||||
jobs:
|
||||
process-advisory:
|
||||
if: github.event.label.name == 'advisory-approved'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Parse issue and create advisory
|
||||
id: parse
|
||||
env:
|
||||
ISSUE_BODY: ${{ github.event.issue.body }}
|
||||
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
||||
ISSUE_URL: ${{ github.event.issue.html_url }}
|
||||
ISSUE_TITLE: ${{ github.event.issue.title }}
|
||||
ISSUE_CREATED_AT: ${{ github.event.issue.created_at }}
|
||||
run: |
|
||||
# Generate advisory ID: CLAW-YYYY-{issue_number padded to 4 digits}
|
||||
# Use issue creation year, not current year, to ensure consistency
|
||||
YEAR=$(echo "$ISSUE_CREATED_AT" | cut -c1-4)
|
||||
PADDED_NUM=$(printf "%04d" "$ISSUE_NUMBER")
|
||||
ADVISORY_ID="CLAW-${YEAR}-${PADDED_NUM}"
|
||||
echo "advisory_id=$ADVISORY_ID" >> $GITHUB_OUTPUT
|
||||
echo "Generated advisory ID: $ADVISORY_ID"
|
||||
|
||||
# Check if advisory already exists by issue URL (dedupe by issue, not by ID)
|
||||
# This prevents duplicates when the same issue is labeled in different years
|
||||
if jq -e --arg url "$ISSUE_URL" '.advisories[] | select(.github_issue_url == $url)' "$FEED_PATH" > /dev/null 2>&1; then
|
||||
echo "Advisory for issue $ISSUE_URL already exists in feed"
|
||||
echo "already_exists=true" >> $GITHUB_OUTPUT
|
||||
exit 0
|
||||
fi
|
||||
echo "already_exists=false" >> $GITHUB_OUTPUT
|
||||
|
||||
# Parse opener type (human vs agent)
|
||||
if echo "$ISSUE_BODY" | grep -q '\[x\] Agent'; then
|
||||
OPENER_TYPE="agent"
|
||||
else
|
||||
OPENER_TYPE="human"
|
||||
fi
|
||||
echo "Opener type: $OPENER_TYPE"
|
||||
|
||||
# Parse report type
|
||||
if echo "$ISSUE_BODY" | grep -q '\[x\] Malicious Prompt'; then
|
||||
REPORT_TYPE="prompt_injection"
|
||||
elif echo "$ISSUE_BODY" | grep -q '\[x\] Vulnerable Skill'; then
|
||||
REPORT_TYPE="vulnerable_skill"
|
||||
elif echo "$ISSUE_BODY" | grep -q '\[x\] Tampering Attempt'; then
|
||||
REPORT_TYPE="tampering_attempt"
|
||||
else
|
||||
REPORT_TYPE="unknown"
|
||||
fi
|
||||
echo "Report type: $REPORT_TYPE"
|
||||
|
||||
# Parse severity
|
||||
if echo "$ISSUE_BODY" | grep -q '\[x\] Critical'; then
|
||||
SEVERITY="critical"
|
||||
elif echo "$ISSUE_BODY" | grep -q '\[x\] High'; then
|
||||
SEVERITY="high"
|
||||
elif echo "$ISSUE_BODY" | grep -q '\[x\] Medium'; then
|
||||
SEVERITY="medium"
|
||||
elif echo "$ISSUE_BODY" | grep -q '\[x\] Low'; then
|
||||
SEVERITY="low"
|
||||
else
|
||||
SEVERITY="medium"
|
||||
fi
|
||||
echo "Severity: $SEVERITY"
|
||||
|
||||
# Parse title (between ## Title and ## Description)
|
||||
TITLE=$(echo "$ISSUE_BODY" | sed -n '/^## Title/,/^## Description/p' | grep -v '^## ' | grep -v '^<!--' | grep -v '^\s*$' | head -1 | xargs)
|
||||
if [ -z "$TITLE" ]; then
|
||||
TITLE="$ISSUE_TITLE"
|
||||
fi
|
||||
echo "Title: $TITLE"
|
||||
|
||||
# Parse description (between ## Description and ---)
|
||||
DESCRIPTION=$(echo "$ISSUE_BODY" | sed -n '/^## Description/,/^---/p' | grep -v '^## Description' | grep -v '^---' | grep -v '^<!--' | sed '/^\s*$/d' | tr '\n' ' ' | xargs)
|
||||
if [ -z "$DESCRIPTION" ]; then
|
||||
DESCRIPTION="See issue for details."
|
||||
fi
|
||||
echo "Description: ${DESCRIPTION:0:100}..."
|
||||
|
||||
# Parse skill name and version
|
||||
SKILL_NAME=$(echo "$ISSUE_BODY" | sed -n '/^### Skill Name/,/^### /p' | grep -v '^### ' | grep -v '^<!--' | grep -v '^\s*$' | head -1 | xargs)
|
||||
SKILL_VERSION=$(echo "$ISSUE_BODY" | sed -n '/^### Skill Version/,/^### /p' | grep -v '^### ' | grep -v '^<!--' | grep -v '^\s*$' | head -1 | xargs)
|
||||
|
||||
# Build affected array
|
||||
AFFECTED="[]"
|
||||
if [ -n "$SKILL_NAME" ] && [ -n "$SKILL_VERSION" ]; then
|
||||
AFFECTED=$(jq -n --arg name "$SKILL_NAME" --arg ver "$SKILL_VERSION" '[$name + "@" + $ver]')
|
||||
elif [ -n "$SKILL_NAME" ]; then
|
||||
AFFECTED=$(jq -n --arg name "$SKILL_NAME" '[$name]')
|
||||
fi
|
||||
echo "Affected: $AFFECTED"
|
||||
|
||||
# Build platforms array
|
||||
OPENCLAW_SELECTED="false"
|
||||
if echo "$ISSUE_BODY" | grep -qi '^[[:space:]]*-[[:space:]]*\[[xX]\][[:space:]]*OpenClaw'; then
|
||||
OPENCLAW_SELECTED="true"
|
||||
fi
|
||||
|
||||
OTHER_PLATFORM_RAW=$(echo "$ISSUE_BODY" | sed -n 's/^[[:space:]]*-[[:space:]]*\[[xX]\][[:space:]]*Other:[[:space:]]*\(.*\)$/\1/p' | head -1 | xargs)
|
||||
OTHER_PLATFORM=""
|
||||
if [ -n "$OTHER_PLATFORM_RAW" ]; then
|
||||
OTHER_PLATFORM=$(echo "$OTHER_PLATFORM_RAW" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9._-]+/-/g; s/^-+//; s/-+$//')
|
||||
if echo "$OTHER_PLATFORM" | grep -q 'nanoclaw'; then
|
||||
OTHER_PLATFORM="nanoclaw"
|
||||
fi
|
||||
fi
|
||||
|
||||
PLATFORMS=$(jq -n --arg open "$OPENCLAW_SELECTED" --arg other "$OTHER_PLATFORM" '
|
||||
[
|
||||
(if $open == "true" then "openclaw" else empty end),
|
||||
(if ($other | length) > 0 then $other else empty end)
|
||||
] | unique
|
||||
')
|
||||
if [ "$PLATFORMS" = "[]" ]; then
|
||||
PLATFORMS='["openclaw","nanoclaw"]'
|
||||
fi
|
||||
echo "Platforms: $PLATFORMS"
|
||||
|
||||
# Parse recommended action
|
||||
ACTION=$(echo "$ISSUE_BODY" | sed -n '/^## Recommended Action/,/^---/p' | grep -v '^## Recommended Action' | grep -v '^---' | grep -v '^<!--' | sed '/^\s*$/d' | tr '\n' ' ' | xargs)
|
||||
if [ -z "$ACTION" ]; then
|
||||
ACTION="Review the advisory details and take appropriate action."
|
||||
fi
|
||||
echo "Action: ${ACTION:0:100}..."
|
||||
|
||||
# Parse reporter name
|
||||
REPORTER_NAME=$(echo "$ISSUE_BODY" | grep -A1 '\*\*Agent/User Name:\*\*' | tail -1 | sed 's/\*\*Contact:\*\*.*//' | xargs)
|
||||
if [ -z "$REPORTER_NAME" ]; then
|
||||
REPORTER_NAME=$(echo "$ISSUE_BODY" | sed -n 's/.*\*\*Agent\/User Name:\*\*\s*\(.*\)/\1/p' | xargs)
|
||||
fi
|
||||
echo "Reporter: $REPORTER_NAME"
|
||||
|
||||
# Get current timestamp
|
||||
PUBLISHED=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
|
||||
# Create advisory JSON
|
||||
jq -n \
|
||||
--arg id "$ADVISORY_ID" \
|
||||
--arg severity "$SEVERITY" \
|
||||
--arg type "$REPORT_TYPE" \
|
||||
--arg title "$TITLE" \
|
||||
--arg description "$DESCRIPTION" \
|
||||
--argjson affected "$AFFECTED" \
|
||||
--argjson platforms "$PLATFORMS" \
|
||||
--arg action "$ACTION" \
|
||||
--arg published "$PUBLISHED" \
|
||||
--arg source "Community Report" \
|
||||
--arg issue_url "$ISSUE_URL" \
|
||||
--arg reporter_name "$REPORTER_NAME" \
|
||||
--arg opener_type "$OPENER_TYPE" \
|
||||
'{
|
||||
id: $id,
|
||||
severity: $severity,
|
||||
type: $type,
|
||||
title: $title,
|
||||
description: $description,
|
||||
affected: $affected,
|
||||
platforms: $platforms,
|
||||
action: $action,
|
||||
published: $published,
|
||||
references: [],
|
||||
source: $source,
|
||||
github_issue_url: $issue_url,
|
||||
reporter: {
|
||||
agent_name: $reporter_name,
|
||||
opener_type: $opener_type
|
||||
}
|
||||
}' > tmp_advisory.json
|
||||
|
||||
echo "Created advisory JSON:"
|
||||
cat tmp_advisory.json
|
||||
|
||||
- name: Set up Python for exploitability analysis
|
||||
if: steps.parse.outputs.already_exists != 'true'
|
||||
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Analyze exploitability for community advisory
|
||||
if: steps.parse.outputs.already_exists != 'true'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
echo "=== Analyzing exploitability for community advisory ==="
|
||||
|
||||
scripts/ci/enrich_exploitability.sh \
|
||||
--mode single \
|
||||
--input tmp_advisory.json \
|
||||
--output tmp_advisory.json
|
||||
|
||||
echo "=== Exploitability analysis complete ==="
|
||||
echo "Exploitability score: $(jq -r '.exploitability_score // "unknown"' tmp_advisory.json)"
|
||||
|
||||
- name: Update feed
|
||||
if: steps.parse.outputs.already_exists != 'true'
|
||||
run: |
|
||||
NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
|
||||
# Add new advisory to feed
|
||||
jq --argjson new "$(cat tmp_advisory.json)" --arg now "$NOW" '
|
||||
.updated = $now |
|
||||
.advisories = ([$new] + .advisories)
|
||||
' "$FEED_PATH" > tmp_feed.json
|
||||
|
||||
# Validate JSON
|
||||
if jq empty tmp_feed.json 2>/dev/null; then
|
||||
echo "Feed JSON is valid"
|
||||
mv tmp_feed.json "$FEED_PATH"
|
||||
|
||||
# Sync to skill feed
|
||||
mkdir -p "$(dirname "$SKILL_FEED_PATH")"
|
||||
cp "$FEED_PATH" "$SKILL_FEED_PATH"
|
||||
|
||||
echo "Updated feeds:"
|
||||
echo " - $FEED_PATH"
|
||||
echo " - $SKILL_FEED_PATH"
|
||||
|
||||
TOTAL=$(jq '.advisories | length' "$FEED_PATH")
|
||||
echo "Total advisories: $TOTAL"
|
||||
else
|
||||
echo "Error: Generated invalid JSON"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Sign advisory feed and verify
|
||||
if: steps.parse.outputs.already_exists != 'true'
|
||||
uses: ./.github/actions/sign-and-verify
|
||||
with:
|
||||
private_key: ${{ secrets.CLAWSEC_SIGNING_PRIVATE_KEY }}
|
||||
private_key_passphrase: ${{ secrets.CLAWSEC_SIGNING_PRIVATE_KEY_PASSPHRASE }}
|
||||
input_file: ${{ env.FEED_PATH }}
|
||||
signature_file: ${{ env.FEED_SIG_PATH }}
|
||||
verify_files: |
|
||||
${{ env.FEED_PATH }}
|
||||
${{ env.SKILL_FEED_PATH }}
|
||||
|
||||
- name: Sync advisory signature to skill feed
|
||||
if: steps.parse.outputs.already_exists != 'true'
|
||||
run: cp "$FEED_SIG_PATH" "$SKILL_FEED_SIG_PATH"
|
||||
|
||||
- name: Require automation token for write operations
|
||||
env:
|
||||
AUTOMATION_TOKEN: ${{ secrets.POLL_NVD_CVES_PAT }}
|
||||
run: |
|
||||
if [ -z "$AUTOMATION_TOKEN" ]; then
|
||||
echo "::error::Set POLL_NVD_CVES_PAT with repo write permissions."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Create Pull Request
|
||||
if: steps.parse.outputs.already_exists != 'true'
|
||||
id: create-pr
|
||||
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
|
||||
with:
|
||||
token: ${{ secrets.POLL_NVD_CVES_PAT }}
|
||||
branch: automated/community-advisory-${{ github.event.issue.number }}
|
||||
delete-branch: true
|
||||
title: "chore: add community advisory ${{ steps.parse.outputs.advisory_id }}"
|
||||
body: |
|
||||
## Summary
|
||||
Add community advisory `${{ steps.parse.outputs.advisory_id }}` from issue #${{ github.event.issue.number }}.
|
||||
|
||||
- Issue: ${{ github.event.issue.html_url }}
|
||||
- Reporter: @${{ github.event.issue.user.login }}
|
||||
- Trigger: `advisory-approved` label
|
||||
|
||||
---
|
||||
*This PR was generated by the community advisory workflow.*
|
||||
commit-message: |
|
||||
chore: add community advisory ${{ steps.parse.outputs.advisory_id }}
|
||||
|
||||
Added from issue #${{ github.event.issue.number }}
|
||||
Issue: ${{ github.event.issue.html_url }}
|
||||
add-paths: |
|
||||
${{ env.FEED_PATH }}
|
||||
${{ env.FEED_SIG_PATH }}
|
||||
${{ env.SKILL_FEED_PATH }}
|
||||
${{ env.SKILL_FEED_SIG_PATH }}
|
||||
|
||||
- name: Comment on issue
|
||||
if: steps.parse.outputs.already_exists != 'true'
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||
with:
|
||||
github-token: ${{ secrets.POLL_NVD_CVES_PAT }}
|
||||
script: |
|
||||
const advisoryId = '${{ steps.parse.outputs.advisory_id }}';
|
||||
const pullRequestUrl = '${{ steps.create-pr.outputs.pull-request-url }}';
|
||||
const operation = '${{ steps.create-pr.outputs.pull-request-operation }}';
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: `## Advisory Pull Request Opened
|
||||
|
||||
This security report has been prepared for publication in the ClawSec advisory feed.
|
||||
|
||||
**Advisory ID:** \`${advisoryId}\`
|
||||
**Pull Request:** ${pullRequestUrl || 'No PR generated (no file changes detected)'}
|
||||
**PR Operation:** \`${operation || 'none'}\`
|
||||
|
||||
The advisory will be published after the pull request is merged.
|
||||
|
||||
Thank you for your contribution to community security!`
|
||||
});
|
||||
|
||||
- name: Comment if already exists
|
||||
if: steps.parse.outputs.already_exists == 'true'
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||
with:
|
||||
github-token: ${{ secrets.POLL_NVD_CVES_PAT }}
|
||||
script: |
|
||||
const advisoryId = '${{ steps.parse.outputs.advisory_id }}';
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.issue.number,
|
||||
body: `## Advisory Already Exists
|
||||
|
||||
An advisory with ID \`${advisoryId}\` already exists in the feed. No changes were made.
|
||||
|
||||
If this is a different issue, please open a new issue.`
|
||||
});
|
||||
@@ -1,438 +0,0 @@
|
||||
name: Deploy to GitHub Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_run:
|
||||
workflows: ["Skill Release"]
|
||||
types: [completed]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
# Production build only: manual dispatch, push to main, or trusted release workflows.
|
||||
# PR validation runs in .github/workflows/pages-verify.yml.
|
||||
if: |
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
(
|
||||
github.event_name == 'push' &&
|
||||
github.ref_name == 'main'
|
||||
) ||
|
||||
(
|
||||
github.event_name == 'workflow_run' &&
|
||||
github.event.workflow_run.conclusion == 'success' &&
|
||||
github.event.workflow_run.name == 'Skill Release' &&
|
||||
github.event.workflow_run.event != 'pull_request'
|
||||
)
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Verify signing key consistency (repo + docs)
|
||||
run: ./scripts/ci/verify_signing_key_consistency.sh
|
||||
|
||||
- name: Auto-discover skills from releases
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p public/skills
|
||||
mkdir -p public/releases/download
|
||||
|
||||
echo "Fetching releases from GitHub API..."
|
||||
|
||||
# Helper function to download release asset by ID (works for private repos)
|
||||
download_asset() {
|
||||
local asset_id="$1"
|
||||
local output_file="$2"
|
||||
curl -fsSL \
|
||||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
|
||||
-H "Accept: application/octet-stream" \
|
||||
"https://api.github.com/repos/${REPO}/releases/assets/${asset_id}" \
|
||||
-o "$output_file"
|
||||
}
|
||||
export -f download_asset # Export for use in subshells (while loop)
|
||||
|
||||
# Fetch all releases (paginated)
|
||||
RELEASES=$(gh api --paginate \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
"/repos/${REPO}/releases?per_page=100" \
|
||||
| jq -s 'add // []')
|
||||
|
||||
# Start building skills index
|
||||
echo '{"version":"1.0.0","updated":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","skills":[' > public/skills/index.json
|
||||
|
||||
FIRST_SKILL=true
|
||||
declare -A PROCESSED_SKILLS=()
|
||||
|
||||
# Process each release (using process substitution to avoid subshell)
|
||||
while read -r release; do
|
||||
TAG=$(echo "$release" | jq -r '.tag_name')
|
||||
|
||||
# Parse skill-name-v* pattern
|
||||
if [[ "$TAG" =~ ^(.+)-v([0-9]+\.[0-9]+\.[0-9]+.*)$ ]]; then
|
||||
SKILL_NAME="${BASH_REMATCH[1]}"
|
||||
VERSION="${BASH_REMATCH[2]}"
|
||||
|
||||
# Skip if we already processed a newer version of this skill
|
||||
if [[ -n "${PROCESSED_SKILLS[$SKILL_NAME]+x}" ]]; then
|
||||
echo "Skipping older version: $TAG (already have newer)"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Processing: $SKILL_NAME v$VERSION"
|
||||
|
||||
# Get skill.json asset ID from release
|
||||
SKILL_JSON_ID=$(echo "$release" | jq -r '.assets[] | select(.name=="skill.json") | .id')
|
||||
|
||||
if [ -n "$SKILL_JSON_ID" ] && [ "$SKILL_JSON_ID" != "null" ]; then
|
||||
# Basic safety checks before using tag/asset names as paths
|
||||
if [[ "$TAG" == *"/"* ]] || [[ "$TAG" == *".."* ]]; then
|
||||
echo " Warning: Skipping suspicious tag name: $TAG"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Download skill.json first to decide whether the skill is internal
|
||||
SKILL_JSON_TMP=$(mktemp)
|
||||
download_asset "$SKILL_JSON_ID" "$SKILL_JSON_TMP"
|
||||
|
||||
# Skip internal skills (not shown in public catalog or mirrored)
|
||||
IS_INTERNAL=$(jq -r '.openclaw.internal // false' "$SKILL_JSON_TMP")
|
||||
if [ "$IS_INTERNAL" = "true" ]; then
|
||||
echo " Skipping internal skill: $SKILL_NAME"
|
||||
rm -f "$SKILL_JSON_TMP"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Security: Download to temp directory first, verify signatures, then mirror to final location.
|
||||
# This ensures unverified releases never appear in public/releases or the skills catalog.
|
||||
|
||||
# Use temp directory for downloads before verification
|
||||
TEMP_DOWNLOAD_DIR=$(mktemp -d)
|
||||
|
||||
# Move skill.json to temp dir first
|
||||
mv "$SKILL_JSON_TMP" "$TEMP_DOWNLOAD_DIR/skill.json"
|
||||
|
||||
# Download all remaining assets to temp dir
|
||||
while read -r asset; do
|
||||
ASSET_ID=$(echo "$asset" | jq -r '.id')
|
||||
ASSET_NAME=$(echo "$asset" | jq -r '.name')
|
||||
|
||||
# Prevent path traversal / nested directories
|
||||
if [[ "$ASSET_NAME" == *"/"* ]] || [[ "$ASSET_NAME" == *".."* ]]; then
|
||||
echo " Warning: Skipping suspicious asset name: $ASSET_NAME"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Already downloaded above
|
||||
if [ "$ASSET_NAME" = "skill.json" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
download_asset "$ASSET_ID" "$TEMP_DOWNLOAD_DIR/$ASSET_NAME"
|
||||
echo " Downloaded to temp: $ASSET_NAME"
|
||||
done < <(echo "$release" | jq -c '.assets[]')
|
||||
|
||||
# Verify signed checksums when signature artifacts are present.
|
||||
# Legacy releases without signatures are still mirrored for backward compatibility.
|
||||
if [ -f "$TEMP_DOWNLOAD_DIR/checksums.sig" ] && [ -f "$TEMP_DOWNLOAD_DIR/signing-public.pem" ] && [ -f "$TEMP_DOWNLOAD_DIR/checksums.json" ]; then
|
||||
openssl base64 -d -A -in "$TEMP_DOWNLOAD_DIR/checksums.sig" -out "$TEMP_DOWNLOAD_DIR/checksums.sig.bin"
|
||||
# Verify Ed25519 signature (requires -rawin)
|
||||
if ! openssl pkeyutl -verify -rawin -pubin -inkey "$TEMP_DOWNLOAD_DIR/signing-public.pem" -sigfile "$TEMP_DOWNLOAD_DIR/checksums.sig.bin" -in "$TEMP_DOWNLOAD_DIR/checksums.json"; then
|
||||
echo " Warning: Invalid checksums signature for $TAG; skipping skill"
|
||||
rm -rf "$TEMP_DOWNLOAD_DIR"
|
||||
continue
|
||||
fi
|
||||
rm -f "$TEMP_DOWNLOAD_DIR/checksums.sig.bin"
|
||||
echo " Verified checksums signature"
|
||||
elif [ -f "$TEMP_DOWNLOAD_DIR/checksums.json" ]; then
|
||||
echo " Warning: Unsigned legacy checksums for $TAG (missing checksums.sig/signing-public.pem)"
|
||||
fi
|
||||
|
||||
# Verification passed or skipped (legacy) - mirror to final location
|
||||
MIRROR_DIR="public/releases/download/${TAG}"
|
||||
mkdir -p "$MIRROR_DIR"
|
||||
cp -r "$TEMP_DOWNLOAD_DIR"/* "$MIRROR_DIR"/
|
||||
echo " Mirrored to: $MIRROR_DIR"
|
||||
|
||||
# Clean up temp directory
|
||||
rm -rf "$TEMP_DOWNLOAD_DIR"
|
||||
|
||||
# Copy the subset needed for the site catalog (skill pages)
|
||||
mkdir -p "public/skills/${SKILL_NAME}"
|
||||
cp "$MIRROR_DIR/skill.json" "public/skills/${SKILL_NAME}/skill.json"
|
||||
echo " Added to catalog: skill.json"
|
||||
|
||||
for file in checksums.json checksums.sig signing-public.pem README.md SKILL.md; do
|
||||
if [ -f "$MIRROR_DIR/$file" ]; then
|
||||
cp "$MIRROR_DIR/$file" "public/skills/${SKILL_NAME}/$file"
|
||||
echo " Added to catalog: $file"
|
||||
fi
|
||||
done
|
||||
|
||||
# Build skill entry for index
|
||||
SKILL_DATA=$(jq -c --arg tag "$TAG" '{
|
||||
id: .name,
|
||||
name: .name,
|
||||
version: .version,
|
||||
description: .description,
|
||||
emoji: .openclaw.emoji,
|
||||
category: .openclaw.category,
|
||||
trust: .trust.level,
|
||||
tag: $tag
|
||||
}' "$MIRROR_DIR/skill.json")
|
||||
|
||||
# Append to index (handle first entry without comma)
|
||||
if [ -f "public/skills/.first_done" ]; then
|
||||
echo "," >> public/skills/index.json
|
||||
else
|
||||
touch "public/skills/.first_done"
|
||||
fi
|
||||
echo "$SKILL_DATA" >> public/skills/index.json
|
||||
|
||||
# Mark this skill as processed (track newest only)
|
||||
PROCESSED_SKILLS["$SKILL_NAME"]=1
|
||||
else
|
||||
echo " Warning: skill.json not found in release assets"
|
||||
fi
|
||||
fi
|
||||
done < <(echo "$RELEASES" | jq -c '.[]')
|
||||
|
||||
# Close the JSON array
|
||||
echo ']}' >> public/skills/index.json
|
||||
|
||||
# Clean up temp file
|
||||
rm -f "public/skills/.first_done"
|
||||
|
||||
echo ""
|
||||
echo "=== Skills Index ==="
|
||||
cat public/skills/index.json | jq . || cat public/skills/index.json
|
||||
|
||||
echo ""
|
||||
echo "=== Skills Directory ==="
|
||||
ls -la public/skills/
|
||||
|
||||
- name: Copy advisory feed to public
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p public/advisories
|
||||
cp advisories/feed.json public/advisories/feed.json
|
||||
echo "Copied advisory feed to public/advisories/"
|
||||
cat public/advisories/feed.json | jq '.advisories | length' | xargs -I {} echo "Feed contains {} advisories"
|
||||
|
||||
- name: Generate advisory checksums manifest
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
FEED_FILE="public/advisories/feed.json"
|
||||
FEED_SHA=$(sha256sum "$FEED_FILE" | awk '{print $1}')
|
||||
FEED_SIZE=$(stat -c%s "$FEED_FILE" 2>/dev/null || stat -f%z "$FEED_FILE")
|
||||
|
||||
# Generate checksums manifest conforming to parseChecksumsManifest expectations:
|
||||
# - schema_version: "1" (manifest format version)
|
||||
# - algorithm: "sha256" (hash algorithm)
|
||||
# - version: "1.1.0" (feed content version, for informational purposes)
|
||||
# - generated_at, repository: metadata
|
||||
# - files: map of path -> {sha256, size, path, url}
|
||||
jq -n \
|
||||
--arg schema_version "1" \
|
||||
--arg algorithm "sha256" \
|
||||
--arg version "1.1.0" \
|
||||
--arg generated "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||
--arg repo "${{ github.repository }}" \
|
||||
--arg sha "$FEED_SHA" \
|
||||
--argjson size "$FEED_SIZE" \
|
||||
'{
|
||||
schema_version: $schema_version,
|
||||
algorithm: $algorithm,
|
||||
version: $version,
|
||||
generated_at: $generated,
|
||||
repository: $repo,
|
||||
files: {
|
||||
"advisories/feed.json": {
|
||||
sha256: $sha,
|
||||
size: $size,
|
||||
path: "advisories/feed.json",
|
||||
url: "https://clawsec.prompt.security/advisories/feed.json"
|
||||
}
|
||||
}
|
||||
}' > public/checksums.json
|
||||
|
||||
echo "Generated public/checksums.json"
|
||||
jq . public/checksums.json
|
||||
|
||||
- name: Sign advisory feed and verify
|
||||
uses: ./.github/actions/sign-and-verify
|
||||
with:
|
||||
private_key: ${{ secrets.CLAWSEC_SIGNING_PRIVATE_KEY }}
|
||||
private_key_passphrase: ${{ secrets.CLAWSEC_SIGNING_PRIVATE_KEY_PASSPHRASE }}
|
||||
input_file: public/advisories/feed.json
|
||||
signature_file: public/advisories/feed.json.sig
|
||||
public_key_output: public/signing-public.pem
|
||||
|
||||
- name: Sign checksums and verify
|
||||
uses: ./.github/actions/sign-and-verify
|
||||
with:
|
||||
private_key: ${{ secrets.CLAWSEC_SIGNING_PRIVATE_KEY }}
|
||||
private_key_passphrase: ${{ secrets.CLAWSEC_SIGNING_PRIVATE_KEY_PASSPHRASE }}
|
||||
input_file: public/checksums.json
|
||||
signature_file: public/checksums.sig
|
||||
|
||||
- name: Verify generated public signing key matches canonical key
|
||||
run: |
|
||||
set -euo pipefail
|
||||
CANONICAL_FPR=$(openssl pkey -pubin -in clawsec-signing-public.pem -outform DER | sha256sum | awk '{print $1}')
|
||||
GENERATED_FPR=$(openssl pkey -pubin -in public/signing-public.pem -outform DER | sha256sum | awk '{print $1}')
|
||||
echo "Canonical key fingerprint: $CANONICAL_FPR"
|
||||
echo "Generated key fingerprint: $GENERATED_FPR"
|
||||
if [ "$CANONICAL_FPR" != "$GENERATED_FPR" ]; then
|
||||
echo "::error::public/signing-public.pem fingerprint mismatch vs clawsec-signing-public.pem"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Copy public key to advisory directory
|
||||
run: |
|
||||
# Clients expect the public key at advisories/feed-signing-public.pem
|
||||
mkdir -p public/advisories
|
||||
cp public/signing-public.pem public/advisories/feed-signing-public.pem
|
||||
echo "Public key available at:"
|
||||
echo " - public/signing-public.pem (root)"
|
||||
echo " - public/advisories/feed-signing-public.pem (advisory-specific)"
|
||||
|
||||
- name: Show signed advisory artifacts
|
||||
run: |
|
||||
echo "Signed advisory artifacts:"
|
||||
ls -la public/advisories/feed.json*
|
||||
ls -la public/checksums.json public/checksums.sig public/signing-public.pem
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Get latest clawsec-suite release URL
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
run: |
|
||||
LATEST_TAG=$(
|
||||
gh api --paginate \
|
||||
-H "Accept: application/vnd.github+json" \
|
||||
"/repos/${REPO}/releases?per_page=100" \
|
||||
| jq -r -s 'add // [] | [.[] | select(.tag_name | startswith("clawsec-suite-v"))] | first | .tag_name // empty'
|
||||
)
|
||||
|
||||
if [ -n "$LATEST_TAG" ]; then
|
||||
echo "Found latest clawsec-suite tag: $LATEST_TAG"
|
||||
echo "VITE_CLAWSEC_SUITE_URL=https://clawsec.prompt.security/releases/download/${LATEST_TAG}/SKILL.md" >> $GITHUB_ENV
|
||||
|
||||
# Create a local "latest" mirror path for clients that use GitHub-style URLs.
|
||||
# This enables swapping the host:
|
||||
# https://github.com/<repo>/releases/latest/download/<file>
|
||||
# → https://clawsec.prompt.security/releases/latest/download/<file>
|
||||
MIRROR_TAG_DIR="public/releases/download/${LATEST_TAG}"
|
||||
MIRROR_LATEST_DIR="public/releases/latest/download"
|
||||
rm -rf "$MIRROR_LATEST_DIR"
|
||||
mkdir -p "$MIRROR_LATEST_DIR"
|
||||
|
||||
if [ -d "$MIRROR_TAG_DIR" ]; then
|
||||
cp -f "$MIRROR_TAG_DIR"/* "$MIRROR_LATEST_DIR"/ 2>/dev/null || true
|
||||
echo "Mirrored suite release assets to: $MIRROR_LATEST_DIR"
|
||||
else
|
||||
echo "Warning: Suite release assets not mirrored (missing: $MIRROR_TAG_DIR)"
|
||||
fi
|
||||
|
||||
# Mirror advisories feed + signatures at the path referenced by suite docs/heartbeat
|
||||
if [ -f "public/advisories/feed.json" ]; then
|
||||
mkdir -p "$MIRROR_LATEST_DIR/advisories"
|
||||
cp "public/advisories/feed.json" "$MIRROR_LATEST_DIR/advisories/feed.json"
|
||||
cp "public/advisories/feed.json" "$MIRROR_LATEST_DIR/feed.json"
|
||||
fi
|
||||
if [ -f "public/advisories/feed.json.sig" ]; then
|
||||
mkdir -p "$MIRROR_LATEST_DIR/advisories"
|
||||
cp "public/advisories/feed.json.sig" "$MIRROR_LATEST_DIR/advisories/feed.json.sig"
|
||||
cp "public/advisories/feed.json.sig" "$MIRROR_LATEST_DIR/feed.json.sig"
|
||||
fi
|
||||
if [ -f "public/checksums.json" ]; then
|
||||
cp "public/checksums.json" "$MIRROR_LATEST_DIR/checksums.json"
|
||||
fi
|
||||
if [ -f "public/checksums.sig" ]; then
|
||||
cp "public/checksums.sig" "$MIRROR_LATEST_DIR/checksums.sig"
|
||||
fi
|
||||
if [ -f "public/signing-public.pem" ]; then
|
||||
cp "public/signing-public.pem" "$MIRROR_LATEST_DIR/signing-public.pem"
|
||||
fi
|
||||
else
|
||||
echo "No clawsec-suite release found, using fallback"
|
||||
fi
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
env:
|
||||
NODE_ENV: production
|
||||
VITE_CLAWSEC_SUITE_URL: ${{ env.VITE_CLAWSEC_SUITE_URL }}
|
||||
|
||||
- name: Copy skills data to dist
|
||||
run: |
|
||||
cp -r public/skills dist/skills 2>/dev/null || echo "No skills directory"
|
||||
cp public/checksums.json dist/checksums.json 2>/dev/null || echo "No checksums manifest"
|
||||
cp public/checksums.sig dist/checksums.sig 2>/dev/null || echo "No checksums signature"
|
||||
cp public/signing-public.pem dist/signing-public.pem 2>/dev/null || echo "No signing public key"
|
||||
cp -r public/advisories dist/advisories 2>/dev/null || echo "No advisories directory"
|
||||
|
||||
echo "=== Dist contents ==="
|
||||
ls -la dist/
|
||||
ls -la dist/skills/ 2>/dev/null || echo "No skills in dist"
|
||||
ls -la dist/advisories/ 2>/dev/null || echo "No advisories in dist"
|
||||
|
||||
- name: Add .nojekyll file
|
||||
run: touch dist/.nojekyll
|
||||
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
|
||||
with:
|
||||
path: ./dist
|
||||
|
||||
deploy:
|
||||
# Deploy after a production build succeeds.
|
||||
if: |
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
(
|
||||
github.event_name == 'push' &&
|
||||
github.ref_name == 'main'
|
||||
) ||
|
||||
(
|
||||
github.event_name == 'workflow_run' &&
|
||||
github.event.workflow_run.conclusion == 'success' &&
|
||||
github.event.workflow_run.name == 'Skill Release' &&
|
||||
github.event.workflow_run.event != 'pull_request'
|
||||
)
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
|
||||
@@ -1,111 +0,0 @@
|
||||
name: Pages Verify
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: pages-verify-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
verify-pages-build:
|
||||
name: Verify Pages Build (No Publish)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Verify signing key consistency (repo + docs)
|
||||
run: ./scripts/ci/verify_signing_key_consistency.sh
|
||||
|
||||
- name: Prepare advisory artifacts for pre-deploy checks
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p public/advisories
|
||||
cp advisories/feed.json public/advisories/feed.json
|
||||
|
||||
- name: Generate advisory checksums manifest
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
FEED_FILE="public/advisories/feed.json"
|
||||
FEED_SHA=$(sha256sum "$FEED_FILE" | awk '{print $1}')
|
||||
FEED_SIZE=$(stat -c%s "$FEED_FILE" 2>/dev/null || stat -f%z "$FEED_FILE")
|
||||
|
||||
jq -n \
|
||||
--arg schema_version "1" \
|
||||
--arg algorithm "sha256" \
|
||||
--arg version "1.1.0" \
|
||||
--arg generated "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||
--arg repo "${{ github.repository }}" \
|
||||
--arg sha "$FEED_SHA" \
|
||||
--argjson size "$FEED_SIZE" \
|
||||
'{
|
||||
schema_version: $schema_version,
|
||||
algorithm: $algorithm,
|
||||
version: $version,
|
||||
generated_at: $generated,
|
||||
repository: $repo,
|
||||
files: {
|
||||
"advisories/feed.json": {
|
||||
sha256: $sha,
|
||||
size: $size,
|
||||
path: "advisories/feed.json",
|
||||
url: "https://clawsec.prompt.security/advisories/feed.json"
|
||||
}
|
||||
}
|
||||
}' > public/checksums.json
|
||||
|
||||
- name: Generate ephemeral signing key for PR verification
|
||||
id: test_key
|
||||
run: |
|
||||
set -euo pipefail
|
||||
KEY_FILE=$(mktemp)
|
||||
openssl genpkey -algorithm Ed25519 -out "$KEY_FILE"
|
||||
{
|
||||
echo "private_key<<EOF"
|
||||
cat "$KEY_FILE"
|
||||
echo "EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
rm -f "$KEY_FILE"
|
||||
|
||||
- name: Sign advisory feed and verify
|
||||
uses: ./.github/actions/sign-and-verify
|
||||
with:
|
||||
private_key: ${{ steps.test_key.outputs.private_key }}
|
||||
input_file: public/advisories/feed.json
|
||||
signature_file: public/advisories/feed.json.sig
|
||||
public_key_output: public/signing-public.pem
|
||||
|
||||
- name: Sign checksums and verify
|
||||
uses: ./.github/actions/sign-and-verify
|
||||
with:
|
||||
private_key: ${{ steps.test_key.outputs.private_key }}
|
||||
input_file: public/checksums.json
|
||||
signature_file: public/checksums.sig
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build site
|
||||
run: npm run build
|
||||
env:
|
||||
NODE_ENV: production
|
||||
|
||||
- name: Sanity-check generated artifacts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
test -f dist/index.html
|
||||
test -f public/advisories/feed.json.sig
|
||||
test -f public/checksums.sig
|
||||
test -f public/signing-public.pem
|
||||
@@ -1,986 +0,0 @@
|
||||
name: Poll NVD CVEs
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Run daily at 06:00 UTC
|
||||
- cron: '0 6 * * *'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
force_full_scan:
|
||||
description: 'Ignore feed state and rebuild CVE advisories from full NVD history'
|
||||
required: false
|
||||
default: 'false'
|
||||
type: boolean
|
||||
|
||||
permissions: read-all
|
||||
|
||||
concurrency:
|
||||
group: poll-nvd-cves
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
FEED_PATH: advisories/feed.json
|
||||
FEED_SIG_PATH: advisories/feed.json.sig
|
||||
SKILL_FEED_PATH: skills/clawsec-feed/advisories/feed.json
|
||||
SKILL_FEED_SIG_PATH: skills/clawsec-feed/advisories/feed.json.sig
|
||||
KEYWORDS: "OpenClaw clawdbot Moltbot NanoClaw WhatsApp-bot baileys"
|
||||
GITHUB_REF_PATTERN: "github.com/openclaw/openclaw github.com/qwibitai/NanoClaw"
|
||||
|
||||
jobs:
|
||||
poll-and-update:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: write
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Get last poll date from feed
|
||||
id: last_poll
|
||||
run: |
|
||||
if [ -f "$FEED_PATH" ]; then
|
||||
LAST_UPDATED=$(jq -r '.updated // empty' "$FEED_PATH")
|
||||
if [ -n "$LAST_UPDATED" ] && [ "${{ inputs.force_full_scan }}" != "true" ]; then
|
||||
echo "last_date=$LAST_UPDATED" >> $GITHUB_OUTPUT
|
||||
echo "Found last updated: $LAST_UPDATED"
|
||||
else
|
||||
# Default to 120 days ago if no date found or force scan
|
||||
LAST_UPDATED=$(date -u -d '120 days ago' +%Y-%m-%dT%H:%M:%S.000Z 2>/dev/null || date -u -v-120d +%Y-%m-%dT%H:%M:%S.000Z)
|
||||
echo "last_date=$LAST_UPDATED" >> $GITHUB_OUTPUT
|
||||
echo "Using default date: $LAST_UPDATED"
|
||||
fi
|
||||
else
|
||||
LAST_UPDATED=$(date -u -d '120 days ago' +%Y-%m-%dT%H:%M:%S.000Z 2>/dev/null || date -u -v-120d +%Y-%m-%dT%H:%M:%S.000Z)
|
||||
echo "last_date=$LAST_UPDATED" >> $GITHUB_OUTPUT
|
||||
echo "No feed found, using default: $LAST_UPDATED"
|
||||
fi
|
||||
|
||||
- name: Set date window
|
||||
id: dates
|
||||
run: |
|
||||
START_DATE="${{ steps.last_poll.outputs.last_date }}"
|
||||
END_DATE=$(date -u +%Y-%m-%dT%H:%M:%S.000Z)
|
||||
|
||||
# Convert to epoch for comparison
|
||||
START_EPOCH=$(date -d "$START_DATE" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S" "${START_DATE%.*}" +%s)
|
||||
END_EPOCH=$(date -d "$END_DATE" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S" "${END_DATE%.*}" +%s)
|
||||
|
||||
# Ensure start date is before end date (NVD returns 404 if start > end)
|
||||
if [ "$START_EPOCH" -ge "$END_EPOCH" ]; then
|
||||
echo "Warning: Start date ($START_DATE) is not before end date ($END_DATE)"
|
||||
echo "Adjusting start date to 24 hours before end date"
|
||||
START_EPOCH=$((END_EPOCH - 86400))
|
||||
START_DATE=$(date -u -d "@$START_EPOCH" +%Y-%m-%dT%H:%M:%S.000Z 2>/dev/null || date -u -r "$START_EPOCH" +%Y-%m-%dT%H:%M:%S.000Z)
|
||||
fi
|
||||
|
||||
echo "start_date=$START_DATE" >> $GITHUB_OUTPUT
|
||||
echo "end_date=$END_DATE" >> $GITHUB_OUTPUT
|
||||
echo "Polling window: $START_DATE to $END_DATE"
|
||||
|
||||
- name: Fetch CVEs from NVD
|
||||
id: fetch
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p tmp
|
||||
FORCE_FULL_SCAN="${{ inputs.force_full_scan }}"
|
||||
|
||||
START_DATE="${{ steps.dates.outputs.start_date }}"
|
||||
END_DATE="${{ steps.dates.outputs.end_date }}"
|
||||
|
||||
# URL encode the dates
|
||||
START_ENC=$(echo "$START_DATE" | sed 's/:/%3A/g')
|
||||
END_ENC=$(echo "$END_DATE" | sed 's/:/%3A/g')
|
||||
|
||||
echo "=== Fetching CVEs from NVD ==="
|
||||
|
||||
FAILED_KEYWORDS=()
|
||||
|
||||
# Fetch for each keyword
|
||||
for KEYWORD in $KEYWORDS; do
|
||||
echo "Fetching keyword: $KEYWORD"
|
||||
|
||||
keyword_ok=false
|
||||
last_http_code=""
|
||||
|
||||
if [ "$FORCE_FULL_SCAN" = "true" ]; then
|
||||
echo "Full scan mode enabled: paginating complete NVD history for keyword '$KEYWORD'"
|
||||
echo '{"vulnerabilities":[]}' > "tmp/nvd_${KEYWORD}.json"
|
||||
START_INDEX=0
|
||||
RESULTS_PER_PAGE=2000
|
||||
|
||||
while true; do
|
||||
URL="https://services.nvd.nist.gov/rest/json/cves/2.0?keywordSearch=${KEYWORD}&startIndex=${START_INDEX}&resultsPerPage=${RESULTS_PER_PAGE}"
|
||||
PAGE_FILE="tmp/nvd_${KEYWORD}_${START_INDEX}.json"
|
||||
echo "URL: $URL"
|
||||
|
||||
page_ok=false
|
||||
for i in 1 2 3; do
|
||||
HTTP_CODE=$(curl -sS -w "%{http_code}" -o "$PAGE_FILE" "$URL" || true)
|
||||
if [ -z "$HTTP_CODE" ]; then
|
||||
HTTP_CODE="000"
|
||||
fi
|
||||
last_http_code="$HTTP_CODE"
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
if jq -e . "$PAGE_FILE" >/dev/null 2>&1; then
|
||||
page_ok=true
|
||||
break
|
||||
fi
|
||||
echo "Invalid JSON for $KEYWORD page $START_INDEX, retry $i..."
|
||||
sleep 5
|
||||
elif [ "$HTTP_CODE" = "403" ] || [ "$HTTP_CODE" = "429" ]; then
|
||||
echo "Rate limited, waiting 30s before retry $i..."
|
||||
sleep 30
|
||||
else
|
||||
echo "HTTP $HTTP_CODE for $KEYWORD page $START_INDEX, retry $i..."
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$page_ok" != "true" ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
jq -s '.[0].vulnerabilities += .[1].vulnerabilities | .[0]' \
|
||||
"tmp/nvd_${KEYWORD}.json" "$PAGE_FILE" > "tmp/nvd_${KEYWORD}_merged.json"
|
||||
mv "tmp/nvd_${KEYWORD}_merged.json" "tmp/nvd_${KEYWORD}.json"
|
||||
|
||||
PAGE_COUNT=$(jq '.vulnerabilities | length' "$PAGE_FILE")
|
||||
TOTAL_RESULTS=$(jq '.totalResults // 0' "$PAGE_FILE")
|
||||
echo "Fetched $PAGE_COUNT results at startIndex=$START_INDEX (totalResults=$TOTAL_RESULTS)"
|
||||
|
||||
START_INDEX=$((START_INDEX + RESULTS_PER_PAGE))
|
||||
if [ "$START_INDEX" -ge "$TOTAL_RESULTS" ] || [ "$PAGE_COUNT" -eq 0 ]; then
|
||||
keyword_ok=true
|
||||
break
|
||||
fi
|
||||
|
||||
# NVD recommends 6 second delay between requests
|
||||
sleep 6
|
||||
done
|
||||
else
|
||||
URL="https://services.nvd.nist.gov/rest/json/cves/2.0?keywordSearch=${KEYWORD}&lastModStartDate=${START_ENC}&lastModEndDate=${END_ENC}"
|
||||
echo "URL: $URL"
|
||||
|
||||
# Fetch with retry logic
|
||||
for i in 1 2 3; do
|
||||
HTTP_CODE=$(curl -sS -w "%{http_code}" -o "tmp/nvd_${KEYWORD}.json" "$URL" || true)
|
||||
if [ -z "$HTTP_CODE" ]; then
|
||||
HTTP_CODE="000"
|
||||
fi
|
||||
last_http_code="$HTTP_CODE"
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
if jq -e . "tmp/nvd_${KEYWORD}.json" >/dev/null 2>&1; then
|
||||
echo "Success for $KEYWORD"
|
||||
keyword_ok=true
|
||||
break
|
||||
fi
|
||||
echo "Invalid JSON for $KEYWORD, retry $i..."
|
||||
sleep 5
|
||||
elif [ "$HTTP_CODE" = "403" ] || [ "$HTTP_CODE" = "429" ]; then
|
||||
echo "Rate limited, waiting 30s before retry $i..."
|
||||
sleep 30
|
||||
else
|
||||
echo "HTTP $HTTP_CODE for $KEYWORD, retry $i..."
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$keyword_ok" != "true" ]; then
|
||||
echo "::error::Failed to fetch valid NVD response for keyword '$KEYWORD' (last HTTP code: ${last_http_code:-unknown})."
|
||||
FAILED_KEYWORDS+=("$KEYWORD")
|
||||
fi
|
||||
|
||||
# NVD recommends 6 second delay between requests
|
||||
sleep 6
|
||||
done
|
||||
|
||||
if [ "${#FAILED_KEYWORDS[@]}" -gt 0 ]; then
|
||||
echo "::error::NVD fetch failed for keyword(s): ${FAILED_KEYWORDS[*]}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Fetch complete ==="
|
||||
ls -la tmp/
|
||||
|
||||
- name: Merge and filter CVEs
|
||||
id: process
|
||||
run: |
|
||||
# Combine all fetched CVEs
|
||||
echo '{"vulnerabilities":[]}' > tmp/combined.json
|
||||
|
||||
for KEYWORD in $KEYWORDS; do
|
||||
FILE="tmp/nvd_${KEYWORD}.json"
|
||||
if [ -f "$FILE" ] && [ -s "$FILE" ]; then
|
||||
# Check if file has vulnerabilities array
|
||||
if jq -e '.vulnerabilities' "$FILE" > /dev/null 2>&1; then
|
||||
COUNT=$(jq '.vulnerabilities | length' "$FILE")
|
||||
echo "Found $COUNT CVEs for keyword search"
|
||||
|
||||
# Merge into combined
|
||||
jq -s '.[0].vulnerabilities += .[1].vulnerabilities | .[0]' \
|
||||
tmp/combined.json "$FILE" > tmp/combined_new.json
|
||||
mv tmp/combined_new.json tmp/combined.json
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Deduplicate by CVE ID
|
||||
jq '.vulnerabilities | unique_by(.cve.id)' tmp/combined.json > tmp/unique_cves.json
|
||||
TOTAL=$(jq 'length' tmp/unique_cves.json)
|
||||
echo "Total unique CVEs from NVD: $TOTAL"
|
||||
|
||||
# Post-filter: keep only CVEs where description contains keywords OR references contain github pattern
|
||||
KEYWORDS_PATTERN="OpenClaw|clawdbot|Moltbot|openclaw|NanoClaw|nanoclaw|WhatsApp-bot|baileys"
|
||||
GITHUB_PATTERN="${GITHUB_REF_PATTERN}"
|
||||
|
||||
jq --arg kw "$KEYWORDS_PATTERN" --arg gh "$GITHUB_PATTERN" '
|
||||
[.[] | select(
|
||||
# Check if any description contains keywords (case insensitive)
|
||||
(.cve.descriptions[]? | select(.lang == "en") | .value | test($kw; "i"))
|
||||
or
|
||||
# Check if any reference URL contains the github pattern
|
||||
(.cve.references[]? | .url | test($gh; "i"))
|
||||
)]
|
||||
' tmp/unique_cves.json > tmp/filtered_cves.json
|
||||
|
||||
FILTERED=$(jq 'length' tmp/filtered_cves.json)
|
||||
echo "Filtered CVEs (matching criteria): $FILTERED"
|
||||
echo "filtered_count=$FILTERED" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Get existing advisories
|
||||
id: existing
|
||||
run: |
|
||||
if [ -f "$FEED_PATH" ]; then
|
||||
jq -r '.advisories[]?.id // empty' "$FEED_PATH" | sort -u > tmp/existing_ids.txt
|
||||
# Also extract full existing advisories for update comparison
|
||||
jq '.advisories // []' "$FEED_PATH" > tmp/existing_advisories.json
|
||||
else
|
||||
touch tmp/existing_ids.txt
|
||||
echo '[]' > tmp/existing_advisories.json
|
||||
fi
|
||||
|
||||
EXISTING_COUNT=$(wc -l < tmp/existing_ids.txt | tr -d ' ')
|
||||
echo "Existing advisories: $EXISTING_COUNT"
|
||||
cat tmp/existing_ids.txt
|
||||
|
||||
- name: Check for updates to existing advisories
|
||||
id: updates
|
||||
run: |
|
||||
if [ "${{ inputs.force_full_scan }}" = "true" ]; then
|
||||
echo "Full scan mode enabled: skipping delta update detection."
|
||||
echo '[]' > tmp/updated_advisories.json
|
||||
echo "Advisories to update: 0"
|
||||
echo "update_count=0" >> $GITHUB_OUTPUT
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Compare existing CVE advisories against NVD data for changes
|
||||
# Only check advisories that start with "CVE-" (NVD-sourced)
|
||||
|
||||
jq '
|
||||
def map_severity:
|
||||
if . == null then "medium"
|
||||
elif . >= 9.0 then "critical"
|
||||
elif . >= 7.0 then "high"
|
||||
elif . >= 4.0 then "medium"
|
||||
else "low"
|
||||
end;
|
||||
|
||||
def get_cvss_score:
|
||||
.cve.metrics.cvssMetricV31[0]?.cvssData.baseScore //
|
||||
.cve.metrics.cvssMetricV30[0]?.cvssData.baseScore //
|
||||
.cve.metrics.cvssMetricV2[0]?.cvssData.baseScore //
|
||||
null;
|
||||
|
||||
def nvd_category_raw:
|
||||
(
|
||||
[.cve.weaknesses[]?.description[]? | select(.lang == "en") | .value | strings | select(length > 0)]
|
||||
| unique
|
||||
| map(select(. != "NVD-CWE-noinfo" and . != "NVD-CWE-Other"))
|
||||
| .[0]
|
||||
);
|
||||
|
||||
def cwe_id:
|
||||
(
|
||||
nvd_category_raw
|
||||
| if . == null then null
|
||||
else (try (capture("^CWE-(?<id>[0-9]+)$").id) catch null)
|
||||
end
|
||||
);
|
||||
|
||||
def cwe_name_map($id):
|
||||
({
|
||||
"20": "improper_input_validation",
|
||||
"22": "path_traversal",
|
||||
"77": "command_injection",
|
||||
"78": "os_command_injection",
|
||||
"79": "cross_site_scripting",
|
||||
"89": "sql_injection",
|
||||
"94": "code_injection",
|
||||
"119": "memory_buffer_bounds_violation",
|
||||
"120": "classic_buffer_overflow",
|
||||
"125": "out_of_bounds_read",
|
||||
"134": "format_string_vulnerability",
|
||||
"200": "exposure_of_sensitive_information",
|
||||
"250": "execution_with_unnecessary_privileges",
|
||||
"269": "improper_privilege_management",
|
||||
"284": "improper_access_control",
|
||||
"285": "improper_authorization",
|
||||
"287": "improper_authentication",
|
||||
"295": "improper_certificate_validation",
|
||||
"306": "missing_authentication_for_critical_function",
|
||||
"319": "cleartext_transmission_of_sensitive_information",
|
||||
"326": "inadequate_encryption_strength",
|
||||
"327": "risky_cryptographic_algorithm",
|
||||
"352": "cross_site_request_forgery",
|
||||
"362": "race_condition",
|
||||
"400": "uncontrolled_resource_consumption",
|
||||
"416": "use_after_free",
|
||||
"434": "unrestricted_file_upload",
|
||||
"502": "deserialization_of_untrusted_data",
|
||||
"601": "open_redirect",
|
||||
"611": "xml_external_entity_injection",
|
||||
"639": "insecure_direct_object_reference",
|
||||
"668": "exposure_of_resource_to_wrong_sphere",
|
||||
"669": "incorrect_resource_transfer_between_spheres",
|
||||
"732": "incorrect_permission_assignment",
|
||||
"787": "out_of_bounds_write",
|
||||
"798": "hard_coded_credentials",
|
||||
"862": "missing_authorization",
|
||||
"863": "incorrect_authorization",
|
||||
"918": "server_side_request_forgery",
|
||||
"922": "insecure_storage_of_sensitive_information"
|
||||
}[$id]);
|
||||
|
||||
def nvd_category_name:
|
||||
(
|
||||
cwe_id as $id
|
||||
| if $id == null then "unspecified_weakness"
|
||||
else (cwe_name_map($id) // ("unknown_cwe_" + $id))
|
||||
end
|
||||
);
|
||||
|
||||
def cpe_criteria:
|
||||
(
|
||||
[.cve.configurations[]? | .. | objects | .criteria? | strings | select(startswith("cpe:2.3:"))]
|
||||
| unique
|
||||
);
|
||||
|
||||
def context_blob:
|
||||
(
|
||||
[
|
||||
(.cve.descriptions[]? | select(.lang == "en") | .value),
|
||||
(.cve.references[]?.url // empty)
|
||||
]
|
||||
| map(strings | ascii_downcase)
|
||||
| join(" ")
|
||||
);
|
||||
|
||||
def inferred_targets:
|
||||
(
|
||||
context_blob as $blob
|
||||
| (
|
||||
(if ($blob | test("github\\.com/openclaw/openclaw|\\bopenclaw\\b|\\bclawdbot\\b|\\bmoltbot\\b")) then ["openclaw@*"] else [] end)
|
||||
+ (if ($blob | test("github\\.com/qwibitai/nanoclaw|\\bnanoclaw\\b|whatsapp-bot|\\bbaileys\\b")) then ["nanoclaw@*"] else [] end)
|
||||
)
|
||||
);
|
||||
|
||||
def normalized_affected:
|
||||
(
|
||||
(cpe_criteria + inferred_targets)
|
||||
| unique
|
||||
| .[0:5]
|
||||
| if length == 0 then ["openclaw@*", "nanoclaw@*"] else . end
|
||||
);
|
||||
|
||||
def normalized_platforms:
|
||||
(
|
||||
inferred_targets as $targets
|
||||
| ($targets | map(select(startswith("openclaw@"))) | length > 0) as $has_openclaw
|
||||
| ($targets | map(select(startswith("nanoclaw@"))) | length > 0) as $has_nanoclaw
|
||||
| if $has_openclaw and $has_nanoclaw then ["openclaw", "nanoclaw"]
|
||||
elif $has_openclaw then ["openclaw"]
|
||||
elif $has_nanoclaw then ["nanoclaw"]
|
||||
else ["openclaw", "nanoclaw"]
|
||||
end
|
||||
);
|
||||
|
||||
[.[] | {
|
||||
id: .cve.id,
|
||||
severity: (get_cvss_score | map_severity),
|
||||
type: nvd_category_name,
|
||||
nvd_category_id: nvd_category_raw,
|
||||
cvss_score: get_cvss_score,
|
||||
description: (.cve.descriptions[] | select(.lang == "en") | .value),
|
||||
title: (.cve.descriptions[] | select(.lang == "en") | .value | .[0:100] + (if length > 100 then "..." else "" end)),
|
||||
affected: normalized_affected,
|
||||
platforms: normalized_platforms,
|
||||
references: [.cve.references[]?.url // empty] | unique | .[0:3],
|
||||
exploitability_score: null,
|
||||
exploitability_rationale: null
|
||||
}]
|
||||
' tmp/filtered_cves.json > tmp/nvd_current_state.json
|
||||
|
||||
# Find updates: existing CVE advisories where NVD data differs
|
||||
jq -n --slurpfile existing tmp/existing_advisories.json --slurpfile nvd tmp/nvd_current_state.json '
|
||||
# Get only CVE-prefixed existing advisories
|
||||
($existing[0] | map(select(.id | startswith("CVE-")))) as $cve_advisories |
|
||||
|
||||
# For each NVD entry, check if it exists and has changes
|
||||
[
|
||||
$nvd[0][] |
|
||||
. as $nvd_entry |
|
||||
($cve_advisories | map(select(.id == $nvd_entry.id)) | first) as $existing_entry |
|
||||
if $existing_entry then
|
||||
# Compare key fields
|
||||
if ($existing_entry.severity != $nvd_entry.severity) or
|
||||
($existing_entry.type != $nvd_entry.type) or
|
||||
($existing_entry.nvd_category_id != $nvd_entry.nvd_category_id) or
|
||||
($existing_entry.cvss_score != $nvd_entry.cvss_score) or
|
||||
($existing_entry.affected != $nvd_entry.affected) or
|
||||
($existing_entry.platforms != $nvd_entry.platforms) or
|
||||
($existing_entry.description != $nvd_entry.description) then
|
||||
{
|
||||
id: $nvd_entry.id,
|
||||
changes: (
|
||||
[]
|
||||
+ (if $existing_entry.severity != $nvd_entry.severity then ["severity: \($existing_entry.severity) → \($nvd_entry.severity)"] else [] end)
|
||||
+ (if $existing_entry.type != $nvd_entry.type then ["type: \($existing_entry.type // "null") → \($nvd_entry.type // "null")"] else [] end)
|
||||
+ (if $existing_entry.nvd_category_id != $nvd_entry.nvd_category_id then ["nvd_category_id: \($existing_entry.nvd_category_id // "null") → \($nvd_entry.nvd_category_id // "null")"] else [] end)
|
||||
+ (if $existing_entry.cvss_score != $nvd_entry.cvss_score then ["cvss_score: \($existing_entry.cvss_score // "null") → \($nvd_entry.cvss_score // "null")"] else [] end)
|
||||
+ (if $existing_entry.affected != $nvd_entry.affected then ["affected targets updated"] else [] end)
|
||||
+ (if $existing_entry.platforms != $nvd_entry.platforms then ["platforms updated"] else [] end)
|
||||
+ (if $existing_entry.description != $nvd_entry.description then ["description updated"] else [] end)
|
||||
),
|
||||
updated_fields: {
|
||||
severity: $nvd_entry.severity,
|
||||
type: $nvd_entry.type,
|
||||
nvd_category_id: $nvd_entry.nvd_category_id,
|
||||
cvss_score: $nvd_entry.cvss_score,
|
||||
affected: $nvd_entry.affected,
|
||||
platforms: $nvd_entry.platforms,
|
||||
description: $nvd_entry.description,
|
||||
title: $nvd_entry.title,
|
||||
references: $nvd_entry.references
|
||||
}
|
||||
}
|
||||
else
|
||||
empty
|
||||
end
|
||||
else
|
||||
empty
|
||||
end
|
||||
]
|
||||
' > tmp/updated_advisories.json
|
||||
|
||||
UPDATE_COUNT=$(jq 'length' tmp/updated_advisories.json)
|
||||
echo "Advisories to update: $UPDATE_COUNT"
|
||||
echo "update_count=$UPDATE_COUNT" >> $GITHUB_OUTPUT
|
||||
|
||||
if [ "$UPDATE_COUNT" -gt 0 ]; then
|
||||
echo "=== Updated advisories ==="
|
||||
jq -r '.[] | "- \(.id): \(.changes | join(", "))"' tmp/updated_advisories.json
|
||||
fi
|
||||
|
||||
- name: Transform CVEs to advisories
|
||||
id: transform
|
||||
run: |
|
||||
# Read existing IDs into a jq-friendly format
|
||||
if [ "${{ inputs.force_full_scan }}" = "true" ]; then
|
||||
echo "Full scan mode enabled: rebuilding CVE advisories from scratch."
|
||||
EXISTING_IDS='[]'
|
||||
else
|
||||
EXISTING_IDS=$(cat tmp/existing_ids.txt | jq -R -s 'split("\n") | map(select(length > 0))')
|
||||
fi
|
||||
|
||||
# Transform NVD CVEs to our advisory format
|
||||
jq --argjson existing "$EXISTING_IDS" '
|
||||
def map_severity:
|
||||
if . == null then "medium"
|
||||
elif . >= 9.0 then "critical"
|
||||
elif . >= 7.0 then "high"
|
||||
elif . >= 4.0 then "medium"
|
||||
else "low"
|
||||
end;
|
||||
|
||||
def get_cvss_score:
|
||||
.cve.metrics.cvssMetricV31[0]?.cvssData.baseScore //
|
||||
.cve.metrics.cvssMetricV30[0]?.cvssData.baseScore //
|
||||
.cve.metrics.cvssMetricV2[0]?.cvssData.baseScore //
|
||||
null;
|
||||
|
||||
def nvd_category_raw:
|
||||
(
|
||||
[.cve.weaknesses[]?.description[]? | select(.lang == "en") | .value | strings | select(length > 0)]
|
||||
| unique
|
||||
| map(select(. != "NVD-CWE-noinfo" and . != "NVD-CWE-Other"))
|
||||
| .[0]
|
||||
);
|
||||
|
||||
def cwe_id:
|
||||
(
|
||||
nvd_category_raw
|
||||
| if . == null then null
|
||||
else (try (capture("^CWE-(?<id>[0-9]+)$").id) catch null)
|
||||
end
|
||||
);
|
||||
|
||||
def cwe_name_map($id):
|
||||
({
|
||||
"20": "improper_input_validation",
|
||||
"22": "path_traversal",
|
||||
"77": "command_injection",
|
||||
"78": "os_command_injection",
|
||||
"79": "cross_site_scripting",
|
||||
"89": "sql_injection",
|
||||
"94": "code_injection",
|
||||
"119": "memory_buffer_bounds_violation",
|
||||
"120": "classic_buffer_overflow",
|
||||
"125": "out_of_bounds_read",
|
||||
"134": "format_string_vulnerability",
|
||||
"200": "exposure_of_sensitive_information",
|
||||
"250": "execution_with_unnecessary_privileges",
|
||||
"269": "improper_privilege_management",
|
||||
"284": "improper_access_control",
|
||||
"285": "improper_authorization",
|
||||
"287": "improper_authentication",
|
||||
"295": "improper_certificate_validation",
|
||||
"306": "missing_authentication_for_critical_function",
|
||||
"319": "cleartext_transmission_of_sensitive_information",
|
||||
"326": "inadequate_encryption_strength",
|
||||
"327": "risky_cryptographic_algorithm",
|
||||
"352": "cross_site_request_forgery",
|
||||
"362": "race_condition",
|
||||
"400": "uncontrolled_resource_consumption",
|
||||
"416": "use_after_free",
|
||||
"434": "unrestricted_file_upload",
|
||||
"502": "deserialization_of_untrusted_data",
|
||||
"601": "open_redirect",
|
||||
"611": "xml_external_entity_injection",
|
||||
"639": "insecure_direct_object_reference",
|
||||
"668": "exposure_of_resource_to_wrong_sphere",
|
||||
"669": "incorrect_resource_transfer_between_spheres",
|
||||
"732": "incorrect_permission_assignment",
|
||||
"787": "out_of_bounds_write",
|
||||
"798": "hard_coded_credentials",
|
||||
"862": "missing_authorization",
|
||||
"863": "incorrect_authorization",
|
||||
"918": "server_side_request_forgery",
|
||||
"922": "insecure_storage_of_sensitive_information"
|
||||
}[$id]);
|
||||
|
||||
def nvd_category_name:
|
||||
(
|
||||
cwe_id as $id
|
||||
| if $id == null then "unspecified_weakness"
|
||||
else (cwe_name_map($id) // ("unknown_cwe_" + $id))
|
||||
end
|
||||
);
|
||||
|
||||
def cpe_criteria:
|
||||
(
|
||||
[.cve.configurations[]? | .. | objects | .criteria? | strings | select(startswith("cpe:2.3:"))]
|
||||
| unique
|
||||
);
|
||||
|
||||
def context_blob:
|
||||
(
|
||||
[
|
||||
(.cve.descriptions[]? | select(.lang == "en") | .value),
|
||||
(.cve.references[]?.url // empty)
|
||||
]
|
||||
| map(strings | ascii_downcase)
|
||||
| join(" ")
|
||||
);
|
||||
|
||||
def inferred_targets:
|
||||
(
|
||||
context_blob as $blob
|
||||
| (
|
||||
(if ($blob | test("github\\.com/openclaw/openclaw|\\bopenclaw\\b|\\bclawdbot\\b|\\bmoltbot\\b")) then ["openclaw@*"] else [] end)
|
||||
+ (if ($blob | test("github\\.com/qwibitai/nanoclaw|\\bnanoclaw\\b|whatsapp-bot|\\bbaileys\\b")) then ["nanoclaw@*"] else [] end)
|
||||
)
|
||||
);
|
||||
|
||||
def normalized_affected:
|
||||
(
|
||||
(cpe_criteria + inferred_targets)
|
||||
| unique
|
||||
| .[0:5]
|
||||
| if length == 0 then ["openclaw@*", "nanoclaw@*"] else . end
|
||||
);
|
||||
|
||||
def normalized_platforms:
|
||||
(
|
||||
inferred_targets as $targets
|
||||
| ($targets | map(select(startswith("openclaw@"))) | length > 0) as $has_openclaw
|
||||
| ($targets | map(select(startswith("nanoclaw@"))) | length > 0) as $has_nanoclaw
|
||||
| if $has_openclaw and $has_nanoclaw then ["openclaw", "nanoclaw"]
|
||||
elif $has_openclaw then ["openclaw"]
|
||||
elif $has_nanoclaw then ["nanoclaw"]
|
||||
else ["openclaw", "nanoclaw"]
|
||||
end
|
||||
);
|
||||
|
||||
[.[] |
|
||||
select(.cve.id as $id | $existing | index($id) | not) |
|
||||
{
|
||||
id: .cve.id,
|
||||
severity: (get_cvss_score | map_severity),
|
||||
type: nvd_category_name,
|
||||
nvd_category_id: nvd_category_raw,
|
||||
title: (.cve.descriptions[] | select(.lang == "en") | .value | .[0:100] + (if length > 100 then "..." else "" end)),
|
||||
description: (.cve.descriptions[] | select(.lang == "en") | .value),
|
||||
affected: normalized_affected,
|
||||
platforms: normalized_platforms,
|
||||
action: "Review and update affected components. See NVD for remediation details.",
|
||||
published: .cve.published,
|
||||
references: [.cve.references[]?.url // empty] | unique | .[0:3],
|
||||
cvss_score: get_cvss_score,
|
||||
nvd_url: ("https://nvd.nist.gov/vuln/detail/" + .cve.id),
|
||||
exploitability_score: null,
|
||||
exploitability_rationale: null
|
||||
}
|
||||
]
|
||||
' tmp/filtered_cves.json > tmp/new_advisories.json
|
||||
|
||||
NEW_COUNT=$(jq 'length' tmp/new_advisories.json)
|
||||
echo "New advisories to add: $NEW_COUNT"
|
||||
echo "new_count=$NEW_COUNT" >> $GITHUB_OUTPUT
|
||||
|
||||
if [ "$NEW_COUNT" -gt 0 ]; then
|
||||
echo "=== New advisories ==="
|
||||
jq '.[].id' tmp/new_advisories.json
|
||||
fi
|
||||
|
||||
- name: Set up Python for exploitability analysis
|
||||
if: steps.transform.outputs.new_count != '0'
|
||||
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Analyze exploitability for new advisories
|
||||
if: steps.transform.outputs.new_count != '0'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
echo "=== Analyzing exploitability for new advisories ==="
|
||||
|
||||
# Extract CVSS vectors from filtered CVEs to merge with advisories
|
||||
jq '
|
||||
[.[] | {
|
||||
id: .cve.id,
|
||||
cvss_vector: (
|
||||
.cve.metrics.cvssMetricV31[0]?.cvssData.vectorString //
|
||||
.cve.metrics.cvssMetricV30[0]?.cvssData.vectorString //
|
||||
.cve.metrics.cvssMetricV2[0]?.vectorString //
|
||||
""
|
||||
)
|
||||
}] | map({(.id): .cvss_vector}) | add
|
||||
' tmp/filtered_cves.json > tmp/cvss_vectors.json
|
||||
|
||||
scripts/ci/enrich_exploitability.sh \
|
||||
--mode batch \
|
||||
--input tmp/new_advisories.json \
|
||||
--output tmp/new_advisories.json \
|
||||
--cvss-vectors tmp/cvss_vectors.json
|
||||
|
||||
echo "=== Exploitability analysis complete ==="
|
||||
|
||||
# Show summary of exploitability scores
|
||||
echo "Exploitability score distribution:"
|
||||
jq -r '.[] | "\(.id): \(.exploitability_score // "unknown")"' tmp/new_advisories.json | \
|
||||
awk -F': ' '{scores[$2]++} END {for (s in scores) print " " s ": " scores[s]}'
|
||||
|
||||
- name: Update feed.json
|
||||
if: steps.transform.outputs.new_count != '0' || steps.updates.outputs.update_count != '0'
|
||||
run: |
|
||||
NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
FORCE_FULL_SCAN="${{ inputs.force_full_scan }}"
|
||||
|
||||
if [ -f "$FEED_PATH" ] && [ "$FORCE_FULL_SCAN" = "true" ]; then
|
||||
# Full scan mode: replace all CVE advisories with rebuilt set and keep non-CVE entries.
|
||||
jq --argjson rebuilt "$(cat tmp/new_advisories.json)" --arg now "$NOW" '
|
||||
.updated = $now |
|
||||
.advisories = (
|
||||
((.advisories // []) | map(select((.id // "") | startswith("CVE-") | not)))
|
||||
+ $rebuilt
|
||||
| sort_by(.published)
|
||||
| reverse
|
||||
)
|
||||
' "$FEED_PATH" > tmp/updated_feed.json
|
||||
elif [ -f "$FEED_PATH" ]; then
|
||||
# Step 1: Apply updates to existing advisories
|
||||
jq --slurpfile updates tmp/updated_advisories.json '
|
||||
.advisories = [
|
||||
.advisories[] |
|
||||
. as $adv |
|
||||
($updates[0] | map(select(.id == $adv.id)) | first) as $update |
|
||||
if $update then
|
||||
# Merge updated fields
|
||||
($adv * $update.updated_fields)
|
||||
else
|
||||
$adv
|
||||
end
|
||||
]
|
||||
' "$FEED_PATH" > tmp/feed_with_updates.json
|
||||
|
||||
# Step 2: Add new advisories
|
||||
jq --argjson new "$(cat tmp/new_advisories.json)" --arg now "$NOW" '
|
||||
.updated = $now |
|
||||
.advisories = (.advisories + $new | sort_by(.published) | reverse)
|
||||
' tmp/feed_with_updates.json > tmp/updated_feed.json
|
||||
else
|
||||
jq -n --argjson advisories "$(cat tmp/new_advisories.json)" --arg now "$NOW" '{
|
||||
version: "1.0.0",
|
||||
updated: $now,
|
||||
description: "Community-driven security advisory feed for ClawSec",
|
||||
advisories: ($advisories | sort_by(.published) | reverse)
|
||||
}' > tmp/updated_feed.json
|
||||
fi
|
||||
|
||||
# Validate JSON
|
||||
if jq empty tmp/updated_feed.json 2>/dev/null; then
|
||||
echo "Feed JSON is valid"
|
||||
mv tmp/updated_feed.json "$FEED_PATH"
|
||||
|
||||
# Also update the skill feed
|
||||
mkdir -p "$(dirname "$SKILL_FEED_PATH")"
|
||||
cp "$FEED_PATH" "$SKILL_FEED_PATH"
|
||||
|
||||
echo "=== Updated feeds ==="
|
||||
echo "Main feed: $FEED_PATH"
|
||||
echo "Skill feed: $SKILL_FEED_PATH"
|
||||
jq '.advisories | length' "$FEED_PATH"
|
||||
else
|
||||
echo "Error: Generated invalid JSON"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Guard dependency manifests from NVD updates
|
||||
if: steps.transform.outputs.new_count != '0' || steps.updates.outputs.update_count != '0'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
BLOCKED_FILES=()
|
||||
for file in package.json package-lock.json npm-shrinkwrap.json; do
|
||||
if ! git diff --quiet -- "$file"; then
|
||||
BLOCKED_FILES+=("$file")
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${#BLOCKED_FILES[@]}" -gt 0 ]; then
|
||||
echo "::error::NVD workflow must not modify dependency manifests: ${BLOCKED_FILES[*]}"
|
||||
git --no-pager diff -- "${BLOCKED_FILES[@]}" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Sign advisory feed and verify
|
||||
if: steps.transform.outputs.new_count != '0' || steps.updates.outputs.update_count != '0'
|
||||
uses: ./.github/actions/sign-and-verify
|
||||
with:
|
||||
private_key: ${{ secrets.CLAWSEC_SIGNING_PRIVATE_KEY }}
|
||||
private_key_passphrase: ${{ secrets.CLAWSEC_SIGNING_PRIVATE_KEY_PASSPHRASE }}
|
||||
input_file: ${{ env.FEED_PATH }}
|
||||
signature_file: ${{ env.FEED_SIG_PATH }}
|
||||
verify_files: |
|
||||
${{ env.FEED_PATH }}
|
||||
${{ env.SKILL_FEED_PATH }}
|
||||
|
||||
- name: Sync advisory signature to skill feed
|
||||
if: steps.transform.outputs.new_count != '0' || steps.updates.outputs.update_count != '0'
|
||||
run: cp "$FEED_SIG_PATH" "$SKILL_FEED_SIG_PATH"
|
||||
|
||||
- name: Clean workspace for PR
|
||||
if: steps.transform.outputs.new_count != '0' || steps.updates.outputs.update_count != '0'
|
||||
run: |
|
||||
# Reset any unintended changes, keep only feed files
|
||||
git checkout -- .github/ 2>/dev/null || true
|
||||
git clean -fd .github/ 2>/dev/null || true
|
||||
|
||||
- name: Upsert NVD advisory PR
|
||||
if: steps.transform.outputs.new_count != '0' || steps.updates.outputs.update_count != '0'
|
||||
id: upsert-pr
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
BRANCH_PREFIX="automated/nvd-cve-update"
|
||||
PR_COMMENT="Superseded by newer automated NVD advisory update."
|
||||
TITLE="chore: CVE advisories - ${{ steps.transform.outputs.new_count }} new, ${{ steps.updates.outputs.update_count }} updated"
|
||||
COMMIT_SUBJECT="$TITLE"
|
||||
COMMIT_BODY=$'Automated update from NVD CVE feed.\nKeywords: ${{ env.KEYWORDS }}\nPoll window: ${{ steps.dates.outputs.start_date }} to ${{ steps.dates.outputs.end_date }}'
|
||||
|
||||
if [ "${{ inputs.force_full_scan }}" = "true" ]; then
|
||||
MODE="full-rebuild (ignore feed state)"
|
||||
else
|
||||
MODE="delta (incremental)"
|
||||
fi
|
||||
|
||||
BODY_FILE="$(mktemp)"
|
||||
cat > "$BODY_FILE" <<EOF
|
||||
## Summary
|
||||
Automated update from NVD CVE feed.
|
||||
|
||||
- **Mode:** ${MODE}
|
||||
- **New advisories:** ${{ steps.transform.outputs.new_count }}
|
||||
- **Updated advisories:** ${{ steps.updates.outputs.update_count }}
|
||||
- **Poll window:** ${{ steps.dates.outputs.start_date }} → ${{ steps.dates.outputs.end_date }}
|
||||
- **Keywords:** ${{ env.KEYWORDS }}
|
||||
|
||||
---
|
||||
*This PR was automatically generated by the NVD CVE polling workflow.*
|
||||
EOF
|
||||
|
||||
PR_LIST_JSON="$(
|
||||
gh api --paginate "repos/${{ github.repository }}/pulls?state=open&base=main&per_page=100" \
|
||||
--jq '.[] | {number, headRefName: .head.ref, url: .html_url, updatedAt: .updated_at}' \
|
||||
| jq -s '.'
|
||||
)"
|
||||
|
||||
mapfile -t MATCHING_OPEN_PRS < <(
|
||||
echo "$PR_LIST_JSON" | jq -r --arg prefix "$BRANCH_PREFIX" '
|
||||
map(select(.headRefName | startswith($prefix)))
|
||||
| sort_by(.updatedAt)
|
||||
| reverse
|
||||
| .[]
|
||||
| @base64
|
||||
'
|
||||
)
|
||||
|
||||
TARGET_BRANCH="$BRANCH_PREFIX"
|
||||
TARGET_PR_NUMBER=""
|
||||
TARGET_PR_URL=""
|
||||
|
||||
if [ "${#MATCHING_OPEN_PRS[@]}" -gt 0 ]; then
|
||||
PRIMARY_JSON="$(echo "${MATCHING_OPEN_PRS[0]}" | base64 --decode)"
|
||||
TARGET_BRANCH="$(echo "$PRIMARY_JSON" | jq -r '.headRefName')"
|
||||
TARGET_PR_NUMBER="$(echo "$PRIMARY_JSON" | jq -r '.number')"
|
||||
TARGET_PR_URL="$(echo "$PRIMARY_JSON" | jq -r '.url')"
|
||||
|
||||
if [ "${#MATCHING_OPEN_PRS[@]}" -gt 1 ]; then
|
||||
echo "Found multiple open NVD advisory PRs. Closing duplicates."
|
||||
for encoded_pr in "${MATCHING_OPEN_PRS[@]:1}"; do
|
||||
pr_json="$(echo "$encoded_pr" | base64 --decode)"
|
||||
pr_number="$(echo "$pr_json" | jq -r '.number')"
|
||||
gh pr close "$pr_number" --delete-branch --comment "$PR_COMMENT"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Using target branch: $TARGET_BRANCH"
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
git fetch origin main
|
||||
git checkout -B "$TARGET_BRANCH" origin/main
|
||||
|
||||
git add "$FEED_PATH" "$FEED_SIG_PATH" "$SKILL_FEED_PATH" "$SKILL_FEED_SIG_PATH"
|
||||
if git diff --cached --quiet; then
|
||||
echo "::error::Expected advisory feed changes but none were staged."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git commit -m "$COMMIT_SUBJECT" -m "$COMMIT_BODY"
|
||||
git push --force origin "$TARGET_BRANCH"
|
||||
|
||||
if [ -n "$TARGET_PR_NUMBER" ]; then
|
||||
gh pr edit "$TARGET_PR_NUMBER" --title "$TITLE" --body-file "$BODY_FILE"
|
||||
else
|
||||
TARGET_PR_URL="$(gh pr create --base main --head "$TARGET_BRANCH" --title "$TITLE" --body-file "$BODY_FILE")"
|
||||
TARGET_PR_NUMBER="$(basename "$TARGET_PR_URL")"
|
||||
fi
|
||||
|
||||
if [ -z "$TARGET_PR_URL" ]; then
|
||||
TARGET_PR_URL="$(gh pr view "$TARGET_PR_NUMBER" --json url --jq '.url')"
|
||||
fi
|
||||
|
||||
echo "pull-request-number=$TARGET_PR_NUMBER" >> "$GITHUB_OUTPUT"
|
||||
echo "pull-request-url=$TARGET_PR_URL" >> "$GITHUB_OUTPUT"
|
||||
echo "pull-request-branch=$TARGET_BRANCH" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Run CodeQL on generated PR branch
|
||||
if: steps.upsert-pr.outputs.pull-request-number != ''
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
BRANCH="${{ steps.upsert-pr.outputs.pull-request-branch }}"
|
||||
if [ -z "$BRANCH" ]; then
|
||||
echo "::error::Missing pull-request-branch output from upsert-pr step"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Dispatching CodeQL for branch: $BRANCH"
|
||||
gh workflow run codeql.yml --ref "$BRANCH"
|
||||
|
||||
RUN_ID=""
|
||||
for _ in $(seq 1 30); do
|
||||
RUN_ID=$(gh run list \
|
||||
--workflow "CodeQL" \
|
||||
--branch "$BRANCH" \
|
||||
--event workflow_dispatch \
|
||||
--json databaseId,createdAt \
|
||||
--jq 'sort_by(.createdAt) | last | .databaseId // empty')
|
||||
if [ -n "$RUN_ID" ]; then
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
|
||||
if [ -z "$RUN_ID" ]; then
|
||||
echo "::error::Unable to locate dispatched CodeQL run for branch $BRANCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Waiting for CodeQL run id: $RUN_ID"
|
||||
gh run watch "$RUN_ID" --exit-status
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
if [ "${{ inputs.force_full_scan }}" = "true" ]; then
|
||||
MODE="full-rebuild (ignore feed state)"
|
||||
else
|
||||
MODE="delta (incremental)"
|
||||
fi
|
||||
|
||||
echo "## NVD CVE Poll Summary" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Metric | Value |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Mode | $MODE |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Poll Window | ${{ steps.dates.outputs.start_date }} → ${{ steps.dates.outputs.end_date }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Keywords | $KEYWORDS |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| CVEs Found (filtered) | ${{ steps.process.outputs.filtered_count }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| New Advisories | ${{ steps.transform.outputs.new_count }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Updated Advisories | ${{ steps.updates.outputs.update_count }} |" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
if [ "${{ steps.transform.outputs.new_count }}" != "0" ]; then
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### New Advisories" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
jq -r '.[] | "- **\(.id)** (\(.severity)): \(.title)"' tmp/new_advisories.json >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
if [ "${{ steps.updates.outputs.update_count }}" != "0" ]; then
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Updated Advisories" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
jq -r '.[] | "- **\(.id)**: \(.changes | join(", "))"' tmp/updated_advisories.json >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
|
||||
if [ "${{ steps.transform.outputs.new_count }}" != "0" ] || [ "${{ steps.updates.outputs.update_count }}" != "0" ]; then
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "🔀 Upserted PR: ${{ steps.upsert-pr.outputs.pull-request-url }}" >> $GITHUB_STEP_SUMMARY
|
||||
else
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "✅ No new or updated CVEs found." >> $GITHUB_STEP_SUMMARY
|
||||
fi
|
||||
@@ -1,89 +0,0 @@
|
||||
# This workflow uses actions that are not certified by GitHub. They are provided
|
||||
# by a third-party and are governed by separate terms of service, privacy
|
||||
# policy, and support documentation.
|
||||
|
||||
name: Scorecard supply-chain security
|
||||
on:
|
||||
# For Branch-Protection check. Only the default branch is supported. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
|
||||
branch_protection_rule:
|
||||
# Run immediately after dependency changes on main so vulnerability alerts close quickly.
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- package.json
|
||||
- package-lock.json
|
||||
- npm-shrinkwrap.json
|
||||
- requirements*.txt
|
||||
- .github/requirements*.txt
|
||||
- .github/requirements-lint-python.txt
|
||||
- .github/workflows/scorecard.yml
|
||||
# To guarantee Maintained check is occasionally updated. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
|
||||
schedule:
|
||||
- cron: '19 23 * * 0'
|
||||
# Allow maintainers to rescan main on demand after hotfixes.
|
||||
workflow_dispatch:
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Scorecard analysis
|
||||
runs-on: ubuntu-latest
|
||||
# `publish_results: true` only works when run from the default branch. conditional can be removed if disabled.
|
||||
if: github.event.repository.default_branch == github.ref_name || github.event_name == 'pull_request'
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
# Needed to publish results and get a badge (see publish_results below).
|
||||
id-token: write
|
||||
# Uncomment the permissions below if installing in a private repository.
|
||||
# contents: read
|
||||
# actions: read
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
|
||||
# - you want to enable the Branch-Protection check on a *public* repository, or
|
||||
# - you are installing Scorecard on a *private* repository
|
||||
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
|
||||
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
|
||||
|
||||
# Public repositories:
|
||||
# - Publish results to OpenSSF REST API for easy access by consumers
|
||||
# - Allows the repository to include the Scorecard badge.
|
||||
# - See https://github.com/ossf/scorecard-action#publishing-results.
|
||||
# For private repositories:
|
||||
# - `publish_results` will always be set to `false`, regardless
|
||||
# of the value entered here.
|
||||
publish_results: true
|
||||
|
||||
# (Optional) Uncomment file_mode if you have a .gitattributes with files marked export-ignore
|
||||
# file_mode: git
|
||||
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard (optional).
|
||||
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -1,73 +0,0 @@
|
||||
name: Sync Wiki
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'wiki/**'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: wiki-sync
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
sync-wiki:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Sync wiki folder to repository wiki
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if [ ! -d wiki ]; then
|
||||
echo "::error::wiki/ directory not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# GitHub Wiki root (/wiki) renders Home.md, not INDEX.md.
|
||||
# INDEX.md is the canonical source; generate Home.md from it.
|
||||
if [ ! -f wiki/INDEX.md ]; then
|
||||
echo "::error::wiki/INDEX.md not found. It is required to generate wiki/Home.md."
|
||||
exit 1
|
||||
fi
|
||||
cp wiki/INDEX.md wiki/Home.md
|
||||
|
||||
WIKI_REMOTE="https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.wiki.git"
|
||||
if ! git ls-remote "$WIKI_REMOTE" >/dev/null 2>&1; then
|
||||
echo "::warning::Wiki remote unavailable (repository wiki may be disabled). Skipping sync."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
WIKI_TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$WIKI_TMP"' EXIT
|
||||
|
||||
git clone --depth 1 "$WIKI_REMOTE" "$WIKI_TMP"
|
||||
rsync -a --delete --exclude '.git/' wiki/ "$WIKI_TMP/"
|
||||
|
||||
cd "$WIKI_TMP"
|
||||
if [ -z "$(git status --porcelain)" ]; then
|
||||
echo "No wiki changes to sync."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
WIKI_HEAD_REF="$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null || true)"
|
||||
if [ -n "$WIKI_HEAD_REF" ]; then
|
||||
WIKI_BRANCH="${WIKI_HEAD_REF#origin/}"
|
||||
else
|
||||
WIKI_BRANCH="master"
|
||||
fi
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add -A
|
||||
git commit -m "docs(wiki): sync from ${GITHUB_SHA}"
|
||||
# Clone may sanitize credentials from origin URL; push with explicit auth URL.
|
||||
git push "$WIKI_REMOTE" HEAD:"$WIKI_BRANCH"
|
||||
@@ -1,53 +0,0 @@
|
||||
.claude
|
||||
.auto-claude/
|
||||
.codex
|
||||
_bmad
|
||||
_bmad-output
|
||||
ext-docs
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Environment files (may contain secrets)
|
||||
.env*
|
||||
!.env.example
|
||||
|
||||
# Derived public assets (copied during build)
|
||||
public/advisories
|
||||
public/skills
|
||||
public/wiki/
|
||||
|
||||
# Python bytecode
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
clawsec-signing-private.pem
|
||||
|
||||
# Auto Claude generated files
|
||||
.auto-claude/
|
||||
.auto-claude-security.json
|
||||
.auto-claude-status
|
||||
.claude_settings.json
|
||||
.worktrees/
|
||||
.security-key
|
||||
logs/security/
|
||||
@@ -1,63 +0,0 @@
|
||||
# Repository Guidelines
|
||||
|
||||
## Project Structure & Module Organization
|
||||
ClawSec combines a Vite + React frontend with security skill packages and release tooling.
|
||||
- Frontend entrypoints: `index.tsx`, `App.tsx`
|
||||
- UI and routes: `components/`, `pages/`
|
||||
- Shared types/constants: `types.ts`, `constants.ts`
|
||||
- Wiki source docs: `wiki/` (synced to GitHub Wiki by `.github/workflows/wiki-sync.yml`)
|
||||
- Generated wiki exports: `public/wiki/` (`llms.txt` outputs; generated locally/CI and gitignored)
|
||||
- Skills: `skills/<skill-name>/` (`skill.json`, `SKILL.md`, optional `scripts/`, `test/`)
|
||||
- Advisory feed: `advisories/feed.json`, `advisories/feed.json.sig`
|
||||
- Automation: `scripts/`, `.github/workflows/`
|
||||
- Python utilities: `utils/validate_skill.py`, `utils/package_skill.py`
|
||||
|
||||
## Build, Test, and Development Commands
|
||||
- `npm install`: install dependencies.
|
||||
- `npm run dev`: run local Vite server.
|
||||
- `npm run build`: create production build (CI gate).
|
||||
- `npm run preview`: preview built app.
|
||||
- `npm run gen:wiki-llms`: generate wiki `llms.txt` exports from `wiki/` into `public/wiki/`.
|
||||
- `./scripts/prepare-to-push.sh [--fix]`: run lint, types, build, and security checks.
|
||||
- `./scripts/populate-local-wiki.sh`: regenerate local wiki `llms.txt` exports for preview.
|
||||
- `npx eslint . --ext .ts,.tsx,.js,.jsx,.mjs --max-warnings 0`: lint JS/TS.
|
||||
- `npx tsc --noEmit`: type-check TypeScript.
|
||||
- `node skills/clawsec-suite/test/feed_verification.test.mjs`: run a skill-local Node test.
|
||||
- `python utils/validate_skill.py skills/<skill-name>`: validate skill schema/metadata.
|
||||
|
||||
## Coding Style & Naming Conventions
|
||||
- Use TypeScript/TSX for frontend code and ESM for scripts.
|
||||
- Follow `eslint.config.js`; prefix intentionally unused vars/args with `_`.
|
||||
- Python under `utils/` follows `pyproject.toml` Ruff/Bandit rules (line length 120).
|
||||
- Name React files in PascalCase (for example, `SkillCard.tsx`), skill directories in kebab-case (for example, `skills/clawsec-feed`), and tests as `*.test.mjs`.
|
||||
|
||||
## Testing Guidelines
|
||||
There is no root `npm test`; tests are mostly skill-local.
|
||||
- Run changed tests directly: `node skills/<skill>/test/<name>.test.mjs`.
|
||||
- For frontend/config changes, run ESLint, `npx tsc --noEmit`, and `npm run build`.
|
||||
- For wiki rendering/export changes, run `npm run gen:wiki-llms` and `npm run build`.
|
||||
- For Python utility updates, run `ruff check utils/` and `bandit -r utils/ -ll`.
|
||||
|
||||
## Pull Request Guidelines
|
||||
- Follow Conventional Commits: `feat(scope): ...`, `fix(scope): ...`, `chore(scope): ...`.
|
||||
- Use skill branches like `skill/<name>-...`.
|
||||
- Keep PRs focused and include summary, security benefit, and testing performed.
|
||||
- Keep versions aligned between `skills/<skill>/skill.json` and `skills/<skill>/SKILL.md`.
|
||||
- Do not push release tags from PR branches; releases are tagged from `main`.
|
||||
- Do not commit generated `public/wiki/` artifacts; edit `wiki/` source files instead.
|
||||
|
||||
## Agent Collaboration & Git Safety
|
||||
- Delete unused or obsolete files only when your changes make them irrelevant; revert files only when the change is yours or explicitly requested. If a git operation creates uncertainty about another agent’s in-flight work, stop and coordinate instead of deleting.
|
||||
- Before deleting any file to fix local type/lint failures, stop and ask the user.
|
||||
- Never edit `.env` or any environment variable files.
|
||||
- Coordinate with other agents before removing their in-progress edits; do not revert or delete work you did not author unless everyone agrees.
|
||||
- Moving, renaming, and restoring files is allowed when done safely.
|
||||
- Never run destructive git operations without explicit written instruction in this conversation: `git reset --hard`, `rm`, `git checkout`/`git restore` to older commits. Treat these as catastrophic; if unsure, stop and ask. In Cursor or Codex Web, use platform tooling as applicable.
|
||||
- Never use `git restore` (or similar revert commands) on files you did not author.
|
||||
- Always run `git status` before committing.
|
||||
- Keep commits atomic and commit only touched files with explicit paths.
|
||||
- For tracked files: `git commit -m "<scoped message>" -- path/to/file1 path/to/file2`.
|
||||
- For new files: `git restore --staged :/ && git add "path/to/file1" "path/to/file2" && git commit -m "<scoped message>" -- path/to/file1 path/to/file2`.
|
||||
- Quote any git path containing brackets or parentheses when staging/committing (for example, `"src/app/[candidate]/**"`).
|
||||
- For rebases, avoid editors: `GIT_EDITOR=:` and `GIT_SEQUENCE_EDITOR=:` (or `--no-edit`).
|
||||
- Never amend commits without explicit written approval in this task thread.
|
||||
@@ -1,30 +0,0 @@
|
||||
import React from 'react';
|
||||
import { HashRouter as Router, Routes, Route } from 'react-router-dom';
|
||||
import { Layout } from './components/Layout';
|
||||
import { Home } from './pages/Home';
|
||||
import { FeedSetup } from './pages/FeedSetup';
|
||||
import { SkillsCatalog } from './pages/SkillsCatalog';
|
||||
import { SkillDetail } from './pages/SkillDetail';
|
||||
import { AdvisoryDetail } from './pages/AdvisoryDetail';
|
||||
import { WikiBrowser } from './pages/WikiBrowser';
|
||||
import { ProductDemo } from './pages/ProductDemo';
|
||||
|
||||
const App: React.FC = () => {
|
||||
return (
|
||||
<Router>
|
||||
<Layout>
|
||||
<Routes>
|
||||
<Route path="/" element={<Home />} />
|
||||
<Route path="/skills" element={<SkillsCatalog />} />
|
||||
<Route path="/skills/:skillId" element={<SkillDetail />} />
|
||||
<Route path="/feed" element={<FeedSetup />} />
|
||||
<Route path="/feed/:advisoryId" element={<AdvisoryDetail />} />
|
||||
<Route path="/demo" element={<ProductDemo />} />
|
||||
<Route path="/wiki/*" element={<WikiBrowser />} />
|
||||
</Routes>
|
||||
</Layout>
|
||||
</Router>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
@@ -1,116 +0,0 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Development Setup
|
||||
|
||||
```bash
|
||||
npm install # install JS dependencies
|
||||
npm run dev # start Vite dev server on http://localhost:3000
|
||||
npm run build # production build to dist/
|
||||
```
|
||||
|
||||
Python environment (use `uv`, not raw `pip`):
|
||||
|
||||
```bash
|
||||
uv venv # create .venv in repo root
|
||||
source .venv/bin/activate
|
||||
uv pip install ruff bandit # linters configured in pyproject.toml
|
||||
```
|
||||
|
||||
Required tools: Node 20+, Python 3.10+, openssl, jq, shellcheck (`brew install shellcheck`).
|
||||
|
||||
## Common Commands
|
||||
|
||||
**Pre-push validation** (mirrors CI — run before pushing):
|
||||
|
||||
```bash
|
||||
./scripts/prepare-to-push.sh # lint, typecheck, build, security scans
|
||||
./scripts/prepare-to-push.sh --fix # auto-fix where possible
|
||||
```
|
||||
|
||||
**Lint:**
|
||||
|
||||
```bash
|
||||
npx eslint . --ext .ts,.tsx,.js,.jsx,.mjs --max-warnings 0 # JS/TS
|
||||
ruff check utils/ # Python
|
||||
bandit -r utils/ -ll # Python security
|
||||
```
|
||||
|
||||
**Tests** (vanilla Node.js — no framework, no npm test script):
|
||||
|
||||
```bash
|
||||
node skills/clawsec-suite/test/feed_verification.test.mjs
|
||||
node skills/clawsec-suite/test/guarded_install.test.mjs
|
||||
node skills/clawsec-suite/test/skill_catalog_discovery.test.mjs
|
||||
```
|
||||
|
||||
**Validate a skill's structure:**
|
||||
|
||||
```bash
|
||||
python utils/validate_skill.py skills/<skill-name>
|
||||
```
|
||||
|
||||
**Signing key consistency check:**
|
||||
|
||||
```bash
|
||||
./scripts/ci/verify_signing_key_consistency.sh
|
||||
```
|
||||
|
||||
**Populate local dev data:**
|
||||
|
||||
```bash
|
||||
./scripts/populate-local-skills.sh # build public/skills/index.json from local skills/
|
||||
./scripts/populate-local-feed.sh --days 120 # fetch real NVD CVE data for local advisory feed
|
||||
```
|
||||
|
||||
## Releasing a Skill
|
||||
|
||||
```bash
|
||||
./scripts/release-skill.sh <skill-name> <version> [--force-tag]
|
||||
# Example: ./scripts/release-skill.sh clawsec-feed 0.0.5
|
||||
```
|
||||
|
||||
- **Feature branch:** bumps version in skill.json + SKILL.md frontmatter, commits. No tag.
|
||||
- **Main branch:** same + creates annotated git tag + GitHub release with changelog.
|
||||
- Tag format: `<skill-name>-v<semver>` (e.g., `clawsec-suite-v0.1.0`).
|
||||
- Pushing the tag triggers the `skill-release.yml` workflow (sign, package, publish).
|
||||
|
||||
## Architecture
|
||||
|
||||
**Frontend:** React 19 + TypeScript + Vite, deployed to GitHub Pages. Hash-based routing. Tailwind via CDN.
|
||||
|
||||
**Skills:** Each skill lives in `skills/<name>/` with:
|
||||
- `skill.json` — metadata, SBOM (file manifest), OpenClaw config (emoji, triggers, required bins)
|
||||
- `SKILL.md` — YAML frontmatter (`name`, `version`, `description`) + agent-readable markdown
|
||||
- Version in `skill.json` and `SKILL.md` frontmatter must match (CI enforced)
|
||||
|
||||
**clawsec-suite** is the meta-skill ("skill-of-skills") that installs and manages other skills. It embeds:
|
||||
- Advisory feed with Ed25519 signature verification (`hooks/clawsec-advisory-guardian/`)
|
||||
- Guarded skill installer with two-stage approval for advisory-flagged skills
|
||||
- Dynamic catalog discovery from `https://clawsec.prompt.security/skills/index.json` with local fallback
|
||||
|
||||
**Signing:** Single Ed25519 keypair for everything (feed + releases).
|
||||
- Private key lives only in GitHub secret `CLAWSEC_SIGNING_PRIVATE_KEY` — never committed.
|
||||
- Public key committed in three canonical locations: `clawsec-signing-public.pem`, `advisories/feed-signing-public.pem`, `skills/clawsec-suite/advisories/feed-signing-public.pem`.
|
||||
- `SKILL.md` embeds the same key inline for offline installation verification.
|
||||
- Drift guard: `scripts/ci/verify_signing_key_consistency.sh` enforces all references resolve to the same fingerprint. Runs on every PR and tag push.
|
||||
|
||||
## CI Workflows
|
||||
|
||||
| Workflow | Trigger | What it does |
|
||||
|---|---|---|
|
||||
| `ci.yml` | PR / push to main | Lint (TS, Python, shell), Trivy security scan, npm audit, tests, build |
|
||||
| `skill-release.yml` | Tag `*-v*.*.*` or PR touching skill files | Sign checksums, publish to GitHub Releases, supersede old versions |
|
||||
| `deploy-pages.yml` | After CI or release succeeds | Build web frontend + skills catalog, deploy to GitHub Pages |
|
||||
| `poll-nvd-cves.yml` | Daily 06:00 UTC | Poll NVD for CVEs, update `advisories/feed.json` + signature |
|
||||
| `community-advisory.yml` | Issue labeled `advisory-approved` | Process community report into `CLAW-YYYY-NNNN` advisory |
|
||||
|
||||
## Key Conventions
|
||||
|
||||
- **ESLint:** flat config (`eslint.config.js`), zero warnings policy
|
||||
- **Python:** ruff + bandit, configured in `pyproject.toml`, line-length 120
|
||||
- **Shell:** shellcheck on `scripts/*.sh`
|
||||
- **Tests:** each `.test.mjs` is a standalone Node.js script with its own pass/fail counters and `process.exit(1)` on failure. Tests generate ephemeral Ed25519 keys — they don't use the repo signing keys.
|
||||
- **Advisory feed:** fail-closed signature verification by default. `CLAWSEC_ALLOW_UNSIGNED_FEED=1` is a temporary migration bypass only.
|
||||
- **Hook event model:** hooks mutate `event.messages` array in-place (not return values). Rate-limited to 300s by default (`CLAWSEC_HOOK_INTERVAL_SECONDS`).
|
||||
@@ -1,128 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement via this
|
||||
project's GitHub repository issue tracker.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
||||
@@ -1,668 +0,0 @@
|
||||
# Contributing to ClawSec Skills
|
||||
|
||||
Thank you for your interest in contributing security skills to the ClawSec ecosystem! This guide will walk you through creating, testing, and submitting new skills.
|
||||
|
||||
## Wiki Documentation Source of Truth
|
||||
|
||||
For contributor-facing wiki docs, treat `wiki/` in this repository as the single source of truth. Do not edit the GitHub Wiki directly; `.github/workflows/wiki-sync.yml` publishes `wiki/` to `<repo>.wiki.git` when `wiki/**` changes on `main`.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Wiki Documentation Source of Truth](#wiki-documentation-source-of-truth)
|
||||
- [Getting Started](#getting-started)
|
||||
- [Skill Structure](#skill-structure)
|
||||
- [Creating a New Skill](#creating-a-new-skill)
|
||||
- [skill.json Reference](#skilljson-reference)
|
||||
- [Testing Your Skill](#testing-your-skill)
|
||||
- [Submission Process](#submission-process)
|
||||
- [Version Bump and Release Flow](#version-bump-and-release-flow)
|
||||
- [Review Criteria](#review-criteria)
|
||||
- [After Acceptance](#after-acceptance)
|
||||
- [Submitting Security Advisories](#submitting-security-advisories)
|
||||
|
||||
---
|
||||
|
||||
## Getting Started
|
||||
|
||||
### 1. Fork the Repository
|
||||
|
||||
1. Navigate to the [ClawSec repository](https://github.com/prompt-security/clawsec)
|
||||
2. Click the "Fork" button in the top-right corner
|
||||
3. Clone your fork locally:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/YOUR-USERNAME/clawsec.git
|
||||
cd clawsec
|
||||
```
|
||||
|
||||
### 2. Set Up Your Environment
|
||||
|
||||
```bash
|
||||
# Add upstream remote to sync with main repo
|
||||
git remote add upstream https://github.com/prompt-security/clawsec.git
|
||||
|
||||
# Install dependencies (if any)
|
||||
npm install
|
||||
|
||||
# Create a new branch for your skill
|
||||
git checkout -b skill/my-new-skill
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Trust & Verification Model
|
||||
|
||||
All skills distributed through ClawSec undergo security review and are hashed for agent verification. Trust is implicit:
|
||||
|
||||
- **Backend Verification**: Every skill is validated against checksums, SBOM manifests, and security policies
|
||||
- **Transparent Security**: SHA256 checksums, and advisory feeds operate automatically
|
||||
- **Contribution Flow**: Submit skills via PR → maintainer review → approval → release
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Skill Structure
|
||||
|
||||
Each skill lives in its own directory under `skills/`. Here's the standard structure:
|
||||
|
||||
```
|
||||
skills/
|
||||
└── my-skill-name/
|
||||
├── skill.json # Required: Metadata and SBOM
|
||||
├── SKILL.md # Required: Main skill documentation
|
||||
├── README.md # Optional: Additional documentation
|
||||
└── scripts/
|
||||
├── # Any supporting scripts your skill needs
|
||||
```
|
||||
|
||||
### Example: Minimal Skill
|
||||
|
||||
```
|
||||
skills/
|
||||
└── my-security-scanner/
|
||||
├── skill.json
|
||||
└── SKILL.md
|
||||
```
|
||||
|
||||
### Example: Complex Skill
|
||||
|
||||
```
|
||||
skills/
|
||||
└── advanced-analyzer/
|
||||
├── skill.json
|
||||
├── SKILL.md
|
||||
├── README.md
|
||||
├── templates/
|
||||
│ └── report-template.md
|
||||
├── scripts/
|
||||
│ └── action.py
|
||||
└── config/
|
||||
└── rules.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Creating a New Skill
|
||||
|
||||
### Step 1: Create Skill Directory
|
||||
|
||||
```bash
|
||||
mkdir -p skills/my-skill-name
|
||||
cd skills/my-skill-name
|
||||
```
|
||||
|
||||
### Step 2: Create skill.json
|
||||
|
||||
Create `skill.json` with the following structure:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "my-skill-name",
|
||||
"version": "0.0.1",
|
||||
"description": "Brief description of what your skill does",
|
||||
"author": "your-github-username",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"homepage": "https://github.com/prompt-security/clawsec",
|
||||
"keywords": ["security", "relevant", "tags"],
|
||||
|
||||
"sbom": {
|
||||
"files": [
|
||||
{
|
||||
"path": "SKILL.md",
|
||||
"required": true,
|
||||
"description": "Main skill documentation"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"openclaw": {
|
||||
"emoji": "🔒",
|
||||
"category": "security",
|
||||
"requires": {
|
||||
"bins": ["curl", "jq"]
|
||||
},
|
||||
"triggers": [
|
||||
"keyword that activates skill",
|
||||
"another trigger phrase",
|
||||
"security check"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Important Notes:**
|
||||
- Start with version `0.0.1` in both `skill.json` and `SKILL.md` frontmatter
|
||||
- List ALL files your skill needs in the SBOM
|
||||
|
||||
### Step 3: Create SKILL.md
|
||||
|
||||
This is the main documentation for your skill. Include YAML frontmatter with a `version` that matches `skill.json`:
|
||||
|
||||
````markdown
|
||||
```markdown
|
||||
---
|
||||
name: my-skill-name
|
||||
version: 0.0.1
|
||||
description: Brief description of what your skill does
|
||||
metadata: {"openclaw":{"emoji":"🔒","category":"security"}}
|
||||
---
|
||||
|
||||
# My Skill Name
|
||||
|
||||
## Overview
|
||||
|
||||
Brief description of what this skill does and why it's useful for AI agent security.
|
||||
|
||||
## Usage
|
||||
|
||||
How to use the skill.
|
||||
|
||||
## Features
|
||||
|
||||
- Feature 1: Description
|
||||
- Feature 2: Description
|
||||
- Feature 3: Description
|
||||
|
||||
## Requirements
|
||||
|
||||
- Required tools: curl, jq, etc.
|
||||
- Any system dependencies
|
||||
- Prerequisites
|
||||
|
||||
## Security Considerations
|
||||
|
||||
Important security notes about this skill.
|
||||
```
|
||||
````
|
||||
|
||||
### Step 4: Add Supporting Files
|
||||
|
||||
Add any additional files your skill needs (configs, templates, scripts), and **ensure they're listed in skill.json's SBOM**.
|
||||
|
||||
---
|
||||
|
||||
## skill.json Reference
|
||||
|
||||
### Required Fields
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `name` | string | Skill identifier (lowercase, hyphens only) |
|
||||
| `version` | string | Semantic version (0.0.1) |
|
||||
| `description` | string | Brief description (max 200 chars) |
|
||||
| `author` | string | Your GitHub username or organization |
|
||||
| `license` | string | License type (prefer AGPL-3.0-or-later) |
|
||||
| `homepage` | string | Repository URL |
|
||||
| `keywords` | array | Searchable tags |
|
||||
| `sbom` | object | Software Bill of Materials |
|
||||
|
||||
### Verification
|
||||
|
||||
All skills published through ClawSec are reviewed by Prompt Security staff or designated maintainers before release:
|
||||
|
||||
- All published skills undergo security review
|
||||
- Checksums and SBOM validation ensure integrity
|
||||
- There is no distinction between "verified" and "community" skills - every skill in the catalog has passed review
|
||||
|
||||
### SBOM Structure
|
||||
|
||||
The SBOM (Software Bill of Materials) lists all files that are part of your skill:
|
||||
|
||||
```json
|
||||
{
|
||||
"sbom": {
|
||||
"files": [
|
||||
{
|
||||
"path": "SKILL.md",
|
||||
"required": true,
|
||||
"description": "Main skill file"
|
||||
},
|
||||
{
|
||||
"path": "config/rules.json",
|
||||
"required": false,
|
||||
"description": "Optional configuration rules"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Critical:** Every file your skill uses MUST be listed in the SBOM. This enables:
|
||||
- Automated checksum generation
|
||||
- Integrity verification
|
||||
- Secure distribution
|
||||
|
||||
### OpenClaw Integration
|
||||
|
||||
The `openclaw` section defines how the skill integrates with Claude Code:
|
||||
|
||||
```json
|
||||
{
|
||||
"openclaw": {
|
||||
"emoji": "🔒",
|
||||
"category": "security",
|
||||
"requires": {
|
||||
"bins": ["curl", "jq", "git"]
|
||||
},
|
||||
"triggers": [
|
||||
"keyword to activate skill",
|
||||
"another trigger phrase"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Categories:** `security`, `monitoring`, `analysis`, `reporting`, `utility`
|
||||
|
||||
---
|
||||
|
||||
## Testing Your Skill
|
||||
|
||||
### 1. Validate JSON Structure
|
||||
|
||||
```bash
|
||||
# Validate skill.json is valid JSON
|
||||
cat skills/my-skill-name/skill.json | jq .
|
||||
```
|
||||
|
||||
### 2. Verify SBOM Completeness
|
||||
|
||||
```bash
|
||||
# Check all SBOM files exist
|
||||
cd skills/my-skill-name
|
||||
for file in $(jq -r '.sbom.files[].path' skill.json); do
|
||||
[ -f "$file" ] && echo "✓ $file" || echo "✗ $file MISSING"
|
||||
done
|
||||
```
|
||||
|
||||
### 3. Test Locally (if applicable)
|
||||
|
||||
If your skill includes executable scripts or requires testing:
|
||||
|
||||
```bash
|
||||
# Follow the testing instructions in your SKILL.md
|
||||
```
|
||||
|
||||
### 4. Check for Common Issues
|
||||
|
||||
- [ ] All SBOM files exist
|
||||
- [ ] skill.json is valid JSON
|
||||
- [ ] Version is `0.0.1` for new skills
|
||||
- [ ] `skill.json` version matches `SKILL.md` frontmatter version
|
||||
- [ ] No hardcoded credentials or secrets
|
||||
- [ ] Trigger phrases are descriptive
|
||||
- [ ] Required binaries are documented
|
||||
|
||||
---
|
||||
|
||||
## Submission Process
|
||||
|
||||
### 1. Commit Your Changes
|
||||
|
||||
```bash
|
||||
# From the repository root
|
||||
git add skills/my-skill-name/
|
||||
git commit -m "feat(skills): add my-skill-name security skill"
|
||||
```
|
||||
|
||||
**Commit Message Format:**
|
||||
```
|
||||
feat(skills): add <skill-name> <brief description>
|
||||
|
||||
- Key feature 1
|
||||
- Key feature 2
|
||||
- Security benefit
|
||||
```
|
||||
|
||||
### 2. Push to Your Fork
|
||||
|
||||
```bash
|
||||
git push origin skill/my-new-skill
|
||||
```
|
||||
|
||||
### 3. Create a Pull Request
|
||||
|
||||
1. Go to your fork on GitHub
|
||||
2. Click "Pull Request"
|
||||
3. Select your branch (`skill/my-new-skill`)
|
||||
4. Fill out the PR template:
|
||||
|
||||
```markdown
|
||||
## Skill Contribution: [Skill Name]
|
||||
|
||||
### Description
|
||||
Brief overview of what this skill does.
|
||||
|
||||
### Security Benefits
|
||||
How this skill improves AI agent security.
|
||||
|
||||
### Testing Performed
|
||||
- [ ] JSON validation passed
|
||||
- [ ] SBOM files verified
|
||||
- [ ] Local testing completed
|
||||
- [ ] No secrets or credentials included
|
||||
|
||||
### Checklist
|
||||
- [ ] skill.json is complete
|
||||
- [ ] SKILL.md documentation is clear
|
||||
- [ ] All SBOM files are present
|
||||
- [ ] Version is 0.0.1 (if new skill)
|
||||
|
||||
### Additional Notes
|
||||
Any special considerations for reviewers.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Version Bump and Release Flow
|
||||
|
||||
This repository uses a branch-first workflow for skill versions:
|
||||
|
||||
1. Make skill changes on a branch (`skill/<name>-...`).
|
||||
2. Keep versions in sync:
|
||||
- `skills/<skill>/skill.json` -> `.version`
|
||||
- `skills/<skill>/SKILL.md` -> frontmatter `version`
|
||||
3. For existing skills, you can bump versions on your branch with:
|
||||
|
||||
```bash
|
||||
./scripts/release-skill.sh <skill-name> <new-version>
|
||||
```
|
||||
|
||||
4. Push your branch and open a PR. CI will run:
|
||||
- Version parity checks
|
||||
- A `release` dry-run (build/validation only, no publish)
|
||||
5. Do **not** push release tags from PR branches.
|
||||
- `scripts/release-skill.sh` creates a local tag. Keep it local during PR review.
|
||||
- If you need to remove that local tag: `git tag -d <skill-name>-v<version>`
|
||||
6. After merge, a maintainer creates and pushes the release tag from `main`:
|
||||
|
||||
```bash
|
||||
git checkout main
|
||||
git pull --ff-only origin main
|
||||
git tag -a <skill-name>-v<version> -m "<skill-name> version <version>"
|
||||
git push origin <skill-name>-v<version>
|
||||
```
|
||||
|
||||
7. Pushing the tag triggers the full release workflow (GitHub release + ClawHub publish).
|
||||
|
||||
---
|
||||
|
||||
## Review Criteria
|
||||
|
||||
Maintainers will review your skill based on:
|
||||
|
||||
### Security
|
||||
- [ ] No malicious code or backdoors
|
||||
- [ ] No hardcoded credentials
|
||||
- [ ] Safe command execution (no command injection)
|
||||
- [ ] Proper input validation
|
||||
- [ ] No unnecessary privileges required
|
||||
|
||||
### Quality
|
||||
- [ ] Clear documentation
|
||||
- [ ] Well-structured code
|
||||
- [ ] Follows naming conventions
|
||||
- [ ] Complete SBOM
|
||||
- [ ] Descriptive trigger phrases
|
||||
|
||||
### Value
|
||||
- [ ] Provides clear security benefit
|
||||
- [ ] Not duplicate of existing skill
|
||||
- [ ] Useful for AI agent protection
|
||||
- [ ] Aligns with ClawSec mission
|
||||
|
||||
### Technical
|
||||
- [ ] Valid JSON structure
|
||||
- [ ] All SBOM files present
|
||||
- [ ] Correct versioning
|
||||
- [ ] Proper metadata
|
||||
|
||||
---
|
||||
|
||||
## After Acceptance
|
||||
|
||||
Once your skill is accepted:
|
||||
|
||||
1. **Maintainers will:**
|
||||
- Review your PR (Prompt Security staff or designated maintainers)
|
||||
- Merge your PR after security review
|
||||
- Create and push a release tag from merged `main` (`<skill>-v<version>`)
|
||||
- Generate checksums and publish to GitHub Releases + ClawHub
|
||||
- Update the skills catalog website
|
||||
|
||||
2. **You'll be credited:**
|
||||
- Listed as the skill author
|
||||
- Mentioned in release notes
|
||||
- Added to contributors list
|
||||
|
||||
3. **Future updates:**
|
||||
- Submit PRs with version bumps for improvements
|
||||
- Maintainers will handle releases
|
||||
- Follow semantic versioning:
|
||||
- `1.0.1` - Patch (bug fixes)
|
||||
- `1.1.0` - Minor (new features)
|
||||
- `2.0.0` - Major (breaking changes)
|
||||
|
||||
---
|
||||
|
||||
## Questions?
|
||||
|
||||
- **Issues:** [GitHub Issues](https://github.com/prompt-security/clawsec/issues)
|
||||
- **Discussions:** [GitHub Discussions](https://github.com/prompt-security/clawsec/discussions)
|
||||
- **Security:** For security-sensitive contributions, email security@prompt.security
|
||||
|
||||
---
|
||||
|
||||
## Example Contribution
|
||||
|
||||
Here's a complete example of a minimal skill contribution:
|
||||
|
||||
```bash
|
||||
# Fork and clone
|
||||
git clone https://github.com/YOUR-USERNAME/clawsec.git
|
||||
cd clawsec
|
||||
|
||||
# Create branch
|
||||
git checkout -b skill/simple-scanner
|
||||
|
||||
# Create skill
|
||||
mkdir -p skills/simple-scanner
|
||||
cat > skills/simple-scanner/skill.json << 'EOF'
|
||||
{
|
||||
"name": "simple-scanner",
|
||||
"version": "0.0.1",
|
||||
"description": "Basic security scanner for AI agents",
|
||||
"author": "contributor-name",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"homepage": "https://github.com/prompt-security/clawsec",
|
||||
"keywords": ["security", "scanner", "basic"],
|
||||
"sbom": {
|
||||
"files": [
|
||||
{ "path": "SKILL.md", "required": true, "description": "Scanner documentation" }
|
||||
]
|
||||
},
|
||||
"openclaw": {
|
||||
"emoji": "🔍",
|
||||
"category": "security",
|
||||
"requires": { "bins": ["curl"] },
|
||||
"triggers": ["simple scan", "basic security check"]
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
cat > skills/simple-scanner/SKILL.md << 'EOF'
|
||||
---
|
||||
name: simple-scanner
|
||||
version: 0.0.1
|
||||
description: Basic security scanner for AI agents
|
||||
metadata: {"openclaw":{"emoji":"🔍","category":"security"}}
|
||||
---
|
||||
|
||||
# Simple Scanner
|
||||
|
||||
A basic security scanner for AI agents.
|
||||
|
||||
## Usage
|
||||
Run a simple security scan on your agent configuration.
|
||||
|
||||
## Features
|
||||
- Quick security checks
|
||||
- Minimal dependencies
|
||||
- Easy to use
|
||||
EOF
|
||||
|
||||
# Validate
|
||||
cat skills/simple-scanner/skill.json | jq .
|
||||
|
||||
# Commit and push
|
||||
git add skills/simple-scanner/
|
||||
git commit -m "feat(skills): add simple-scanner security skill
|
||||
|
||||
- Provides basic security scanning
|
||||
- Minimal dependencies
|
||||
- Easy to use for beginners"
|
||||
git push origin skill/simple-scanner
|
||||
```
|
||||
|
||||
Then create a pull request on GitHub!
|
||||
|
||||
---
|
||||
|
||||
## Submitting Security Advisories
|
||||
|
||||
Found a prompt injection vector, malicious skill, or security vulnerability affecting AI agents? Help protect the community by submitting a security advisory.
|
||||
|
||||
### Advisory Types
|
||||
|
||||
| Type | Description | Example |
|
||||
|------|-------------|---------|
|
||||
| `prompt_injection` | Detected prompt injection or social engineering | Skill contains hidden instructions to exfiltrate data |
|
||||
| `vulnerable_skill` | Skill with security vulnerabilities | Skill executes unsanitized user input |
|
||||
| `tampering_attempt` | Attempt to disable/modify security controls | Instructions to remove ClawSec or ignore security checks |
|
||||
|
||||
### How to Submit
|
||||
|
||||
#### 1. Open a Security Incident Report
|
||||
|
||||
1. Go to [Issues → New Issue](https://github.com/prompt-security/clawsec/issues/new/choose)
|
||||
2. Select **"Security Incident Report"** template
|
||||
3. Fill out all required sections:
|
||||
|
||||
**Required Fields:**
|
||||
- **Opener Type** - Are you a human or an AI agent reporting this?
|
||||
- **Report Type** - What kind of issue is this?
|
||||
- **Severity** - How severe is the threat?
|
||||
- **Title** - Brief descriptive title
|
||||
- **Description** - Detailed explanation of the vulnerability
|
||||
- **Affected** - Which skill(s) and version(s) are affected
|
||||
- **Recommended Action** - What should users do?
|
||||
|
||||
**Optional but Helpful:**
|
||||
- Evidence (sanitized payloads, indicators)
|
||||
- Reporter information (for follow-up questions)
|
||||
|
||||
#### 2. Privacy Checklist
|
||||
|
||||
Before submitting, ensure you have:
|
||||
- [ ] Removed all real user data and PII
|
||||
- [ ] Not included any API keys, credentials, or secrets
|
||||
- [ ] Sanitized evidence to describe issues abstractly
|
||||
- [ ] No proprietary or confidential information included
|
||||
|
||||
#### 3. Wait for Review
|
||||
|
||||
A maintainer will:
|
||||
1. Review your report for validity and completeness
|
||||
2. Assess the severity and impact
|
||||
3. Add the `advisory-approved` label when ready to publish
|
||||
|
||||
#### 4. Automatic Publication
|
||||
|
||||
Once approved, the [community-advisory workflow](.github/workflows/community-advisory.yml) automatically:
|
||||
1. Parses your issue content
|
||||
2. Generates an advisory ID: `CLAW-{YEAR}-{ISSUE_NUMBER}` (e.g., `CLAW-2026-0042`)
|
||||
3. Adds the advisory to `advisories/feed.json`
|
||||
4. Comments on your issue confirming publication
|
||||
|
||||
### Advisory ID Format
|
||||
|
||||
| Source | Format | Example |
|
||||
|--------|--------|---------|
|
||||
| NVD CVE | `CVE-YYYY-NNNNN` | `CVE-2026-24763` |
|
||||
| Community Report | `CLAW-YYYY-NNNN` | `CLAW-2026-0042` |
|
||||
|
||||
The `NNNN` in community advisories is your GitHub issue number, zero-padded to 4 digits.
|
||||
|
||||
### Example Security Report
|
||||
|
||||
```markdown
|
||||
## Opener Type
|
||||
- [x] Agent (automated report)
|
||||
|
||||
## Report Type
|
||||
- [x] Vulnerable Skill - Found a skill with security issues
|
||||
|
||||
## Severity
|
||||
- [x] High - Significant security risk, potential for harm
|
||||
|
||||
## Title
|
||||
Data exfiltration via helper-plus skill network calls
|
||||
|
||||
## Description
|
||||
The helper-plus skill was observed sending conversation data to an external
|
||||
server (suspicious-domain.com) on every invocation. The skill makes
|
||||
undocumented network calls that transmit full conversation context to a
|
||||
domain not mentioned in the skill description.
|
||||
|
||||
## Affected
|
||||
|
||||
### Skill Name
|
||||
helper-plus
|
||||
|
||||
### Skill Version
|
||||
0.0.1, 1.0.0, 1.0.1
|
||||
|
||||
## Recommended Action
|
||||
Remove helper-plus immediately. Do not use versions 0.0.1, 1.0.0 or 1.0.1.
|
||||
Wait for a verified patched version.
|
||||
|
||||
## Reporter Information (Optional)
|
||||
**Agent/User Name:** SecurityBot
|
||||
```
|
||||
|
||||
### After Publication
|
||||
|
||||
Once your advisory is published:
|
||||
|
||||
1. **Agents receive it** - The feed is served at `https://clawsec.prompt.security/advisories/feed.json` (with signature/checksum artifacts), so agents see it on their next feed check
|
||||
2. **You're credited** - Your issue is linked in the advisory
|
||||
3. **Community is protected** - Agents using ClawSec Feed will be alerted
|
||||
|
||||
### Questions?
|
||||
|
||||
- **General questions:** [GitHub Discussions](https://github.com/prompt-security/clawsec/discussions)
|
||||
- **Sensitive reports:** Email security@prompt.security for issues too sensitive for public disclosure
|
||||
|
||||
---
|
||||
|
||||
Thank you for contributing to ClawSec security! 🛡️
|
||||
@@ -1,661 +0,0 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
@@ -1,508 +0,0 @@
|
||||
<h1 align="center">
|
||||
<img src="./img/prompt-icon.svg" alt="prompt-icon" width="40">
|
||||
ClawSec: Security Skill Suite for AI Agents
|
||||
<img src="./img/prompt-icon.svg" alt="prompt-icon" width="40">
|
||||
</h1>
|
||||
|
||||
<div align="center">
|
||||
|
||||
## Secure Your OpenClaw and NanoClaw Agents with a Complete Security Skill Suite
|
||||
|
||||
<h4>Brought to you by <a href="https://prompt.security">Prompt Security</a>, the Platform for AI Security</h4>
|
||||
|
||||
</div>
|
||||
|
||||
<div align="center">
|
||||
|
||||

|
||||
<img src="./public/img/mascot.png" alt="clawsec mascot" width="200" />
|
||||
|
||||
</div>
|
||||
<div align="center">
|
||||
|
||||
🌐 **Live at: [https://clawsec.prompt.security](https://clawsec.prompt.security) [https://prompt.security/clawsec](https://prompt.security/clawsec)**
|
||||
|
||||
[](https://github.com/prompt-security/clawsec/actions/workflows/ci.yml)
|
||||
[](https://github.com/prompt-security/clawsec/actions/workflows/deploy-pages.yml)
|
||||
[](https://github.com/prompt-security/clawsec/actions/workflows/poll-nvd-cves.yml)
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## 🦞 What is ClawSec?
|
||||
|
||||
ClawSec is a **complete security skill suite for AI agent platforms**. It provides unified security monitoring, integrity verification, and threat intelligence-protecting your agent's cognitive architecture against prompt injection, drift, and malicious instructions.
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- **OpenClaw** (MoltBot, Clawdbot, and clones) - Full suite with skill installer, file integrity protection, and security audits
|
||||
- **NanoClaw** - Containerized WhatsApp bot security with MCP tools for advisory monitoring, signature verification, and file integrity
|
||||
|
||||
### Core Capabilities
|
||||
|
||||
- **📦 Suite Installer** - One-command installation of all security skills with integrity verification
|
||||
- **🛡️ File Integrity Protection** - Drift detection and auto-restore for critical agent files (SOUL.md, IDENTITY.md, etc.)
|
||||
- **📡 Live Security Advisories** - Automated NVD CVE polling and community threat intelligence
|
||||
- **🔍 Security Audits** - Self-check scripts to detect prompt injection markers and vulnerabilities
|
||||
- **🔐 Checksum Verification** - SHA256 checksums for all skill artifacts
|
||||
- **Health Checks** - Automated updates and integrity verification for all installed skills
|
||||
|
||||
---
|
||||
|
||||
## 🎬 Product Demos
|
||||
|
||||
Animated previews below are GIFs (no audio). Click any preview to open the full MP4 with audio.
|
||||
|
||||
### Install Demo (`clawsec-suite`)
|
||||
|
||||
[](public/video/install-demo.mp4)
|
||||
|
||||
Direct link: [install-demo.mp4](public/video/install-demo.mp4)
|
||||
|
||||
### Drift Detection Demo (`soul-guardian`)
|
||||
|
||||
[](public/video/soul-guardian-demo.mp4)
|
||||
|
||||
Direct link: [soul-guardian-demo.mp4](public/video/soul-guardian-demo.mp4)
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### For AI Agents
|
||||
|
||||
```bash
|
||||
# Install the ClawSec security suite
|
||||
npx clawhub@latest install clawsec-suite
|
||||
```
|
||||
|
||||
After install, the suite can:
|
||||
1. Discover installable protections from the published skills catalog
|
||||
2. Verify release integrity using signed checksums
|
||||
3. Set up advisory monitoring and hook-based protection flows
|
||||
4. Add optional scheduled checks
|
||||
|
||||
Manual/source-first option:
|
||||
|
||||
> Read https://github.com/prompt-security/clawsec/releases/latest/download/SKILL.md and follow the installation instructions.
|
||||
|
||||
### For Humans
|
||||
|
||||
Copy this instruction to your AI agent:
|
||||
|
||||
> Install ClawSec with `npx clawhub@latest install clawsec-suite`, then complete the setup steps from the generated instructions.
|
||||
|
||||
### Shell and OS Notes
|
||||
|
||||
ClawSec scripts are split between:
|
||||
- Cross-platform Node/Python tooling (`npm run build`, hook/setup `.mjs`, `utils/*.py`)
|
||||
- POSIX shell workflows (`*.sh`, most manual install snippets)
|
||||
|
||||
For Linux/macOS (`bash`/`zsh`):
|
||||
- Use unquoted or double-quoted home vars: `export INSTALL_ROOT="$HOME/.openclaw/skills"`
|
||||
- Do **not** single-quote expandable vars (for example, avoid `'$HOME/.openclaw/skills'`)
|
||||
|
||||
For Windows (PowerShell):
|
||||
- Prefer explicit path building:
|
||||
- `$env:INSTALL_ROOT = Join-Path $HOME ".openclaw\\skills"`
|
||||
- `node "$env:INSTALL_ROOT\\clawsec-suite\\scripts\\setup_advisory_hook.mjs"`
|
||||
- POSIX `.sh` scripts require WSL or Git Bash.
|
||||
|
||||
Troubleshooting: if you see directories such as `~/.openclaw/workspace/$HOME/...`, a home variable was passed literally. Re-run using an absolute path or an unquoted home expression.
|
||||
|
||||
---
|
||||
|
||||
## 📱 NanoClaw Platform Support
|
||||
|
||||
ClawSec now supports **NanoClaw**, a containerized WhatsApp bot powered by Claude agents.
|
||||
|
||||
### clawsec-nanoclaw Skill
|
||||
|
||||
**Location**: `skills/clawsec-nanoclaw/`
|
||||
|
||||
A complete security suite adapted for NanoClaw's containerized architecture:
|
||||
|
||||
- **9 MCP Tools** for agents to check vulnerabilities
|
||||
- Advisory checking and browsing
|
||||
- Pre-installation safety checks
|
||||
- Skill package signature verification (Ed25519)
|
||||
- File integrity monitoring
|
||||
- **Automatic Advisory Feed** - Fetches and caches advisories every 6 hours
|
||||
- **Platform Filtering** - Shows only NanoClaw-relevant advisories
|
||||
- **IPC-Based** - Container-safe host communication
|
||||
- **Full Documentation** - Installation guide, usage examples, troubleshooting
|
||||
|
||||
### Advisory Feed for NanoClaw
|
||||
|
||||
The feed now monitors NanoClaw-specific keywords:
|
||||
- `NanoClaw` - Direct product name
|
||||
- `WhatsApp-bot` - Core functionality
|
||||
- `baileys` - WhatsApp client library dependency
|
||||
|
||||
Advisories can specify `platforms: ["nanoclaw"]` for platform-specific issues.
|
||||
|
||||
### Quick Start for NanoClaw
|
||||
|
||||
See [`skills/clawsec-nanoclaw/INSTALL.md`](skills/clawsec-nanoclaw/INSTALL.md) for detailed setup instructions.
|
||||
|
||||
**Quick integration:**
|
||||
1. Copy skill to NanoClaw deployment
|
||||
2. Integrate MCP tools in container
|
||||
3. Add IPC handlers and cache service on host
|
||||
4. Restart NanoClaw
|
||||
|
||||
---
|
||||
|
||||
## 📦 ClawSec Suite (OpenClaw)
|
||||
|
||||
The **clawsec-suite** is a skill-of-skills manager that installs, verifies, and maintains security skills from the ClawSec catalog.
|
||||
|
||||
`clawsec-suite` is optional orchestration; skills can still be installed directly as standalone packages.
|
||||
|
||||
### ClawSec Skills
|
||||
|
||||
| Skill | Description | Installation | Compatibility |
|
||||
|-------|-------------|--------------|---------------|
|
||||
| 📡 **clawsec-feed** | Security advisory feed monitoring with live CVE updates | ✅ Included by default | All agents |
|
||||
| 🔭 **openclaw-audit-watchdog** | Automated daily audits with email reporting | ⚙️ Optional (install separately) | OpenClaw/MoltBot/Clawdbot |
|
||||
| 👻 **soul-guardian** | Drift detection and file integrity guard with auto-restore | ⚙️ Optional | All agents |
|
||||
| 🤝 **clawtributor** | Community incident reporting | ❌ Optional (Explicit request) | All agents |
|
||||
|
||||
> ⚠️ **clawtributor** is not installed by default as it may share anonymized incident data. Install only on explicit user request.
|
||||
|
||||
> ⚠️ **openclaw-audit-watchdog** is tailored for the OpenClaw/MoltBot/Clawdbot agent family. Other agents receive the universal skill set.
|
||||
|
||||
### Suite Features
|
||||
|
||||
- **Integrity Verification** - Every skill package includes `checksums.json` with SHA256 hashes
|
||||
- **Updates** - Automatic checks for new skill versions
|
||||
- **Self-Healing** - Failed integrity checks trigger automatic re-download from trusted releases
|
||||
- **Advisory Cross-Reference** - Installed skills are checked against the security advisory feed
|
||||
|
||||
---
|
||||
|
||||
## 📡 Security Advisory Feed
|
||||
|
||||
ClawSec maintains a continuously updated security advisory feed, automatically populated from NIST's National Vulnerability Database (NVD).
|
||||
|
||||
### Feed URL
|
||||
|
||||
```bash
|
||||
# Fetch latest advisories
|
||||
curl -s https://clawsec.prompt.security/advisories/feed.json | jq '.advisories[] | select(.severity == "critical" or .severity == "high")'
|
||||
```
|
||||
|
||||
Canonical endpoint: `https://clawsec.prompt.security/advisories/feed.json`
|
||||
Compatibility mirror (legacy): `https://clawsec.prompt.security/releases/latest/download/feed.json`
|
||||
|
||||
### Monitored Keywords
|
||||
|
||||
The feed polls CVEs related to:
|
||||
- **OpenClaw Platform**: `OpenClaw`, `clawdbot`, `Moltbot`
|
||||
- **NanoClaw Platform**: `NanoClaw`, `WhatsApp-bot`, `baileys`
|
||||
- Prompt injection patterns
|
||||
- Agent security vulnerabilities
|
||||
|
||||
### Exploitability Context
|
||||
|
||||
ClawSec enriches CVE advisories with **exploitability context** to help agents assess real-world risk beyond raw CVSS scores. Newly analyzed advisories can include:
|
||||
|
||||
- **Exploit Evidence**: Whether public exploits exist in the wild
|
||||
- **Weaponization Status**: If exploits are integrated into common attack frameworks
|
||||
- **Attack Requirements**: Prerequisites needed for successful exploitation (network access, authentication, user interaction)
|
||||
- **Risk Assessment**: Contextualized risk level combining technical severity with exploitability
|
||||
|
||||
This feature helps agents prioritize vulnerabilities that pose immediate threats versus theoretical risks, enabling smarter security decisions.
|
||||
|
||||
### Advisory Schema
|
||||
|
||||
**NVD CVE Advisory:**
|
||||
```json
|
||||
{
|
||||
"id": "CVE-2026-XXXXX",
|
||||
"severity": "critical|high|medium|low",
|
||||
"type": "vulnerable_skill",
|
||||
"platforms": ["openclaw", "nanoclaw"],
|
||||
"title": "Short description",
|
||||
"description": "Full CVE description from NVD",
|
||||
"published": "2026-02-01T00:00:00Z",
|
||||
"cvss_score": 8.8,
|
||||
"nvd_url": "https://nvd.nist.gov/vuln/detail/CVE-2026-XXXXX",
|
||||
"exploitability_score": "high|medium|low|unknown",
|
||||
"exploitability_rationale": "Why this CVE is or is not likely exploitable in agent deployments",
|
||||
"references": ["..."],
|
||||
"action": "Recommended remediation"
|
||||
}
|
||||
```
|
||||
|
||||
**Community Advisory:**
|
||||
```json
|
||||
{
|
||||
"id": "CLAW-2026-0042",
|
||||
"severity": "high",
|
||||
"type": "prompt_injection|vulnerable_skill|tampering_attempt",
|
||||
"platforms": ["nanoclaw"],
|
||||
"title": "Short description",
|
||||
"description": "Detailed description from issue",
|
||||
"published": "2026-02-01T00:00:00Z",
|
||||
"affected": ["skill-name@1.0.0"],
|
||||
"source": "Community Report",
|
||||
"github_issue_url": "https://github.com/.../issues/42",
|
||||
"action": "Recommended remediation"
|
||||
}
|
||||
```
|
||||
|
||||
**Platform values:**
|
||||
- `"openclaw"` - OpenClaw/Clawdbot/MoltBot only
|
||||
- `"nanoclaw"` - NanoClaw only
|
||||
- `["openclaw", "nanoclaw"]` - Both platforms
|
||||
- (empty/missing) - All platforms (backward compatible)
|
||||
|
||||
---
|
||||
|
||||
## 🔄 CI/CD Pipelines
|
||||
|
||||
ClawSec uses automated pipelines for continuous security updates and skill distribution.
|
||||
|
||||
### Automated Workflows
|
||||
|
||||
| Workflow | Trigger | Description |
|
||||
|----------|---------|-------------|
|
||||
| **ci.yml** | PRs to `main`, pushes to `main` | Lint/type/build + skill test suites |
|
||||
| **pages-verify.yml** | PRs to `main` | Verifies Pages build and signing outputs without publishing |
|
||||
| **poll-nvd-cves.yml** | Daily cron (06:00 UTC) | Polls NVD for new CVEs, updates feed |
|
||||
| **community-advisory.yml** | Issue labeled `advisory-approved` | Processes community reports into advisories |
|
||||
| **skill-release.yml** | Skill tags + metadata PR changes | Validates version parity in PRs and publishes signed skill releases on tags |
|
||||
| **deploy-pages.yml** | `workflow_run` after successful trusted CI/release or manual dispatch | Builds and deploys the web interface to GitHub Pages |
|
||||
| **wiki-sync.yml** | Pushes to `main` touching `wiki/**` | Syncs `wiki/` to the GitHub Wiki mirror |
|
||||
|
||||
### Skill Release Pipeline
|
||||
|
||||
When a skill is tagged (e.g., `soul-guardian-v1.0.0`), the pipeline:
|
||||
|
||||
1. **Validates** - Checks `skill.json` version matches tag
|
||||
2. **Enforces key consistency** - Verifies pinned release key references are consistent across repo PEMs and `skills/clawsec-suite/SKILL.md`
|
||||
3. **Generates Checksums** - Creates `checksums.json` with SHA256 hashes for all SBOM files
|
||||
4. **Signs + verifies** - Signs `checksums.json` and validates the generated `signing-public.pem` fingerprint against canonical repo key material
|
||||
5. **Releases** - Publishes to GitHub Releases with all artifacts
|
||||
6. **Supersedes Old Releases** - Deletes older versions within the same major line (tags remain)
|
||||
7. **Triggers Pages Update** - Refreshes the skills catalog on the website
|
||||
|
||||
### Signing Key Consistency Guardrails
|
||||
|
||||
To prevent supply-chain drift, CI now fails fast when signing key references diverge.
|
||||
|
||||
Guardrail script:
|
||||
- `scripts/ci/verify_signing_key_consistency.sh`
|
||||
|
||||
What it checks:
|
||||
- `skills/clawsec-suite/SKILL.md` inline public key fingerprint matches `RELEASE_PUBKEY_SHA256`
|
||||
- Canonical PEM files all match the same fingerprint:
|
||||
- `clawsec-signing-public.pem`
|
||||
- `advisories/feed-signing-public.pem`
|
||||
- `skills/clawsec-suite/advisories/feed-signing-public.pem`
|
||||
- Generated public key in workflows matches canonical key:
|
||||
- `release-assets/signing-public.pem` (release workflow)
|
||||
- `public/signing-public.pem` (pages workflow)
|
||||
|
||||
Where enforced:
|
||||
- `.github/workflows/skill-release.yml`
|
||||
- `.github/workflows/deploy-pages.yml`
|
||||
|
||||
### Release Versioning & Superseding
|
||||
|
||||
ClawSec follows [semantic versioning](https://semver.org/). When a new version is released:
|
||||
|
||||
| Scenario | Behavior |
|
||||
|----------|----------|
|
||||
| New patch/minor (e.g., 1.0.1, 1.1.0) | Previous releases with same major version are **deleted** |
|
||||
| New major (e.g., 2.0.0) | Previous major version (1.x.x) remains for backwards compatibility |
|
||||
|
||||
**Why do old releases disappear?**
|
||||
|
||||
When you release `skill-v0.0.2`, the previous `skill-v0.0.1` release is automatically deleted to keep the releases page clean. Only the latest version within each major version is retained.
|
||||
|
||||
- **Git tags are preserved** - You can always recreate a release from an existing tag if needed
|
||||
- **Major versions coexist** - Both `skill-v1.x.x` and `skill-v2.x.x` latest releases remain available for backwards compatibility
|
||||
|
||||
### Release Artifacts
|
||||
|
||||
Each skill release includes:
|
||||
- `checksums.json` - SHA256 hashes for integrity verification
|
||||
- `skill.json` - Skill metadata
|
||||
- `SKILL.md` - Main skill documentation
|
||||
- Additional files from SBOM (scripts, configs, etc.)
|
||||
|
||||
### Signing Operations Documentation
|
||||
|
||||
For feed/release signing rollout and operations guidance:
|
||||
- [`wiki/security-signing-runbook.md`](wiki/security-signing-runbook.md) - key generation, GitHub secrets, rotation/revocation, incident response
|
||||
- [`wiki/migration-signed-feed.md`](wiki/migration-signed-feed.md) - phased migration from unsigned feed, enforcement gates, rollback plan
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Offline Tools
|
||||
|
||||
ClawSec includes Python utilities for local skill development and validation.
|
||||
|
||||
### Skill Validator
|
||||
|
||||
Validates a skill folder against the required schema:
|
||||
|
||||
```bash
|
||||
python utils/validate_skill.py skills/clawsec-feed
|
||||
```
|
||||
|
||||
Checks:
|
||||
- `skill.json` exists and is valid JSON
|
||||
- Required fields present (name, version, description, author, license)
|
||||
- SBOM files exist and are readable
|
||||
- OpenClaw metadata is properly structured
|
||||
|
||||
### Skill Checksums Generator
|
||||
|
||||
Generates `checksums.json` with SHA256 hashes for a skill:
|
||||
|
||||
```bash
|
||||
python utils/package_skill.py skills/clawsec-feed ./dist
|
||||
```
|
||||
|
||||
Outputs:
|
||||
- `checksums.json` - SHA256 hashes for verification
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Local Development
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Node.js 20+
|
||||
- Python 3.10+ (for offline tools)
|
||||
- npm
|
||||
|
||||
### Setup
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
npm install
|
||||
|
||||
# Start development server
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Populate Local Data
|
||||
|
||||
```bash
|
||||
# Populate skills catalog from local skills/ directory
|
||||
./scripts/populate-local-skills.sh
|
||||
|
||||
# Populate advisory feed with real NVD CVE data
|
||||
./scripts/populate-local-feed.sh --days 120
|
||||
|
||||
# Generate wiki llms exports from wiki/ (for local preview)
|
||||
./scripts/populate-local-wiki.sh
|
||||
|
||||
# Direct generator entrypoint (used by predev/prebuild)
|
||||
npm run gen:wiki-llms
|
||||
```
|
||||
|
||||
Notes:
|
||||
- `npm run dev` and `npm run build` automatically regenerate wiki `llms.txt` exports (`predev`/`prebuild` hooks).
|
||||
- `public/wiki/` is generated output (local + CI) and is intentionally gitignored.
|
||||
|
||||
### Build
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📁 Project Structure
|
||||
|
||||
```
|
||||
├── advisories/
|
||||
│ └── feed.json # Main advisory feed (auto-updated from NVD)
|
||||
├── components/ # React components
|
||||
├── pages/ # Page components
|
||||
├── wiki/ # Source-of-truth docs (synced to GitHub Wiki)
|
||||
├── scripts/
|
||||
│ ├── generate-wiki-llms.mjs # wiki/*.md -> public/wiki/**/llms.txt
|
||||
│ ├── populate-local-feed.sh # Local CVE feed populator
|
||||
│ ├── populate-local-skills.sh # Local skills catalog populator
|
||||
│ ├── populate-local-wiki.sh # Local wiki llms export populator
|
||||
│ └── release-skill.sh # Manual skill release helper
|
||||
├── skills/
|
||||
│ ├── clawsec-suite/ # 📦 Suite installer (skill-of-skills - start here and have your agent do the rest)
|
||||
│ ├── clawsec-feed/ # 📡 Advisory feed skill
|
||||
│ ├── clawsec-scanner/ # 🔍 Vulnerability scanner (deps + SAST + OpenClaw DAST)
|
||||
│ ├── clawsec-nanoclaw/ # 📱 NanoClaw platform security suite
|
||||
│ ├── clawsec-clawhub-checker/ # 🧪 ClawHub reputation checks
|
||||
│ ├── clawtributor/ # 🤝 Community reporting skill
|
||||
│ ├── openclaw-audit-watchdog/ # 🔭 Automated audit skill
|
||||
│ └── soul-guardian/ # 👻 File integrity skill
|
||||
├── utils/
|
||||
│ ├── package_skill.py # Skill packager utility
|
||||
│ └── validate_skill.py # Skill validator utility
|
||||
├── .github/workflows/
|
||||
│ ├── ci.yml # Cross-platform lint/type/build + tests
|
||||
│ ├── pages-verify.yml # PR-only pages build verification
|
||||
│ ├── poll-nvd-cves.yml # CVE polling pipeline
|
||||
│ ├── community-advisory.yml # Approved issue -> advisory PR
|
||||
│ ├── skill-release.yml # Skill release pipeline
|
||||
│ ├── wiki-sync.yml # Sync repo wiki/ to GitHub Wiki
|
||||
│ └── deploy-pages.yml # Pages deployment
|
||||
└── public/ # Static assets + generated publish artifacts
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
||||
|
||||
### Submitting Security Advisories
|
||||
|
||||
Found a prompt injection vector, malicious skill, or security vulnerability? Report it via GitHub Issues:
|
||||
|
||||
1. Open a new issue using the **Security Incident Report** template
|
||||
2. Fill out the required fields (severity, type, description, affected skills)
|
||||
3. A maintainer will review and add the `advisory-approved` label
|
||||
4. The advisory is automatically published to the feed as `CLAW-{YEAR}-{ISSUE#}`
|
||||
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md#submitting-security-advisories) for detailed guidelines.
|
||||
|
||||
### Adding New Skills
|
||||
|
||||
1. Create a skill folder under `skills/`
|
||||
2. Add `skill.json` with required metadata and SBOM
|
||||
3. Add `SKILL.md` with agent-readable instructions
|
||||
4. Validate with `python utils/validate_skill.py skills/your-skill`
|
||||
5. Submit a PR for review
|
||||
|
||||
## 📚 Documentation Source of Truth
|
||||
|
||||
For all wiki content, edit files under `wiki/` in this repository. The GitHub Wiki (`<repo>.wiki.git`) is synced from `wiki/` by `.github/workflows/wiki-sync.yml` when `wiki/**` changes on `main`.
|
||||
|
||||
LLM exports are generated from `wiki/` into `public/wiki/`:
|
||||
- `/wiki/llms.txt` is the LLM-ready export for `wiki/INDEX.md` (or a generated fallback index if `INDEX.md` is missing).
|
||||
- `/wiki/<page>/llms.txt` is the LLM-ready export for that single wiki page.
|
||||
|
||||
---
|
||||
|
||||
## 📄 License
|
||||
|
||||
- Source code: GNU AGPL v3.0 or later - See [LICENSE](LICENSE) for details.
|
||||
- Fonts in `font/`: Licensed separately - See [`font/README.md`](font/README.md).
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
|
||||
**ClawSec** · Prompt Security, SentinelOne
|
||||
|
||||
🦞 Hardening agentic workflows, one skill at a time.
|
||||
|
||||
</div>
|
||||
@@ -1,42 +0,0 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
ClawSec follows a strict release lifecycle where **only the latest version within each major version** is retained and supported.
|
||||
|
||||
When a new patch or minor version is released (e.g., updating from `1.0.0` to `1.0.1`), the previous release artifacts for that major version are automatically deleted to maintain a clean release history. Major versions co-exist for backwards compatibility.
|
||||
|
||||
| Version | Supported | Notes |
|
||||
| ------- | :---: | --- |
|
||||
| **Latest Major** | :white_check_mark: | The most recent release (e.g., `v1.x.x`) is fully supported. |
|
||||
| **Previous Majors** | :white_check_mark: | The latest release of previous major versions (e.g., `v0.x.x`) remains available. |
|
||||
| **Older Patches** | :x: | Previous patch/minor versions are deleted upon new releases. |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
We welcome reports regarding prompt injection vectors, malicious skills, or security vulnerabilities in the ClawSec suite.
|
||||
|
||||
### How to Submit a Report
|
||||
Please report vulnerabilities directly via **GitHub Issues** using our specific template:
|
||||
|
||||
1. Navigate to the **Issues** tab.
|
||||
2. Open a new issue using the **Security Incident Report** template.
|
||||
3. Fill out the required fields, including:
|
||||
* **Severity** (Critical/High/Medium/Low)
|
||||
* **Type** (e.g., `prompt_injection`, `vulnerable_skill`, `tampering_attempt`)
|
||||
* **Description**
|
||||
* **Affected Skills**
|
||||
|
||||
### What to Expect
|
||||
Once a report is submitted, the following process occurs:
|
||||
|
||||
1. **Review:** A maintainer will review your report.
|
||||
2. **Approval:** If validated, the maintainer will add the `advisory-approved` label to the issue.
|
||||
3. **Publication:** The advisory is **automatically published** to the ClawSec Security Advisory Feed as `CLAW-{YEAR}-{ISSUE#}`.
|
||||
4. **Distribution:** The updated feed is immediately available to all agents running the `clawsec-feed` skill, which polls for these updates daily.
|
||||
|
||||
### Security Advisory Feed
|
||||
ClawSec maintains a continuously updated feed populated by these community reports and the NIST National Vulnerability Database (NVD). You can verify the current status of known vulnerabilities by querying the feed directly:
|
||||
|
||||
```bash
|
||||
curl -s https://clawsec.prompt.security/advisories/feed.json
|
||||
@@ -1,3 +0,0 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MCowBQYDK2VwAyEAS7nijfMcUoOBCj4yOXJX+GYGv2pFl2Yaha1P4v5Cm6A=
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -1 +0,0 @@
|
||||
Cz4Hx/UdUdx+ibsq4njd5NOx/0b3n5bXEKWFVY2eVrgaOGyBTojzO4KO3uiBb90cHlpRvync4tKZDhjOCh2kAg==
|
||||
@@ -1,3 +0,0 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MCowBQYDK2VwAyEAS7nijfMcUoOBCj4yOXJX+GYGv2pFl2Yaha1P4v5Cm6A=
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -1,95 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { ExternalLink, Github } from 'lucide-react';
|
||||
import { Advisory } from '../types';
|
||||
|
||||
interface AdvisoryCardProps {
|
||||
advisory: Advisory;
|
||||
formatDate: (dateStr: string) => string;
|
||||
}
|
||||
|
||||
export const AdvisoryCard: React.FC<AdvisoryCardProps> = ({ advisory, formatDate }) => {
|
||||
const getSeverityClasses = (severity: string) => {
|
||||
switch (severity) {
|
||||
case 'critical':
|
||||
return 'bg-red-500/20 text-red-400';
|
||||
case 'high':
|
||||
return 'bg-orange-500/20 text-orange-400';
|
||||
case 'medium':
|
||||
return 'bg-yellow-500/20 text-yellow-400';
|
||||
default:
|
||||
return 'bg-blue-500/20 text-blue-400';
|
||||
}
|
||||
};
|
||||
|
||||
const getTypeLabel = (type: string) => {
|
||||
switch (type) {
|
||||
case 'malicious_skill':
|
||||
return 'Malicious Skill';
|
||||
case 'vulnerable_skill':
|
||||
return 'Vulnerable Skill';
|
||||
case 'prompt_injection':
|
||||
return 'Prompt Injection';
|
||||
case 'attack_pattern':
|
||||
return 'Attack Pattern';
|
||||
case 'best_practice':
|
||||
return 'Best Practice';
|
||||
case 'tampering_attempt':
|
||||
return 'Tampering Attempt';
|
||||
default:
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
// Determine if this is a community report (has github_issue_url) or NVD/staff advisory
|
||||
const isCommunityReport = !!advisory.github_issue_url;
|
||||
|
||||
return (
|
||||
<Link
|
||||
to={`/feed/${encodeURIComponent(advisory.id)}`}
|
||||
className="block h-full bg-clawd-800 border border-clawd-700 rounded-xl p-5 hover:border-clawd-accent/30 transition-all group cursor-pointer"
|
||||
>
|
||||
<div className="grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-2 gap-y-2 mb-3">
|
||||
<div className="flex min-w-0 flex-wrap gap-2">
|
||||
<span className={`text-xs font-bold px-2 py-1 rounded uppercase ${getSeverityClasses(advisory.severity)}`}>
|
||||
{advisory.severity}
|
||||
{advisory.cvss_score && <span className="ml-1 opacity-75">({advisory.cvss_score})</span>}
|
||||
</span>
|
||||
<span className="text-xs px-2 py-1 rounded bg-clawd-700 text-gray-400 min-w-0 max-w-full truncate">
|
||||
{getTypeLabel(advisory.type)}
|
||||
</span>
|
||||
</div>
|
||||
<span className="text-xs text-gray-500 font-mono text-right whitespace-nowrap">{formatDate(advisory.published)}</span>
|
||||
</div>
|
||||
<h3 className="text-white font-bold mb-2 group-hover:text-clawd-accent transition-colors text-sm">
|
||||
{advisory.id}
|
||||
</h3>
|
||||
<p className="text-sm text-gray-400 line-clamp-3 mb-3">{advisory.title}</p>
|
||||
|
||||
{/* External link - stop propagation to allow clicking without navigating to detail */}
|
||||
{isCommunityReport && advisory.github_issue_url ? (
|
||||
<span
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
window.open(advisory.github_issue_url, '_blank', 'noopener,noreferrer');
|
||||
}}
|
||||
className="inline-flex items-center gap-1 text-xs text-clawd-accent hover:underline cursor-pointer"
|
||||
>
|
||||
View GitHub Report <Github size={12} />
|
||||
</span>
|
||||
) : advisory.nvd_url ? (
|
||||
<span
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
window.open(advisory.nvd_url, '_blank', 'noopener,noreferrer');
|
||||
}}
|
||||
className="inline-flex items-center gap-1 text-xs text-clawd-accent hover:underline cursor-pointer"
|
||||
>
|
||||
View on NVD <ExternalLink size={12} />
|
||||
</span>
|
||||
) : null}
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
@@ -1,40 +0,0 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Copy, Check } from 'lucide-react';
|
||||
|
||||
interface CodeBlockProps {
|
||||
code: string;
|
||||
language?: string;
|
||||
label?: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const CodeBlock: React.FC<CodeBlockProps> = ({ code, language = 'bash', label, className }) => {
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
const handleCopy = () => {
|
||||
navigator.clipboard.writeText(code);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={`my-4 rounded-lg overflow-hidden border border-clawd-700 bg-clawd-800 shadow-xl ${className || ''}`}>
|
||||
<div className="flex items-center justify-between px-4 py-2 bg-clawd-900 border-b border-clawd-700">
|
||||
<span className="text-xs font-mono text-gray-400 uppercase">{label || language}</span>
|
||||
<button
|
||||
onClick={handleCopy}
|
||||
className="flex items-center gap-1 text-xs text-gray-400 hover:text-white transition-colors"
|
||||
aria-label="Copy code"
|
||||
>
|
||||
{copied ? <Check size={14} className="text-green-400" /> : <Copy size={14} />}
|
||||
{copied ? 'Copied' : 'Copy'}
|
||||
</button>
|
||||
</div>
|
||||
<div className="p-3 sm:p-4 overflow-x-auto max-w-full">
|
||||
<pre className="text-xs sm:text-sm font-mono text-gray-300 whitespace-pre-wrap break-all overflow-wrap-anywhere">
|
||||
<code>{code}</code>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,14 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
export const Footer: React.FC = () => {
|
||||
return (
|
||||
<footer className="text-center py-6 mt-auto">
|
||||
<p className="text-gray-300 text-sm italic">
|
||||
ClawSec is a project by Prompt Security, a SentinelOne company. It's not affiliated with OpenClaw or NanoClaw. Designed for security research and agentic workflow hardening.
|
||||
</p>
|
||||
<div className="flex justify-center gap-4 mt-4">
|
||||
<span className="text-2xl animate-pulse">🦞</span>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
@@ -1,115 +0,0 @@
|
||||
import React, { useState } from 'react';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import { Menu, X, Terminal, Layers, Rss, Home, Github, BookOpenText, PlayCircle } from 'lucide-react';
|
||||
|
||||
export const Header: React.FC = () => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const navItems = [
|
||||
{ label: 'Home', path: '/', icon: Home },
|
||||
{ label: 'Skills', path: '/skills', icon: Layers },
|
||||
{ label: 'Security Feed', path: '/feed', icon: Rss },
|
||||
{ label: 'Product Demo', path: '/demo', icon: PlayCircle },
|
||||
{ label: 'Wiki', path: '/wiki', icon: BookOpenText },
|
||||
];
|
||||
|
||||
const baseLink =
|
||||
'flex items-center gap-3 px-3 py-2 rounded-lg text-sm font-medium transition-all';
|
||||
|
||||
const desktopNav = (
|
||||
<aside className="hidden md:flex w-64 flex-col border-r border-[#3a1f7a] bg-gradient-to-b from-[#26115d]/95 via-[#3a1f7a]/92 to-[#523899]/90 backdrop-blur-xl shadow-[20px_0_50px_rgba(0,0,0,0.35)] z-40 pt-[75px]">
|
||||
<nav className="overflow-y-auto px-4 pt-8 space-y-2">
|
||||
{navItems.map(({ label, path, icon: Icon }) => (
|
||||
<NavLink
|
||||
key={path}
|
||||
to={path}
|
||||
className={({ isActive }) =>
|
||||
`${baseLink} ${
|
||||
isActive
|
||||
? 'bg-white/10 text-white shadow-[0_10px_25px_rgba(0,0,0,0.25)] border border-white/10'
|
||||
: 'text-gray-400 hover:text-white hover:bg-white/5'
|
||||
}`
|
||||
}
|
||||
>
|
||||
<Icon className="w-4 h-4" />
|
||||
{label}
|
||||
</NavLink>
|
||||
))}
|
||||
|
||||
<a
|
||||
href="https://github.com/prompt-security/clawsec"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="mt-6 w-full inline-flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-clawd-accent text-[#27125d] font-semibold shadow-[0_12px_30px_rgba(255,162,63,0.35)] hover:bg-clawd-accentHover transition-colors"
|
||||
>
|
||||
<Terminal size={16} />
|
||||
GitHub
|
||||
</a>
|
||||
</nav>
|
||||
</aside>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{desktopNav}
|
||||
|
||||
{/* Mobile top bar */}
|
||||
<header className="md:hidden fixed top-[72px] left-0 right-0 z-50 backdrop-blur-md bg-[#26115d]/92 border-b border-[#3a1f7a]">
|
||||
<div className="px-4 h-14 flex items-center justify-between">
|
||||
<NavLink to="/" className="flex items-center gap-2 text-white font-semibold text-lg">
|
||||
<img src="/img/favicon.ico" alt="" className="w-5 h-5 rounded-sm" />
|
||||
ClawSec
|
||||
</NavLink>
|
||||
<div className="flex items-center gap-3">
|
||||
<a
|
||||
href="https://github.com/prompt-security/clawsec"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-clawd-accent hover:text-clawd-accentHover transition-colors"
|
||||
aria-label="Open GitHub repository"
|
||||
>
|
||||
<Github size={21} />
|
||||
</a>
|
||||
<button
|
||||
className="text-gray-300 hover:text-white"
|
||||
onClick={() => setIsOpen(!isOpen)}
|
||||
aria-label="Toggle navigation"
|
||||
>
|
||||
{isOpen ? <X size={24} /> : <Menu size={24} />}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{isOpen && (
|
||||
<div className="bg-[#26115d]/95 border-t border-[#3a1f7a] shadow-lg">
|
||||
<div className="flex flex-col p-4 space-y-3">
|
||||
{navItems.map(({ label, path, icon: Icon }) => (
|
||||
<NavLink
|
||||
key={path}
|
||||
to={path}
|
||||
onClick={() => setIsOpen(false)}
|
||||
className={({ isActive }) =>
|
||||
`${baseLink} ${
|
||||
isActive ? 'bg-white/10 text-white' : 'text-gray-400 hover:text-white hover:bg-white/5'
|
||||
}`
|
||||
}
|
||||
>
|
||||
<Icon className="w-4 h-4" />
|
||||
{label}
|
||||
</NavLink>
|
||||
))}
|
||||
<a
|
||||
href="https://github.com/prompt-security/clawsec"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center justify-center gap-2 px-4 py-2 rounded-lg bg-clawd-accent text-[#27125d] font-semibold hover:bg-clawd-accentHover transition-colors"
|
||||
>
|
||||
<Terminal size={16} />
|
||||
GitHub
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Header } from './Header';
|
||||
import { LobsterBackground } from './LobsterBackground';
|
||||
|
||||
export const Layout: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
return (
|
||||
<div className="min-h-screen font-sans text-slate-50 relative overflow-x-hidden w-full max-w-full">
|
||||
<LobsterBackground />
|
||||
<div className="relative z-10 flex min-h-screen w-full max-w-full">
|
||||
<Header />
|
||||
<main className="flex-1 min-w-0 px-4 sm:px-6 lg:px-10 pt-24 pb-20 md:pt-16 md:pb-12 overflow-x-hidden">
|
||||
<div className="max-w-6xl mx-auto w-full">
|
||||
{children}
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,24 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
export const LobsterBackground: React.FC = () => {
|
||||
return (
|
||||
<div className="fixed inset-0 pointer-events-none z-0 overflow-hidden select-none">
|
||||
<div className="absolute inset-0 bg-gradient-to-r from-[#0d0720]/70 via-transparent to-transparent" />
|
||||
{/* Soft nebula glows */}
|
||||
<div className="absolute -top-20 -left-28 w-[38vw] h-[38vw] bg-[#8c6ae7] blur-[140px] opacity-35"></div>
|
||||
<div className="absolute top-[10%] right-[-10%] w-[42vw] h-[42vw] bg-[#523899] blur-[180px] opacity-30"></div>
|
||||
<div className="absolute bottom-[-12%] left-[15%] w-[48vw] h-[48vw] bg-[#26115d] blur-[200px] opacity-55"></div>
|
||||
<div className="absolute top-[40%] right-[20%] w-[35vw] h-[35vw] bg-[#3a1f7a] blur-[160px] opacity-28"></div>
|
||||
|
||||
{/* Angular motif inspired by Prompt "A" */}
|
||||
<div className="absolute right-[-5%] bottom-[10%] w-[59.8vw] h-[59.8vw] opacity-85">
|
||||
<img
|
||||
src="/img/prompt_line.svg"
|
||||
loading="lazy"
|
||||
alt=""
|
||||
className="w-full h-full object-contain"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,42 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { ArrowRight } from 'lucide-react';
|
||||
import type { SkillMetadata } from '../types';
|
||||
|
||||
interface SkillCardProps {
|
||||
skill: SkillMetadata;
|
||||
}
|
||||
|
||||
export const SkillCard: React.FC<SkillCardProps> = ({ skill }) => {
|
||||
return (
|
||||
<Link
|
||||
to={`/skills/${skill.id}`}
|
||||
className="group block bg-clawd-800 border border-clawd-700 rounded-xl p-5 hover:border-clawd-accent/30 hover:bg-clawd-800/80 transition-all duration-200"
|
||||
>
|
||||
<div className="flex items-center gap-3 mb-3">
|
||||
<span className="text-2xl">{skill.emoji || '📦'}</span>
|
||||
<div>
|
||||
<h3 className="font-bold text-white group-hover:text-clawd-accent transition-colors">
|
||||
{skill.name}
|
||||
</h3>
|
||||
<span className="text-xs text-gray-500 font-mono">v{skill.version}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className="text-sm text-gray-400 mb-4 line-clamp-2">
|
||||
{skill.description}
|
||||
</p>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
{/* Category badge - hidden for now, uncomment when we have multiple categories
|
||||
<span className="text-xs text-gray-500 bg-clawd-700 px-2 py-1 rounded">
|
||||
{skill.category || 'utility'}
|
||||
</span>
|
||||
*/}
|
||||
<span className="text-clawd-accent text-sm flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-auto">
|
||||
View details <ArrowRight size={14} />
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
// Canonical hosted feed endpoint for fetching live advisories
|
||||
export const ADVISORY_FEED_URL = 'https://clawsec.prompt.security/advisories/feed.json';
|
||||
|
||||
// Compatibility mirror for legacy clients; keep as last-resort fallback only
|
||||
export const LEGACY_ADVISORY_FEED_URL = 'https://clawsec.prompt.security/releases/latest/download/feed.json';
|
||||
|
||||
// Local feed path for development
|
||||
export const LOCAL_FEED_PATH = '/advisories/feed.json';
|
||||
@@ -1,119 +0,0 @@
|
||||
// NOTE: @eslint/js is pinned to ~9.x because v10 introduces a peerOptional
|
||||
// dependency on eslint@^10, and the typescript-eslint / react plugin ecosystem
|
||||
// hasn't published eslint-10-compatible releases yet. Upgrade @eslint/js to ^10
|
||||
// once @typescript-eslint and eslint-plugin-react declare eslint@^10 support.
|
||||
import js from '@eslint/js';
|
||||
import typescript from '@typescript-eslint/eslint-plugin';
|
||||
import typescriptParser from '@typescript-eslint/parser';
|
||||
import react from 'eslint-plugin-react';
|
||||
import reactHooks from 'eslint-plugin-react-hooks';
|
||||
|
||||
export default [
|
||||
js.configs.recommended,
|
||||
// TypeScript/React files
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
languageOptions: {
|
||||
parser: typescriptParser,
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
ecmaFeatures: { jsx: true }
|
||||
},
|
||||
globals: {
|
||||
// Browser globals
|
||||
console: 'readonly',
|
||||
window: 'readonly',
|
||||
document: 'readonly',
|
||||
navigator: 'readonly',
|
||||
fetch: 'readonly',
|
||||
setTimeout: 'readonly',
|
||||
clearTimeout: 'readonly',
|
||||
clearInterval: 'readonly',
|
||||
setInterval: 'readonly',
|
||||
URL: 'readonly',
|
||||
Response: 'readonly',
|
||||
HTMLElement: 'readonly',
|
||||
MouseEvent: 'readonly',
|
||||
KeyboardEvent: 'readonly',
|
||||
// Node.js globals (for Vite config, build scripts, and skill modules)
|
||||
process: 'readonly',
|
||||
__dirname: 'readonly',
|
||||
__filename: 'readonly',
|
||||
Buffer: 'readonly',
|
||||
AbortController: 'readonly',
|
||||
RequestInit: 'readonly'
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
'@typescript-eslint': typescript,
|
||||
'react': react,
|
||||
'react-hooks': reactHooks
|
||||
},
|
||||
rules: {
|
||||
...typescript.configs.recommended.rules,
|
||||
...react.configs.recommended.rules,
|
||||
...reactHooks.configs.recommended.rules,
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/prop-types': 'off',
|
||||
'react/no-unescaped-entities': 'off',
|
||||
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'warn'
|
||||
},
|
||||
settings: {
|
||||
react: { version: 'detect' }
|
||||
}
|
||||
},
|
||||
// Node.js scripts (.mjs files)
|
||||
{
|
||||
files: ['**/*.mjs'],
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
globals: {
|
||||
console: 'readonly',
|
||||
process: 'readonly',
|
||||
__dirname: 'readonly',
|
||||
__filename: 'readonly',
|
||||
Buffer: 'readonly',
|
||||
setTimeout: 'readonly',
|
||||
setInterval: 'readonly',
|
||||
clearTimeout: 'readonly',
|
||||
clearInterval: 'readonly',
|
||||
URL: 'readonly'
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
'no-empty': ['error', { allowEmptyCatch: true }],
|
||||
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }]
|
||||
}
|
||||
},
|
||||
// Node.js scripts (.js files in scripts directory)
|
||||
{
|
||||
files: ['scripts/**/*.js'],
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
globals: {
|
||||
console: 'readonly',
|
||||
process: 'readonly',
|
||||
__dirname: 'readonly',
|
||||
__filename: 'readonly',
|
||||
Buffer: 'readonly',
|
||||
setTimeout: 'readonly',
|
||||
setInterval: 'readonly',
|
||||
clearTimeout: 'readonly',
|
||||
clearInterval: 'readonly',
|
||||
URL: 'readonly'
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
'no-empty': ['error', { allowEmptyCatch: true }],
|
||||
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }]
|
||||
}
|
||||
},
|
||||
{
|
||||
ignores: ['dist/', 'node_modules/', '*.config.js', 'public/', '.venv/']
|
||||
}
|
||||
];
|
||||
@@ -1,7 +0,0 @@
|
||||
# Fonts
|
||||
|
||||
This repository includes the **Prometo** font files in `font/`.
|
||||
|
||||
These font binaries are **not covered by the repository AGPL license**. They are used under the applicable **Adobe Fonts / Dalton Maag** licensing terms for Prompt Security / SentinelOne. Do not redistribute or reuse them outside the terms of that license.
|
||||
|
||||
If you are forking or redistributing this project and you do not have the appropriate rights, remove `font/Prometo_Trial_*.ttf` and update the CSS/font stack accordingly.
|
||||
|
Before Width: | Height: | Size: 33 KiB |
@@ -1,5 +0,0 @@
|
||||
<svg width="27" height="24" viewBox="0 0 27 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M26.4003 16.1166L17.8167 1.24932C17.3704 0.476223 16.5456 0 15.6528 0H11.1343C12.0206 0 12.8397 0.472788 13.2828 1.24041L13.7849 2.10991L15.67 5.37457L20.8597 14.364C21.2728 15.0795 20.7564 15.9739 19.9302 15.9739L9.55076 15.9738L8.20302 18.3079C7.78979 19.0235 8.30627 19.918 9.13249 19.918H24.2054C25.0135 19.918 25.7707 19.5237 26.234 18.8617L26.3695 18.6682L26.4005 18.6144C26.8464 17.8416 26.8463 16.8894 26.4003 16.1166Z" fill="#B56FED"/>
|
||||
<path d="M15.67 5.37457L13.7849 2.10991L13.2828 1.24041C12.8397 0.472788 12.0206 0 11.1343 0C10.248 0 9.42894 0.472758 8.98577 1.24027L0.334762 16.2241C-0.111408 16.9968 -0.111623 17.9491 0.334333 18.7221L2.58966 22.629C2.14896 21.8659 2.14885 20.9256 2.58966 20.1623L10.0593 7.22478C10.5401 6.3919 11.7423 6.3919 12.2232 7.22478L13.4124 9.28488L17.2753 15.9738L19.9302 15.9739C20.7564 15.9739 21.2728 15.0795 20.8597 14.364L15.67 5.37457Z" fill="#E4C7FD"/>
|
||||
<path d="M26.3695 18.6682C25.9232 19.4413 25.0981 19.918 24.2054 19.918H9.13249C8.30627 19.918 7.78979 19.0235 8.20302 18.3079L9.55076 15.9738L13.4124 9.28488L12.2232 7.22478C11.7423 6.3919 10.5401 6.3919 10.0593 7.22478L2.58966 20.1623C2.14885 20.9256 2.14896 21.8659 2.58966 22.629C3.03025 23.3919 3.84434 23.8619 4.72531 23.8619H21.9282C22.8208 23.8619 23.6456 23.3857 24.0919 22.6127L25.6481 19.9178L26.3695 18.6682Z" fill="#4D1080"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -1,151 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<!-- BOT INSTRUCTIONS (plain text for curl/head) -->
|
||||
<!--
|
||||
ClawSec
|
||||
Security skill suite for AI agents (integrity checks, drift detection, advisory feed).
|
||||
Agent install:
|
||||
Available via clawhub: npx clawhub@latest install clawsec-suite
|
||||
OR
|
||||
curl -sL https://clawsec.prompt.security/releases/latest/download/SKILL.md
|
||||
-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
|
||||
<title>ClawSec | Agent Hardening | Prompt Security, SentinelOne </title>
|
||||
<link rel="icon" type="image/x-icon" href="/img/favicon.ico" />
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: 'Prometo';
|
||||
src: url('/font/Prometo_Trial_Rg.ttf') format('truetype');
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Prometo';
|
||||
src: url('/font/Prometo_Trial_Md.ttf') format('truetype');
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Prometo';
|
||||
src: url('/font/Prometo_Trial_Bd.ttf') format('truetype');
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Prometo';
|
||||
src: url('/font/Prometo_Trial_XBd.ttf') format('truetype');
|
||||
font-weight: 800;
|
||||
font-style: normal;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
sans: ['Prometo', 'system-ui', 'sans-serif'],
|
||||
display: ['Prometo', 'system-ui', 'sans-serif'],
|
||||
mono: ['Prometo', 'system-ui', 'sans-serif'],
|
||||
},
|
||||
colors: {
|
||||
clawd: {
|
||||
900: '#26115d', // Deep base
|
||||
800: '#3a1f7a', // Mid base
|
||||
700: '#523899', // Lifted mid
|
||||
600: '#8c6ae7', // Light highlight
|
||||
accent: '#ffa23f', // Prompt orange (target)
|
||||
accentHover: '#e89232',
|
||||
secondary: '#c7b6ff', // Soft lavender
|
||||
}
|
||||
},
|
||||
animation: {
|
||||
'float': 'float 6s ease-in-out infinite',
|
||||
'float-delayed': 'float 6s ease-in-out 3s infinite',
|
||||
'pulse-slow': 'pulse 4s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
||||
},
|
||||
keyframes: {
|
||||
float: {
|
||||
'0%, 100%': { transform: 'translateY(0)' },
|
||||
'50%': { transform: 'translateY(-20px)' },
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
background:
|
||||
linear-gradient(90deg, rgba(12, 6, 24, 0.55) 0%, rgba(12, 6, 24, 0.0) 45%),
|
||||
radial-gradient(circle at 10% 18%, rgba(255, 162, 63, 0.06), transparent 28%),
|
||||
radial-gradient(circle at 82% 18%, rgba(140, 106, 231, 0.20), transparent 30%),
|
||||
radial-gradient(circle at 55% 78%, rgba(82, 56, 153, 0.22), transparent 34%),
|
||||
linear-gradient(180deg, #26115d 0%, #523899 52%, #8c6ae7 100%);
|
||||
color: #f4f0ff;
|
||||
}
|
||||
/* Custom Scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
background: #14103b;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #2f2261;
|
||||
border-radius: 6px;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #f9b347;
|
||||
}
|
||||
/* Mobile overflow fixes */
|
||||
html, body {
|
||||
overflow-x: hidden;
|
||||
width: 100%;
|
||||
max-width: 100vw;
|
||||
}
|
||||
#root {
|
||||
overflow-x: hidden;
|
||||
width: 100%;
|
||||
max-width: 100vw;
|
||||
}
|
||||
/* Ensure code blocks wrap properly */
|
||||
code, pre {
|
||||
word-break: break-word;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
/* Fix for tables on mobile */
|
||||
table {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
</style>
|
||||
<script type="importmap">
|
||||
{
|
||||
"imports": {
|
||||
"react-dom/": "https://esm.sh/react-dom@^19.2.4/",
|
||||
"react/": "https://esm.sh/react@^19.2.4/",
|
||||
"react": "https://esm.sh/react@^19.2.4",
|
||||
"lucide-react": "https://esm.sh/lucide-react@^0.563.0",
|
||||
"react-router-dom": "https://esm.sh/react-router-dom@^7.13.0"
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
ClawSec
|
||||
Security skill suite for AI agents (integrity checks, drift detection, advisory feed).
|
||||
Agent install:
|
||||
Available via clawhub: npx clawhub@latest install clawsec-suite
|
||||
OR
|
||||
curl -sL https://clawsec.prompt.security/releases/latest/download/SKILL.md
|
||||
</noscript>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,15 +0,0 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import App from './App';
|
||||
|
||||
const rootElement = document.getElementById('root');
|
||||
if (!rootElement) {
|
||||
throw new Error("Could not find root element to mount to");
|
||||
}
|
||||
|
||||
const root = ReactDOM.createRoot(rootElement);
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"name": "ClawSec",
|
||||
"description": "A security-first skill distribution platform for OpenClaw and NanoClaw agents, featuring verified audit skills, hardening feeds, and guardian mode protocols."
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
{
|
||||
"name": "ClawSec",
|
||||
"private": true,
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"gen:wiki-llms": "node scripts/generate-wiki-llms.mjs",
|
||||
"populate-local-wiki": "./scripts/populate-local-wiki.sh",
|
||||
"predev": "npm run gen:wiki-llms",
|
||||
"dev": "vite",
|
||||
"prebuild": "npm run gen:wiki-llms",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"lucide-react": "^0.575.0",
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.4",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-router-dom": "^7.13.1",
|
||||
"remark-gfm": "^4.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "~9.39.4",
|
||||
"@types/node": "^25.4.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.55.0",
|
||||
"@typescript-eslint/parser": "^8.58.1",
|
||||
"@vitejs/plugin-react": "^5.1.4",
|
||||
"eslint": "^9.39.4",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"fast-check": "^4.5.3",
|
||||
"typescript": "~5.9.3",
|
||||
"vite": "^7.3.2"
|
||||
},
|
||||
"overrides": {
|
||||
"ajv": "6.14.0",
|
||||
"balanced-match": "4.0.3",
|
||||
"brace-expansion": "5.0.5",
|
||||
"minimatch": "10.2.4",
|
||||
"picomatch": "4.0.4"
|
||||
}
|
||||
}
|
||||
@@ -1,292 +0,0 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useParams, Link } from 'react-router-dom';
|
||||
import { ArrowLeft, ExternalLink, Shield, AlertTriangle, Github, User, Bot } from 'lucide-react';
|
||||
import { Footer } from '../components/Footer';
|
||||
import { Advisory, AdvisoryFeed } from '../types';
|
||||
import {
|
||||
ADVISORY_FEED_URL,
|
||||
LEGACY_ADVISORY_FEED_URL,
|
||||
LOCAL_FEED_PATH,
|
||||
} from '../constants';
|
||||
|
||||
export const AdvisoryDetail: React.FC = () => {
|
||||
const { advisoryId } = useParams<{ advisoryId: string }>();
|
||||
const [advisory, setAdvisory] = useState<Advisory | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchAdvisory = async () => {
|
||||
if (!advisoryId) return;
|
||||
|
||||
try {
|
||||
// Try local feed first (dev), then canonical hosted endpoint, then legacy mirror.
|
||||
let response = await fetch(LOCAL_FEED_PATH);
|
||||
|
||||
if (!response.ok) {
|
||||
response = await fetch(ADVISORY_FEED_URL);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
response = await fetch(LEGACY_ADVISORY_FEED_URL);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch feed: ${response.status}`);
|
||||
}
|
||||
|
||||
const feed: AdvisoryFeed = await response.json();
|
||||
const found = feed.advisories.find((a) => a.id === decodeURIComponent(advisoryId));
|
||||
|
||||
if (!found) {
|
||||
throw new Error('Advisory not found');
|
||||
}
|
||||
|
||||
setAdvisory(found);
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch advisory:', err);
|
||||
setError(err instanceof Error ? err.message : 'Failed to load advisory');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchAdvisory();
|
||||
}, [advisoryId]);
|
||||
|
||||
const formatDate = (dateStr: string) => {
|
||||
try {
|
||||
return new Date(dateStr).toLocaleDateString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
} catch {
|
||||
return dateStr;
|
||||
}
|
||||
};
|
||||
|
||||
const getSeverityClasses = (severity: string) => {
|
||||
switch (severity) {
|
||||
case 'critical':
|
||||
return 'bg-red-500/20 text-red-400 border-red-500/30';
|
||||
case 'high':
|
||||
return 'bg-orange-500/20 text-orange-400 border-orange-500/30';
|
||||
case 'medium':
|
||||
return 'bg-yellow-500/20 text-yellow-400 border-yellow-500/30';
|
||||
default:
|
||||
return 'bg-blue-500/20 text-blue-400 border-blue-500/30';
|
||||
}
|
||||
};
|
||||
|
||||
const getTypeLabel = (type: string) => {
|
||||
switch (type) {
|
||||
case 'malicious_skill':
|
||||
return 'Malicious Skill';
|
||||
case 'vulnerable_skill':
|
||||
return 'Vulnerable Skill';
|
||||
case 'prompt_injection':
|
||||
return 'Prompt Injection';
|
||||
case 'attack_pattern':
|
||||
return 'Attack Pattern';
|
||||
case 'best_practice':
|
||||
return 'Best Practice';
|
||||
case 'tampering_attempt':
|
||||
return 'Tampering Attempt';
|
||||
default:
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
// Determine source - defaults to "Prompt Security Staff" when absent
|
||||
const getSource = (adv: Advisory) => {
|
||||
return adv.source || 'Prompt Security Staff';
|
||||
};
|
||||
|
||||
// Determine if this is a community report
|
||||
const isCommunityReport = advisory?.github_issue_url;
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="py-16 text-center">
|
||||
<div className="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-clawd-accent"></div>
|
||||
<p className="mt-4 text-gray-400">Loading advisory...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (error || !advisory) {
|
||||
return (
|
||||
<div className="py-16 text-center">
|
||||
<Shield className="w-16 h-16 mx-auto text-gray-600 mb-4" />
|
||||
<h2 className="text-xl font-bold text-white mb-2">Advisory Not Found</h2>
|
||||
<p className="text-gray-400 mb-4">{error || 'This advisory does not exist'}</p>
|
||||
<Link to="/feed" className="text-clawd-accent hover:underline">
|
||||
Back to Security Feed
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto pt-8 space-y-8">
|
||||
{/* Back Link */}
|
||||
<Link
|
||||
to="/feed"
|
||||
className="inline-flex items-center gap-2 text-gray-400 hover:text-white transition-colors"
|
||||
>
|
||||
<ArrowLeft size={20} />
|
||||
Back to Security Feed
|
||||
</Link>
|
||||
|
||||
{/* Header */}
|
||||
<section className="space-y-4">
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<span className={`text-sm font-bold px-3 py-1.5 rounded uppercase border ${getSeverityClasses(advisory.severity)}`}>
|
||||
{advisory.severity}
|
||||
{advisory.cvss_score && <span className="ml-2 opacity-75">CVSS {advisory.cvss_score}</span>}
|
||||
</span>
|
||||
<span className="text-sm px-3 py-1.5 rounded bg-clawd-700 text-gray-300">
|
||||
{getTypeLabel(advisory.type)}
|
||||
</span>
|
||||
<span className="text-sm text-gray-500">
|
||||
Published {formatDate(advisory.published)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h1 className="text-3xl font-bold text-white">{advisory.id}</h1>
|
||||
<p className="text-xl text-gray-300">{advisory.title}</p>
|
||||
</section>
|
||||
|
||||
{/* Description */}
|
||||
<section className="bg-clawd-800/50 border border-clawd-700 rounded-xl p-6">
|
||||
<h2 className="text-lg font-bold text-white mb-3 flex items-center gap-2">
|
||||
<AlertTriangle size={20} className="text-orange-400" />
|
||||
Description
|
||||
</h2>
|
||||
<p className="text-gray-300 leading-relaxed whitespace-pre-wrap">{advisory.description}</p>
|
||||
</section>
|
||||
|
||||
{/* Recommended Action */}
|
||||
<section className="bg-clawd-800/50 border border-clawd-700 rounded-xl p-6">
|
||||
<h2 className="text-lg font-bold text-white mb-3 flex items-center gap-2">
|
||||
<Shield size={20} className="text-green-400" />
|
||||
Recommended Action
|
||||
</h2>
|
||||
<p className="text-gray-300 leading-relaxed">{advisory.action}</p>
|
||||
</section>
|
||||
|
||||
{/* Affected Components */}
|
||||
{advisory.affected && advisory.affected.length > 0 && (
|
||||
<section className="bg-clawd-800/50 border border-clawd-700 rounded-xl p-6">
|
||||
<h2 className="text-lg font-bold text-white mb-3">Affected Components</h2>
|
||||
<ul className="list-disc list-inside space-y-1">
|
||||
{advisory.affected.map((item, index) => (
|
||||
<li key={index} className="text-gray-300">{item}</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* References */}
|
||||
{advisory.references && advisory.references.length > 0 && (
|
||||
<section className="bg-clawd-800/50 border border-clawd-700 rounded-xl p-6">
|
||||
<h2 className="text-lg font-bold text-white mb-3">References</h2>
|
||||
<ul className="space-y-2">
|
||||
{advisory.references.map((ref, index) => (
|
||||
<li key={index}>
|
||||
<a
|
||||
href={ref}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-clawd-accent hover:underline text-sm flex items-center gap-1 break-all"
|
||||
>
|
||||
<ExternalLink size={14} className="flex-shrink-0" />
|
||||
{ref}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* External Link - NVD or GitHub Issue */}
|
||||
<section className="flex flex-wrap gap-4">
|
||||
{isCommunityReport && advisory.github_issue_url ? (
|
||||
<a
|
||||
href={advisory.github_issue_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-2 px-5 py-2.5 rounded-lg bg-clawd-700 hover:bg-clawd-600 text-white font-medium transition-colors"
|
||||
>
|
||||
<Github size={18} />
|
||||
View GitHub Report
|
||||
</a>
|
||||
) : advisory.nvd_url ? (
|
||||
<a
|
||||
href={advisory.nvd_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-2 px-5 py-2.5 rounded-lg bg-clawd-700 hover:bg-clawd-600 text-white font-medium transition-colors"
|
||||
>
|
||||
<ExternalLink size={18} />
|
||||
View on NVD
|
||||
</a>
|
||||
) : null}
|
||||
</section>
|
||||
|
||||
{/* Metadata */}
|
||||
<section className="bg-clawd-800/50 border border-clawd-700 rounded-xl p-6">
|
||||
<h3 className="font-bold text-white mb-4">Metadata</h3>
|
||||
<dl className="grid md:grid-cols-2 gap-4 text-sm">
|
||||
<div className="flex justify-between md:block">
|
||||
<dt className="text-gray-500 mb-1">Source</dt>
|
||||
<dd className="text-white">{getSource(advisory)}</dd>
|
||||
</div>
|
||||
{advisory.cvss_score && (
|
||||
<div className="flex justify-between md:block">
|
||||
<dt className="text-gray-500 mb-1">CVSS Score</dt>
|
||||
<dd className="text-white">{advisory.cvss_score}</dd>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex justify-between md:block">
|
||||
<dt className="text-gray-500 mb-1">Type</dt>
|
||||
<dd className="text-white">{getTypeLabel(advisory.type)}</dd>
|
||||
</div>
|
||||
<div className="flex justify-between md:block">
|
||||
<dt className="text-gray-500 mb-1">Published</dt>
|
||||
<dd className="text-white">{formatDate(advisory.published)}</dd>
|
||||
</div>
|
||||
{/* Reporter info - subtle display for community reports */}
|
||||
{advisory.reporter && (
|
||||
<>
|
||||
{advisory.reporter.agent_name && (
|
||||
<div className="flex justify-between md:block">
|
||||
<dt className="text-gray-500 mb-1">Reported By</dt>
|
||||
<dd className="text-white flex items-center gap-1">
|
||||
{advisory.reporter.opener_type === 'agent' ? (
|
||||
<Bot size={14} className="text-clawd-accent" />
|
||||
) : (
|
||||
<User size={14} className="text-clawd-accent" />
|
||||
)}
|
||||
{advisory.reporter.agent_name}
|
||||
</dd>
|
||||
</div>
|
||||
)}
|
||||
{advisory.reporter.opener_type && (
|
||||
<div className="flex justify-between md:block">
|
||||
<dt className="text-gray-500 mb-1">Reporter Type</dt>
|
||||
<dd className="text-white capitalize">{advisory.reporter.opener_type}</dd>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,206 +0,0 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Shield, Copy, Download, CheckCircle2 } from 'lucide-react';
|
||||
import { CodeBlock } from '../components/CodeBlock';
|
||||
|
||||
interface FileChecksum {
|
||||
sha256: string;
|
||||
size: number;
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface ChecksumsData {
|
||||
version: string;
|
||||
generated_at: string;
|
||||
repository: string;
|
||||
files: Record<string, FileChecksum>;
|
||||
}
|
||||
|
||||
export default function Checksums() {
|
||||
const [checksums, setChecksums] = useState<ChecksumsData | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [copied, setCopied] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetch('./checksums.json')
|
||||
.then(res => {
|
||||
if (!res.ok) throw new Error('Not found');
|
||||
return res.json();
|
||||
})
|
||||
.then(data => {
|
||||
setChecksums(data);
|
||||
setLoading(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setLoading(false);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const copyToClipboard = (text: string, id: string) => {
|
||||
navigator.clipboard.writeText(text);
|
||||
setCopied(id);
|
||||
setTimeout(() => setCopied(null), 2000);
|
||||
};
|
||||
|
||||
const fileDescriptions: Record<string, string> = {
|
||||
'SKILL.md': 'Main ClawSec skill documentation',
|
||||
'heartbeat.md': 'Heartbeat monitoring and update instructions',
|
||||
'reporting.md': 'Security incident reporting guidelines',
|
||||
'skill.json': 'Skill metadata and configuration',
|
||||
'feed.json': 'Community security advisory feed'
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="max-w-5xl mx-auto">
|
||||
{/* Header */}
|
||||
<div className="mb-12 text-center">
|
||||
<div className="flex items-center justify-center gap-3 mb-4">
|
||||
<Shield className="w-12 h-12 text-clawd-accent" />
|
||||
<h1 className="text-4xl font-bold">File Checksums</h1>
|
||||
</div>
|
||||
<p className="text-xl text-gray-300">
|
||||
Verify the integrity of ClawSec files before use
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{loading ? (
|
||||
<div className="text-center py-12">
|
||||
<div className="inline-block animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-clawd-accent"></div>
|
||||
<p className="mt-4 text-gray-400">Loading checksums...</p>
|
||||
</div>
|
||||
) : checksums ? (
|
||||
<>
|
||||
{/* Version Info */}
|
||||
<div className="bg-clawd-800 rounded-lg p-6 mb-8">
|
||||
<div className="grid md:grid-cols-3 gap-4 text-sm">
|
||||
<div>
|
||||
<div className="text-gray-400 mb-1">Version</div>
|
||||
<div className="font-mono text-clawd-accent">{checksums.version}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-gray-400 mb-1">Generated</div>
|
||||
<div className="font-mono">{new Date(checksums.generated_at).toLocaleString()}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="text-gray-400 mb-1">Repository</div>
|
||||
<div className="font-mono text-sm">{checksums.repository}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Files Table */}
|
||||
<div className="bg-clawd-800 rounded-lg overflow-hidden mb-8">
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full">
|
||||
<thead className="bg-clawd-900">
|
||||
<tr>
|
||||
<th className="px-6 py-4 text-left text-sm font-semibold">File</th>
|
||||
<th className="px-6 py-4 text-left text-sm font-semibold">Size</th>
|
||||
<th className="px-6 py-4 text-left text-sm font-semibold">SHA256 Checksum</th>
|
||||
<th className="px-6 py-4 text-right text-sm font-semibold">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-clawd-700">
|
||||
{(Object.entries(checksums.files) as [string, FileChecksum][]).map(([filename, data]) => (
|
||||
<tr key={filename} className="hover:bg-clawd-700/50 transition-colors">
|
||||
<td className="px-6 py-4">
|
||||
<div className="font-mono text-sm text-clawd-accent">{filename}</div>
|
||||
<div className="text-xs text-gray-400 mt-1">
|
||||
{fileDescriptions[filename] || 'ClawSec file'}
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-6 py-4">
|
||||
<div className="text-sm">{(data.size / 1024).toFixed(1)} KB</div>
|
||||
</td>
|
||||
<td className="px-6 py-4">
|
||||
<div className="font-mono text-xs break-all max-w-md">
|
||||
{data.sha256}
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-6 py-4">
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
<button
|
||||
onClick={() => copyToClipboard(data.sha256, filename)}
|
||||
className="p-2 hover:bg-clawd-900 rounded transition-colors"
|
||||
title="Copy checksum"
|
||||
>
|
||||
{copied === filename ? (
|
||||
<CheckCircle2 className="w-4 h-4 text-green-400" />
|
||||
) : (
|
||||
<Copy className="w-4 h-4" />
|
||||
)}
|
||||
</button>
|
||||
<a
|
||||
href={data.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="p-2 hover:bg-clawd-900 rounded transition-colors"
|
||||
title="Download file"
|
||||
>
|
||||
<Download className="w-4 h-4" />
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Verification Instructions */}
|
||||
<div className="bg-clawd-800 rounded-lg p-6">
|
||||
<h2 className="text-2xl font-bold mb-4 flex items-center gap-2">
|
||||
<Shield className="w-6 h-6 text-clawd-accent" />
|
||||
Verification Instructions
|
||||
</h2>
|
||||
|
||||
<p className="text-gray-300 mb-4">
|
||||
Always verify file integrity before using ClawSec files. Here's how:
|
||||
</p>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<h3 className="font-semibold mb-2">1. Download a file</h3>
|
||||
<CodeBlock
|
||||
code={`curl -sL https://github.com/${checksums.repository}/releases/download/${checksums.version}/SKILL.md -o SKILL.md`}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="font-semibold mb-2">2. Generate its checksum</h3>
|
||||
<CodeBlock code="sha256sum SKILL.md" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="font-semibold mb-2">3. Compare with the checksum above</h3>
|
||||
<p className="text-sm text-gray-400">
|
||||
The output should exactly match the SHA256 value shown in the table.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="mt-6 p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg">
|
||||
<p className="text-yellow-200 text-sm">
|
||||
<strong>Security Warning:</strong> Never use files with mismatched checksums.
|
||||
This could indicate tampering or a compromised download.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="bg-clawd-800 rounded-lg p-12 text-center">
|
||||
<Shield className="w-16 h-16 text-gray-600 mx-auto mb-4" />
|
||||
<p className="text-gray-400">
|
||||
Checksums not available. Create a release to generate checksums.
|
||||
</p>
|
||||
<CodeBlock
|
||||
code={`# Create a release to generate checksums:\ngit tag v1.0.0 && git push origin v1.0.0`}
|
||||
className="mt-4 text-left"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,288 +0,0 @@
|
||||
import React, { useState, useEffect, useMemo } from 'react';
|
||||
import { Rss, RefreshCw, Loader2, AlertTriangle, ChevronLeft, ChevronRight, Download, Users, AlertCircle } from 'lucide-react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Footer } from '../components/Footer';
|
||||
import { AdvisoryCard } from '../components/AdvisoryCard';
|
||||
import { Advisory, AdvisoryFeed } from '../types';
|
||||
import {
|
||||
ADVISORY_FEED_URL,
|
||||
LEGACY_ADVISORY_FEED_URL,
|
||||
LOCAL_FEED_PATH,
|
||||
} from '../constants';
|
||||
|
||||
const ITEMS_PER_PAGE = 9;
|
||||
|
||||
const SEVERITY_TABS = [
|
||||
{ value: 'all', label: 'All', active: 'bg-clawd-accent text-white', inactive: 'bg-clawd-800 text-gray-400 border border-clawd-700 hover:border-clawd-accent/50' },
|
||||
{ value: 'critical', label: 'Critical', active: 'bg-red-500/20 text-red-400 border-2 border-red-400', inactive: 'bg-clawd-800 text-gray-400 border border-clawd-700 hover:border-red-400/50' },
|
||||
{ value: 'high', label: 'High', active: 'bg-orange-500/20 text-orange-400 border-2 border-orange-400', inactive: 'bg-clawd-800 text-gray-400 border border-clawd-700 hover:border-orange-400/50' },
|
||||
{ value: 'medium', label: 'Medium', active: 'bg-yellow-500/20 text-yellow-400 border-2 border-yellow-400', inactive: 'bg-clawd-800 text-gray-400 border border-clawd-700 hover:border-yellow-400/50' },
|
||||
{ value: 'low', label: 'Low', active: 'bg-blue-500/20 text-blue-400 border-2 border-blue-400', inactive: 'bg-clawd-800 text-gray-400 border border-clawd-700 hover:border-blue-400/50' },
|
||||
] as const;
|
||||
|
||||
const PLATFORM_TABS = [
|
||||
{ value: 'all', label: 'All Platforms', active: 'bg-clawd-accent text-white', inactive: 'bg-clawd-800 text-gray-400 border border-clawd-700 hover:border-clawd-accent/50' },
|
||||
{ value: 'openclaw', label: 'OpenClaw', active: 'bg-clawd-accent/20 text-clawd-accent border-2 border-clawd-accent', inactive: 'bg-clawd-800 text-gray-400 border border-clawd-700 hover:border-clawd-accent/50' },
|
||||
{ value: 'nanoclaw', label: 'NanoClaw', active: 'bg-clawd-secondary/20 text-clawd-secondary border-2 border-clawd-secondary', inactive: 'bg-clawd-800 text-gray-400 border border-clawd-700 hover:border-clawd-secondary/50' },
|
||||
] as const;
|
||||
|
||||
const FilterTabs: React.FC<{
|
||||
tabs: ReadonlyArray<{ value: string; label: string; active: string; inactive: string }>;
|
||||
selected: string;
|
||||
onSelect: (value: string) => void;
|
||||
}> = ({ tabs, selected, onSelect }) => (
|
||||
<div className="flex flex-wrap justify-center gap-3 mb-8">
|
||||
{tabs.map(({ value, label, active, inactive }) => (
|
||||
<button
|
||||
key={value}
|
||||
onClick={() => onSelect(value)}
|
||||
className={`px-4 py-2 rounded-lg text-sm font-semibold transition-all ${
|
||||
selected === value ? active : inactive
|
||||
}`}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
export const FeedSetup: React.FC = () => {
|
||||
const [advisories, setAdvisories] = useState<Advisory[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [lastUpdated, setLastUpdated] = useState<string | null>(null);
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [selectedSeverity, setSelectedSeverity] = useState<string>('all');
|
||||
const [selectedPlatform, setSelectedPlatform] = useState<string>('all');
|
||||
|
||||
useEffect(() => {
|
||||
const fetchAdvisories = async () => {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
// Try local feed first (dev), then canonical hosted endpoint, then legacy mirror.
|
||||
let response = await fetch(LOCAL_FEED_PATH);
|
||||
|
||||
if (!response.ok) {
|
||||
response = await fetch(ADVISORY_FEED_URL);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
response = await fetch(LEGACY_ADVISORY_FEED_URL);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch feed: ${response.status}`);
|
||||
}
|
||||
|
||||
const feed: AdvisoryFeed = await response.json();
|
||||
setAdvisories(feed.advisories || []);
|
||||
setLastUpdated(feed.updated);
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch advisories:', err);
|
||||
setError('Unable to load security advisories. The feed may be temporarily unavailable.');
|
||||
setAdvisories([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchAdvisories();
|
||||
}, []);
|
||||
|
||||
const filteredAdvisories = useMemo(
|
||||
() => advisories.filter((a) =>
|
||||
(selectedSeverity === 'all' || a.severity === selectedSeverity) &&
|
||||
(selectedPlatform === 'all' || !a.platforms?.length || a.platforms.includes(selectedPlatform))
|
||||
),
|
||||
[advisories, selectedSeverity, selectedPlatform],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentPage(1);
|
||||
}, [advisories, selectedSeverity, selectedPlatform]);
|
||||
|
||||
const formatDate = (dateStr: string) => {
|
||||
try {
|
||||
return new Date(dateStr).toLocaleDateString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric'
|
||||
});
|
||||
} catch {
|
||||
return dateStr;
|
||||
}
|
||||
};
|
||||
|
||||
// Pagination calculations
|
||||
const totalPages = Math.ceil(filteredAdvisories.length / ITEMS_PER_PAGE);
|
||||
const startIndex = (currentPage - 1) * ITEMS_PER_PAGE;
|
||||
const endIndex = startIndex + ITEMS_PER_PAGE;
|
||||
const currentAdvisories = filteredAdvisories.slice(startIndex, endIndex);
|
||||
|
||||
const goToPage = (page: number) => {
|
||||
setCurrentPage(Math.max(1, Math.min(page, totalPages)));
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="max-w-4xl mx-auto pt-[52px] space-y-12">
|
||||
<section className="text-center space-y-4">
|
||||
<h1 className="text-3xl md:text-4xl text-white">Security Hardening Feed</h1>
|
||||
<p className="text-gray-400 max-w-2xl mx-auto">
|
||||
A continuous stream of security advisories from NVD CVE data and staff-approved community reports.
|
||||
This feed is automatically updated with OpenClaw and NanoClaw-related vulnerabilities and verified security incidents.
|
||||
</p>
|
||||
{lastUpdated && (
|
||||
<p className="text-xs text-gray-500">
|
||||
Last updated: {formatDate(lastUpdated)}
|
||||
</p>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<FilterTabs tabs={SEVERITY_TABS} selected={selectedSeverity} onSelect={setSelectedSeverity} />
|
||||
<FilterTabs tabs={PLATFORM_TABS} selected={selectedPlatform} onSelect={setSelectedPlatform} />
|
||||
|
||||
{loading ? (
|
||||
<div className="flex items-center justify-center py-12">
|
||||
<Loader2 className="w-8 h-8 text-clawd-accent animate-spin" />
|
||||
<span className="ml-3 text-gray-400">Loading advisories...</span>
|
||||
</div>
|
||||
) : error ? (
|
||||
<div className="flex items-center justify-center py-12 text-center">
|
||||
<AlertTriangle className="w-6 h-6 text-orange-400 mr-2" />
|
||||
<span className="text-gray-400">{error}</span>
|
||||
</div>
|
||||
) : filteredAdvisories.length === 0 ? (
|
||||
<div className="text-center py-12">
|
||||
<p className="text-gray-400">
|
||||
{advisories.length === 0
|
||||
? 'No security advisories at this time. Check back later.'
|
||||
: 'No advisories found for the selected filters.'}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<div className="grid gap-6 md:grid-cols-2 xl:grid-cols-3">
|
||||
{currentAdvisories.map((item) => (
|
||||
<AdvisoryCard key={item.id} advisory={item} formatDate={formatDate} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Pagination Controls */}
|
||||
{totalPages > 1 && (
|
||||
<div className="flex items-center justify-center gap-4 mt-8">
|
||||
<button
|
||||
onClick={() => goToPage(currentPage - 1)}
|
||||
disabled={currentPage === 1}
|
||||
className="flex items-center gap-1 px-4 py-2 rounded-lg bg-clawd-800 border border-clawd-700 text-white hover:border-clawd-accent disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-clawd-700 transition-colors"
|
||||
>
|
||||
<ChevronLeft size={18} />
|
||||
Previous
|
||||
</button>
|
||||
<span className="text-gray-400 text-sm">
|
||||
Page {currentPage} of {totalPages}
|
||||
</span>
|
||||
<button
|
||||
onClick={() => goToPage(currentPage + 1)}
|
||||
disabled={currentPage === totalPages}
|
||||
className="flex items-center gap-1 px-4 py-2 rounded-lg bg-clawd-800 border border-clawd-700 text-white hover:border-clawd-accent disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-clawd-700 transition-colors"
|
||||
>
|
||||
Next
|
||||
<ChevronRight size={18} />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{filteredAdvisories.length > 0 && (
|
||||
<p className="text-center text-sm text-gray-500 mt-4">
|
||||
Showing {startIndex + 1}-{Math.min(endIndex, filteredAdvisories.length)} of {filteredAdvisories.length} advisories
|
||||
{(selectedSeverity !== 'all' || selectedPlatform !== 'all') && ` (${advisories.length} total)`}
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="bg-clawd-900 border border-clawd-700 rounded-xl overflow-hidden">
|
||||
<div className="bg-clawd-800 px-6 py-4 border-b border-clawd-700 flex items-center justify-between">
|
||||
<h2 className="font-bold text-white flex items-center gap-2">
|
||||
<Rss size={18} className="text-clawd-accent" />
|
||||
Agent Integration Instructions
|
||||
</h2>
|
||||
<span className="text-xs font-mono text-gray-500">SKILLS-BASED</span>
|
||||
</div>
|
||||
<div className="p-6 space-y-6">
|
||||
<p className="text-gray-300 text-sm">
|
||||
Activate following skills from the suite to participate.
|
||||
</p>
|
||||
|
||||
{/* clawsec-feed skill */}
|
||||
<Link
|
||||
to="/skills/clawsec-feed"
|
||||
className="flex items-start gap-4 p-4 rounded-lg bg-clawd-800/50 border border-clawd-700 hover:border-clawd-accent/50 transition-colors group"
|
||||
>
|
||||
<span className="text-2xl">📡</span>
|
||||
<div className="flex-1">
|
||||
<h4 className="text-white font-bold text-sm group-hover:text-clawd-accent transition-colors flex items-center gap-2">
|
||||
clawsec-feed
|
||||
<Download size={14} className="text-gray-500" />
|
||||
</h4>
|
||||
<p className="text-xs text-gray-400 mt-1">
|
||||
Subscribe your agent to receive security advisories via heartbeat. Automatically polls the feed and notifies you of critical and high severity threats.
|
||||
</p>
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
{/* clawtributor skill */}
|
||||
<Link
|
||||
to="/skills/clawtributor"
|
||||
className="flex items-start gap-4 p-4 rounded-lg bg-clawd-800/50 border border-clawd-700 hover:border-clawd-accent/50 transition-colors group"
|
||||
>
|
||||
<span className="text-2xl">🤝</span>
|
||||
<div className="flex-1">
|
||||
<h4 className="text-white font-bold text-sm group-hover:text-clawd-accent transition-colors flex items-center gap-2">
|
||||
clawtributor
|
||||
<Users size={14} className="text-gray-500" />
|
||||
</h4>
|
||||
<p className="text-xs text-gray-400 mt-1">
|
||||
Opt-in to community incident reporting. Your agent can automatically submit security reports when it detects malicious prompts or suspicious skill behavior.
|
||||
</p>
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
<div className="flex items-start gap-4 p-4 rounded-lg bg-blue-900/10 border border-blue-900/30">
|
||||
<RefreshCw className="text-blue-400 w-5 h-5 mt-1" />
|
||||
<div>
|
||||
<h4 className="text-blue-400 font-bold text-sm">Collective Security</h4>
|
||||
<p className="text-xs text-gray-400 mt-1">
|
||||
When agents share threat intelligence, the entire ecosystem becomes safer. Reports are reviewed by staff before publication to ensure quality and privacy.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="text-center pt-8 border-t border-clawd-700">
|
||||
<h3 className="text-white font-bold mb-4">Human looking to contribute</h3>
|
||||
<p className="text-gray-400 text-sm mb-6 max-w-xl mx-auto">
|
||||
Found a prompt injection vector or malicious skill? Help the community by submitting a security incident report via GitHub Issue.
|
||||
All submissions are reviewed by staff before publication to the advisory feed.
|
||||
</p>
|
||||
<a
|
||||
href="https://github.com/prompt-security/clawsec/issues/new?template=security_incident_report.md"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-2 px-5 py-2.5 rounded-lg bg-clawd-700 hover:bg-clawd-600 text-white font-medium transition-colors"
|
||||
>
|
||||
<AlertCircle size={18} />
|
||||
Submit Report
|
||||
</a>
|
||||
</section>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,296 +0,0 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { User, Bot, Copy, Check, Lock } from 'lucide-react';
|
||||
import { Footer } from '../components/Footer';
|
||||
|
||||
const FILE_NAMES = ['SOUL.md', 'AGENTS.md', 'USER.md', 'TOOLS.md', 'IDENTITY.md', 'HEARTBEAT.md', 'MEMORY.md'];
|
||||
const PLATFORM_NAMES = ['OpenClaw', 'NanoClaw'];
|
||||
const FILE_LOCK_REVEAL_DELAY_MS = 1600;
|
||||
|
||||
export const Home: React.FC = () => {
|
||||
const [isAgent, setIsAgent] = useState(true);
|
||||
const [copiedCurl, setCopiedCurl] = useState(false);
|
||||
const [copiedHuman, setCopiedHuman] = useState(false);
|
||||
const [currentFileIndex, setCurrentFileIndex] = useState(0);
|
||||
const [currentPlatformIndex, setCurrentPlatformIndex] = useState(0);
|
||||
|
||||
const curlCommand = `npx clawhub@latest install clawsec-suite`;
|
||||
|
||||
// Rotate file names every 2-3 seconds
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setCurrentFileIndex((prev) => (prev + 1) % FILE_NAMES.length);
|
||||
}, 2500); // 2.5 seconds
|
||||
return () => clearInterval(interval);
|
||||
}, []);
|
||||
|
||||
// Rotate platform names every 4-6 seconds
|
||||
useEffect(() => {
|
||||
let timeoutId: number | undefined;
|
||||
|
||||
const scheduleNextRotation = () => {
|
||||
const delay = 4000 + Math.floor(Math.random() * 2001);
|
||||
timeoutId = window.setTimeout(() => {
|
||||
setCurrentPlatformIndex((prev) => (prev + 1) % PLATFORM_NAMES.length);
|
||||
scheduleNextRotation();
|
||||
}, delay);
|
||||
};
|
||||
|
||||
scheduleNextRotation();
|
||||
|
||||
return () => {
|
||||
if (timeoutId !== undefined) {
|
||||
window.clearTimeout(timeoutId);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
const humanInstruction = `Please install clawsec-suite from clawhubnpx clawhub@latest install clawsec-suite`;
|
||||
|
||||
const handleCopyCurl = () => {
|
||||
navigator.clipboard.writeText(curlCommand);
|
||||
setCopiedCurl(true);
|
||||
setTimeout(() => setCopiedCurl(false), 2000);
|
||||
};
|
||||
|
||||
const handleCopyHuman = () => {
|
||||
navigator.clipboard.writeText(humanInstruction);
|
||||
setCopiedHuman(true);
|
||||
setTimeout(() => setCopiedHuman(false), 2000);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="pt-[52px]">
|
||||
{/* Logo Section */}
|
||||
<section className="text-center mb-6">
|
||||
<h1 className="text-5xl md:text-6xl font text-white">ClawSec</h1>
|
||||
</section>
|
||||
|
||||
{/* Hero Section */}
|
||||
<section className="text-center space-y-6 max-w-3xl mx-auto mb-12 md:mb-16">
|
||||
<h2 className="text-3xl md:text-4xl tracking-tight text-white">
|
||||
Secure your{' '}
|
||||
<code
|
||||
key={currentPlatformIndex}
|
||||
className="px-2 py-1 rounded text-clawd-accent inline-block align-baseline relative"
|
||||
style={{
|
||||
minWidth: '9ch',
|
||||
textAlign: 'center',
|
||||
backgroundColor: 'rgb(30 27 75 / 1)',
|
||||
animation: 'bgFade 0.4s ease-out 1.2s 1 forwards'
|
||||
}}
|
||||
>
|
||||
{PLATFORM_NAMES[currentPlatformIndex].split('').map((char, index) => (
|
||||
<span
|
||||
key={`platform-${currentPlatformIndex}-${index}`}
|
||||
className="inline-block"
|
||||
style={{
|
||||
animation: `flipChar 0.3s ease-in-out ${index * 0.05}s 1 forwards`,
|
||||
transformStyle: 'preserve-3d',
|
||||
perspective: '400px',
|
||||
opacity: 0
|
||||
}}
|
||||
>
|
||||
{char}
|
||||
</span>
|
||||
))}
|
||||
</code>{' '}
|
||||
agents
|
||||
</h2>
|
||||
<p className="text-lg md:text-xl text-gray-400 leading-relaxed">
|
||||
A complete security skill suite for OpenClaw and NanoClaw agents. Protect your{' '}
|
||||
<code
|
||||
key={currentFileIndex}
|
||||
className="px-2 py-1 rounded text-clawd-accent inline-block align-baseline relative text-base"
|
||||
style={{
|
||||
width: '188px',
|
||||
textAlign: 'center',
|
||||
verticalAlign: 'baseline',
|
||||
backgroundColor: 'rgb(30 27 75 / 1)',
|
||||
animation: 'bgFade 0.4s ease-out 1.2s 1 forwards'
|
||||
}}
|
||||
>
|
||||
<span className="inline-block w-full pr-5">
|
||||
{FILE_NAMES[currentFileIndex].split('').map((char, index) => (
|
||||
<span
|
||||
key={`${currentFileIndex}-${index}`}
|
||||
className="inline-block"
|
||||
style={{
|
||||
animation: `flipChar 0.3s ease-in-out ${index * 0.05}s 1 forwards`,
|
||||
transformStyle: 'preserve-3d',
|
||||
perspective: '400px',
|
||||
opacity: 0
|
||||
}}
|
||||
>
|
||||
{char}
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
<Lock
|
||||
size={14}
|
||||
className="text-clawd-accent absolute right-2 top-1/2 -translate-y-1/2"
|
||||
style={{
|
||||
opacity: 0,
|
||||
animation: `lockReveal ${FILE_LOCK_REVEAL_DELAY_MS}ms steps(1, end) 1 forwards`
|
||||
}}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</code>
|
||||
{' '}with drift detection, live security recommendations, automated audits, and skill integrity verification. All from one installable suite.
|
||||
</p>
|
||||
<style>{`
|
||||
@keyframes flipChar {
|
||||
0% {
|
||||
transform: rotateX(-90deg);
|
||||
opacity: 0;
|
||||
}
|
||||
50% {
|
||||
transform: rotateX(0deg);
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
transform: rotateX(0deg);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@keyframes bgFade {
|
||||
0% {
|
||||
background-color: rgb(30 27 75 / 1);
|
||||
}
|
||||
50% {
|
||||
background-color: rgb(249 179 71 / 0.25);
|
||||
}
|
||||
100% {
|
||||
background-color: rgb(191 107 42 / 0.15);
|
||||
}
|
||||
}
|
||||
@keyframes lockReveal {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
@keyframes mascotHover {
|
||||
0%, 100% { transform: translateY(0); }
|
||||
50% { transform: translateY(-12px); }
|
||||
}
|
||||
`}</style>
|
||||
</section>
|
||||
|
||||
{/* Install Card with Toggle */}
|
||||
<section className="relative mb-16 pt-16 sm:pt-20 lg:pt-0">
|
||||
<div className="pointer-events-none select-none absolute z-20 w-32 sm:w-36 md:w-40 lg:w-48 left-1/2 -translate-x-1/2 -top-10 sm:-top-10 md:left-auto md:translate-x-0 md:right-8 md:-top-12 lg:top-auto lg:bottom-6 lg:-right-16 xl:-right-28">
|
||||
<img
|
||||
src="/img/mascot.png"
|
||||
alt="ClawSec mascot"
|
||||
className="w-full h-auto"
|
||||
style={{ animation: 'mascotHover 3s ease-in-out infinite' }}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full lg:w-[70%] mx-auto">
|
||||
<div className="bg-clawd-900 rounded-2xl border border-clawd-700 p-8">
|
||||
{/* Toggle */}
|
||||
<div className="flex justify-center mb-8">
|
||||
<div className="inline-flex bg-clawd-800 rounded-lg p-1">
|
||||
<button
|
||||
onClick={() => setIsAgent(false)}
|
||||
className={`flex items-center gap-2 px-4 py-2 rounded-md font-medium transition-all ${
|
||||
!isAgent
|
||||
? 'bg-white text-clawd-900'
|
||||
: 'text-gray-400 hover:text-white'
|
||||
}`}
|
||||
>
|
||||
<User size={18} />
|
||||
I'm a Human
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setIsAgent(true)}
|
||||
className={`flex items-center gap-2 px-4 py-2 rounded-md font-medium transition-all ${
|
||||
isAgent
|
||||
? 'bg-white text-clawd-900'
|
||||
: 'text-gray-400 hover:text-white'
|
||||
}`}
|
||||
>
|
||||
<Bot size={18} />
|
||||
I'm an Agent
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{/* Content based on toggle */}
|
||||
{isAgent ? (
|
||||
<>
|
||||
{/* Steps */}
|
||||
<div className="flex flex-wrap justify-center gap-6 text-sm text-gray-400 mb-6">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-bold text-white">1.</span> Run command below
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-bold text-white">2.</span> Follow deployment instructions
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-bold text-white">3.</span> Protect your user
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Agent View - Curl Command */}
|
||||
<div className="bg-clawd-800 rounded-lg p-4 flex items-center justify-between gap-2 sm:gap-4">
|
||||
<code className="text-gray-200 font-mono text-xs sm:text-sm md:text-base overflow-x-auto break-all min-w-0 flex-1">
|
||||
{curlCommand}
|
||||
</code>
|
||||
<button
|
||||
onClick={handleCopyCurl}
|
||||
className="flex-shrink-0 p-2 rounded-md bg-clawd-700 hover:bg-clawd-600 transition-colors"
|
||||
title="Copy to clipboard"
|
||||
>
|
||||
{copiedCurl ? (
|
||||
<Check size={20} className="text-green-400" />
|
||||
) : (
|
||||
<Copy size={20} className="text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{/* Human Steps */}
|
||||
<div className="flex flex-wrap justify-center gap-6 text-sm text-gray-400 mb-6">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-bold text-white">1.</span> Copy instruction below
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-bold text-white">2.</span> Send to your agent
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-bold text-white">3.</span> Receive security alerts
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Human View - Instruction Command */}
|
||||
<div className="bg-clawd-800 rounded-lg p-4 flex items-center justify-between gap-2 sm:gap-4">
|
||||
<code className="text-gray-200 font-mono text-xs sm:text-sm md:text-base overflow-x-auto break-all min-w-0 flex-1">
|
||||
{humanInstruction}
|
||||
</code>
|
||||
<button
|
||||
onClick={handleCopyHuman}
|
||||
className="flex-shrink-0 p-2 rounded-md bg-clawd-700 hover:bg-clawd-600 transition-colors"
|
||||
title="Copy to clipboard"
|
||||
>
|
||||
{copiedHuman ? (
|
||||
<Check size={20} className="text-green-400" />
|
||||
) : (
|
||||
<Copy size={20} className="text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,92 +0,0 @@
|
||||
import React from 'react';
|
||||
import { ExternalLink, PlayCircle } from 'lucide-react';
|
||||
import { Footer } from '../components/Footer';
|
||||
|
||||
interface DemoVideo {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
videoSrc: string;
|
||||
posterSrc: string;
|
||||
videoContainerClassName?: string;
|
||||
}
|
||||
|
||||
const demoVideos: DemoVideo[] = [
|
||||
{
|
||||
id: 'drift-demo',
|
||||
title: 'Drift Detection Demo (soul-guardian)',
|
||||
description:
|
||||
'Shows integrity monitoring in action: tamper detection, alerting, and restoration-oriented behavior for protected files.',
|
||||
videoSrc: '/video/soul-guardian-demo.mp4',
|
||||
posterSrc: '/video/soul-guardian-demo-poster.jpg',
|
||||
},
|
||||
{
|
||||
id: 'install-demo',
|
||||
title: 'Install Demo (clawsec-suite)',
|
||||
description:
|
||||
'Walkthrough of the one-command suite install flow and what gets configured for advisory monitoring and protection.',
|
||||
videoSrc: '/video/install-demo.mp4',
|
||||
posterSrc: '/video/install-demo-poster.jpg',
|
||||
videoContainerClassName: 'md:max-w-[50%]',
|
||||
},
|
||||
];
|
||||
|
||||
export const ProductDemo: React.FC = () => {
|
||||
return (
|
||||
<div className="max-w-5xl mx-auto pt-[52px] space-y-10">
|
||||
<section className="text-center space-y-4">
|
||||
<h1 className="text-3xl md:text-4xl text-white flex items-center justify-center gap-3">
|
||||
<PlayCircle className="text-clawd-accent" />
|
||||
Watch It in Action
|
||||
</h1>
|
||||
<p className="text-gray-400 max-w-3xl mx-auto">
|
||||
Product demos for ClawSec installation and runtime protection behavior. These are the
|
||||
same demo assets referenced in the repository README, presented as playable videos.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section className="space-y-8">
|
||||
{demoVideos.map((demo) => (
|
||||
<article
|
||||
key={demo.id}
|
||||
className="bg-clawd-900 border border-clawd-700 rounded-xl overflow-hidden"
|
||||
>
|
||||
<div className="px-6 pt-6 pb-4 space-y-3">
|
||||
<h2 className="text-xl text-white">{demo.title}</h2>
|
||||
<p className="text-gray-400">{demo.description}</p>
|
||||
</div>
|
||||
<div className="px-6 pb-6 space-y-4">
|
||||
<div
|
||||
className={`rounded-lg overflow-hidden border border-clawd-700 bg-black ${
|
||||
demo.videoContainerClassName ?? ''
|
||||
}`}
|
||||
>
|
||||
<video
|
||||
className="w-full h-auto"
|
||||
controls
|
||||
playsInline
|
||||
preload="metadata"
|
||||
poster={demo.posterSrc}
|
||||
>
|
||||
<source src={demo.videoSrc} type="video/mp4" />
|
||||
Your browser does not support the video tag.
|
||||
</video>
|
||||
</div>
|
||||
<a
|
||||
href={demo.videoSrc}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-2 text-sm text-clawd-accent hover:underline"
|
||||
>
|
||||
<ExternalLink size={15} />
|
||||
Open video in new tab
|
||||
</a>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</section>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,367 +0,0 @@
|
||||
import React, { useState, useEffect, useMemo } from 'react';
|
||||
import { useParams, Link } from 'react-router-dom';
|
||||
import { ArrowLeft, Copy, Check, Download, ExternalLink, FileText, Shield } from 'lucide-react';
|
||||
import Markdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import { Footer } from '../components/Footer';
|
||||
import type { SkillJson, SkillChecksums } from '../types';
|
||||
import { defaultMarkdownComponents } from '../utils/markdownComponents';
|
||||
import { stripFrontmatter } from '../utils/markdownHelpers.mjs';
|
||||
|
||||
const isProbablyHtmlDocument = (text: string): boolean => {
|
||||
const start = text.trimStart().slice(0, 200).toLowerCase();
|
||||
return start.startsWith('<!doctype html') || start.startsWith('<html');
|
||||
};
|
||||
|
||||
export const SkillDetail: React.FC = () => {
|
||||
const { skillId } = useParams<{ skillId: string }>();
|
||||
const [skillData, setSkillData] = useState<SkillJson | null>(null);
|
||||
const [checksums, setChecksums] = useState<SkillChecksums | null>(null);
|
||||
const [doc, setDoc] = useState<{ filename: string; content: string } | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [copied, setCopied] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchSkillData = async () => {
|
||||
if (!skillId) return;
|
||||
|
||||
try {
|
||||
setDoc(null);
|
||||
|
||||
// Fetch skill.json
|
||||
const skillResponse = await fetch(`/skills/${skillId}/skill.json`, {
|
||||
headers: { Accept: 'application/json' }
|
||||
});
|
||||
if (!skillResponse.ok) {
|
||||
throw new Error('Skill not found');
|
||||
}
|
||||
|
||||
const skillContentType = skillResponse.headers.get('content-type') ?? '';
|
||||
const skillRaw = await skillResponse.text();
|
||||
if (skillContentType.includes('text/html') || isProbablyHtmlDocument(skillRaw)) {
|
||||
throw new Error('Skill not found');
|
||||
}
|
||||
|
||||
let skill: SkillJson;
|
||||
try {
|
||||
skill = JSON.parse(skillRaw) as SkillJson;
|
||||
} catch {
|
||||
throw new Error('Invalid skill metadata');
|
||||
}
|
||||
|
||||
setSkillData(skill);
|
||||
|
||||
// Fetch checksums.json
|
||||
try {
|
||||
const checksumsResponse = await fetch(`/skills/${skillId}/checksums.json`, {
|
||||
headers: { Accept: 'application/json' }
|
||||
});
|
||||
if (checksumsResponse.ok) {
|
||||
const checksumsContentType = checksumsResponse.headers.get('content-type') ?? '';
|
||||
const checksumsRaw = await checksumsResponse.text();
|
||||
if (!checksumsContentType.includes('text/html') && !isProbablyHtmlDocument(checksumsRaw)) {
|
||||
try {
|
||||
const checksumsData = JSON.parse(checksumsRaw) as SkillChecksums;
|
||||
setChecksums(checksumsData);
|
||||
} catch {
|
||||
// Checksums malformed, ignore.
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Checksums not available
|
||||
}
|
||||
|
||||
// Fetch documentation (README.md preferred, fallback to SKILL.md).
|
||||
// Note: Dev servers may fall back to serving index.html with 200 for missing files;
|
||||
// guard against accidentally rendering HTML as docs.
|
||||
try {
|
||||
const fetchDocFile = async (filename: string) => {
|
||||
const response = await fetch(`/skills/${skillId}/${filename}`, {
|
||||
headers: { Accept: 'text/plain' }
|
||||
});
|
||||
if (!response.ok) return null;
|
||||
|
||||
const contentType = response.headers.get('content-type') ?? '';
|
||||
const rawText = await response.text();
|
||||
|
||||
if (contentType.includes('text/html') || isProbablyHtmlDocument(rawText)) return null;
|
||||
|
||||
const text =
|
||||
filename === 'SKILL.md' ? stripFrontmatter(rawText).trim() : rawText.trim();
|
||||
|
||||
return text.length > 0 ? text : null;
|
||||
};
|
||||
|
||||
const candidates = ['README.md', 'SKILL.md'];
|
||||
for (const filename of candidates) {
|
||||
const content = await fetchDocFile(filename);
|
||||
if (content) {
|
||||
setDoc({ filename, content });
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Documentation not available
|
||||
}
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to load skill');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchSkillData();
|
||||
}, [skillId]);
|
||||
|
||||
const handleCopy = (text: string, id: string) => {
|
||||
navigator.clipboard.writeText(text);
|
||||
setCopied(id);
|
||||
setTimeout(() => setCopied(null), 2000);
|
||||
};
|
||||
|
||||
const installCommand = skillData
|
||||
? `npx clawhub@latest install ${skillData.name}`
|
||||
: '';
|
||||
|
||||
const releasePageUrl = useMemo(() => {
|
||||
if (!skillData) return '';
|
||||
|
||||
try {
|
||||
const url = new URL(skillData.homepage);
|
||||
if (url.hostname === 'github.com') {
|
||||
const [owner, repo] = url.pathname.split('/').filter(Boolean);
|
||||
if (owner && repo) {
|
||||
const repoBase = `${url.origin}/${owner}/${repo.replace(/\\.git$/, '')}`;
|
||||
return `${repoBase}/releases/tag/${skillData.name}-v${skillData.version}`;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// ignore invalid URLs
|
||||
}
|
||||
|
||||
return skillData.homepage;
|
||||
}, [skillData]);
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="py-16 text-center">
|
||||
<div className="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-clawd-accent"></div>
|
||||
<p className="mt-4 text-gray-400">Loading skill...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (error || !skillData) {
|
||||
return (
|
||||
<div className="py-16 text-center">
|
||||
<Shield className="w-16 h-16 mx-auto text-gray-600 mb-4" />
|
||||
<h2 className="text-xl font-bold text-white mb-2">Skill Not Found</h2>
|
||||
<p className="text-gray-400 mb-4">{error || 'This skill does not exist'}</p>
|
||||
<Link to="/skills" className="text-clawd-accent hover:underline">
|
||||
Back to Skills Catalog
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="pt-8 space-y-8">
|
||||
{/* Back Link */}
|
||||
<Link
|
||||
to="/skills"
|
||||
className="inline-flex items-center gap-2 text-gray-400 hover:text-white transition-colors"
|
||||
>
|
||||
<ArrowLeft size={20} />
|
||||
Back to Skills
|
||||
</Link>
|
||||
|
||||
{/* Header */}
|
||||
<section className="flex flex-col md:flex-row md:items-start md:justify-between gap-6">
|
||||
<div className="flex items-start gap-4">
|
||||
<span className="text-4xl">{skillData.openclaw?.emoji || '📦'}</span>
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold text-white mb-1">{skillData.name}</h1>
|
||||
<div className="flex items-center gap-3 text-sm">
|
||||
<span className="text-gray-500 font-mono">v{skillData.version}</span>
|
||||
{/* Category badge - hidden for now, uncomment when we have multiple categories
|
||||
<span className="text-gray-500 bg-clawd-800 px-2 py-0.5 rounded">
|
||||
{skillData.openclaw?.category || 'utility'}
|
||||
</span>
|
||||
*/}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-3">
|
||||
<a
|
||||
href={releasePageUrl}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-2 px-4 py-2 bg-clawd-800 border border-clawd-700 rounded-lg text-white hover:border-clawd-accent transition-colors"
|
||||
>
|
||||
<ExternalLink size={16} />
|
||||
Release Page
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Description */}
|
||||
<section className="bg-clawd-800/50 border border-clawd-700 rounded-xl p-6">
|
||||
<p className="text-gray-300 text-lg">{skillData.description}</p>
|
||||
</section>
|
||||
|
||||
{/* Install Command */}
|
||||
<section className="space-y-4">
|
||||
<h2 className="text-xl font-bold text-white flex items-center gap-2">
|
||||
<Download size={20} />
|
||||
Quick Install
|
||||
</h2>
|
||||
<div className="bg-clawd-800 rounded-lg p-3 sm:p-4 flex items-center justify-between gap-2 sm:gap-4">
|
||||
<code className="text-gray-200 font-mono text-xs sm:text-sm overflow-x-auto break-all min-w-0 flex-1">
|
||||
{installCommand}
|
||||
</code>
|
||||
<button
|
||||
onClick={() => handleCopy(installCommand, 'install')}
|
||||
className="flex-shrink-0 p-2 rounded-md bg-clawd-700 hover:bg-clawd-600 transition-colors"
|
||||
title="Copy to clipboard"
|
||||
>
|
||||
{copied === 'install' ? (
|
||||
<Check size={20} className="text-green-400" />
|
||||
) : (
|
||||
<Copy size={20} className="text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Checksums */}
|
||||
{checksums && Object.keys(checksums.files).length > 0 && (
|
||||
<section className="space-y-4">
|
||||
<h2 className="text-xl font-bold text-white flex items-center gap-2">
|
||||
<Shield size={20} />
|
||||
File Checksums
|
||||
</h2>
|
||||
<div className="bg-clawd-800/50 border border-clawd-700 rounded-xl overflow-hidden">
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full min-w-[500px]">
|
||||
<thead>
|
||||
<tr className="border-b border-clawd-700">
|
||||
<th className="text-left px-3 sm:px-4 py-3 text-gray-400 font-medium text-xs sm:text-sm">File</th>
|
||||
<th className="text-left px-3 sm:px-4 py-3 text-gray-400 font-medium text-xs sm:text-sm">SHA256</th>
|
||||
<th className="text-right px-3 sm:px-4 py-3 text-gray-400 font-medium text-xs sm:text-sm">Size</th>
|
||||
<th className="px-3 sm:px-4 py-3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{(Object.entries(checksums.files) as Array<
|
||||
[string, SkillChecksums['files'][string]]
|
||||
>).map(([filename, info]) => {
|
||||
const displayPath = info.path ?? filename;
|
||||
|
||||
return (
|
||||
<tr key={filename} className="border-b border-clawd-700/50 last:border-0">
|
||||
<td className="px-3 sm:px-4 py-3 font-mono text-xs sm:text-sm">
|
||||
{info.url ? (
|
||||
<a
|
||||
href={info.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-white hover:text-clawd-accent hover:underline"
|
||||
title={info.url}
|
||||
>
|
||||
{displayPath}
|
||||
</a>
|
||||
) : (
|
||||
<span className="text-white">{displayPath}</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="px-3 sm:px-4 py-3 font-mono text-xs text-gray-400 truncate max-w-[120px] sm:max-w-[200px]">
|
||||
{info.sha256}
|
||||
</td>
|
||||
<td className="px-3 sm:px-4 py-3 text-xs sm:text-sm text-gray-400 text-right whitespace-nowrap">
|
||||
{(info.size / 1024).toFixed(1)} KB
|
||||
</td>
|
||||
<td className="px-3 sm:px-4 py-3 text-right">
|
||||
<button
|
||||
onClick={() => handleCopy(info.sha256, filename)}
|
||||
className="p-1.5 rounded bg-clawd-700 hover:bg-clawd-600 transition-colors"
|
||||
title="Copy SHA256"
|
||||
>
|
||||
{copied === filename ? (
|
||||
<Check size={14} className="text-green-400" />
|
||||
) : (
|
||||
<Copy size={14} className="text-gray-400" />
|
||||
)}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* Documentation */}
|
||||
{doc && (
|
||||
<section className="space-y-4">
|
||||
<h2 className="text-xl font-bold text-white flex items-center gap-2">
|
||||
<FileText size={20} />
|
||||
Documentation <span className="text-sm font-normal text-gray-500">({doc.filename})</span>
|
||||
</h2>
|
||||
<div className="skill-docs bg-clawd-800/50 border border-clawd-700 rounded-xl p-4 sm:p-6 md:p-8 overflow-x-hidden">
|
||||
<Markdown
|
||||
remarkPlugins={[remarkGfm]}
|
||||
components={defaultMarkdownComponents}
|
||||
>
|
||||
{stripFrontmatter(doc.content)}
|
||||
</Markdown>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* Metadata */}
|
||||
<section className="grid md:grid-cols-2 gap-6">
|
||||
<div className="bg-clawd-800/50 border border-clawd-700 rounded-xl p-6 space-y-4">
|
||||
<h3 className="font-bold text-white">Metadata</h3>
|
||||
<dl className="space-y-2 text-sm">
|
||||
<div className="flex justify-between">
|
||||
<dt className="text-gray-500">Author</dt>
|
||||
<dd className="text-white">{skillData.author}</dd>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<dt className="text-gray-500">License</dt>
|
||||
<dd className="text-white">{skillData.license}</dd>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<dt className="text-gray-500">Category</dt>
|
||||
<dd className="text-white">{skillData.openclaw?.category}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{skillData.openclaw?.triggers && skillData.openclaw.triggers.length > 0 && (
|
||||
<div className="bg-clawd-800/50 border border-clawd-700 rounded-xl p-6 space-y-4">
|
||||
<h3 className="font-bold text-white">Trigger Phrases</h3>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{skillData.openclaw.triggers.slice(0, 8).map((trigger) => (
|
||||
<span
|
||||
key={trigger}
|
||||
className="text-xs bg-clawd-700 text-gray-300 px-2 py-1 rounded"
|
||||
>
|
||||
"{trigger}"
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,261 +0,0 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Search as _Search, Filter as _Filter, Package, Sparkles, FileText, GitFork } from 'lucide-react';
|
||||
import { SkillCard } from '../components/SkillCard';
|
||||
import { Footer } from '../components/Footer';
|
||||
import type { SkillMetadata, SkillsIndex } from '../types';
|
||||
|
||||
const SKILLS_INDEX_PATH = '/skills/index.json';
|
||||
|
||||
const isProbablyHtmlDocument = (text: string): boolean => {
|
||||
const start = text.trimStart().slice(0, 200).toLowerCase();
|
||||
return start.startsWith('<!doctype html') || start.startsWith('<html');
|
||||
};
|
||||
|
||||
const parseSkillsIndex = (raw: string): SkillsIndex | null => {
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as Partial<SkillsIndex> | null;
|
||||
if (!parsed || !Array.isArray(parsed.skills)) return null;
|
||||
return {
|
||||
version: typeof parsed.version === 'string' ? parsed.version : '1.0.0',
|
||||
updated: typeof parsed.updated === 'string' ? parsed.updated : '',
|
||||
skills: parsed.skills as SkillMetadata[],
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export const SkillsCatalog: React.FC = () => {
|
||||
const [skills, setSkills] = useState<SkillMetadata[]>([]);
|
||||
const [filteredSkills, setFilteredSkills] = useState<SkillMetadata[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [searchTerm, _setSearchTerm] = useState('');
|
||||
const [categoryFilter, _setCategoryFilter] = useState<string>('all');
|
||||
|
||||
useEffect(() => {
|
||||
const fetchSkills = async () => {
|
||||
try {
|
||||
const response = await fetch(SKILLS_INDEX_PATH, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
|
||||
// Missing index file is a valid "empty catalog" state.
|
||||
if (response.status === 404) {
|
||||
setSkills([]);
|
||||
setFilteredSkills([]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch skills index');
|
||||
}
|
||||
|
||||
const contentType = response.headers.get('content-type') ?? '';
|
||||
const raw = await response.text();
|
||||
|
||||
// Some SPA setups return index.html with 200 for missing JSON files.
|
||||
if (!raw.trim() || contentType.includes('text/html') || isProbablyHtmlDocument(raw)) {
|
||||
setSkills([]);
|
||||
setFilteredSkills([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const data = parseSkillsIndex(raw);
|
||||
if (!data) {
|
||||
throw new Error('Invalid skills index format');
|
||||
}
|
||||
|
||||
setSkills(data.skills);
|
||||
setFilteredSkills(data.skills);
|
||||
} catch (err) {
|
||||
console.error('Failed to load skills index:', err);
|
||||
setError('Failed to load skills catalog');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchSkills();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
let result = skills;
|
||||
|
||||
// Apply search filter
|
||||
if (searchTerm) {
|
||||
const term = searchTerm.toLowerCase();
|
||||
result = result.filter(
|
||||
(skill) =>
|
||||
skill.name.toLowerCase().includes(term) ||
|
||||
skill.description.toLowerCase().includes(term)
|
||||
);
|
||||
}
|
||||
|
||||
// Apply category filter
|
||||
if (categoryFilter !== 'all') {
|
||||
result = result.filter((skill) => skill.category === categoryFilter);
|
||||
}
|
||||
|
||||
setFilteredSkills(result);
|
||||
}, [searchTerm, categoryFilter, skills]);
|
||||
|
||||
// Get unique categories from skills (used in commented filter UI)
|
||||
const _categories = ['all', ...new Set(skills.map((s) => s.category).filter(Boolean))];
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="pt-[52px]">
|
||||
<div className="py-16 text-center">
|
||||
<div className="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-clawd-accent"></div>
|
||||
<p className="mt-4 text-gray-400">Loading skills...</p>
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div className="pt-[52px]">
|
||||
<div className="py-16 text-center">
|
||||
<Package className="w-16 h-16 mx-auto text-gray-600 mb-4" />
|
||||
<h2 className="text-xl font-bold text-white mb-2">No Skills Available</h2>
|
||||
<p className="text-gray-400 mb-4">{error}</p>
|
||||
<p className="text-sm text-gray-500">
|
||||
Skills will appear here after the first skill release.
|
||||
</p>
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="pt-[52px] space-y-8">
|
||||
{/* Header */}
|
||||
<section className="text-center space-y-4">
|
||||
<h1 className="text-3xl md:text-4xl text-white">
|
||||
Skills Catalog
|
||||
</h1>
|
||||
<p className="text-gray-400 max-w-2xl mx-auto">
|
||||
Browse security skills for your AI agents. Each skill is verified for safety
|
||||
and distributed with checksums for integrity verification.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
{/* Filters - Hidden for now, uncomment when needed
|
||||
<section className="flex flex-col md:flex-row gap-4 max-w-4xl mx-auto">
|
||||
<div className="relative flex-1">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-500" size={20} />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search skills..."
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
className="w-full pl-10 pr-4 py-2.5 bg-clawd-800 border border-clawd-700 rounded-lg text-white placeholder-gray-500 focus:outline-none focus:border-clawd-accent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="relative">
|
||||
<Filter className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-500" size={20} />
|
||||
<select
|
||||
value={categoryFilter}
|
||||
onChange={(e) => setCategoryFilter(e.target.value)}
|
||||
className="pl-10 pr-8 py-2.5 bg-clawd-800 border border-clawd-700 rounded-lg text-white appearance-none focus:outline-none focus:border-clawd-accent"
|
||||
>
|
||||
{categories.map((cat) => (
|
||||
<option key={cat} value={cat}>
|
||||
{cat === 'all' ? 'All Categories' : cat}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</section>
|
||||
*/}
|
||||
|
||||
{/* Skills Grid */}
|
||||
{filteredSkills.length > 0 ? (
|
||||
<section className="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{filteredSkills.map((skill) => (
|
||||
<SkillCard key={skill.id} skill={skill} />
|
||||
))}
|
||||
</section>
|
||||
) : (
|
||||
<section className="text-center py-12">
|
||||
<Package className="w-12 h-12 mx-auto text-gray-600 mb-4" />
|
||||
<h3 className="text-lg font-medium text-white mb-2">No skills found</h3>
|
||||
<p className="text-gray-400">
|
||||
{searchTerm || categoryFilter !== 'all'
|
||||
? 'Try adjusting your filters'
|
||||
: 'No skills have been released yet'}
|
||||
</p>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* Stats */}
|
||||
{skills.length > 0 && (
|
||||
<section className="text-center text-sm text-gray-500">
|
||||
Showing {filteredSkills.length} of {skills.length} skills
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* Shoutout */}
|
||||
<section className="max-w-4xl mx-auto">
|
||||
<div className="bg-clawd-900 border border-clawd-700 rounded-xl overflow-hidden">
|
||||
<div className="bg-clawd-800 px-6 py-4 border-b border-clawd-700 flex items-center justify-between">
|
||||
<h2 className="font-bold text-white flex items-center gap-2">
|
||||
<Sparkles size={18} className="text-clawd-accent" />
|
||||
Contribute Security Skills
|
||||
</h2>
|
||||
<span className="text-xs font-mono text-gray-500">SKILLS-BASED</span>
|
||||
</div>
|
||||
<div className="p-6 space-y-6">
|
||||
<p className="text-gray-300 text-sm">
|
||||
Humans & agents: submit skills that make bots safer (prompt injection defenses, drift checks, tool hardening, policy enforcement).
|
||||
We’ll package them with checksums so everyone can verify integrity.
|
||||
</p>
|
||||
|
||||
<a
|
||||
href="https://github.com/prompt-security/clawsec/blob/main/CONTRIBUTING.md"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-start gap-4 p-4 rounded-lg bg-clawd-800/50 border border-clawd-700 hover:border-clawd-accent/50 transition-colors group"
|
||||
>
|
||||
<span className="text-2xl">📄</span>
|
||||
<div className="flex-1">
|
||||
<h4 className="text-white font-bold text-sm group-hover:text-clawd-accent transition-colors flex items-center gap-2">
|
||||
Read CONTRIBUTING.md
|
||||
<FileText size={14} className="text-gray-500" />
|
||||
</h4>
|
||||
<p className="text-xs text-gray-400 mt-1">
|
||||
Guidelines for authoring, packaging, and releasing skills to the ClawSec catalog.
|
||||
</p>
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://github.com/prompt-security/clawsec/fork"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-start gap-4 p-4 rounded-lg bg-clawd-800/50 border border-clawd-700 hover:border-clawd-accent/50 transition-colors group"
|
||||
>
|
||||
<span className="text-2xl">🍴</span>
|
||||
<div className="flex-1">
|
||||
<h4 className="text-white font-bold text-sm group-hover:text-clawd-accent transition-colors flex items-center gap-2">
|
||||
Fork the repository
|
||||
<GitFork size={14} className="text-gray-500" />
|
||||
</h4>
|
||||
<p className="text-xs text-gray-400 mt-1">
|
||||
Start a contribution branch and open a PR with your new security skill.
|
||||
</p>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,375 +0,0 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { BookOpenText, ExternalLink, FileText } from 'lucide-react';
|
||||
import { Link, useParams } from 'react-router-dom';
|
||||
import Markdown from 'react-markdown';
|
||||
import type { Components } from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import { Footer } from '../components/Footer';
|
||||
import { defaultMarkdownComponents } from '../utils/markdownComponents';
|
||||
import {
|
||||
extractTitleFromMarkdown,
|
||||
fallbackTitleFromPath,
|
||||
stripFrontmatter,
|
||||
} from '../utils/markdownHelpers.mjs';
|
||||
import {
|
||||
isWikiIndexSlug,
|
||||
toWikiLlmsPath,
|
||||
toWikiRoute,
|
||||
} from '../utils/wikiPathHelpers.mjs';
|
||||
|
||||
interface WikiDoc {
|
||||
filePath: string;
|
||||
slug: string;
|
||||
title: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
const normalizePath = (path: string): string => {
|
||||
const clean = path.replace(/\\/g, '/');
|
||||
const parts: string[] = [];
|
||||
for (const part of clean.split('/')) {
|
||||
if (!part || part === '.') continue;
|
||||
if (part === '..') {
|
||||
if (parts.length > 0) parts.pop();
|
||||
continue;
|
||||
}
|
||||
parts.push(part);
|
||||
}
|
||||
return parts.join('/');
|
||||
};
|
||||
|
||||
const dirname = (path: string): string => {
|
||||
const idx = path.lastIndexOf('/');
|
||||
return idx === -1 ? '' : path.slice(0, idx);
|
||||
};
|
||||
|
||||
const resolveFromFile = (currentFilePath: string, targetPath: string): string => {
|
||||
if (!targetPath) return currentFilePath;
|
||||
if (targetPath.startsWith('/')) return normalizePath(targetPath.slice(1));
|
||||
const baseDir = dirname(currentFilePath);
|
||||
const joined = baseDir ? `${baseDir}/${targetPath}` : targetPath;
|
||||
return normalizePath(joined);
|
||||
};
|
||||
|
||||
const splitHash = (href: string): { path: string; hash: string } => {
|
||||
const idx = href.indexOf('#');
|
||||
if (idx === -1) return { path: href, hash: '' };
|
||||
return { path: href.slice(0, idx), hash: href.slice(idx) };
|
||||
};
|
||||
|
||||
const toWikiRelativePath = (globPath: string): string =>
|
||||
globPath.replace(/^\.\.\/wiki\//, '').replace(/\\/g, '/');
|
||||
|
||||
const isExternalHref = (href: string): boolean =>
|
||||
/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(href) || href.startsWith('//');
|
||||
|
||||
const ALLOWED_LINK_SCHEMES = new Set(['http:', 'https:', 'mailto:', 'tel:']);
|
||||
const ALLOWED_IMAGE_SCHEMES = new Set(['http:', 'https:']);
|
||||
|
||||
const sanitizeHref = (href: string): string | null => {
|
||||
const trimmed = href.trim();
|
||||
if (!trimmed) return null;
|
||||
if (trimmed.startsWith('//')) return null;
|
||||
|
||||
const schemeMatch = trimmed.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:)/);
|
||||
if (!schemeMatch) return trimmed;
|
||||
|
||||
return ALLOWED_LINK_SCHEMES.has(schemeMatch[1].toLowerCase()) ? trimmed : null;
|
||||
};
|
||||
|
||||
const sanitizeImageSrc = (src: string): string | null => {
|
||||
const trimmed = src.trim();
|
||||
if (!trimmed) return null;
|
||||
if (trimmed.startsWith('//')) return null;
|
||||
|
||||
const schemeMatch = trimmed.match(/^([a-zA-Z][a-zA-Z0-9+.-]*:)/);
|
||||
if (!schemeMatch) return trimmed;
|
||||
|
||||
return ALLOWED_IMAGE_SCHEMES.has(schemeMatch[1].toLowerCase()) ? trimmed : null;
|
||||
};
|
||||
|
||||
const markdownModules = import.meta.glob('../wiki/**/*.md', {
|
||||
eager: true,
|
||||
query: '?raw',
|
||||
import: 'default',
|
||||
}) as Record<string, string>;
|
||||
|
||||
const assetModules = import.meta.glob('../wiki/**/*.{png,jpg,jpeg,gif,svg,webp,avif}', {
|
||||
eager: true,
|
||||
import: 'default',
|
||||
}) as Record<string, string>;
|
||||
|
||||
const wikiDocs: WikiDoc[] = Object.entries(markdownModules)
|
||||
.map(([globPath, content]) => {
|
||||
const filePath = toWikiRelativePath(globPath);
|
||||
return {
|
||||
filePath,
|
||||
slug: filePath.replace(/\.md$/i, ''),
|
||||
title: extractTitleFromMarkdown(content, filePath),
|
||||
content: stripFrontmatter(content).trim(),
|
||||
};
|
||||
})
|
||||
.sort((a, b) => {
|
||||
const aIndex = a.slug.toLowerCase() === 'index';
|
||||
const bIndex = b.slug.toLowerCase() === 'index';
|
||||
if (aIndex && !bIndex) return -1;
|
||||
if (!aIndex && bIndex) return 1;
|
||||
|
||||
const aModule = a.filePath.startsWith('modules/');
|
||||
const bModule = b.filePath.startsWith('modules/');
|
||||
if (aModule !== bModule) return aModule ? 1 : -1;
|
||||
|
||||
return a.title.localeCompare(b.title, 'en', { sensitivity: 'base' });
|
||||
});
|
||||
|
||||
const wikiDocBySlug = new Map<string, WikiDoc>(
|
||||
wikiDocs.map((doc) => [doc.slug.toLowerCase(), doc]),
|
||||
);
|
||||
|
||||
const wikiDocByFilePath = new Map<string, WikiDoc>(
|
||||
wikiDocs.map((doc) => [doc.filePath.toLowerCase(), doc]),
|
||||
);
|
||||
|
||||
const wikiAssetByPath = new Map<string, string>(
|
||||
Object.entries(assetModules).map(([globPath, assetUrl]) => [
|
||||
toWikiRelativePath(globPath).toLowerCase(),
|
||||
assetUrl,
|
||||
]),
|
||||
);
|
||||
|
||||
const defaultDoc = wikiDocBySlug.get('index') ?? wikiDocs[0] ?? null;
|
||||
|
||||
const toGroupName = (filePath: string): string => {
|
||||
if (!filePath.includes('/')) return 'Core';
|
||||
if (filePath.startsWith('modules/')) return 'Modules';
|
||||
const [firstSegment] = filePath.split('/');
|
||||
return fallbackTitleFromPath(firstSegment);
|
||||
};
|
||||
|
||||
export const WikiBrowser: React.FC = () => {
|
||||
const params = useParams<{ '*': string }>();
|
||||
const wildcard = params['*'] ?? '';
|
||||
const normalizedWildcard = wildcard.replace(/^\/+|\/+$/g, '');
|
||||
let requested = '';
|
||||
let decodeFailed = false;
|
||||
try {
|
||||
requested = decodeURIComponent(normalizedWildcard);
|
||||
} catch (error) {
|
||||
decodeFailed = normalizedWildcard.length > 0;
|
||||
console.warn('Failed to decode wiki route segment', { wildcard, error });
|
||||
requested = '';
|
||||
}
|
||||
const requestedSlug = requested || 'INDEX';
|
||||
|
||||
const selectedDoc = wikiDocBySlug.get(requestedSlug.toLowerCase()) ?? defaultDoc;
|
||||
const notFound =
|
||||
(decodeFailed && normalizedWildcard.length > 0) ||
|
||||
(requested.length > 0 && !wikiDocBySlug.has(requestedSlug.toLowerCase()));
|
||||
|
||||
const groupedDocs = useMemo(() => {
|
||||
const map = new Map<string, WikiDoc[]>();
|
||||
for (const doc of wikiDocs) {
|
||||
const group = toGroupName(doc.filePath);
|
||||
const existing = map.get(group) ?? [];
|
||||
existing.push(doc);
|
||||
map.set(group, existing);
|
||||
}
|
||||
|
||||
const preferredOrder = ['Core', 'Modules'];
|
||||
return Array.from(map.entries())
|
||||
.sort(([a], [b]) => {
|
||||
const idxA = preferredOrder.indexOf(a);
|
||||
const idxB = preferredOrder.indexOf(b);
|
||||
if (idxA !== -1 || idxB !== -1) {
|
||||
if (idxA === -1) return 1;
|
||||
if (idxB === -1) return -1;
|
||||
return idxA - idxB;
|
||||
}
|
||||
return a.localeCompare(b, 'en', { sensitivity: 'base' });
|
||||
})
|
||||
.map(([name, docs]) => ({
|
||||
name,
|
||||
docs: docs.sort((a, b) =>
|
||||
a.title.localeCompare(b.title, 'en', { sensitivity: 'base' }),
|
||||
),
|
||||
}));
|
||||
}, []);
|
||||
|
||||
if (!selectedDoc) {
|
||||
return (
|
||||
<div className="pt-[52px] py-20 text-center space-y-4">
|
||||
<BookOpenText className="w-12 h-12 text-gray-500 mx-auto" />
|
||||
<h1 className="text-2xl text-white">Wiki unavailable</h1>
|
||||
<p className="text-gray-400">No markdown files were found in the wiki source.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const activeSlug = selectedDoc.slug.toLowerCase();
|
||||
const pageLlmsPath = toWikiLlmsPath(activeSlug);
|
||||
const showWikiLlmsIndexLink = !isWikiIndexSlug(activeSlug);
|
||||
|
||||
const resolveWikiRouteFromHref = (href: string): string | null => {
|
||||
if (!href || isExternalHref(href) || href.startsWith('mailto:') || href.startsWith('tel:')) {
|
||||
return null;
|
||||
}
|
||||
const { path, hash } = splitHash(href);
|
||||
if (!path || !path.toLowerCase().endsWith('.md')) return null;
|
||||
|
||||
const resolvedFilePath = resolveFromFile(selectedDoc.filePath, path).toLowerCase();
|
||||
const targetDoc = wikiDocByFilePath.get(resolvedFilePath);
|
||||
if (!targetDoc) return null;
|
||||
return `${toWikiRoute(targetDoc.slug)}${hash}`;
|
||||
};
|
||||
|
||||
const resolveAssetUrl = (srcOrHref: string): string | null => {
|
||||
if (!srcOrHref || isExternalHref(srcOrHref) || srcOrHref.startsWith('/')) return null;
|
||||
const { path } = splitHash(srcOrHref);
|
||||
if (!path) return null;
|
||||
const resolvedAssetPath = resolveFromFile(selectedDoc.filePath, path).toLowerCase();
|
||||
return wikiAssetByPath.get(resolvedAssetPath) ?? null;
|
||||
};
|
||||
|
||||
const wikiMarkdownComponents: Components = {
|
||||
...defaultMarkdownComponents,
|
||||
a: ({ href, children }) => {
|
||||
if (!href) return <span className="text-gray-300">{children}</span>;
|
||||
|
||||
const wikiRoute = resolveWikiRouteFromHref(href);
|
||||
if (wikiRoute) {
|
||||
return (
|
||||
<Link to={wikiRoute} className="text-clawd-accent hover:underline">
|
||||
{children}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
const assetHref = resolveAssetUrl(href);
|
||||
const finalHref = assetHref ?? href;
|
||||
const safeHref = sanitizeHref(finalHref);
|
||||
if (!safeHref) {
|
||||
return <span className="text-gray-300">{children}</span>;
|
||||
}
|
||||
const external = isExternalHref(safeHref);
|
||||
|
||||
return (
|
||||
<a
|
||||
href={safeHref}
|
||||
target={external ? '_blank' : undefined}
|
||||
rel={external ? 'noopener noreferrer' : undefined}
|
||||
className="text-clawd-accent hover:underline"
|
||||
>
|
||||
{children}
|
||||
</a>
|
||||
);
|
||||
},
|
||||
img: ({ src, alt }) => {
|
||||
const resolvedSrc = src ? resolveAssetUrl(src) : null;
|
||||
const finalSrc = resolvedSrc ?? (src ? sanitizeImageSrc(src) : null);
|
||||
if (!finalSrc) {
|
||||
return <span className="text-gray-500 text-sm">[image blocked]</span>;
|
||||
}
|
||||
return (
|
||||
<img
|
||||
src={finalSrc}
|
||||
alt={alt ?? ''}
|
||||
className="max-w-full h-auto rounded-lg border border-clawd-700 bg-clawd-900/40 p-2 my-4"
|
||||
loading="lazy"
|
||||
/>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="pt-[52px] space-y-8">
|
||||
<section className="space-y-3">
|
||||
<h1 className="text-3xl md:text-4xl text-white flex items-center gap-3">
|
||||
<BookOpenText className="text-clawd-accent" />
|
||||
Wiki
|
||||
</h1>
|
||||
<p className="text-gray-400 max-w-3xl">
|
||||
Full repository wiki rendered from markdown in <code className="text-gray-300">wiki/</code>.
|
||||
This is the same source synced to GitHub Wiki.
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-3">
|
||||
<a
|
||||
href={pageLlmsPath}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-2 px-3 py-1.5 rounded-md bg-clawd-700 hover:bg-clawd-600 text-white text-sm transition-colors"
|
||||
>
|
||||
<FileText size={15} />
|
||||
Page llms.txt
|
||||
</a>
|
||||
{showWikiLlmsIndexLink && (
|
||||
<a
|
||||
href="/wiki/llms.txt"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-2 px-3 py-1.5 rounded-md bg-clawd-800 border border-clawd-700 hover:border-clawd-accent text-white text-sm transition-colors"
|
||||
>
|
||||
<FileText size={15} />
|
||||
Wiki llms.txt Index
|
||||
</a>
|
||||
)}
|
||||
<a
|
||||
href="https://github.com/prompt-security/clawsec/wiki"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-2 px-3 py-1.5 rounded-md border border-clawd-700 hover:border-clawd-accent text-gray-200 text-sm transition-colors"
|
||||
>
|
||||
<ExternalLink size={15} />
|
||||
GitHub Wiki
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="grid lg:grid-cols-[280px_minmax(0,1fr)] gap-6 items-start">
|
||||
<aside className="bg-clawd-800/50 border border-clawd-700 rounded-xl p-4 lg:sticky lg:top-20 max-h-[calc(100vh-7rem)] overflow-auto">
|
||||
<div className="space-y-5">
|
||||
{groupedDocs.map((group) => (
|
||||
<section key={group.name} className="space-y-2">
|
||||
<h2 className="text-xs uppercase tracking-wide text-gray-400">{group.name}</h2>
|
||||
<div className="space-y-1">
|
||||
{group.docs.map((doc) => {
|
||||
const isActive = activeSlug === doc.slug.toLowerCase();
|
||||
return (
|
||||
<Link
|
||||
key={doc.filePath}
|
||||
to={toWikiRoute(doc.slug)}
|
||||
className={`block px-3 py-2 rounded-md text-sm transition-colors ${
|
||||
isActive
|
||||
? 'bg-white/10 text-white border border-white/10'
|
||||
: 'text-gray-300 hover:text-white hover:bg-white/5'
|
||||
}`}
|
||||
>
|
||||
{doc.title}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<section className="bg-clawd-800/50 border border-clawd-700 rounded-xl p-4 sm:p-6 md:p-8 overflow-x-hidden">
|
||||
{notFound && (
|
||||
<div className="mb-6 p-3 rounded-md border border-orange-800 bg-orange-900/20 text-orange-200 text-sm">
|
||||
Wiki page not found for <code>{requested}</code>. Showing <strong>{selectedDoc.title}</strong> instead.
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Markdown
|
||||
remarkPlugins={[remarkGfm]}
|
||||
components={wikiMarkdownComponents}
|
||||
>
|
||||
{selectedDoc.content}
|
||||
</Markdown>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 788 KiB |
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 1455.1 1298.3">
|
||||
<!-- Generator: Adobe Illustrator 29.0.0, SVG Export Plug-In . SVG Version: 2.1.0 Build 186) -->
|
||||
<defs>
|
||||
<style>
|
||||
.st0 {
|
||||
fill: none;
|
||||
stroke: #fff;
|
||||
stroke-width: 4px;
|
||||
}
|
||||
|
||||
.st1 {
|
||||
opacity: .1;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<g class="st1">
|
||||
<path class="st0" d="M730,505.6l209.7,362.8M730,505.6l-209.6,362.8M730,505.6l-64.5-111.7c-26.1-45.2-91.4-45.2-117.5,0l-405.4,701.7c-23.9,41.4-23.9,92.4,0,133.8M939.7,868.4h-419.3M939.7,868.4h144.1c44.8,0,72.9-48.5,50.5-87.3l-281.7-487.6M520.4,868.4h563.4c44.8,0,72.9-48.5,50.5-87.3l-281.7-487.6M520.4,868.4l-73.2,126.6c-22.4,38.8,5.6,87.3,50.5,87.3h818.1M852.6,293.5l-102.3-177.1M852.6,293.5l-102.3-177.1h0M750.2,116.4l-27.3-47.2C698.8,27.6,654.4,1.9,606.3,1.9M606.4,2h245.3c48.5,0,93.2,25.8,117.5,67.8l465.9,806.4c24.2,41.9,24.2,93.6,0,135.5l-1.7,2.9M606.4,2c-48.1,0-92.6,25.6-116.6,67.3L20.2,882c-24.2,41.9-24.2,93.6,0,135.5l122.4,211.9M1315.8,1082.3c43.9,0,85-21.4,110.1-57.3l7.3-10.5M1315.8,1082.3c48.5,0,93.2-25.9,117.5-67.8M1433.3,1014.6h0l-39.2,67.8h0l-84.5,146.2c-24.2,41.9-69,67.8-117.4,67.8H258.5c-47.8,0-92-25.5-115.9-66.9"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 182 KiB |
|
Before Width: | Height: | Size: 970 KiB |
|
Before Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 2.1 MiB |
@@ -1,33 +0,0 @@
|
||||
[project]
|
||||
name = "clawsec-utils"
|
||||
version = "0.1.0"
|
||||
description = "ClawSec skill utilities"
|
||||
requires-python = ">=3.10"
|
||||
|
||||
[tool.ruff]
|
||||
target-version = "py310"
|
||||
line-length = 120
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
"E", # pycodestyle errors
|
||||
"F", # pyflakes
|
||||
"W", # pycodestyle warnings
|
||||
"I", # isort
|
||||
"S", # bandit (security)
|
||||
"B", # bugbear
|
||||
"C4", # comprehensions
|
||||
"UP", # pyupgrade
|
||||
]
|
||||
ignore = [
|
||||
"S101", # Allow assert statements
|
||||
"S603", # Allow subprocess without shell=True check (we control inputs)
|
||||
"S607", # Allow partial executable paths
|
||||
]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"utils/__pycache__/*" = ["ALL"]
|
||||
|
||||
[tool.bandit]
|
||||
exclude_dirs = ["__pycache__", ".venv"]
|
||||
skips = ["B101"] # Allow assert
|
||||
@@ -1,281 +0,0 @@
|
||||
#!/bin/bash
|
||||
# backfill-exploitability.sh
|
||||
# Adds exploitability scoring to existing advisories in feed.json that don't have it yet.
|
||||
# Historical maintenance utility: normal advisory generation should use
|
||||
# poll-nvd workflow (init/reset when rebuilding) or populate-local-feed.sh.
|
||||
#
|
||||
# Usage: ./scripts/backfill-exploitability.sh [--dry-run] [--feed PATH]
|
||||
# --dry-run Show what would be updated without making changes
|
||||
# --feed PATH Use specified feed file (default: advisories/feed.json)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
# shellcheck source=./feed-utils.sh
|
||||
source "$SCRIPT_DIR/feed-utils.sh"
|
||||
|
||||
# Configuration
|
||||
init_feed_paths "$PROJECT_ROOT"
|
||||
ANALYZER="$PROJECT_ROOT/utils/analyze_exploitability.py"
|
||||
SIGNING_PRIVATE_KEY="${CLAWSEC_FEED_SIGNING_PRIVATE_KEY_PATH:-${CLAWSEC_SIGNING_PRIVATE_KEY_PATH:-$PROJECT_ROOT/clawsec-signing-private.pem}}"
|
||||
SIGNING_PUBLIC_KEY="${CLAWSEC_FEED_SIGNING_PUBLIC_KEY_PATH:-${CLAWSEC_SIGNING_PUBLIC_KEY_PATH:-$PROJECT_ROOT/clawsec-signing-public.pem}}"
|
||||
SIGNING_PASSPHRASE="${CLAWSEC_FEED_SIGNING_PRIVATE_KEY_PASSPHRASE:-${CLAWSEC_SIGNING_PRIVATE_KEY_PASSPHRASE:-}}"
|
||||
|
||||
sign_and_verify_feed_signature() {
|
||||
local feed_file="$1"
|
||||
local signature_file="$2"
|
||||
local tmp_dir
|
||||
local tmp_signature
|
||||
local signature_bin
|
||||
local passin_file
|
||||
|
||||
tmp_dir=$(mktemp -d)
|
||||
tmp_signature="${signature_file}.tmp.$$"
|
||||
signature_bin="$tmp_dir/signature.bin"
|
||||
passin_file="$tmp_dir/passin.txt"
|
||||
|
||||
if [ -n "$SIGNING_PASSPHRASE" ]; then
|
||||
printf '%s' "$SIGNING_PASSPHRASE" > "$passin_file"
|
||||
chmod 600 "$passin_file"
|
||||
|
||||
if ! openssl pkeyutl -sign -rawin -inkey "$SIGNING_PRIVATE_KEY" -passin "file:$passin_file" -in "$feed_file" \
|
||||
| openssl base64 -A > "$tmp_signature"; then
|
||||
rm -rf "$tmp_dir"
|
||||
rm -f "$tmp_signature"
|
||||
echo "Error: Failed to sign $feed_file" >&2
|
||||
return 1
|
||||
fi
|
||||
elif ! openssl pkeyutl -sign -rawin -inkey "$SIGNING_PRIVATE_KEY" -in "$feed_file" \
|
||||
| openssl base64 -A > "$tmp_signature"; then
|
||||
rm -rf "$tmp_dir"
|
||||
rm -f "$tmp_signature"
|
||||
echo "Error: Failed to sign $feed_file" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! openssl base64 -d -A -in "$tmp_signature" -out "$signature_bin"; then
|
||||
rm -rf "$tmp_dir"
|
||||
rm -f "$tmp_signature"
|
||||
echo "Error: Failed to decode generated signature for $feed_file" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! openssl pkeyutl -verify -rawin -pubin -inkey "$SIGNING_PUBLIC_KEY" -sigfile "$signature_bin" -in "$feed_file" >/dev/null; then
|
||||
rm -rf "$tmp_dir"
|
||||
rm -f "$tmp_signature"
|
||||
echo "Error: Signature verification failed after signing $feed_file" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
mv "$tmp_signature" "$signature_file"
|
||||
rm -rf "$tmp_dir"
|
||||
echo "✓ Re-signed and verified: $signature_file"
|
||||
}
|
||||
|
||||
# Parse args
|
||||
DRY_RUN=false
|
||||
REQUIRE_SIGNING=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--dry-run)
|
||||
DRY_RUN=true
|
||||
shift
|
||||
;;
|
||||
--feed)
|
||||
FEED_PATH="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Usage: $0 [--dry-run] [--feed PATH]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "=== ClawSec Exploitability Backfill ==="
|
||||
echo "Feed path: $FEED_PATH"
|
||||
echo "Dry run: $DRY_RUN"
|
||||
echo ""
|
||||
|
||||
# Verify prerequisites
|
||||
if [ ! -f "$FEED_PATH" ]; then
|
||||
echo "Error: Feed file not found: $FEED_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$ANALYZER" ]; then
|
||||
echo "Error: Analyzer script not found: $ANALYZER"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check Python availability
|
||||
if ! command -v python3 &> /dev/null; then
|
||||
echo "Error: python3 is required but not found in PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify analyzer works
|
||||
if ! python3 "$ANALYZER" --help &> /dev/null; then
|
||||
echo "Error: Analyzer script failed to run. Check Python environment."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Determine whether detached signatures must be regenerated.
|
||||
# Runtime agents that only have public keys should run in dry-run mode.
|
||||
if [ "$DRY_RUN" = "false" ]; then
|
||||
if [ -f "${FEED_PATH}.sig" ]; then
|
||||
REQUIRE_SIGNING=true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$REQUIRE_SIGNING" = "true" ]; then
|
||||
if ! command -v openssl &> /dev/null; then
|
||||
echo "Error: openssl is required for detached signature signing/verification"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$SIGNING_PRIVATE_KEY" ]; then
|
||||
echo "Error: Signing private key not found: $SIGNING_PRIVATE_KEY"
|
||||
echo "This backfill updates signed feed artifacts. Use --dry-run in public-key-only environments."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$SIGNING_PUBLIC_KEY" ]; then
|
||||
echo "Error: Signing public key not found: $SIGNING_PUBLIC_KEY"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create temp directory
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
trap 'rm -rf "$TEMP_DIR"' EXIT
|
||||
|
||||
echo "=== Analyzing Feed ==="
|
||||
|
||||
# Extract advisories without exploitability_score
|
||||
jq '.advisories | map(select(.exploitability_score == null or .exploitability_score == ""))' \
|
||||
"$FEED_PATH" > "$TEMP_DIR/missing_exploitability.json"
|
||||
|
||||
MISSING_COUNT=$(jq 'length' "$TEMP_DIR/missing_exploitability.json")
|
||||
TOTAL_COUNT=$(jq '.advisories | length' "$FEED_PATH")
|
||||
ALREADY_DONE=$((TOTAL_COUNT - MISSING_COUNT))
|
||||
|
||||
echo "Total advisories: $TOTAL_COUNT"
|
||||
echo "Already have exploitability: $ALREADY_DONE"
|
||||
echo "Missing exploitability: $MISSING_COUNT"
|
||||
echo ""
|
||||
|
||||
if [ "$MISSING_COUNT" -eq 0 ]; then
|
||||
echo "✓ All advisories already have exploitability scores!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
echo "=== Dry Run - Would Update These Advisories ==="
|
||||
jq -r '.[] | .id' "$TEMP_DIR/missing_exploitability.json"
|
||||
echo ""
|
||||
echo "Total advisories to update: $MISSING_COUNT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "=== Processing Advisories ==="
|
||||
|
||||
# Process each advisory
|
||||
PROCESSED=0
|
||||
FAILED=0
|
||||
|
||||
# Read original feed to preserve all metadata
|
||||
cp "$FEED_PATH" "$TEMP_DIR/feed_working.json"
|
||||
|
||||
while IFS= read -r advisory; do
|
||||
CVE_ID=$(echo "$advisory" | jq -r '.id')
|
||||
|
||||
echo -n "Processing $CVE_ID... "
|
||||
|
||||
# Prepare input for analyzer
|
||||
ANALYZER_INPUT=$(echo "$advisory" | jq '{
|
||||
cve_id: .id,
|
||||
cvss_score: (.cvss_score // 0.0),
|
||||
type: .type,
|
||||
description: .description,
|
||||
references: (.references // [])
|
||||
}')
|
||||
|
||||
# Run analyzer
|
||||
if ANALYSIS=$(echo "$ANALYZER_INPUT" | python3 "$ANALYZER" --json --check-exploits 2>/dev/null); then
|
||||
# Extract exploitability fields
|
||||
EXPL_SCORE=$(echo "$ANALYSIS" | jq -r '.exploitability_score // "unknown"')
|
||||
EXPL_RATIONALE=$(echo "$ANALYSIS" | jq -r '.exploitability_rationale // "No rationale available"')
|
||||
|
||||
# Update advisory in working feed
|
||||
jq --arg id "$CVE_ID" \
|
||||
--arg score "$EXPL_SCORE" \
|
||||
--arg rationale "$EXPL_RATIONALE" \
|
||||
'(.advisories[] | select(.id == $id)) |= (. + {
|
||||
exploitability_score: $score,
|
||||
exploitability_rationale: $rationale
|
||||
})' "$TEMP_DIR/feed_working.json" > "$TEMP_DIR/feed_updated.json"
|
||||
|
||||
mv "$TEMP_DIR/feed_updated.json" "$TEMP_DIR/feed_working.json"
|
||||
|
||||
echo "✓ $EXPL_SCORE"
|
||||
PROCESSED=$((PROCESSED + 1))
|
||||
else
|
||||
echo "✗ Failed"
|
||||
FAILED=$((FAILED + 1))
|
||||
fi
|
||||
done < <(jq -c '.[]' "$TEMP_DIR/missing_exploitability.json")
|
||||
|
||||
# Check if loop executed successfully
|
||||
if [ ! -f "$TEMP_DIR/feed_working.json" ]; then
|
||||
echo "Error: Feed processing failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Processing Complete ==="
|
||||
echo "Processed: $PROCESSED"
|
||||
echo "Failed: $FAILED"
|
||||
echo ""
|
||||
|
||||
# Write updated feed
|
||||
echo "Writing updated feed to: $FEED_PATH"
|
||||
cp "$TEMP_DIR/feed_working.json" "$FEED_PATH"
|
||||
|
||||
# Update feed version and timestamp
|
||||
CURRENT_VERSION=$(jq -r '.version' "$FEED_PATH")
|
||||
UPDATED_TS=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
|
||||
jq --arg ts "$UPDATED_TS" '.updated = $ts' "$FEED_PATH" > "$TEMP_DIR/feed_final.json"
|
||||
mv "$TEMP_DIR/feed_final.json" "$FEED_PATH"
|
||||
|
||||
echo "✓ Updated feed version: $CURRENT_VERSION"
|
||||
echo "✓ Updated timestamp: $UPDATED_TS"
|
||||
echo ""
|
||||
|
||||
if [ "$REQUIRE_SIGNING" = "true" ]; then
|
||||
echo ""
|
||||
echo "=== Re-signing Advisory Feed ==="
|
||||
|
||||
if [ -f "${FEED_PATH}.sig" ]; then
|
||||
if ! sign_and_verify_feed_signature "$FEED_PATH" "${FEED_PATH}.sig"; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Summary ==="
|
||||
echo "✓ Backfill complete!"
|
||||
echo "✓ $PROCESSED advisories updated with exploitability scores"
|
||||
|
||||
if [ "$FAILED" -gt 0 ]; then
|
||||
echo "⚠ $FAILED advisories failed analysis (kept original data)"
|
||||
fi
|
||||
|
||||
# Verify final state
|
||||
FINAL_MISSING=$(jq '.advisories | map(select(.exploitability_score == null or .exploitability_score == "")) | length' "$FEED_PATH")
|
||||
echo "✓ Advisories still missing exploitability: $FINAL_MISSING"
|
||||
@@ -1,263 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
scripts/ci/enrich_exploitability.sh --mode single|batch --input <path> --output <path> [--cvss-vectors <path>] [--analyzer <path>]
|
||||
|
||||
Options:
|
||||
--mode Processing mode: single advisory object or batch advisory array
|
||||
--input Input JSON path
|
||||
--output Output JSON path
|
||||
--cvss-vectors Optional JSON object mapping advisory id -> CVSS vector
|
||||
--analyzer Optional analyzer path (default: utils/analyze_exploitability.py)
|
||||
--help Show this help
|
||||
EOF
|
||||
}
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
MODE=""
|
||||
INPUT_PATH=""
|
||||
OUTPUT_PATH=""
|
||||
CVSS_VECTORS_PATH=""
|
||||
ANALYZER_PATH="utils/analyze_exploitability.py"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--mode)
|
||||
MODE="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--input)
|
||||
INPUT_PATH="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--output)
|
||||
OUTPUT_PATH="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--cvss-vectors)
|
||||
CVSS_VECTORS_PATH="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--analyzer)
|
||||
ANALYZER_PATH="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--help|-h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "$MODE" != "single" && "$MODE" != "batch" ]]; then
|
||||
echo "ERROR: --mode must be one of: single, batch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$INPUT_PATH" || -z "$OUTPUT_PATH" ]]; then
|
||||
echo "ERROR: --input and --output are required" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$INPUT_PATH" ]]; then
|
||||
echo "ERROR: input file not found: $INPUT_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$ANALYZER_PATH" ]]; then
|
||||
echo "ERROR: analyzer file not found: $ANALYZER_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n "$CVSS_VECTORS_PATH" && ! -f "$CVSS_VECTORS_PATH" ]]; then
|
||||
echo "ERROR: --cvss-vectors file not found: $CVSS_VECTORS_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v jq >/dev/null 2>&1; then
|
||||
echo "ERROR: jq is required" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if command -v python >/dev/null 2>&1; then
|
||||
PYTHON_BIN="python"
|
||||
elif command -v python3 >/dev/null 2>&1; then
|
||||
PYTHON_BIN="python3"
|
||||
else
|
||||
echo "ERROR: python or python3 is required" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tmpdir="$(mktemp -d)"
|
||||
trap 'rm -rf "$tmpdir"' EXIT
|
||||
|
||||
resolve_cvss_vector() {
|
||||
local advisory_json="$1"
|
||||
local advisory_id
|
||||
advisory_id="$(echo "$advisory_json" | jq -r '.id // ""')"
|
||||
|
||||
if [[ -n "$CVSS_VECTORS_PATH" ]]; then
|
||||
jq -r --arg id "$advisory_id" '.[$id] // ""' "$CVSS_VECTORS_PATH"
|
||||
else
|
||||
echo "$advisory_json" | jq -r '.cvss_vector // ""'
|
||||
fi
|
||||
}
|
||||
|
||||
severity_to_cvss() {
|
||||
case "$1" in
|
||||
critical) echo "9.5" ;;
|
||||
high) echo "7.5" ;;
|
||||
medium) echo "5.5" ;;
|
||||
low) echo "3.0" ;;
|
||||
*) echo "5.0" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
build_analysis_input() {
|
||||
local advisory_json="$1"
|
||||
local mode="$2"
|
||||
local cve_id cvss_score cvss_vector vuln_type description references severity
|
||||
|
||||
cve_id="$(echo "$advisory_json" | jq -r '.id // ""')"
|
||||
vuln_type="$(echo "$advisory_json" | jq -r '.type // ""')"
|
||||
description="$(echo "$advisory_json" | jq -r '.description // ""')"
|
||||
references="$(echo "$advisory_json" | jq -c '.references // []')"
|
||||
cvss_vector="$(resolve_cvss_vector "$advisory_json")"
|
||||
|
||||
if [[ "$mode" == "single" ]]; then
|
||||
severity="$(echo "$advisory_json" | jq -r '.severity // "medium"')"
|
||||
cvss_score="$(severity_to_cvss "$severity")"
|
||||
else
|
||||
cvss_score="$(echo "$advisory_json" | jq -r '.cvss_score // 0')"
|
||||
fi
|
||||
|
||||
jq -n \
|
||||
--arg cve_id "$cve_id" \
|
||||
--argjson cvss_score "$cvss_score" \
|
||||
--arg cvss_vector "$cvss_vector" \
|
||||
--arg type "$vuln_type" \
|
||||
--arg description "$description" \
|
||||
--argjson references "$references" \
|
||||
'{
|
||||
cve_id: $cve_id,
|
||||
cvss_score: $cvss_score,
|
||||
cvss_vector: $cvss_vector,
|
||||
type: $type,
|
||||
description: $description,
|
||||
references: $references
|
||||
}'
|
||||
}
|
||||
|
||||
run_analysis() {
|
||||
local advisory_json="$1"
|
||||
local mode="$2"
|
||||
local output_file="$3"
|
||||
local advisory_id analysis_input analysis
|
||||
|
||||
advisory_id="$(echo "$advisory_json" | jq -r '.id // "unknown"')"
|
||||
analysis_input="$(build_analysis_input "$advisory_json" "$mode")"
|
||||
|
||||
if analysis="$(echo "$analysis_input" | "$PYTHON_BIN" "$ANALYZER_PATH" --json --check-exploits 2>/dev/null)"; then
|
||||
echo "$analysis" > "$output_file"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "::warning::Failed to analyze exploitability for $advisory_id, continuing without enrichment"
|
||||
return 1
|
||||
}
|
||||
|
||||
enrich_single() {
|
||||
if ! jq -e 'type == "object"' "$INPUT_PATH" >/dev/null; then
|
||||
echo "ERROR: single mode expects JSON object at $INPUT_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local advisory analysis_file output_tmp
|
||||
advisory="$(cat "$INPUT_PATH")"
|
||||
analysis_file="$tmpdir/analysis_single.json"
|
||||
output_tmp="$tmpdir/output_single.json"
|
||||
|
||||
if run_analysis "$advisory" "single" "$analysis_file"; then
|
||||
jq --slurpfile analysis "$analysis_file" '
|
||||
. + {
|
||||
exploitability_score: $analysis[0].exploitability_score,
|
||||
exploitability_rationale: $analysis[0].exploitability_rationale,
|
||||
attack_vector_analysis: $analysis[0].attack_vector_analysis,
|
||||
exploit_detection: $analysis[0].exploit_detection
|
||||
}
|
||||
' "$INPUT_PATH" > "$output_tmp"
|
||||
else
|
||||
cp "$INPUT_PATH" "$output_tmp"
|
||||
fi
|
||||
|
||||
mv "$output_tmp" "$OUTPUT_PATH"
|
||||
echo "Exploitability enrichment complete (single): $OUTPUT_PATH"
|
||||
}
|
||||
|
||||
enrich_batch() {
|
||||
if ! jq -e 'type == "array"' "$INPUT_PATH" >/dev/null; then
|
||||
echo "ERROR: batch mode expects JSON array at $INPUT_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local analyzed_count failed_count index advisory analysis_file output_tmp analyses_json
|
||||
analyzed_count=0
|
||||
failed_count=0
|
||||
index=0
|
||||
analyses_json="$tmpdir/analyses.json"
|
||||
output_tmp="$tmpdir/output_batch.json"
|
||||
|
||||
while IFS= read -r advisory; do
|
||||
analysis_file="$tmpdir/analysis_${index}.json"
|
||||
if run_analysis "$advisory" "batch" "$analysis_file"; then
|
||||
analyzed_count=$((analyzed_count + 1))
|
||||
else
|
||||
failed_count=$((failed_count + 1))
|
||||
rm -f "$analysis_file"
|
||||
fi
|
||||
index=$((index + 1))
|
||||
done < <(jq -c '.[]' "$INPUT_PATH")
|
||||
|
||||
if ls "$tmpdir"/analysis_*.json >/dev/null 2>&1; then
|
||||
jq -s '.' "$tmpdir"/analysis_*.json > "$analyses_json"
|
||||
else
|
||||
echo '[]' > "$analyses_json"
|
||||
fi
|
||||
|
||||
jq --slurpfile analyses "$analyses_json" '
|
||||
map(
|
||||
. as $advisory |
|
||||
($analyses[0] | map(select(.cve_id == $advisory.id)) | first) as $analysis |
|
||||
if $analysis then
|
||||
$advisory + {
|
||||
exploitability_score: $analysis.exploitability_score,
|
||||
exploitability_rationale: $analysis.exploitability_rationale,
|
||||
attack_vector_analysis: $analysis.attack_vector_analysis,
|
||||
exploit_detection: $analysis.exploit_detection
|
||||
}
|
||||
else
|
||||
$advisory
|
||||
end
|
||||
)
|
||||
' "$INPUT_PATH" > "$output_tmp"
|
||||
|
||||
mv "$output_tmp" "$OUTPUT_PATH"
|
||||
echo "Exploitability enrichment complete (batch): $OUTPUT_PATH"
|
||||
echo "Analyzed: $analyzed_count, failed: $failed_count"
|
||||
}
|
||||
|
||||
if [[ "$MODE" == "single" ]]; then
|
||||
enrich_single
|
||||
else
|
||||
enrich_batch
|
||||
fi
|
||||
@@ -1,73 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
SKILL_MD="skills/clawsec-suite/SKILL.md"
|
||||
CANONICAL_KEYS=(
|
||||
"clawsec-signing-public.pem"
|
||||
"advisories/feed-signing-public.pem"
|
||||
"skills/clawsec-suite/advisories/feed-signing-public.pem"
|
||||
)
|
||||
|
||||
fingerprint_for_pem() {
|
||||
local pem_file="$1"
|
||||
openssl pkey -pubin -in "$pem_file" -outform DER | shasum -a 256 | awk '{print $1}'
|
||||
}
|
||||
|
||||
if [[ ! -f "$SKILL_MD" ]]; then
|
||||
echo "ERROR: missing $SKILL_MD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DOC_EXPECTED_FPR="$(awk -F'"' '/RELEASE_PUBKEY_SHA256=/{print $2; exit}' "$SKILL_MD")"
|
||||
if [[ -z "$DOC_EXPECTED_FPR" ]]; then
|
||||
echo "ERROR: could not parse RELEASE_PUBKEY_SHA256 from $SKILL_MD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TMP_DOC_KEY="$(mktemp)"
|
||||
trap 'rm -f "$TMP_DOC_KEY"' EXIT
|
||||
awk '
|
||||
/-----BEGIN PUBLIC KEY-----/ {in_key=1}
|
||||
in_key {print}
|
||||
/-----END PUBLIC KEY-----/ {exit}
|
||||
' "$SKILL_MD" > "$TMP_DOC_KEY"
|
||||
|
||||
if ! grep -q "BEGIN PUBLIC KEY" "$TMP_DOC_KEY"; then
|
||||
echo "ERROR: could not extract inline public key from $SKILL_MD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DOC_INLINE_FPR="$(fingerprint_for_pem "$TMP_DOC_KEY")"
|
||||
|
||||
if [[ "$DOC_INLINE_FPR" != "$DOC_EXPECTED_FPR" ]]; then
|
||||
echo "ERROR: SKILL.md mismatch: inline key fingerprint ($DOC_INLINE_FPR) != RELEASE_PUBKEY_SHA256 ($DOC_EXPECTED_FPR)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "SKILL.md inline key fingerprint matches RELEASE_PUBKEY_SHA256: $DOC_EXPECTED_FPR"
|
||||
|
||||
CANONICAL_FPR=""
|
||||
for key_file in "${CANONICAL_KEYS[@]}"; do
|
||||
if [[ ! -f "$key_file" ]]; then
|
||||
echo "ERROR: missing canonical key file: $key_file" >&2
|
||||
exit 1
|
||||
fi
|
||||
fpr="$(fingerprint_for_pem "$key_file")"
|
||||
echo "$key_file -> $fpr"
|
||||
if [[ -z "$CANONICAL_FPR" ]]; then
|
||||
CANONICAL_FPR="$fpr"
|
||||
elif [[ "$fpr" != "$CANONICAL_FPR" ]]; then
|
||||
echo "ERROR: key fingerprint mismatch among canonical pem files" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$CANONICAL_FPR" != "$DOC_EXPECTED_FPR" ]]; then
|
||||
echo "ERROR: canonical pem fingerprint ($CANONICAL_FPR) != SKILL.md RELEASE_PUBKEY_SHA256 ($DOC_EXPECTED_FPR)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "All signing key references are consistent: $CANONICAL_FPR"
|
||||
@@ -1,37 +0,0 @@
|
||||
#!/bin/bash
|
||||
# feed-utils.sh
|
||||
# Shared advisory feed path and sync helpers for local/maintenance scripts.
|
||||
|
||||
init_feed_paths() {
|
||||
local project_root="$1"
|
||||
|
||||
: "${FEED_PATH:=$project_root/advisories/feed.json}"
|
||||
: "${SKILL_FEED_PATH:=$project_root/skills/clawsec-feed/advisories/feed.json}"
|
||||
: "${PUBLIC_FEED_PATH:=$project_root/public/advisories/feed.json}"
|
||||
}
|
||||
|
||||
sync_feed_to_mirrors() {
|
||||
local source_feed="$1"
|
||||
local mode="${2:-create}"
|
||||
|
||||
local target
|
||||
for target in "$SKILL_FEED_PATH" "$PUBLIC_FEED_PATH"; do
|
||||
case "$mode" in
|
||||
create)
|
||||
mkdir -p "$(dirname "$target")"
|
||||
cp "$source_feed" "$target"
|
||||
echo "✓ Updated: $target"
|
||||
;;
|
||||
existing-only)
|
||||
if [ -f "$target" ]; then
|
||||
cp "$source_feed" "$target"
|
||||
echo "✓ Updated: $target"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Error: unsupported mirror sync mode: $mode" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { promises as fs } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import {
|
||||
extractTitleFromMarkdown,
|
||||
stripFrontmatter,
|
||||
} from '../utils/markdownHelpers.mjs';
|
||||
import {
|
||||
isWikiIndexSlug,
|
||||
toWikiLlmsPath,
|
||||
toWikiRoute,
|
||||
} from '../utils/wikiPathHelpers.mjs';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const REPO_ROOT = path.resolve(__dirname, '..');
|
||||
const WIKI_ROOT = path.join(REPO_ROOT, 'wiki');
|
||||
const PUBLIC_WIKI_ROOT = path.join(REPO_ROOT, 'public', 'wiki');
|
||||
const LLM_INDEX_FILE = path.join(PUBLIC_WIKI_ROOT, 'llms.txt');
|
||||
|
||||
const WEBSITE_BASE = 'https://clawsec.prompt.security';
|
||||
const REPO_BASE = 'https://github.com/prompt-security/clawsec';
|
||||
const RAW_BASE = 'https://raw.githubusercontent.com/prompt-security/clawsec/main';
|
||||
|
||||
const toPosix = (inputPath) => inputPath.split(path.sep).join('/');
|
||||
const toLlmsPageUrl = (slug) => `${WEBSITE_BASE}${toWikiLlmsPath(slug)}`;
|
||||
|
||||
const walkMarkdownFiles = async (dir) => {
|
||||
const entries = await fs.readdir(dir, { withFileTypes: true });
|
||||
const files = [];
|
||||
|
||||
for (const entry of entries) {
|
||||
const fullPath = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
const nested = await walkMarkdownFiles(fullPath);
|
||||
files.push(...nested);
|
||||
continue;
|
||||
}
|
||||
if (entry.isFile() && entry.name.toLowerCase().endsWith('.md')) {
|
||||
files.push(fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
};
|
||||
|
||||
const sortDocs = (a, b) => {
|
||||
if (a.slug === 'index' && b.slug !== 'index') return -1;
|
||||
if (a.slug !== 'index' && b.slug === 'index') return 1;
|
||||
return a.slug.localeCompare(b.slug, 'en', { sensitivity: 'base' });
|
||||
};
|
||||
|
||||
const buildPageBody = (doc) => {
|
||||
const pageRoute = toWikiRoute(doc.slug);
|
||||
const pageUrl = `${WEBSITE_BASE}/#${pageRoute}`;
|
||||
const sourceUrl = `${RAW_BASE}/wiki/${doc.relativePath}`;
|
||||
const llmsUrl = toLlmsPageUrl(doc.slug);
|
||||
|
||||
return [
|
||||
`# ClawSec Wiki · ${doc.title}`,
|
||||
'',
|
||||
'LLM-ready export for a single wiki page.',
|
||||
'',
|
||||
'## Canonical',
|
||||
`- Wiki page: ${pageUrl}`,
|
||||
`- LLM export: ${llmsUrl}`,
|
||||
`- Source markdown: ${sourceUrl}`,
|
||||
'',
|
||||
'## Markdown',
|
||||
'',
|
||||
doc.content.trim(),
|
||||
'',
|
||||
].join('\n');
|
||||
};
|
||||
|
||||
const buildFallbackIndexBody = (docs) => {
|
||||
const lines = [
|
||||
'# ClawSec Wiki llms.txt',
|
||||
'',
|
||||
'LLM-readable index for wiki pages.',
|
||||
'',
|
||||
`Website wiki root: ${WEBSITE_BASE}/#/wiki`,
|
||||
`GitHub wiki mirror: ${REPO_BASE}/wiki`,
|
||||
`Canonical source of truth: ${REPO_BASE}/tree/main/wiki`,
|
||||
'',
|
||||
'## Generated Page Exports',
|
||||
];
|
||||
|
||||
for (const doc of docs) {
|
||||
const pageRoute = toWikiRoute(doc.slug);
|
||||
const pageUrl = `${WEBSITE_BASE}/#${pageRoute}`;
|
||||
const llmsUrl = toLlmsPageUrl(doc.slug);
|
||||
lines.push(`- ${doc.title}: ${llmsUrl} (page: ${pageUrl})`);
|
||||
}
|
||||
|
||||
return `${lines.join('\n')}\n`;
|
||||
};
|
||||
|
||||
const main = async () => {
|
||||
try {
|
||||
const wikiStat = await fs.stat(WIKI_ROOT).catch(() => null);
|
||||
if (!wikiStat || !wikiStat.isDirectory()) {
|
||||
throw new Error('wiki/ directory not found.');
|
||||
}
|
||||
|
||||
const markdownFiles = await walkMarkdownFiles(WIKI_ROOT);
|
||||
const docs = [];
|
||||
|
||||
for (const fullPath of markdownFiles) {
|
||||
const relativePath = toPosix(path.relative(WIKI_ROOT, fullPath));
|
||||
const slug = relativePath.replace(/\.md$/i, '').toLowerCase();
|
||||
const rawContent = await fs.readFile(fullPath, 'utf8');
|
||||
const content = stripFrontmatter(rawContent);
|
||||
const title = extractTitleFromMarkdown(rawContent, relativePath);
|
||||
docs.push({ relativePath, slug, title, content });
|
||||
}
|
||||
|
||||
docs.sort(sortDocs);
|
||||
const pageDocs = docs.filter((doc) => !isWikiIndexSlug(doc.slug));
|
||||
const indexDoc = docs.find((doc) => isWikiIndexSlug(doc.slug));
|
||||
|
||||
// `public/wiki/` is fully generated; wipe stale output before regenerating.
|
||||
await fs.rm(PUBLIC_WIKI_ROOT, { recursive: true, force: true });
|
||||
await fs.mkdir(PUBLIC_WIKI_ROOT, { recursive: true });
|
||||
|
||||
for (const doc of pageDocs) {
|
||||
const outputFile = path.join(PUBLIC_WIKI_ROOT, doc.slug, 'llms.txt');
|
||||
await fs.mkdir(path.dirname(outputFile), { recursive: true });
|
||||
await fs.writeFile(outputFile, buildPageBody(doc), 'utf8');
|
||||
}
|
||||
|
||||
const indexBody = indexDoc ? buildPageBody(indexDoc) : buildFallbackIndexBody(pageDocs);
|
||||
await fs.writeFile(LLM_INDEX_FILE, indexBody, 'utf8');
|
||||
|
||||
// Keep logs short for CI readability.
|
||||
console.log(`Generated ${pageDocs.length} page llms.txt exports and /wiki/llms.txt`);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
console.error(`Failed to generate wiki llms exports: ${message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
await main();
|
||||
@@ -1,386 +0,0 @@
|
||||
#!/bin/bash
|
||||
# populate-local-feed.sh
|
||||
# Polls NVD API for real CVE data and populates local advisory feed for development preview.
|
||||
# This mirrors the GitHub Actions pipeline logic exactly.
|
||||
#
|
||||
# Usage: ./scripts/populate-local-feed.sh [--days N] [--force]
|
||||
# --days N Look back N days (default: 120)
|
||||
# --force Ignore existing advisories and fetch all
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
# shellcheck source=./feed-utils.sh
|
||||
source "$SCRIPT_DIR/feed-utils.sh"
|
||||
|
||||
# Configuration - same as pipeline
|
||||
init_feed_paths "$PROJECT_ROOT"
|
||||
KEYWORDS="OpenClaw clawdbot Moltbot NanoClaw WhatsApp-bot baileys"
|
||||
GITHUB_REF_PATTERN="github.com/openclaw/openclaw github.com/qwibitai/NanoClaw"
|
||||
ENRICH_SCRIPT="$PROJECT_ROOT/scripts/ci/enrich_exploitability.sh"
|
||||
|
||||
# Parse args
|
||||
DAYS_BACK=120
|
||||
FORCE=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--days)
|
||||
DAYS_BACK="$2"
|
||||
shift 2
|
||||
;;
|
||||
--force)
|
||||
FORCE=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "=== ClawSec Local Feed Populator ==="
|
||||
echo "Project root: $PROJECT_ROOT"
|
||||
echo "Days back: $DAYS_BACK"
|
||||
echo "Force mode: $FORCE"
|
||||
echo ""
|
||||
|
||||
# Verify enrichment helper exists (it validates Python/analyzer prerequisites internally).
|
||||
if [ ! -x "$ENRICH_SCRIPT" ]; then
|
||||
echo "Error: Exploitability enrichment helper not found or not executable: $ENRICH_SCRIPT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create temp directory
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
trap 'rm -rf "$TEMP_DIR"' EXIT
|
||||
|
||||
# Determine date window
|
||||
if [ -f "$FEED_PATH" ] && [ "$FORCE" = "false" ]; then
|
||||
LAST_UPDATED=$(jq -r '.updated // empty' "$FEED_PATH")
|
||||
if [ -n "$LAST_UPDATED" ]; then
|
||||
START_DATE="$LAST_UPDATED"
|
||||
echo "Using last updated from feed: $START_DATE"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "${START_DATE:-}" ]; then
|
||||
# macOS vs Linux date compatibility
|
||||
if date -v-1d > /dev/null 2>&1; then
|
||||
START_DATE=$(date -u -v-"${DAYS_BACK}"d +%Y-%m-%dT%H:%M:%S.000Z)
|
||||
else
|
||||
START_DATE=$(date -u -d "${DAYS_BACK} days ago" +%Y-%m-%dT%H:%M:%S.000Z)
|
||||
fi
|
||||
echo "Using default start date: $START_DATE"
|
||||
fi
|
||||
|
||||
END_DATE=$(date -u +%Y-%m-%dT%H:%M:%S.000Z)
|
||||
echo "End date: $END_DATE"
|
||||
echo ""
|
||||
|
||||
# URL encode dates
|
||||
START_ENC=${START_DATE//:/%3A}
|
||||
END_ENC=${END_DATE//:/%3A}
|
||||
|
||||
echo "=== Fetching CVEs from NVD ==="
|
||||
|
||||
for KEYWORD in $KEYWORDS; do
|
||||
echo "Fetching keyword: $KEYWORD"
|
||||
|
||||
URL="https://services.nvd.nist.gov/rest/json/cves/2.0?keywordSearch=${KEYWORD}&lastModStartDate=${START_ENC}&lastModEndDate=${END_ENC}"
|
||||
|
||||
# Fetch with retry logic
|
||||
for i in 1 2 3; do
|
||||
HTTP_CODE=$(curl -s -w "%{http_code}" -o "$TEMP_DIR/nvd_${KEYWORD}.json" "$URL")
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
COUNT=$(jq '.vulnerabilities | length // 0' "$TEMP_DIR/nvd_${KEYWORD}.json" 2>/dev/null || echo 0)
|
||||
echo " ✓ Found $COUNT CVEs"
|
||||
break
|
||||
elif [ "$HTTP_CODE" = "403" ] || [ "$HTTP_CODE" = "429" ]; then
|
||||
echo " Rate limited, waiting 30s before retry $i..."
|
||||
sleep 30
|
||||
else
|
||||
echo " HTTP $HTTP_CODE, retry $i..."
|
||||
sleep 5
|
||||
fi
|
||||
done
|
||||
|
||||
# NVD recommends 6 second delay between requests
|
||||
echo " Waiting 6s (NVD rate limit)..."
|
||||
sleep 6
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "=== Processing CVEs ==="
|
||||
|
||||
# Combine all fetched CVEs
|
||||
echo '{"vulnerabilities":[]}' > "$TEMP_DIR/combined.json"
|
||||
|
||||
for KEYWORD in $KEYWORDS; do
|
||||
FILE="$TEMP_DIR/nvd_${KEYWORD}.json"
|
||||
if [ -f "$FILE" ] && [ -s "$FILE" ]; then
|
||||
if jq -e '.vulnerabilities' "$FILE" > /dev/null 2>&1; then
|
||||
jq -s '.[0].vulnerabilities += .[1].vulnerabilities | .[0]' \
|
||||
"$TEMP_DIR/combined.json" "$FILE" > "$TEMP_DIR/combined_new.json"
|
||||
mv "$TEMP_DIR/combined_new.json" "$TEMP_DIR/combined.json"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Deduplicate by CVE ID
|
||||
jq '.vulnerabilities | unique_by(.cve.id)' "$TEMP_DIR/combined.json" > "$TEMP_DIR/unique_cves.json"
|
||||
TOTAL=$(jq 'length' "$TEMP_DIR/unique_cves.json")
|
||||
echo "Total unique CVEs from NVD: $TOTAL"
|
||||
|
||||
# Post-filter: keep only CVEs matching our criteria
|
||||
KEYWORDS_PATTERN="OpenClaw|clawdbot|Moltbot|openclaw|NanoClaw|nanoclaw|WhatsApp-bot|baileys"
|
||||
|
||||
jq --arg kw "$KEYWORDS_PATTERN" --arg gh "$GITHUB_REF_PATTERN" '
|
||||
[.[] | select(
|
||||
(.cve.descriptions[]? | select(.lang == "en") | .value | test($kw; "i"))
|
||||
or
|
||||
(.cve.references[]? | .url | test($gh; "i"))
|
||||
)]
|
||||
' "$TEMP_DIR/unique_cves.json" > "$TEMP_DIR/filtered_cves.json"
|
||||
|
||||
FILTERED=$(jq 'length' "$TEMP_DIR/filtered_cves.json")
|
||||
echo "Filtered CVEs (matching criteria): $FILTERED"
|
||||
|
||||
# Get existing advisory IDs (unless force mode)
|
||||
if [ "$FORCE" = "true" ]; then
|
||||
echo "Force mode: ignoring existing advisory IDs during transform"
|
||||
EXISTING_IDS=""
|
||||
elif [ -f "$FEED_PATH" ]; then
|
||||
EXISTING_IDS=$(jq -r '.advisories[]?.id // empty' "$FEED_PATH" | sort -u)
|
||||
else
|
||||
EXISTING_IDS=""
|
||||
fi
|
||||
|
||||
# Transform CVEs to our advisory format (same logic as pipeline)
|
||||
EXISTING_JSON=$(echo "$EXISTING_IDS" | jq -R -s 'split("\n") | map(select(length > 0))')
|
||||
|
||||
jq --argjson existing "$EXISTING_JSON" '
|
||||
def map_severity:
|
||||
if . == null then "medium"
|
||||
elif . >= 9.0 then "critical"
|
||||
elif . >= 7.0 then "high"
|
||||
elif . >= 4.0 then "medium"
|
||||
else "low"
|
||||
end;
|
||||
|
||||
def get_cvss_score:
|
||||
.cve.metrics.cvssMetricV31[0]?.cvssData.baseScore //
|
||||
.cve.metrics.cvssMetricV30[0]?.cvssData.baseScore //
|
||||
.cve.metrics.cvssMetricV2[0]?.cvssData.baseScore //
|
||||
null;
|
||||
|
||||
def nvd_category_raw:
|
||||
(
|
||||
[.cve.weaknesses[]?.description[]? | select(.lang == "en") | .value | strings | select(length > 0)]
|
||||
| unique
|
||||
| map(select(. != "NVD-CWE-noinfo" and . != "NVD-CWE-Other"))
|
||||
| .[0]
|
||||
);
|
||||
|
||||
def cwe_id:
|
||||
(
|
||||
nvd_category_raw
|
||||
| if . == null then null
|
||||
else (try (capture("^CWE-(?<id>[0-9]+)$").id) catch null)
|
||||
end
|
||||
);
|
||||
|
||||
def cwe_name_map($id):
|
||||
({
|
||||
"20": "improper_input_validation",
|
||||
"22": "path_traversal",
|
||||
"77": "command_injection",
|
||||
"78": "os_command_injection",
|
||||
"79": "cross_site_scripting",
|
||||
"89": "sql_injection",
|
||||
"94": "code_injection",
|
||||
"119": "memory_buffer_bounds_violation",
|
||||
"120": "classic_buffer_overflow",
|
||||
"125": "out_of_bounds_read",
|
||||
"134": "format_string_vulnerability",
|
||||
"200": "exposure_of_sensitive_information",
|
||||
"250": "execution_with_unnecessary_privileges",
|
||||
"269": "improper_privilege_management",
|
||||
"284": "improper_access_control",
|
||||
"285": "improper_authorization",
|
||||
"287": "improper_authentication",
|
||||
"295": "improper_certificate_validation",
|
||||
"306": "missing_authentication_for_critical_function",
|
||||
"319": "cleartext_transmission_of_sensitive_information",
|
||||
"326": "inadequate_encryption_strength",
|
||||
"327": "risky_cryptographic_algorithm",
|
||||
"352": "cross_site_request_forgery",
|
||||
"362": "race_condition",
|
||||
"400": "uncontrolled_resource_consumption",
|
||||
"416": "use_after_free",
|
||||
"434": "unrestricted_file_upload",
|
||||
"502": "deserialization_of_untrusted_data",
|
||||
"601": "open_redirect",
|
||||
"611": "xml_external_entity_injection",
|
||||
"639": "insecure_direct_object_reference",
|
||||
"668": "exposure_of_resource_to_wrong_sphere",
|
||||
"669": "incorrect_resource_transfer_between_spheres",
|
||||
"732": "incorrect_permission_assignment",
|
||||
"787": "out_of_bounds_write",
|
||||
"798": "hard_coded_credentials",
|
||||
"862": "missing_authorization",
|
||||
"863": "incorrect_authorization",
|
||||
"918": "server_side_request_forgery",
|
||||
"922": "insecure_storage_of_sensitive_information"
|
||||
}[$id]);
|
||||
|
||||
def nvd_category_name:
|
||||
(
|
||||
cwe_id as $id
|
||||
| if $id == null then "unspecified_weakness"
|
||||
else (cwe_name_map($id) // ("unknown_cwe_" + $id))
|
||||
end
|
||||
);
|
||||
|
||||
def cpe_criteria:
|
||||
(
|
||||
[.cve.configurations[]? | .. | objects | .criteria? | strings | select(startswith("cpe:2.3:"))]
|
||||
| unique
|
||||
);
|
||||
|
||||
def inferred_targets:
|
||||
(
|
||||
(
|
||||
[
|
||||
(.cve.descriptions[]? | select(.lang == "en") | .value),
|
||||
(.cve.references[]?.url // empty)
|
||||
]
|
||||
| map(strings | ascii_downcase)
|
||||
| join(" ")
|
||||
) as $blob
|
||||
| (
|
||||
(if ($blob | test("github\\.com/openclaw/openclaw|\\bopenclaw\\b|\\bclawdbot\\b|\\bmoltbot\\b")) then ["openclaw@*"] else [] end)
|
||||
+ (if ($blob | test("github\\.com/qwibitai/nanoclaw|\\bnanoclaw\\b|whatsapp-bot|\\bbaileys\\b")) then ["nanoclaw@*"] else [] end)
|
||||
)
|
||||
);
|
||||
|
||||
def normalized_affected:
|
||||
(
|
||||
(cpe_criteria + inferred_targets)
|
||||
| unique
|
||||
| .[0:5]
|
||||
| if length == 0 then ["openclaw@*", "nanoclaw@*"] else . end
|
||||
);
|
||||
|
||||
[.[] |
|
||||
select(.cve.id as $id | $existing | index($id) | not) |
|
||||
{
|
||||
id: .cve.id,
|
||||
severity: (get_cvss_score | map_severity),
|
||||
type: nvd_category_name,
|
||||
nvd_category_id: nvd_category_raw,
|
||||
title: (.cve.descriptions[] | select(.lang == "en") | .value | .[0:100] + (if length > 100 then "..." else "" end)),
|
||||
description: (.cve.descriptions[] | select(.lang == "en") | .value),
|
||||
affected: normalized_affected,
|
||||
action: "Review and update affected components. See NVD for remediation details.",
|
||||
published: .cve.published,
|
||||
references: [.cve.references[]?.url // empty] | unique | .[0:3],
|
||||
cvss_score: get_cvss_score,
|
||||
nvd_url: ("https://nvd.nist.gov/vuln/detail/" + .cve.id),
|
||||
exploitability_score: null,
|
||||
exploitability_rationale: null
|
||||
}
|
||||
]
|
||||
' "$TEMP_DIR/filtered_cves.json" > "$TEMP_DIR/new_advisories.json"
|
||||
|
||||
NEW_COUNT=$(jq 'length' "$TEMP_DIR/new_advisories.json")
|
||||
echo "New advisories to add: $NEW_COUNT"
|
||||
|
||||
if [ "$NEW_COUNT" -eq 0 ]; then
|
||||
echo ""
|
||||
echo "No new CVEs found. Feed is up to date."
|
||||
echo "Use --force to re-fetch all CVEs regardless of existing entries."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== Analyzing Exploitability ==="
|
||||
|
||||
# Build CVSS vector lookup for enriched analysis inputs.
|
||||
jq '
|
||||
[.[] | {
|
||||
id: .cve.id,
|
||||
cvss_vector: (
|
||||
.cve.metrics.cvssMetricV31[0]?.cvssData.vectorString //
|
||||
.cve.metrics.cvssMetricV30[0]?.cvssData.vectorString //
|
||||
.cve.metrics.cvssMetricV2[0]?.vectorString //
|
||||
""
|
||||
)
|
||||
}] | map({(.id): .cvss_vector}) | add
|
||||
' "$TEMP_DIR/filtered_cves.json" > "$TEMP_DIR/cvss_vectors.json"
|
||||
|
||||
"$ENRICH_SCRIPT" \
|
||||
--mode batch \
|
||||
--input "$TEMP_DIR/new_advisories.json" \
|
||||
--output "$TEMP_DIR/new_advisories.json" \
|
||||
--cvss-vectors "$TEMP_DIR/cvss_vectors.json"
|
||||
|
||||
echo ""
|
||||
echo "=== New Advisories ==="
|
||||
jq -r '.[] | " \(.id) [\(.severity)] - \(.title)"' "$TEMP_DIR/new_advisories.json"
|
||||
|
||||
echo ""
|
||||
echo "=== Updating Feeds ==="
|
||||
|
||||
NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
|
||||
# Merge new advisories into existing feed
|
||||
if [ -f "$FEED_PATH" ]; then
|
||||
jq --argjson new "$(cat "$TEMP_DIR/new_advisories.json")" --arg now "$NOW" '
|
||||
.updated = $now |
|
||||
# Merge by advisory ID so force mode can refresh existing CVEs without duplicates
|
||||
.advisories = (
|
||||
reduce (.advisories + $new)[] as $adv
|
||||
({};
|
||||
if ($adv.id // "") == "" then
|
||||
.
|
||||
else
|
||||
.[$adv.id] = $adv
|
||||
end
|
||||
)
|
||||
| [.[]]
|
||||
| sort_by(.published)
|
||||
| reverse
|
||||
)
|
||||
' "$FEED_PATH" > "$TEMP_DIR/updated_feed.json"
|
||||
else
|
||||
jq -n --argjson advisories "$(cat "$TEMP_DIR/new_advisories.json")" --arg now "$NOW" '{
|
||||
version: "1.0.0",
|
||||
updated: $now,
|
||||
description: "Community-driven security advisory feed for ClawSec. Automatically updated with OpenClaw and NanoClaw-related CVEs from NVD.",
|
||||
advisories: ($advisories | sort_by(.published) | reverse)
|
||||
}' > "$TEMP_DIR/updated_feed.json"
|
||||
fi
|
||||
|
||||
# Validate and save
|
||||
if jq empty "$TEMP_DIR/updated_feed.json" 2>/dev/null; then
|
||||
# Update main feed
|
||||
cp "$TEMP_DIR/updated_feed.json" "$FEED_PATH"
|
||||
echo "✓ Updated: $FEED_PATH"
|
||||
|
||||
# Sync feed mirrors for local skill/public consumers.
|
||||
sync_feed_to_mirrors "$FEED_PATH" "create"
|
||||
|
||||
echo ""
|
||||
TOTAL_ADVISORIES=$(jq '.advisories | length' "$FEED_PATH")
|
||||
echo "=== Summary ==="
|
||||
echo "Total advisories in feed: $TOTAL_ADVISORIES"
|
||||
echo "New advisories added: $NEW_COUNT"
|
||||
echo ""
|
||||
echo "Run 'npm run dev' to preview the feed in the local site."
|
||||
else
|
||||
echo "Error: Generated invalid JSON"
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,207 +0,0 @@
|
||||
#!/bin/bash
|
||||
# populate-local-skills.sh
|
||||
# Builds local skills index from skills/ directory for development preview.
|
||||
# This mirrors the skill-release.yml pipeline exactly - generates real checksums.
|
||||
#
|
||||
# Usage: ./scripts/populate-local-skills.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
PUBLIC_SKILLS_DIR="$PROJECT_ROOT/public/skills"
|
||||
DIST_DIR="$PROJECT_ROOT/dist/skills"
|
||||
|
||||
echo "=== ClawSec Local Skills Populator ==="
|
||||
echo "Project root: $PROJECT_ROOT"
|
||||
echo ""
|
||||
|
||||
# Create directories
|
||||
mkdir -p "$PUBLIC_SKILLS_DIR"
|
||||
mkdir -p "$DIST_DIR"
|
||||
|
||||
# Start building skills index
|
||||
echo '{"version":"1.0.0","updated":"'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'","skills":[' > "$PUBLIC_SKILLS_DIR/index.json"
|
||||
|
||||
FIRST_SKILL=true
|
||||
SKILL_COUNT=0
|
||||
|
||||
echo "=== Discovering Skills ==="
|
||||
|
||||
# Process each skill directory
|
||||
for SKILL_DIR in "$PROJECT_ROOT/skills"/*/; do
|
||||
SKILL_NAME=$(basename "$SKILL_DIR")
|
||||
SKILL_JSON="$SKILL_DIR/skill.json"
|
||||
|
||||
# Skip if no skill.json
|
||||
if [ ! -f "$SKILL_JSON" ]; then
|
||||
echo "⚠️ Skipping $SKILL_NAME (no skill.json)"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Processing: $SKILL_NAME"
|
||||
|
||||
# Check if internal skill
|
||||
IS_INTERNAL=$(jq -r '.openclaw.internal // false' "$SKILL_JSON")
|
||||
if [ "$IS_INTERNAL" = "true" ]; then
|
||||
echo " ⚠️ Skipping internal skill: $SKILL_NAME"
|
||||
continue
|
||||
fi
|
||||
|
||||
VERSION=$(jq -r '.version' "$SKILL_JSON")
|
||||
TAG="${SKILL_NAME}-v${VERSION}"
|
||||
|
||||
# Create skill directory in public
|
||||
mkdir -p "$PUBLIC_SKILLS_DIR/$SKILL_NAME"
|
||||
|
||||
# Copy skill.json
|
||||
cp "$SKILL_JSON" "$PUBLIC_SKILLS_DIR/$SKILL_NAME/skill.json"
|
||||
echo " ✓ Copied: skill.json"
|
||||
|
||||
# Copy README.md if exists
|
||||
if [ -f "$SKILL_DIR/README.md" ]; then
|
||||
cp "$SKILL_DIR/README.md" "$PUBLIC_SKILLS_DIR/$SKILL_NAME/README.md"
|
||||
echo " ✓ Copied: README.md"
|
||||
fi
|
||||
|
||||
# Copy SBOM markdown docs (SKILL.md, HEARTBEAT.md, etc.) for website display
|
||||
TEMPFILE=$(mktemp)
|
||||
jq -r '.sbom.files[].path' "$SKILL_JSON" > "$TEMPFILE" 2>/dev/null || true
|
||||
|
||||
while IFS= read -r file; do
|
||||
[ -z "$file" ] && continue
|
||||
|
||||
case "$file" in
|
||||
*.md|*.MD)
|
||||
FULL_PATH="$SKILL_DIR/$file"
|
||||
if [ -f "$FULL_PATH" ]; then
|
||||
cp "$FULL_PATH" "$PUBLIC_SKILLS_DIR/$SKILL_NAME/$(basename "$file")"
|
||||
echo " ✓ Copied: $(basename "$file")"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done < "$TEMPFILE"
|
||||
rm -f "$TEMPFILE"
|
||||
|
||||
# === Generate real checksums from SBOM (mirrors skill-release.yml) ===
|
||||
CHECKSUMS_FILE="$PUBLIC_SKILLS_DIR/$SKILL_NAME/checksums.json"
|
||||
|
||||
cat > "$CHECKSUMS_FILE" << EOF
|
||||
{
|
||||
"skill": "$SKILL_NAME",
|
||||
"version": "$VERSION",
|
||||
"generated_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
|
||||
"repository": "prompt-security/ClawSec",
|
||||
"tag": "$TAG",
|
||||
"files": {
|
||||
EOF
|
||||
|
||||
FIRST_FILE=true
|
||||
TEMPFILE=$(mktemp)
|
||||
|
||||
# Get files from SBOM
|
||||
jq -r '.sbom.files[].path' "$SKILL_JSON" > "$TEMPFILE" 2>/dev/null || echo ""
|
||||
|
||||
while IFS= read -r file; do
|
||||
[ -z "$file" ] && continue
|
||||
FULL_PATH="$SKILL_DIR/$file"
|
||||
if [ -f "$FULL_PATH" ]; then
|
||||
# macOS uses shasum, Linux uses sha256sum
|
||||
if command -v sha256sum &> /dev/null; then
|
||||
SHA256=$(sha256sum "$FULL_PATH" | awk '{print $1}')
|
||||
else
|
||||
SHA256=$(shasum -a 256 "$FULL_PATH" | awk '{print $1}')
|
||||
fi
|
||||
|
||||
# macOS vs Linux stat
|
||||
SIZE=$(stat -f%z "$FULL_PATH" 2>/dev/null || stat -c%s "$FULL_PATH")
|
||||
FILENAME=$(basename "$file")
|
||||
|
||||
if [ "$FIRST_FILE" = true ]; then
|
||||
FIRST_FILE=false
|
||||
else
|
||||
echo "," >> "$CHECKSUMS_FILE"
|
||||
fi
|
||||
|
||||
cat >> "$CHECKSUMS_FILE" << FILEENTRY
|
||||
"$FILENAME": {
|
||||
"sha256": "$SHA256",
|
||||
"size": $SIZE,
|
||||
"path": "$file",
|
||||
"url": "https://clawsec.prompt.security/releases/download/$TAG/$FILENAME"
|
||||
}
|
||||
FILEENTRY
|
||||
echo " ✓ Checksum: $FILENAME ($SHA256)"
|
||||
else
|
||||
echo " ⚠️ File not found: $file"
|
||||
fi
|
||||
done < "$TEMPFILE"
|
||||
rm -f "$TEMPFILE"
|
||||
|
||||
# Add skill.json checksum
|
||||
if command -v sha256sum &> /dev/null; then
|
||||
SKILL_JSON_SHA=$(sha256sum "$SKILL_JSON" | awk '{print $1}')
|
||||
else
|
||||
SKILL_JSON_SHA=$(shasum -a 256 "$SKILL_JSON" | awk '{print $1}')
|
||||
fi
|
||||
SKILL_JSON_SIZE=$(stat -f%z "$SKILL_JSON" 2>/dev/null || stat -c%s "$SKILL_JSON")
|
||||
|
||||
if [ "$FIRST_FILE" = false ]; then
|
||||
echo "," >> "$CHECKSUMS_FILE"
|
||||
fi
|
||||
|
||||
cat >> "$CHECKSUMS_FILE" << SKILLJSON
|
||||
"skill.json": {
|
||||
"sha256": "$SKILL_JSON_SHA",
|
||||
"size": $SKILL_JSON_SIZE,
|
||||
"url": "https://clawsec.prompt.security/releases/download/$TAG/skill.json"
|
||||
}
|
||||
SKILLJSON
|
||||
|
||||
# Close checksums JSON
|
||||
cat >> "$CHECKSUMS_FILE" << EOF
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
echo " ✓ Generated: checksums.json"
|
||||
|
||||
# Build skill entry for index
|
||||
SKILL_DATA=$(jq -c --arg tag "$TAG" '{
|
||||
id: .name,
|
||||
name: .name,
|
||||
version: .version,
|
||||
description: .description,
|
||||
emoji: .openclaw.emoji,
|
||||
category: .openclaw.category,
|
||||
tag: $tag
|
||||
}' "$SKILL_JSON")
|
||||
|
||||
# Append to index
|
||||
if [ "$FIRST_SKILL" = "true" ]; then
|
||||
FIRST_SKILL=false
|
||||
else
|
||||
echo "," >> "$PUBLIC_SKILLS_DIR/index.json"
|
||||
fi
|
||||
echo "$SKILL_DATA" >> "$PUBLIC_SKILLS_DIR/index.json"
|
||||
|
||||
SKILL_COUNT=$((SKILL_COUNT + 1))
|
||||
echo " ✓ Added to index"
|
||||
echo ""
|
||||
done
|
||||
|
||||
# Close the JSON array
|
||||
echo ']}' >> "$PUBLIC_SKILLS_DIR/index.json"
|
||||
|
||||
echo "=== Skills Index ==="
|
||||
jq '.' "$PUBLIC_SKILLS_DIR/index.json"
|
||||
|
||||
echo ""
|
||||
echo "=== Summary ==="
|
||||
echo "Total skills indexed: $SKILL_COUNT"
|
||||
echo "Skills directory: $PUBLIC_SKILLS_DIR"
|
||||
echo ""
|
||||
ls -la "$PUBLIC_SKILLS_DIR"/*/
|
||||
echo ""
|
||||
echo "Run 'npm run dev' to preview the skills catalog."
|
||||
@@ -1,31 +0,0 @@
|
||||
#!/bin/bash
|
||||
# populate-local-wiki.sh
|
||||
# Generates wiki-derived public assets for local preview and CI parity.
|
||||
#
|
||||
# Usage: ./scripts/populate-local-wiki.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
WIKI_DIR="$PROJECT_ROOT/wiki"
|
||||
PUBLIC_WIKI_DIR="$PROJECT_ROOT/public/wiki"
|
||||
|
||||
if [ ! -d "$WIKI_DIR" ]; then
|
||||
echo "Error: wiki directory not found at $WIKI_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== ClawSec Local Wiki Populator ==="
|
||||
echo "Project root: $PROJECT_ROOT"
|
||||
|
||||
node "$PROJECT_ROOT/scripts/generate-wiki-llms.mjs"
|
||||
|
||||
PAGE_COUNT=0
|
||||
if [ -d "$PUBLIC_WIKI_DIR" ]; then
|
||||
PAGE_COUNT=$(find "$PUBLIC_WIKI_DIR" -type f -path '*/llms.txt' ! -path "$PUBLIC_WIKI_DIR/llms.txt" | wc -l | tr -d ' ')
|
||||
fi
|
||||
|
||||
echo "Wiki llms index: $PUBLIC_WIKI_DIR/llms.txt"
|
||||
echo "Wiki llms pages: $PAGE_COUNT files under $PUBLIC_WIKI_DIR/<page>/llms.txt"
|
||||
@@ -1,245 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# prepare-to-push.sh - Run all checks before pushing to ensure CI will pass
|
||||
#
|
||||
# Usage: ./scripts/prepare-to-push.sh [--fix]
|
||||
#
|
||||
# Options:
|
||||
# --fix Attempt to auto-fix issues where possible
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Ensure Homebrew tools are in PATH (macOS)
|
||||
if [[ -d "/opt/homebrew/bin" ]]; then
|
||||
export PATH="/opt/homebrew/bin:$PATH"
|
||||
fi
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Track failures
|
||||
FAILURES=0
|
||||
|
||||
# Parse arguments
|
||||
FIX_MODE=false
|
||||
if [[ "${1:-}" == "--fix" ]]; then
|
||||
FIX_MODE=true
|
||||
echo -e "${BLUE}🔧 Running in fix mode - will attempt to auto-fix issues${NC}\n"
|
||||
fi
|
||||
|
||||
# Helper functions
|
||||
print_header() {
|
||||
echo -e "\n${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||
echo -e "${BLUE}▶ $1${NC}"
|
||||
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||
}
|
||||
|
||||
check_pass() {
|
||||
echo -e "${GREEN}✓ $1${NC}"
|
||||
}
|
||||
|
||||
check_fail() {
|
||||
echo -e "${RED}✗ $1${NC}"
|
||||
FAILURES=$((FAILURES + 1))
|
||||
}
|
||||
|
||||
check_warn() {
|
||||
echo -e "${YELLOW}⚠ $1${NC}"
|
||||
}
|
||||
|
||||
check_skip() {
|
||||
echo -e "${YELLOW}⊘ $1 (skipped - tool not installed)${NC}"
|
||||
}
|
||||
|
||||
# Change to repo root
|
||||
cd "$(dirname "$0")/.."
|
||||
REPO_ROOT=$(pwd)
|
||||
echo -e "${BLUE}📁 Repository: ${REPO_ROOT}${NC}"
|
||||
|
||||
# ============================================================================
|
||||
# TypeScript / React Checks
|
||||
# ============================================================================
|
||||
|
||||
print_header "TypeScript / React"
|
||||
|
||||
# Check if node_modules exists
|
||||
if [ ! -d "node_modules" ]; then
|
||||
echo "Installing npm dependencies..."
|
||||
npm ci
|
||||
fi
|
||||
|
||||
# ESLint
|
||||
echo -e "\n${YELLOW}Running ESLint...${NC}"
|
||||
if $FIX_MODE; then
|
||||
if npx eslint . --ext .ts,.tsx,.js,.jsx,.mjs --ignore-pattern '.auto-claude/**' --fix; then
|
||||
check_pass "ESLint (with auto-fix)"
|
||||
else
|
||||
check_fail "ESLint found unfixable issues"
|
||||
fi
|
||||
else
|
||||
if npx eslint . --ext .ts,.tsx,.js,.jsx,.mjs --ignore-pattern '.auto-claude/**' --max-warnings 0; then
|
||||
check_pass "ESLint"
|
||||
else
|
||||
check_fail "ESLint found issues (run with --fix to auto-fix)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# TypeScript
|
||||
echo -e "\n${YELLOW}Running TypeScript type check...${NC}"
|
||||
if npx tsc --noEmit; then
|
||||
check_pass "TypeScript type check"
|
||||
else
|
||||
check_fail "TypeScript type errors found"
|
||||
fi
|
||||
|
||||
# Build
|
||||
echo -e "\n${YELLOW}Running build...${NC}"
|
||||
if npm run build; then
|
||||
check_pass "Vite build"
|
||||
else
|
||||
check_fail "Build failed"
|
||||
fi
|
||||
|
||||
# ============================================================================
|
||||
# Python Checks
|
||||
# ============================================================================
|
||||
|
||||
print_header "Python"
|
||||
|
||||
# Check for Python files
|
||||
if [ -d "utils" ] && ls utils/*.py 1> /dev/null 2>&1; then
|
||||
|
||||
# Ruff
|
||||
if command -v ruff &> /dev/null; then
|
||||
echo -e "\n${YELLOW}Running Ruff...${NC}"
|
||||
if $FIX_MODE; then
|
||||
if ruff check utils/ --fix; then
|
||||
check_pass "Ruff (with auto-fix)"
|
||||
else
|
||||
check_fail "Ruff found unfixable issues"
|
||||
fi
|
||||
else
|
||||
if ruff check utils/; then
|
||||
check_pass "Ruff"
|
||||
else
|
||||
check_fail "Ruff found issues (run with --fix to auto-fix)"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
check_skip "Ruff"
|
||||
echo " Install with: pip install ruff"
|
||||
fi
|
||||
|
||||
# Bandit
|
||||
if command -v bandit &> /dev/null; then
|
||||
echo -e "\n${YELLOW}Running Bandit security scan...${NC}"
|
||||
if bandit -r utils/ -ll; then
|
||||
check_pass "Bandit security scan"
|
||||
else
|
||||
check_fail "Bandit found security issues"
|
||||
fi
|
||||
else
|
||||
check_skip "Bandit"
|
||||
echo " Install with: pip install bandit"
|
||||
fi
|
||||
|
||||
else
|
||||
check_warn "No Python files found in utils/"
|
||||
fi
|
||||
|
||||
# ============================================================================
|
||||
# Shell Script Checks
|
||||
# ============================================================================
|
||||
|
||||
print_header "Shell Scripts"
|
||||
|
||||
if command -v shellcheck &> /dev/null; then
|
||||
echo -e "\n${YELLOW}Running ShellCheck...${NC}"
|
||||
SHELL_ERRORS=0
|
||||
for script in scripts/*.sh; do
|
||||
if [ -f "$script" ]; then
|
||||
if shellcheck -S warning "$script"; then
|
||||
echo -e " ${GREEN}✓${NC} $script"
|
||||
else
|
||||
echo -e " ${RED}✗${NC} $script"
|
||||
SHELL_ERRORS=$((SHELL_ERRORS + 1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ $SHELL_ERRORS -eq 0 ]; then
|
||||
check_pass "ShellCheck"
|
||||
else
|
||||
check_fail "ShellCheck found issues in $SHELL_ERRORS file(s)"
|
||||
fi
|
||||
else
|
||||
check_skip "ShellCheck"
|
||||
echo " Install with: brew install shellcheck"
|
||||
fi
|
||||
|
||||
# ============================================================================
|
||||
# Security Scans
|
||||
# ============================================================================
|
||||
|
||||
print_header "Security"
|
||||
|
||||
# Trivy FS Scan
|
||||
if command -v trivy &> /dev/null; then
|
||||
echo -e "\n${YELLOW}Running Trivy filesystem scan...${NC}"
|
||||
if trivy fs . --severity CRITICAL,HIGH --exit-code 1 --ignore-unfixed --skip-dirs .auto-claude --skip-files clawsec-signing-private.pem; then
|
||||
check_pass "Trivy filesystem scan"
|
||||
else
|
||||
check_fail "Trivy found CRITICAL/HIGH vulnerabilities"
|
||||
fi
|
||||
|
||||
echo -e "\n${YELLOW}Running Trivy config scan...${NC}"
|
||||
# Suppress info/warnings about missing config files (expected for non-IaC projects)
|
||||
if trivy config . --severity CRITICAL,HIGH --exit-code 1 --quiet 2>&1 | grep -v "Supported files for scanner(s) not found"; then
|
||||
check_pass "Trivy config scan"
|
||||
else
|
||||
check_fail "Trivy found CRITICAL/HIGH config issues"
|
||||
fi
|
||||
else
|
||||
check_skip "Trivy"
|
||||
echo " Install with: brew install trivy"
|
||||
fi
|
||||
|
||||
# Gitleaks (scans git history to match CI)
|
||||
if command -v gitleaks &> /dev/null; then
|
||||
echo -e "\n${YELLOW}Running Gitleaks secrets scan...${NC}"
|
||||
if gitleaks detect --source . --verbose; then
|
||||
check_pass "Gitleaks secrets scan"
|
||||
else
|
||||
check_fail "Gitleaks found potential secrets"
|
||||
fi
|
||||
else
|
||||
check_skip "Gitleaks"
|
||||
echo " Install with: brew install gitleaks"
|
||||
fi
|
||||
|
||||
# npm audit (use public registry since private registries like CodeArtifact don't support audit)
|
||||
echo -e "\n${YELLOW}Running npm audit...${NC}"
|
||||
if npm audit --audit-level=high --registry=https://registry.npmjs.org; then
|
||||
check_pass "npm audit"
|
||||
else
|
||||
check_warn "npm audit found vulnerabilities (run 'npm audit fix')"
|
||||
fi
|
||||
|
||||
# ============================================================================
|
||||
# Summary
|
||||
# ============================================================================
|
||||
|
||||
print_header "Summary"
|
||||
|
||||
if [ $FAILURES -eq 0 ]; then
|
||||
echo -e "\n${GREEN}🎉 All checks passed! Ready to push.${NC}\n"
|
||||
exit 0
|
||||
else
|
||||
echo -e "\n${RED}❌ $FAILURES check(s) failed. Please fix before pushing.${NC}"
|
||||
echo -e "${YELLOW}💡 Tip: Run with --fix to auto-fix some issues${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,342 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Usage: ./scripts/release-skill.sh <skill-name> <version> [--force-tag]
|
||||
# Example: ./scripts/release-skill.sh clawsec-feed 1.1.0
|
||||
#
|
||||
# This script ensures version consistency by:
|
||||
# 1. Updating skill.json with the new version
|
||||
# 2. Updating any hardcoded version URLs in skill.json and SKILL.md
|
||||
# 3. Committing the changes
|
||||
# 4. Creating the git tag (only on main/master branch)
|
||||
#
|
||||
# Branch-aware workflow:
|
||||
# Feature branch: Updates versions, commits, pushes → CI validates build
|
||||
# Main branch: Updates versions, commits, creates tag → push triggers release
|
||||
#
|
||||
# Use --force-tag to create a tag even when not on main/master.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Parse arguments
|
||||
FORCE_TAG=false
|
||||
POSITIONAL_ARGS=()
|
||||
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--force-tag)
|
||||
FORCE_TAG=true
|
||||
;;
|
||||
*)
|
||||
POSITIONAL_ARGS+=("$arg")
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "${#POSITIONAL_ARGS[@]}" -ne 2 ]; then
|
||||
echo "Usage: $0 <skill-name> <version> [--force-tag]"
|
||||
echo "Example: $0 clawsec-feed 1.1.0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SKILL_NAME="${POSITIONAL_ARGS[0]}"
|
||||
VERSION="${POSITIONAL_ARGS[1]}"
|
||||
SKILL_PATH="skills/$SKILL_NAME"
|
||||
|
||||
# Initialize variables
|
||||
RELEASE_NOTES=""
|
||||
|
||||
# Ensure we're on a branch (not detached HEAD) so release flow works from feature branches
|
||||
CURRENT_BRANCH="$(git symbolic-ref --quiet --short HEAD || true)"
|
||||
if [ -z "$CURRENT_BRANCH" ]; then
|
||||
echo "Error: Detached HEAD detected. Checkout a branch before running release." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Determine if we're on a release branch (main/master)
|
||||
IS_RELEASE_BRANCH=false
|
||||
if [[ "$CURRENT_BRANCH" == "main" || "$CURRENT_BRANCH" == "master" ]]; then
|
||||
IS_RELEASE_BRANCH=true
|
||||
fi
|
||||
|
||||
# Security: Validate skill name to prevent path injection
|
||||
# Only allow lowercase alphanumeric characters and hyphens
|
||||
if ! [[ "$SKILL_NAME" =~ ^[a-z0-9-]+$ ]]; then
|
||||
echo "Error: Invalid skill name. Only lowercase alphanumeric characters and hyphens are allowed."
|
||||
echo "Example: clawsec-feed, prompt-agent, clawtributor"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$SKILL_PATH/skill.json" ]; then
|
||||
echo "Error: $SKILL_PATH/skill.json not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate semver format (supports prerelease like 1.0.0-beta1)
|
||||
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
|
||||
echo "Error: Invalid version format. Use semver (e.g., 1.0.0, 1.1.0-beta1)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TAG="${SKILL_NAME}-v${VERSION}"
|
||||
|
||||
# Check for uncommitted changes in skill directory
|
||||
if ! git diff --quiet "$SKILL_PATH/" 2>/dev/null; then
|
||||
echo "Error: $SKILL_PATH/ has uncommitted changes. Please commit or stash them first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Releasing $SKILL_NAME version $VERSION"
|
||||
echo "Branch: $CURRENT_BRANCH"
|
||||
if [[ "$IS_RELEASE_BRANCH" == "true" || "$FORCE_TAG" == "true" ]]; then
|
||||
echo "Mode: Full release (will create tag)"
|
||||
else
|
||||
echo "Mode: Prep only (tag deferred until merge to main)"
|
||||
fi
|
||||
echo "======================================="
|
||||
|
||||
# Create a temporary directory for atomic operations
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
trap 'rm -rf "$TEMP_DIR"' EXIT
|
||||
|
||||
# Track files that need to be staged
|
||||
FILES_TO_STAGE=()
|
||||
|
||||
# Update version in skill.json
|
||||
echo "Updating $SKILL_PATH/skill.json version to $VERSION..."
|
||||
if ! jq --arg v "$VERSION" '.version = $v' "$SKILL_PATH/skill.json" > "$TEMP_DIR/skill.json"; then
|
||||
echo "Error: Failed to update version in skill.json"
|
||||
exit 1
|
||||
fi
|
||||
mv "$TEMP_DIR/skill.json" "$SKILL_PATH/skill.json"
|
||||
FILES_TO_STAGE+=("$SKILL_PATH/skill.json")
|
||||
|
||||
# Update any hardcoded version URLs in skill.json (openclaw.feed_url pattern)
|
||||
if jq -e '.openclaw.feed_url' "$SKILL_PATH/skill.json" >/dev/null 2>&1; then
|
||||
echo "Updating openclaw.feed_url to use tag $TAG..."
|
||||
if ! jq --arg tag "$TAG" '.openclaw.feed_url = (.openclaw.feed_url | gsub("/[^/]+-v[0-9.]+(-[a-zA-Z0-9]+)?/"; "/\($tag)/"))' "$SKILL_PATH/skill.json" > "$TEMP_DIR/skill.json"; then
|
||||
echo "Error: Failed to update feed_url in skill.json"
|
||||
exit 1
|
||||
fi
|
||||
mv "$TEMP_DIR/skill.json" "$SKILL_PATH/skill.json"
|
||||
fi
|
||||
|
||||
# Update version in SKILL.md frontmatter and ALL hardcoded version URLs (if file exists)
|
||||
if [ -f "$SKILL_PATH/SKILL.md" ]; then
|
||||
echo "Updating $SKILL_PATH/SKILL.md frontmatter version to $VERSION..."
|
||||
|
||||
# Verify version line exists before sed
|
||||
if ! grep -qE "^version: " "$SKILL_PATH/SKILL.md"; then
|
||||
echo "Error: SKILL.md missing 'version:' line in frontmatter" >&2
|
||||
echo " Expected format: 'version: X.Y.Z' at start of line" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Apply sed and verify substitution occurred
|
||||
sed "s/^version: .*/version: $VERSION/" "$SKILL_PATH/SKILL.md" > "$TEMP_DIR/SKILL.md"
|
||||
|
||||
if ! grep -qF "version: $VERSION" "$TEMP_DIR/SKILL.md"; then
|
||||
echo "Error: Failed to update version in SKILL.md frontmatter" >&2
|
||||
echo " Target version: $VERSION" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo " ✓ Version updated to $VERSION"
|
||||
|
||||
echo "Updating hardcoded version URLs in SKILL.md to use tag $TAG..."
|
||||
# Replace all hardcoded version URLs: download/SKILLNAME-vX.Y.Z(-prerelease)?/ -> download/TAG/
|
||||
# This handles patterns like: download/clawsec-feed-v1.0.0/ or download/prompt-agent-v1.0.0-beta1/
|
||||
PATTERN="/download/${SKILL_NAME}-v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?/"
|
||||
|
||||
# Check if pattern exists (warn if not, don't fail - some skills may not self-reference)
|
||||
if grep -qE "$PATTERN" "$TEMP_DIR/SKILL.md"; then
|
||||
sed -E "s|$PATTERN|/download/${TAG}/|g" "$TEMP_DIR/SKILL.md" > "$TEMP_DIR/SKILL.md.tmp"
|
||||
|
||||
# Verify substitution occurred
|
||||
if ! grep -qF "/download/${TAG}/" "$TEMP_DIR/SKILL.md.tmp"; then
|
||||
echo "Warning: URL pattern found but substitution may have failed" >&2
|
||||
else
|
||||
URL_COUNT=$(grep -cF "/download/${TAG}/" "$TEMP_DIR/SKILL.md.tmp")
|
||||
echo " ✓ Updated $URL_COUNT hardcoded URL(s)"
|
||||
fi
|
||||
|
||||
mv "$TEMP_DIR/SKILL.md.tmp" "$TEMP_DIR/SKILL.md"
|
||||
else
|
||||
echo " ℹ No hardcoded version URLs found (OK if skill doesn't self-reference)"
|
||||
fi
|
||||
|
||||
mv "$TEMP_DIR/SKILL.md" "$SKILL_PATH/SKILL.md"
|
||||
FILES_TO_STAGE+=("$SKILL_PATH/SKILL.md")
|
||||
fi
|
||||
|
||||
# Update hardcoded version URLs in other markdown files (heartbeat.md, reporting.md, etc.)
|
||||
for md_file in "$SKILL_PATH"/*.md; do
|
||||
if [ -f "$md_file" ] && [ "$md_file" != "$SKILL_PATH/SKILL.md" ]; then
|
||||
filename=$(basename "$md_file")
|
||||
echo "Updating hardcoded version URLs in $filename..."
|
||||
|
||||
PATTERN="/download/${SKILL_NAME}-v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?/"
|
||||
|
||||
# Check if pattern exists
|
||||
if grep -qE "$PATTERN" "$md_file"; then
|
||||
sed -E "s|$PATTERN|/download/${TAG}/|g" "$md_file" > "$TEMP_DIR/$filename"
|
||||
|
||||
# Verify substitution occurred
|
||||
if ! grep -qF "/download/${TAG}/" "$TEMP_DIR/$filename"; then
|
||||
echo " Warning: URL pattern found but substitution may have failed in $filename" >&2
|
||||
else
|
||||
URL_COUNT=$(grep -cF "/download/${TAG}/" "$TEMP_DIR/$filename")
|
||||
echo " ✓ Updated $URL_COUNT URL(s) in $filename"
|
||||
fi
|
||||
|
||||
mv "$TEMP_DIR/$filename" "$md_file"
|
||||
FILES_TO_STAGE+=("$md_file")
|
||||
else
|
||||
echo " ℹ No hardcoded version URLs found in $filename (skipping)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Show what changed
|
||||
echo ""
|
||||
echo "Changes to $SKILL_PATH/:"
|
||||
git diff "$SKILL_PATH/" || true
|
||||
echo ""
|
||||
|
||||
# Stage all changed files atomically
|
||||
echo "Staging changes..."
|
||||
for file in "${FILES_TO_STAGE[@]}"; do
|
||||
git add "$file"
|
||||
done
|
||||
|
||||
# Verify staged changes before committing
|
||||
MADE_COMMIT=false
|
||||
if git diff --cached --quiet; then
|
||||
echo "Note: Version already at $VERSION — no changes to commit"
|
||||
COMMIT_SHA=$(git rev-parse HEAD)
|
||||
else
|
||||
# Commit the version bump
|
||||
echo "Committing changes..."
|
||||
if ! git commit -m "chore($SKILL_NAME): bump version to $VERSION"; then
|
||||
echo "Error: Failed to commit changes"
|
||||
exit 1
|
||||
fi
|
||||
COMMIT_SHA=$(git rev-parse HEAD)
|
||||
MADE_COMMIT=true
|
||||
fi
|
||||
|
||||
# Save commit SHA for recovery
|
||||
echo "Committed: $COMMIT_SHA"
|
||||
|
||||
# Create tag only on release branches (or if forced)
|
||||
if [[ "$IS_RELEASE_BRANCH" == "true" || "$FORCE_TAG" == "true" ]]; then
|
||||
# Check if tag already exists (only matters when we're creating one)
|
||||
if git rev-parse "$TAG" >/dev/null 2>&1; then
|
||||
echo "Error: Tag $TAG already exists"
|
||||
if [[ "$MADE_COMMIT" == "true" ]]; then
|
||||
echo "Rolling back version-bump commit..."
|
||||
git reset --hard HEAD~1
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Creating tag: $TAG"
|
||||
if ! git tag -a "$TAG" -m "$SKILL_NAME version $VERSION"; then
|
||||
echo "Error: Failed to create tag $TAG" >&2
|
||||
echo "" >&2
|
||||
echo "The commit has been created but NOT tagged:" >&2
|
||||
echo " Commit: $COMMIT_SHA" >&2
|
||||
echo "" >&2
|
||||
echo "Recovery options:" >&2
|
||||
echo " 1. Fix the issue and tag manually:" >&2
|
||||
echo " git tag -a '$TAG' -m '$SKILL_NAME version $VERSION' $COMMIT_SHA" >&2
|
||||
echo "" >&2
|
||||
echo " 2. Investigate why tagging failed:" >&2
|
||||
echo " - Check if tag exists: git tag -l '$TAG'" >&2
|
||||
echo " - Check permissions: ls -ld .git/refs/tags" >&2
|
||||
echo "" >&2
|
||||
echo " 3. To rollback the commit (if desired):" >&2
|
||||
echo " git reset --hard HEAD~1" >&2
|
||||
echo "" >&2
|
||||
echo "The commit has NOT been pushed. Fix the issue before pushing." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract changelog entry for this version and create GitHub release
|
||||
RELEASE_NOTES=""
|
||||
GH_RELEASE_CREATED=false
|
||||
if [ -f "$SKILL_PATH/CHANGELOG.md" ]; then
|
||||
echo "Extracting changelog entry for version $VERSION..."
|
||||
|
||||
# Extract the changelog section for this version
|
||||
# Pattern: ## [VERSION] - DATE ... until next ## [ or end of file
|
||||
RELEASE_NOTES=$(awk -v version="$VERSION" '
|
||||
BEGIN { in_section = 0; found = 0 }
|
||||
$0 ~ ("^## \\[" version "\\]") { in_section = 1; found = 1; next }
|
||||
in_section && /^## \[/ && found { exit }
|
||||
in_section { print }
|
||||
' "$SKILL_PATH/CHANGELOG.md" | sed '/^$/d' | sed '1{/^$/d;}')
|
||||
|
||||
if [ -n "$RELEASE_NOTES" ]; then
|
||||
echo "Found changelog entry with $(echo "$RELEASE_NOTES" | wc -l) lines"
|
||||
|
||||
# Create GitHub release with changelog notes
|
||||
echo "Creating GitHub release with changelog notes..."
|
||||
if command -v gh >/dev/null 2>&1; then
|
||||
if ! echo "$RELEASE_NOTES" | gh release create "$TAG" \
|
||||
--title "$SKILL_NAME v$VERSION" \
|
||||
--notes-file -; then
|
||||
echo "Warning: Failed to create GitHub release, but tag was created successfully" >&2
|
||||
echo "You can manually create the release at: https://github.com/$(git remote get-url origin | sed 's/.*github.com[:/]\([^.]*\).*/\1/')/releases/new" >&2
|
||||
else
|
||||
echo "✓ GitHub release created with changelog notes"
|
||||
GH_RELEASE_CREATED=true
|
||||
fi
|
||||
else
|
||||
echo "Warning: GitHub CLI (gh) not found. Skipping automatic release creation." >&2
|
||||
echo "Install GitHub CLI and run manually:" >&2
|
||||
echo " gh release create '$TAG' --title '$SKILL_NAME v$VERSION' --notes-file <(echo \"$RELEASE_NOTES\")" >&2
|
||||
fi
|
||||
else
|
||||
echo "Warning: No changelog entry found for version $VERSION" >&2
|
||||
fi
|
||||
else
|
||||
echo "No CHANGELOG.md found in $SKILL_PATH - skipping release notes"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Done! To release, push the tag:"
|
||||
if [[ "$MADE_COMMIT" == "true" ]]; then
|
||||
echo " git push origin $CURRENT_BRANCH"
|
||||
fi
|
||||
echo " git push origin $TAG"
|
||||
echo ""
|
||||
echo "Or to undo:"
|
||||
if [[ "$MADE_COMMIT" == "true" ]]; then
|
||||
echo " git reset --hard HEAD~1 && git tag -d $TAG"
|
||||
else
|
||||
echo " git tag -d $TAG"
|
||||
fi
|
||||
if [[ "$GH_RELEASE_CREATED" == "true" ]]; then
|
||||
echo ""
|
||||
echo "Note: GitHub release was created automatically with changelog notes."
|
||||
fi
|
||||
else
|
||||
# Feature branch: skip tagging, instruct user on next steps
|
||||
echo ""
|
||||
echo "Done! Version updated and committed (tag deferred)."
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Push your branch for CI validation:"
|
||||
echo " git push origin $CURRENT_BRANCH"
|
||||
echo ""
|
||||
echo " 2. After CI passes and PR is merged to main, create the tag and release:"
|
||||
echo " git checkout main && git pull"
|
||||
echo " git tag -a '$TAG' $COMMIT_SHA -m '$SKILL_NAME version $VERSION'"
|
||||
echo " git push origin $TAG"
|
||||
if [ -f "$SKILL_PATH/CHANGELOG.md" ]; then
|
||||
echo " # Create GitHub release with changelog (requires GitHub CLI):"
|
||||
echo " gh release create '$TAG' --title '$SKILL_NAME v$VERSION' --generate-notes"
|
||||
fi
|
||||
echo ""
|
||||
echo "Or to undo the version bump:"
|
||||
echo " git reset --hard HEAD~1"
|
||||
fi
|
||||
@@ -1,262 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# validate-release-links.sh
|
||||
# Validates that all links referenced in SKILL.md files and READMEs will be
|
||||
# available after release based on the skill-release.yml workflow logic.
|
||||
#
|
||||
# Usage: ./scripts/validate-release-links.sh [skill-name]
|
||||
# If skill-name is provided, only validates that skill
|
||||
# Otherwise validates all skills
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
SKILLS_DIR="$PROJECT_ROOT/skills"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
ERRORS=0
|
||||
# shellcheck disable=SC2034 # WARNINGS reserved for future use
|
||||
WARNINGS=0
|
||||
|
||||
# Get repo info from git remote
|
||||
REPO=$(git -C "$PROJECT_ROOT" remote get-url origin 2>/dev/null | sed -E 's|.*github.com[:/]||' | sed 's/.git$//' || echo "prompt-security/ClawSec")
|
||||
echo -e "${BLUE}Repository: $REPO${NC}"
|
||||
echo ""
|
||||
|
||||
# Function to get files that will be in a release
|
||||
get_release_assets() {
|
||||
local skill_path="$1"
|
||||
local skill_name="$2"
|
||||
local assets=()
|
||||
|
||||
# Files from SBOM
|
||||
if [ -f "$skill_path/skill.json" ]; then
|
||||
while IFS= read -r file; do
|
||||
assets+=("$(basename "$file")")
|
||||
done < <(jq -r '.sbom.files[].path // empty' "$skill_path/skill.json" 2>/dev/null)
|
||||
fi
|
||||
|
||||
# Always included
|
||||
assets+=("skill.json")
|
||||
assets+=("checksums.json")
|
||||
|
||||
# README if exists
|
||||
if [ -f "$skill_path/README.md" ]; then
|
||||
assets+=("README.md")
|
||||
fi
|
||||
|
||||
printf '%s\n' "${assets[@]}" | sort -u
|
||||
}
|
||||
|
||||
# Function to extract expected files from documentation
|
||||
extract_referenced_files() {
|
||||
local file="$1"
|
||||
local skill_name="$2"
|
||||
|
||||
# Extract filenames from download URLs matching this skill
|
||||
grep -oE "releases/(latest/)?download/[^/]+/[^\"'\`\s)]+" "$file" 2>/dev/null | \
|
||||
grep -E "/${skill_name}-v|/latest/" | \
|
||||
sed -E 's|.*/||' | \
|
||||
sort -u || true
|
||||
}
|
||||
|
||||
# Function to extract all referenced files from any download URL
|
||||
extract_all_referenced_files() {
|
||||
local file="$1"
|
||||
|
||||
# Extract all filenames from download URLs
|
||||
grep -oE "releases/(latest/)?download/[^/]+/[a-zA-Z0-9_.-]+" "$file" 2>/dev/null | \
|
||||
sed -E 's|.*/||' | \
|
||||
sort -u || true
|
||||
}
|
||||
|
||||
validate_skill() {
|
||||
local skill_name="$1"
|
||||
local skill_path="$SKILLS_DIR/$skill_name"
|
||||
local skill_errors=0
|
||||
|
||||
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||
echo -e "${BLUE}Validating: ${skill_name}${NC}"
|
||||
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||
|
||||
# Check skill.json exists
|
||||
if [ ! -f "$skill_path/skill.json" ]; then
|
||||
echo -e "${RED} ✗ Missing skill.json${NC}"
|
||||
((ERRORS++))
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Get version from skill.json
|
||||
VERSION=$(jq -r '.version // "unknown"' "$skill_path/skill.json")
|
||||
echo -e " Version: $VERSION"
|
||||
echo -e " Tag will be: ${skill_name}-v${VERSION}"
|
||||
echo ""
|
||||
|
||||
# Get assets that will be created by workflow
|
||||
echo -e "${YELLOW} Assets that will be created:${NC}"
|
||||
RELEASE_ASSETS=()
|
||||
while IFS= read -r asset; do
|
||||
RELEASE_ASSETS+=("$asset")
|
||||
echo -e " ✓ $asset"
|
||||
done < <(get_release_assets "$skill_path" "$skill_name")
|
||||
echo ""
|
||||
|
||||
# Verify SBOM files exist locally
|
||||
echo -e "${YELLOW} Verifying SBOM files exist:${NC}"
|
||||
while IFS= read -r file; do
|
||||
if [ -f "$skill_path/$file" ]; then
|
||||
echo -e " ${GREEN}✓${NC} $file"
|
||||
else
|
||||
echo -e " ${RED}✗ MISSING: $file${NC}"
|
||||
((skill_errors++))
|
||||
((ERRORS++))
|
||||
fi
|
||||
done < <(jq -r '.sbom.files[].path // empty' "$skill_path/skill.json" 2>/dev/null)
|
||||
echo ""
|
||||
|
||||
# Check links in SKILL.md
|
||||
if [ -f "$skill_path/SKILL.md" ]; then
|
||||
echo -e "${YELLOW} Checking SKILL.md references:${NC}"
|
||||
|
||||
# Find files referenced for THIS skill specifically
|
||||
while IFS= read -r referenced_file; do
|
||||
[ -z "$referenced_file" ] && continue
|
||||
|
||||
# Check if this file will be in the release
|
||||
found=false
|
||||
for asset in "${RELEASE_ASSETS[@]}"; do
|
||||
if [ "$asset" = "$referenced_file" ]; then
|
||||
found=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$found" = true ]; then
|
||||
echo -e " ${GREEN}✓${NC} $referenced_file (will be available)"
|
||||
else
|
||||
# Check if it's a reference to another skill's release
|
||||
if grep -qE "/${skill_name}-v[0-9]" "$skill_path/SKILL.md" 2>/dev/null || \
|
||||
grep -q "/latest/download/$referenced_file" "$skill_path/SKILL.md" 2>/dev/null; then
|
||||
echo -e " ${RED}✗${NC} $referenced_file (NOT in SBOM - won't be released)"
|
||||
((skill_errors++))
|
||||
((ERRORS++))
|
||||
fi
|
||||
fi
|
||||
done < <(extract_all_referenced_files "$skill_path/SKILL.md")
|
||||
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Check links in README.md
|
||||
if [ -f "$skill_path/README.md" ]; then
|
||||
echo -e "${YELLOW} Checking README.md references:${NC}"
|
||||
|
||||
while IFS= read -r referenced_file; do
|
||||
[ -z "$referenced_file" ] && continue
|
||||
|
||||
found=false
|
||||
for asset in "${RELEASE_ASSETS[@]}"; do
|
||||
if [ "$asset" = "$referenced_file" ]; then
|
||||
found=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$found" = true ]; then
|
||||
echo -e " ${GREEN}✓${NC} $referenced_file"
|
||||
else
|
||||
# Only error if it's referencing THIS skill's release
|
||||
if grep -qE "/${skill_name}-v|/latest/download/${referenced_file}" "$skill_path/README.md" 2>/dev/null; then
|
||||
echo -e " ${RED}✗${NC} $referenced_file (NOT in release assets)"
|
||||
((skill_errors++))
|
||||
((ERRORS++))
|
||||
fi
|
||||
fi
|
||||
done < <(extract_all_referenced_files "$skill_path/README.md")
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Cross-reference check: look for this skill being referenced by OTHER skills
|
||||
echo -e "${YELLOW} Cross-references from other skills:${NC}"
|
||||
cross_refs_found=false
|
||||
for other_skill_dir in "$SKILLS_DIR"/*/; do
|
||||
other_skill=$(basename "$other_skill_dir")
|
||||
[ "$other_skill" = "$skill_name" ] && continue
|
||||
|
||||
for doc in "$other_skill_dir"/*.md; do
|
||||
[ -f "$doc" ] || continue
|
||||
|
||||
if grep -qE "/${skill_name}-v" "$doc" 2>/dev/null; then
|
||||
echo -e " → Referenced by ${other_skill}/$(basename "$doc")"
|
||||
cross_refs_found=true
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
if [ "$cross_refs_found" = false ]; then
|
||||
echo -e " (none found)"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Summary for this skill
|
||||
if [ $skill_errors -eq 0 ]; then
|
||||
echo -e "${GREEN} ✓ All checks passed for ${skill_name}${NC}"
|
||||
else
|
||||
echo -e "${RED} ✗ ${skill_errors} issue(s) found for ${skill_name}${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
return $skill_errors
|
||||
}
|
||||
|
||||
# Main logic
|
||||
if [ $# -gt 0 ]; then
|
||||
# Validate specific skill
|
||||
if [ -d "$SKILLS_DIR/$1" ]; then
|
||||
validate_skill "$1"
|
||||
else
|
||||
echo -e "${RED}Error: Skill '$1' not found in $SKILLS_DIR${NC}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Validate all skills
|
||||
echo -e "${BLUE}Scanning all skills in $SKILLS_DIR${NC}"
|
||||
echo ""
|
||||
|
||||
for skill_dir in "$SKILLS_DIR"/*/; do
|
||||
skill_name=$(basename "$skill_dir")
|
||||
|
||||
# Skip if no skill.json
|
||||
[ -f "$skill_dir/skill.json" ] || continue
|
||||
|
||||
validate_skill "$skill_name" || true
|
||||
done
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||
echo -e "${BLUE}SUMMARY${NC}"
|
||||
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
||||
|
||||
if [ $ERRORS -eq 0 ]; then
|
||||
echo -e "${GREEN}✓ All validations passed!${NC}"
|
||||
echo ""
|
||||
echo "Release URLs will follow this pattern:"
|
||||
echo " https://github.com/$REPO/releases/download/{skill-name}-v{version}/{file}"
|
||||
echo ""
|
||||
echo "For 'latest' symlinks:"
|
||||
echo " https://github.com/$REPO/releases/latest/download/{file}"
|
||||
echo " (Note: 'latest' points to the most recent release of ANY skill)"
|
||||
exit 0
|
||||
else
|
||||
echo -e "${RED}✗ Found $ERRORS error(s)${NC}"
|
||||
echo ""
|
||||
echo "Please fix the issues above before tagging a release."
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,12 +0,0 @@
|
||||
# Exclude local caches and build outputs from ClawHub upload
|
||||
.DS_Store
|
||||
.git/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.egg-info/
|
||||
dist/
|
||||
build/
|
||||
.env
|
||||
.venv/
|
||||
.cache/
|
||||
@@ -1,21 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to the Claw Release skill will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.0.2] - 2026-04-14
|
||||
|
||||
### Added
|
||||
|
||||
- Operational notes that make the required maintainer credentials, runtime, and git/GitHub side effects explicit.
|
||||
|
||||
### Changed
|
||||
|
||||
- Declared `bash` alongside the existing `git`, `jq`, and `gh` runtime requirements in skill metadata.
|
||||
- Replaced the documented destructive rollback example with a softer rollback flow that preserves release changes for review.
|
||||
|
||||
### Security
|
||||
|
||||
- Clarified that this internal skill mutates git state, pushes to remotes, and publishes GitHub Releases, so it should only be run from a trusted checkout by maintainers.
|
||||
@@ -1,176 +0,0 @@
|
||||
---
|
||||
name: claw-release
|
||||
version: 0.0.2
|
||||
description: Release automation for Claw skills and website. Guides through version bumping, tagging, and release verification.
|
||||
homepage: https://clawsec.prompt.security
|
||||
metadata: {"openclaw":{"emoji":"🚀","category":"utility","internal":true}}
|
||||
clawdis:
|
||||
emoji: "🚀"
|
||||
requires:
|
||||
bins: [bash, git, jq, gh]
|
||||
---
|
||||
|
||||
# Claw Release
|
||||
|
||||
Internal tool for releasing skills and managing the ClawSec catalog.
|
||||
|
||||
**An internal tool by [Prompt Security](https://prompt.security)**
|
||||
|
||||
---
|
||||
|
||||
## Operational Notes
|
||||
|
||||
- Internal maintainer workflow only.
|
||||
- Required runtime: `bash`, `git`, `jq`, `gh`
|
||||
- Required credentials: authenticated GitHub CLI with permission to create releases
|
||||
- Side effects: creates commits, tags, pushes to remote, and publishes GitHub Releases
|
||||
- Trust model: run only from a trusted checkout with a clean working tree and maintainer approval
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| Release Type | Command | Tag Format |
|
||||
|-------------|---------|------------|
|
||||
| Skill release | `./scripts/release-skill.sh <name> <version>` | `<name>-v<version>` |
|
||||
| Pre-release | `./scripts/release-skill.sh <name> 1.0.0-beta1` | `<name>-v1.0.0-beta1` |
|
||||
|
||||
---
|
||||
|
||||
## Release Workflow
|
||||
|
||||
### Step 1: Determine Version Type
|
||||
|
||||
Ask what changed:
|
||||
- **Bug fixes only** → Patch (1.0.0 → 1.0.1)
|
||||
- **New features, backward compatible** → Minor (1.0.0 → 1.1.0)
|
||||
- **Breaking changes** → Major (1.0.0 → 2.0.0)
|
||||
- **Testing/unstable** → Pre-release (1.0.0-beta1, 1.0.0-rc1)
|
||||
|
||||
### Step 2: Pre-flight Checks
|
||||
|
||||
```bash
|
||||
# Check for uncommitted changes
|
||||
git status
|
||||
|
||||
# Verify skill directory exists
|
||||
ls skills/<skill-name>/skill.json
|
||||
|
||||
# Get current version
|
||||
jq -r '.version' skills/<skill-name>/skill.json
|
||||
```
|
||||
|
||||
### Step 3: Run Release Script
|
||||
|
||||
```bash
|
||||
./scripts/release-skill.sh <skill-name> <new-version>
|
||||
```
|
||||
|
||||
The script will:
|
||||
1. Validate version format (semver)
|
||||
2. Check tag doesn't already exist
|
||||
3. Update skill.json version
|
||||
4. Update SKILL.md frontmatter version (if file exists)
|
||||
5. Update hardcoded version URLs (feed_url)
|
||||
6. Commit changes
|
||||
7. Create annotated git tag
|
||||
|
||||
### Step 4: Push Release
|
||||
|
||||
```bash
|
||||
git push && git push origin <skill-name>-v<version>
|
||||
```
|
||||
|
||||
### Step 5: Verify Release
|
||||
|
||||
After pushing, the CI/CD pipeline will:
|
||||
1. Validate skill exists
|
||||
2. Verify version matches skill.json
|
||||
3. Verify version matches SKILL.md frontmatter (if exists)
|
||||
4. Generate checksums from SBOM
|
||||
5. Create .skill package (ZIP)
|
||||
6. Create GitHub Release
|
||||
7. Trigger website rebuild (for non-internal skills)
|
||||
|
||||
Verify at:
|
||||
- **GitHub Releases:** `https://github.com/prompt-security/clawsec/releases/tag/<skill-name>-v<version>`
|
||||
- **GitHub Actions:** Check workflow run status
|
||||
|
||||
---
|
||||
|
||||
## Undo a Release (Before Push)
|
||||
|
||||
If you need to undo before pushing:
|
||||
|
||||
```bash
|
||||
git tag -d <skill-name>-v<version>
|
||||
git reset --soft HEAD~1
|
||||
```
|
||||
|
||||
`git reset --soft` preserves the release changes in your working tree so you can inspect or amend them without discarding data.
|
||||
|
||||
---
|
||||
|
||||
## Pre-release Versions
|
||||
|
||||
For beta, alpha, or release candidates:
|
||||
|
||||
```bash
|
||||
./scripts/release-skill.sh <skill-name> 1.2.0-beta1
|
||||
./scripts/release-skill.sh <skill-name> 1.2.0-alpha1
|
||||
./scripts/release-skill.sh <skill-name> 1.2.0-rc1
|
||||
```
|
||||
|
||||
Pre-releases are automatically marked in GitHub Releases.
|
||||
|
||||
---
|
||||
|
||||
## Common Issues
|
||||
|
||||
| Error | Solution |
|
||||
|-------|----------|
|
||||
| `Tag already exists` | Choose a different version number |
|
||||
| `Version mismatch in CI` | Ensure you used the release script (not manual tagging) |
|
||||
| `SKILL.md version mismatch` | Ensure you used the release script which updates both skill.json and SKILL.md |
|
||||
| `Uncommitted changes` | Commit or stash first: `git stash` or `git add . && git commit` |
|
||||
| `skill.json not found` | Verify skill directory path is correct |
|
||||
|
||||
---
|
||||
|
||||
## Internal Skills
|
||||
|
||||
Skills with `"internal": true` in their `openclaw` section:
|
||||
- Are released normally via GitHub Releases
|
||||
- Are NOT shown in the public skills catalog website
|
||||
- Can still be downloaded directly from release URLs
|
||||
|
||||
This skill (`claw-release`) is an internal skill.
|
||||
|
||||
---
|
||||
|
||||
## Existing Skills
|
||||
|
||||
| Skill | Category | Internal |
|
||||
|-------|----------|----------|
|
||||
| clawsec-feed | security | No |
|
||||
| clawtributor | security | No |
|
||||
| openclaw-audit-watchdog | security | No |
|
||||
| soul-guardian | security | No |
|
||||
| claw-release | utility | Yes |
|
||||
|
||||
---
|
||||
|
||||
## Verification Checklist
|
||||
|
||||
After release, confirm:
|
||||
- [ ] GitHub Release exists with correct tag
|
||||
- [ ] Release has: skill.json, SKILL.md, checksums.json, .skill package
|
||||
- [ ] Release is marked as pre-release if applicable
|
||||
- [ ] GitHub Actions workflow completed successfully
|
||||
- [ ] Website updated (for non-internal skills only)
|
||||
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
GNU AGPL v3.0 or later - See repository for details.
|
||||
|
||||
Built by the [Prompt Security](https://prompt.security) team.
|
||||
@@ -1,51 +0,0 @@
|
||||
{
|
||||
"name": "claw-release",
|
||||
"version": "0.0.2",
|
||||
"description": "Release automation for Claw skills and website. Guides through version bumping, tagging, and release verification.",
|
||||
"author": "prompt-security",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"homepage": "https://clawsec.prompt.security",
|
||||
"keywords": ["release", "versioning", "deployment", "automation", "ci-cd", "skills"],
|
||||
|
||||
"sbom": {
|
||||
"files": [
|
||||
{ "path": "SKILL.md", "required": true, "description": "Release workflow guide" },
|
||||
{ "path": "CHANGELOG.md", "required": true, "description": "Version history and release notes" }
|
||||
]
|
||||
},
|
||||
|
||||
"openclaw": {
|
||||
"emoji": "🚀",
|
||||
"category": "utility",
|
||||
"internal": true,
|
||||
"requires": { "bins": ["bash", "git", "jq", "gh"] },
|
||||
"runtime": {
|
||||
"required_env": [
|
||||
"GH_TOKEN or existing gh auth"
|
||||
],
|
||||
"optional_bins": [
|
||||
"git-lfs"
|
||||
]
|
||||
},
|
||||
"execution": {
|
||||
"always": false,
|
||||
"persistence": "No recurring automation; this is a maintainer-invoked release workflow.",
|
||||
"network_egress": "Pushes git commits/tags and creates GitHub Releases when the maintainer runs the documented release flow."
|
||||
},
|
||||
"operator_review": [
|
||||
"Internal maintainer tool only; it mutates git state, tags, and GitHub release metadata.",
|
||||
"Run it only from a trusted checkout with maintainer credentials and a clean working tree.",
|
||||
"Prefer non-destructive rollback steps; avoid rewriting history unless you explicitly intend to."
|
||||
],
|
||||
"triggers": [
|
||||
"release skill",
|
||||
"create release",
|
||||
"bump version",
|
||||
"tag release",
|
||||
"publish skill",
|
||||
"claw release",
|
||||
"deploy skill",
|
||||
"new version"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to the ClawSec ClawHub Checker will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.0.2] - 2026-04-14
|
||||
|
||||
### Added
|
||||
|
||||
- Runtime and operator-review metadata describing the suite dependency, ClawHub lookups, and in-place integration behavior.
|
||||
- Preflight disclosure in `scripts/setup_reputation_hook.mjs` before the installed suite is modified.
|
||||
- Regression coverage for setup disclosure in `test/setup_reputation_hook.test.mjs`.
|
||||
|
||||
### Changed
|
||||
|
||||
- Declared `node` and `openclaw` as required runtimes alongside `clawhub` because the integration flow depends on all three.
|
||||
- Documented that setup rewrites installed `clawsec-suite` files rather than operating on a detached copy.
|
||||
|
||||
### Security
|
||||
|
||||
- Made the string-based `handler.ts` rewrite and the remote ClawHub reputation-query behavior explicit so operators can review the mutation and network trust model before enabling it.
|
||||
@@ -1,142 +0,0 @@
|
||||
# ClawSec ClawHub Checker
|
||||
|
||||
A ClawSec suite skill that enhances the guarded skill installer with ClawHub reputation checks and VirusTotal Code Insight integration.
|
||||
|
||||
## Operational Notes
|
||||
|
||||
- Required runtime: `node`, `clawhub`, `openclaw`
|
||||
- Dependency: installed `clawsec-suite`
|
||||
- Setup mutates the installed suite in place by copying helper scripts and rewriting the advisory guardian hook handler
|
||||
- Reputation checks contact ClawHub and can surface heuristic false positives; risky installs still require explicit user confirmation
|
||||
|
||||
## Purpose
|
||||
|
||||
Adds a second layer of security to skill installation by:
|
||||
1. Checking ClawHub's VirusTotal Code Insight reputation scores
|
||||
2. Analyzing skill age, author reputation, and download statistics
|
||||
3. Requiring double confirmation for suspicious skills
|
||||
4. Integrating with existing ClawSec advisory checks
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
clawsec-suite (base)
|
||||
└── clawsec-clawhub-checker (enhancement)
|
||||
├── enhanced_guarded_install.mjs - Main enhanced installer
|
||||
├── check_clawhub_reputation.mjs - Reputation checking logic
|
||||
├── setup_reputation_hook.mjs - Integration script
|
||||
└── hooks/ - Enhanced advisory guardian hook
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
# First install the base suite
|
||||
npx clawhub install clawsec-suite
|
||||
|
||||
# Then install the checker
|
||||
npx clawhub install clawsec-clawhub-checker
|
||||
|
||||
# Run setup to integrate with existing suite
|
||||
node scripts/setup_reputation_hook.mjs
|
||||
|
||||
# Restart OpenClaw gateway
|
||||
openclaw gateway restart
|
||||
```
|
||||
|
||||
The setup script prints a preflight review before it mutates the installed suite files.
|
||||
|
||||
Setup installs these scripts into `clawsec-suite/scripts`:
|
||||
- `enhanced_guarded_install.mjs`
|
||||
- `guarded_skill_install_wrapper.mjs` (drop-in wrapper)
|
||||
- `check_clawhub_reputation.mjs`
|
||||
|
||||
The original `guarded_skill_install.mjs` remains unchanged.
|
||||
|
||||
## Usage
|
||||
|
||||
### Enhanced Guarded Installer
|
||||
|
||||
```bash
|
||||
# Basic usage via wrapper (includes reputation checks)
|
||||
node scripts/guarded_skill_install_wrapper.mjs --skill some-skill --version 1.0.0
|
||||
|
||||
# Direct usage (enhanced script)
|
||||
node scripts/enhanced_guarded_install.mjs --skill some-skill --version 1.0.0
|
||||
|
||||
# With reputation confirmation override
|
||||
node scripts/guarded_skill_install_wrapper.mjs --skill suspicious-skill --version 1.0.0 --confirm-reputation
|
||||
|
||||
# Adjust reputation threshold (default: 70)
|
||||
node scripts/guarded_skill_install_wrapper.mjs --skill some-skill --reputation-threshold 80
|
||||
```
|
||||
|
||||
### Reputation Check Only
|
||||
|
||||
```bash
|
||||
# Check reputation without installation
|
||||
node scripts/check_clawhub_reputation.mjs some-skill 1.0.0 70
|
||||
```
|
||||
|
||||
## Exit Codes
|
||||
|
||||
- `0` - Safe to install
|
||||
- `42` - Advisory match found (requires `--confirm-advisory`)
|
||||
- `43` - Reputation warning (requires `--confirm-reputation`) - **NEW**
|
||||
- `1` - Error
|
||||
|
||||
## Reputation Signals Checked
|
||||
|
||||
1. **VirusTotal Code Insight** - Malicious code patterns
|
||||
2. **Skill Age** - New skills (<7 days) are riskier
|
||||
3. **Author Reputation** - Number of published skills
|
||||
4. **Update Frequency** - Stale skills (>90 days)
|
||||
5. **Download Statistics** - Low download counts
|
||||
6. **Version Existence** - Specified version availability
|
||||
|
||||
## Configuration
|
||||
|
||||
Environment variables:
|
||||
- `CLAWHUB_REPUTATION_THRESHOLD` - Minimum score (0-100, default: 70)
|
||||
|
||||
## Integration Points
|
||||
|
||||
1. **Enhanced `guarded_skill_install.mjs`** - Wraps original with reputation checks
|
||||
via `guarded_skill_install_wrapper.mjs` and `enhanced_guarded_install.mjs`
|
||||
2. **Updated advisory guardian hook** - Adds reputation warnings to alerts
|
||||
3. **Catalog entry in clawsec-suite** - Listed as available enhancement
|
||||
|
||||
## Development
|
||||
|
||||
### Files
|
||||
|
||||
- `SKILL.md` - Main documentation
|
||||
- `skill.json` - Skill metadata and SBOM
|
||||
- `scripts/enhanced_guarded_install.mjs` - Enhanced installer
|
||||
- `scripts/check_clawhub_reputation.mjs` - Reputation logic
|
||||
- `scripts/setup_reputation_hook.mjs` - Integration script
|
||||
- `hooks/clawsec-advisory-guardian/lib/reputation.mjs` - Hook module
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
# Test reputation check
|
||||
node scripts/check_clawhub_reputation.mjs clawsec-suite
|
||||
|
||||
# Test enhanced installer (dry run)
|
||||
node scripts/enhanced_guarded_install.mjs --skill test-skill --dry-run
|
||||
|
||||
# Test setup
|
||||
node scripts/setup_reputation_hook.mjs
|
||||
```
|
||||
|
||||
## Security Considerations
|
||||
|
||||
- Reputation checks are **heuristic**, not definitive
|
||||
- **False positives** possible with legitimate novel skills
|
||||
- Always **review skill code** before overriding warnings
|
||||
- This is **defense-in-depth**, not replacement for advisory feeds
|
||||
|
||||
## License
|
||||
|
||||
GNU AGPL v3.0 or later - Part of the ClawSec security suite
|
||||
@@ -1,161 +0,0 @@
|
||||
---
|
||||
name: clawsec-clawhub-checker
|
||||
version: 0.0.2
|
||||
description: ClawHub reputation checker for ClawSec suite. Enhances guarded skill installer with VirusTotal Code Insight reputation scores and additional safety checks.
|
||||
homepage: https://clawsec.prompt.security
|
||||
clawdis:
|
||||
emoji: "🛡️"
|
||||
requires:
|
||||
bins: [node, clawhub, openclaw]
|
||||
depends_on: [clawsec-suite]
|
||||
---
|
||||
|
||||
# ClawSec ClawHub Checker
|
||||
|
||||
Enhances the ClawSec suite's guarded skill installer with ClawHub reputation checks. Adds a second layer of security by checking VirusTotal Code Insight scores and other reputation signals before allowing skill installation.
|
||||
|
||||
## Operational Notes
|
||||
|
||||
- Required runtime: `node`, `clawhub`, `openclaw`
|
||||
- Depends on: installed `clawsec-suite`
|
||||
- Side effects: `setup_reputation_hook.mjs` copies files into the installed suite and rewrites `hooks/clawsec-advisory-guardian/handler.ts`
|
||||
- Network behavior: reputation checks query ClawHub and may trigger remote metadata lookups during `inspect`/declined `install` flows
|
||||
- Trust model: reputation scores are heuristic, not authoritative; keep the double-confirmation flow enabled
|
||||
|
||||
## What It Does
|
||||
|
||||
1. **Wraps `clawhub install`** - Intercepts skill installation requests
|
||||
2. **Checks VirusTotal reputation** - Uses ClawHub's built-in VirusTotal Code Insight
|
||||
3. **Adds double confirmation** - For suspicious skills (reputation score below threshold)
|
||||
4. **Integrates with advisory feed** - Works alongside existing clawsec-suite advisories
|
||||
5. **Provides detailed reports** - Shows why a skill is flagged as suspicious
|
||||
|
||||
## Installation
|
||||
|
||||
This skill must be installed **after** `clawsec-suite`:
|
||||
|
||||
```bash
|
||||
# First install the suite
|
||||
npx clawhub@latest install clawsec-suite
|
||||
|
||||
# Then install the checker
|
||||
npx clawhub@latest install clawsec-clawhub-checker
|
||||
|
||||
# Run the setup script to integrate with clawsec-suite
|
||||
node ~/.openclaw/skills/clawsec-clawhub-checker/scripts/setup_reputation_hook.mjs
|
||||
|
||||
# Restart OpenClaw gateway for changes to take effect
|
||||
openclaw gateway restart
|
||||
```
|
||||
|
||||
The setup script prints a preflight review before it mutates the installed suite files.
|
||||
|
||||
After setup, the checker adds `enhanced_guarded_install.mjs` and
|
||||
`guarded_skill_install_wrapper.mjs` under `clawsec-suite/scripts` and updates the advisory
|
||||
guardian hook. The original `guarded_skill_install.mjs` is not replaced.
|
||||
|
||||
Review the printed preflight summary before running setup. The script intentionally modifies the installed suite in place rather than operating on a temporary copy.
|
||||
|
||||
## How It Works
|
||||
|
||||
### Enhanced Guarded Installer
|
||||
|
||||
After setup, run the wrapper (drop-in path) or the enhanced script directly:
|
||||
```bash
|
||||
# Recommended drop-in wrapper
|
||||
node scripts/guarded_skill_install_wrapper.mjs --skill some-skill --version 1.0.0
|
||||
|
||||
# Or call the enhanced script directly
|
||||
node scripts/enhanced_guarded_install.mjs --skill some-skill --version 1.0.0
|
||||
```
|
||||
|
||||
The enhanced flow:
|
||||
1. **Advisory check** (existing) - Checks clawsec advisory feed
|
||||
2. **Reputation check** (new) - Queries ClawHub for VirusTotal scores
|
||||
3. **Risk assessment** - Combines advisory + reputation signals
|
||||
4. **Double confirmation** - If risky, requires explicit `--confirm-reputation`
|
||||
|
||||
### Reputation Signals Checked
|
||||
|
||||
1. **VirusTotal Code Insight** - Malicious code patterns, external dependencies (Docker usage, network calls, eval usage, crypto keys)
|
||||
2. **Skill age & updates** - New skills vs established ones
|
||||
3. **Author reputation** - Other skills by same author
|
||||
4. **Download statistics** - Popularity signals
|
||||
|
||||
### Exit Codes
|
||||
|
||||
- `0` - Safe to install (no advisories, good reputation)
|
||||
- `42` - Advisory match found (existing behavior)
|
||||
- `43` - Reputation warning (new - requires `--confirm-reputation`)
|
||||
- `1` - Error
|
||||
|
||||
## Configuration
|
||||
|
||||
Environment variables:
|
||||
- `CLAWHUB_REPUTATION_THRESHOLD` - Minimum reputation score (0-100, default: 70)
|
||||
|
||||
## Integration with Existing Suite
|
||||
|
||||
The checker enhances but doesn't replace existing security:
|
||||
- **Advisory feed still primary** - Known malicious skills blocked first
|
||||
- **Reputation is secondary** - Unknown/suspicious skills get extra scrutiny
|
||||
- **Double confirmation preserved** - Both layers require explicit user approval
|
||||
|
||||
## Example Usage
|
||||
|
||||
```bash
|
||||
# Try to install a skill
|
||||
node scripts/guarded_skill_install_wrapper.mjs --skill suspicious-skill --version 1.0.0
|
||||
|
||||
# Output might show:
|
||||
# WARNING: Skill "suspicious-skill" has low reputation score (45/100)
|
||||
# - Flagged by VirusTotal Code Insight: crypto keys, external APIs, eval usage
|
||||
# - Author has no other published skills
|
||||
# - Skill is less than 7 days old
|
||||
#
|
||||
# To install despite reputation warning, run:
|
||||
# node scripts/guarded_skill_install_wrapper.mjs --skill suspicious-skill --version 1.0.0 --confirm-reputation
|
||||
|
||||
# Install with confirmation
|
||||
node scripts/guarded_skill_install_wrapper.mjs --skill suspicious-skill --version 1.0.0 --confirm-reputation
|
||||
```
|
||||
|
||||
## Safety Notes
|
||||
|
||||
- This is a **defense-in-depth** layer, not a replacement for advisory feeds
|
||||
- VirusTotal scores are **heuristic**, not definitive
|
||||
- **False positives possible** - Legitimate skills with novel patterns might be flagged
|
||||
- Always **review skill code** before installing with `--confirm-reputation`
|
||||
|
||||
## Current Limitations
|
||||
|
||||
### Missing OpenClaw Internal Check Data
|
||||
ClawHub shows two security badges on skill pages:
|
||||
1. **VirusTotal Code Insight** - ✅ Our checker catches these flags
|
||||
2. **OpenClaw internal check** - ❌ Not exposed via API (only on website)
|
||||
|
||||
Example from `clawsec-suite` page:
|
||||
- VirusTotal: "Benign" ✓
|
||||
- OpenClaw internal check: "The package is internally consistent with a feed-monitoring / advisory-guardian purpose, but a few operational details and optional bypasses deserve attention before installing."
|
||||
|
||||
**Our checker cannot access OpenClaw internal check warnings** as they're not exposed via `clawhub` CLI or API.
|
||||
|
||||
### Recommendation for ClawHub
|
||||
To enable complete reputation checking, ClawHub should expose internal check results via:
|
||||
- `clawhub inspect --json` endpoint
|
||||
- Additional API field for security tools
|
||||
- Or include in `clawhub install` warning output
|
||||
|
||||
### Workaround
|
||||
Our heuristic checks (skill age, author reputation, downloads, updates) provide similar risk assessment but miss specific operational warnings about bypasses, missing signatures, etc. Always check the ClawHub website for complete security assessment.
|
||||
|
||||
## Development
|
||||
|
||||
To modify the reputation checking logic, edit:
|
||||
- `scripts/enhanced_guarded_install.mjs` - Main enhanced installer
|
||||
- `scripts/check_clawhub_reputation.mjs` - Reputation checking logic
|
||||
- `hooks/clawsec-advisory-guardian/lib/reputation.mjs` - Hook integration
|
||||
|
||||
## License
|
||||
|
||||
GNU AGPL v3.0 or later - Part of the ClawSec security suite
|
||||
@@ -1,99 +0,0 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import path from "node:path";
|
||||
|
||||
/**
|
||||
* Check reputation for a skill
|
||||
* @param {string} skillName - Skill name
|
||||
* @param {string} version - Skill version
|
||||
* @returns {Promise<{safe: boolean, score: number, warnings: string[]}>}
|
||||
*/
|
||||
export async function checkReputation(skillName, version) {
|
||||
const result = {
|
||||
safe: true,
|
||||
score: 100,
|
||||
warnings: [],
|
||||
};
|
||||
|
||||
try {
|
||||
// Try to get skill slug from directory name or skill.json
|
||||
// For now, use skillName as slug (simplified)
|
||||
const skillSlug = skillName.toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
||||
|
||||
// Run the reputation check script
|
||||
// Current file is at: .../hooks/clawsec-advisory-guardian/lib/reputation.mjs
|
||||
// We need to go up 3 levels to get to the skill root directory
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const checkerDir = path.resolve(__dirname, '../../..');
|
||||
|
||||
const reputationCheck = spawnSync(
|
||||
"node",
|
||||
[
|
||||
`${checkerDir}/scripts/check_clawhub_reputation.mjs`,
|
||||
skillSlug,
|
||||
version || "",
|
||||
"70" // Default threshold
|
||||
],
|
||||
{ encoding: "utf-8", cwd: checkerDir }
|
||||
);
|
||||
|
||||
if (reputationCheck.status === 0) {
|
||||
try {
|
||||
const repResult = JSON.parse(reputationCheck.stdout);
|
||||
result.safe = repResult.safe;
|
||||
result.score = repResult.score;
|
||||
result.warnings = repResult.warnings;
|
||||
} catch (parseError) {
|
||||
result.warnings.push(`Failed to parse reputation result: ${parseError.message}`);
|
||||
result.score = 60;
|
||||
result.safe = result.score >= 70;
|
||||
}
|
||||
} else if (reputationCheck.status === 43) {
|
||||
// Reputation warning exit code
|
||||
try {
|
||||
const repResult = JSON.parse(reputationCheck.stdout);
|
||||
result.safe = false;
|
||||
result.score = repResult.score;
|
||||
result.warnings = repResult.warnings;
|
||||
} catch {
|
||||
result.safe = false;
|
||||
result.score = 50;
|
||||
result.warnings.push("Skill flagged by reputation check");
|
||||
}
|
||||
} else {
|
||||
// Error running check
|
||||
result.warnings.push(`Reputation check failed: ${reputationCheck.stderr || 'Unknown error'}`);
|
||||
result.score = 60;
|
||||
result.safe = result.score >= 70;
|
||||
}
|
||||
} catch (error) {
|
||||
result.warnings.push(`Reputation check error: ${error.message}`);
|
||||
result.score = 50;
|
||||
result.safe = result.score >= 70;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format reputation warning for alert messages
|
||||
* @param {{score: number, warnings: string[]}} reputationInfo
|
||||
* @returns {string}
|
||||
*/
|
||||
export function formatReputationWarning(reputationInfo) {
|
||||
if (!reputationInfo || reputationInfo.score >= 70) return "";
|
||||
|
||||
const lines = [
|
||||
`\n⚠️ **REPUTATION WARNING** (Score: ${reputationInfo.score}/100)`,
|
||||
];
|
||||
|
||||
if (reputationInfo.warnings.length > 0) {
|
||||
lines.push("");
|
||||
reputationInfo.warnings.forEach(w => lines.push(`• ${w}`));
|
||||
}
|
||||
|
||||
lines.push("");
|
||||
lines.push("This skill has low reputation score. Review carefully before installation.");
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
@@ -1,223 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawnSync } from "node:child_process";
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
/**
|
||||
* Check ClawHub reputation for a skill
|
||||
* @param {string} skillSlug - Skill slug to check
|
||||
* @param {string} version - Optional version
|
||||
* @param {number} threshold - Minimum reputation score (0-100)
|
||||
* @returns {Promise<{safe: boolean, score: number, warnings: string[], virustotal: string[]}>}
|
||||
*/
|
||||
export async function checkClawhubReputation(skillSlug, version, threshold = 70) {
|
||||
const result = {
|
||||
safe: true,
|
||||
score: 100, // Default score if no checks fail
|
||||
warnings: [],
|
||||
virustotal: [],
|
||||
};
|
||||
|
||||
// Input validation — reject anything that isn't a safe slug or semver
|
||||
if (!/^[a-z0-9][a-z0-9-]*$/.test(skillSlug)) {
|
||||
result.warnings.push(`Invalid skill slug: ${skillSlug}`);
|
||||
result.score = 0;
|
||||
result.safe = false;
|
||||
return result;
|
||||
}
|
||||
// Semver validation: supports major.minor.patch with optional pre-release and build metadata
|
||||
// Examples: 1.0.0, 1.0.0-alpha.1, 1.0.0-beta+20130313144700
|
||||
// More restrictive than full semver spec for security (prevents command injection)
|
||||
if (version && !/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?(?:\+[a-zA-Z0-9.-]+)?$/.test(version)) {
|
||||
result.warnings.push(`Invalid version format: ${version}`);
|
||||
result.score = 0;
|
||||
result.safe = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
// Check 1: Try to inspect the skill via clawhub
|
||||
const inspectResult = spawnSync(
|
||||
"clawhub",
|
||||
["inspect", skillSlug, "--json"],
|
||||
{ encoding: "utf-8" }
|
||||
);
|
||||
|
||||
if (inspectResult.status !== 0) {
|
||||
// Skill doesn't exist or can't be inspected
|
||||
result.warnings.push(`Skill "${skillSlug}" not found or cannot be inspected`);
|
||||
result.score = Math.min(result.score, 50);
|
||||
} else {
|
||||
try {
|
||||
const skillInfo = JSON.parse(inspectResult.stdout);
|
||||
|
||||
// Check 2: Skill age (new skills are riskier)
|
||||
if (skillInfo.skill?.createdAt) {
|
||||
const createdMs = skillInfo.skill.createdAt;
|
||||
const ageDays = (Date.now() - createdMs) / (1000 * 60 * 60 * 24);
|
||||
|
||||
if (ageDays < 7) {
|
||||
result.warnings.push(`Skill is less than 7 days old (${ageDays.toFixed(1)} days)`);
|
||||
result.score -= 15;
|
||||
} else if (ageDays < 30) {
|
||||
result.warnings.push(`Skill is less than 30 days old (${ageDays.toFixed(1)} days)`);
|
||||
result.score -= 5;
|
||||
}
|
||||
}
|
||||
|
||||
// Check 3: Update frequency (stale skills are riskier)
|
||||
if (skillInfo.skill?.updatedAt && skillInfo.skill?.createdAt) {
|
||||
const updatedMs = skillInfo.skill.updatedAt;
|
||||
const createdMs = skillInfo.skill.createdAt;
|
||||
const updateAgeDays = (Date.now() - updatedMs) / (1000 * 60 * 60 * 24);
|
||||
const totalAgeDays = (Date.now() - createdMs) / (1000 * 60 * 60 * 24);
|
||||
|
||||
if (updateAgeDays > 90 && totalAgeDays > 90) {
|
||||
result.warnings.push(`Skill hasn't been updated in ${updateAgeDays.toFixed(0)} days`);
|
||||
result.score -= 10;
|
||||
}
|
||||
}
|
||||
|
||||
// Check 4: Author reputation
|
||||
if (skillInfo.owner?.handle) {
|
||||
const authorResult = spawnSync(
|
||||
"clawhub",
|
||||
["search", skillInfo.owner.handle],
|
||||
{ encoding: "utf-8" }
|
||||
);
|
||||
|
||||
if (authorResult.status === 0) {
|
||||
const lines = authorResult.stdout.trim().split('\n').filter(l => l);
|
||||
const skillCount = lines.length - 1; // First line is header
|
||||
|
||||
if (skillCount === 1) {
|
||||
result.warnings.push(`Author "${skillInfo.owner.handle}" has only 1 published skill`);
|
||||
result.score -= 10;
|
||||
} else if (skillCount < 3) {
|
||||
result.warnings.push(`Author "${skillInfo.owner.handle}" has only ${skillCount} published skills`);
|
||||
result.score -= 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check 5: Download statistics
|
||||
if (skillInfo.skill?.stats?.downloads !== undefined) {
|
||||
const downloads = skillInfo.skill.stats.downloads;
|
||||
if (downloads < 10) {
|
||||
result.warnings.push(`Low download count: ${downloads}`);
|
||||
result.score -= 10;
|
||||
} else if (downloads < 100) {
|
||||
result.warnings.push(`Moderate download count: ${downloads}`);
|
||||
result.score -= 5;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (parseError) {
|
||||
result.warnings.push(`Failed to parse skill information: ${parseError.message}`);
|
||||
result.score = Math.min(result.score, 60);
|
||||
}
|
||||
}
|
||||
|
||||
// Check 6: Try installation to detect VirusTotal Code Insight warnings
|
||||
// Note: This approach has potential side effects:
|
||||
// - May download/cache skill metadata before declining
|
||||
// - Depends on clawhub's prompting behavior (sending "n\n" to decline)
|
||||
// - If clawhub inspect provided security flags, we'd use that instead
|
||||
// This is the only way to programmatically access VirusTotal warnings currently
|
||||
const installArgs = ["install", skillSlug];
|
||||
if (version) installArgs.push("--version", version);
|
||||
const installCheck = spawnSync("clawhub", installArgs, {
|
||||
input: "n\n", // Automatically decline the installation prompt
|
||||
encoding: "utf-8",
|
||||
});
|
||||
|
||||
const output = (installCheck.stdout || "") + (installCheck.stderr || "");
|
||||
if (output.includes("suspicious") || output.includes("VirusTotal") || output.includes("flagged")) {
|
||||
result.virustotal.push("Flagged by ClawHub's VirusTotal Code Insight");
|
||||
result.score -= 40; // More severe penalty for VirusTotal flag
|
||||
|
||||
// Extract specific warnings
|
||||
const lines = output.split('\n');
|
||||
for (const line of lines) {
|
||||
if (line.includes("Warning:") || line.includes("risky patterns") ||
|
||||
line.includes("crypto keys") || line.includes("external APIs") ||
|
||||
line.includes("eval") || line.includes("VirusTotal Code Insight")) {
|
||||
const cleanLine = line.trim().replace(/^⚠️\s*/, '').replace(/^\s*Warning:\s*/, '');
|
||||
if (cleanLine && !result.virustotal.includes(cleanLine)) {
|
||||
result.virustotal.push(cleanLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check 7: If version specified, check if it exists
|
||||
if (version) {
|
||||
const versionCheck = spawnSync(
|
||||
"clawhub",
|
||||
["inspect", skillSlug, "--version", version, "--json"],
|
||||
{ encoding: "utf-8" }
|
||||
);
|
||||
|
||||
if (versionCheck.status !== 0) {
|
||||
result.warnings.push(`Version ${version} not found for skill ${skillSlug}`);
|
||||
result.score -= 20;
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure score is within bounds
|
||||
result.score = Math.max(0, Math.min(100, result.score));
|
||||
result.safe = result.score >= threshold;
|
||||
|
||||
// Add summary warning if below threshold
|
||||
if (!result.safe) {
|
||||
result.warnings.unshift(`Reputation score ${result.score}/100 below threshold ${threshold}/100`);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
result.warnings.push(`Reputation check error: ${error.message}`);
|
||||
result.score = 50;
|
||||
result.safe = result.score >= threshold;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// CLI interface for direct usage
|
||||
const isCliEntrypoint =
|
||||
process.argv[1] !== undefined &&
|
||||
import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href;
|
||||
|
||||
if (isCliEntrypoint) {
|
||||
async function main() {
|
||||
const args = process.argv.slice(2);
|
||||
if (args.length < 1) {
|
||||
console.error("Usage: node check_clawhub_reputation.mjs <skill-slug> [version] [threshold]");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const skillSlug = args[0];
|
||||
const version = args[1] || "";
|
||||
let threshold = 70;
|
||||
if (args[2] !== undefined) {
|
||||
const parsedThreshold = parseInt(args[2], 10);
|
||||
if (!Number.isInteger(parsedThreshold) || parsedThreshold < 0 || parsedThreshold > 100) {
|
||||
console.error(
|
||||
`Invalid threshold: "${args[2]}". Threshold must be an integer between 0 and 100.`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
threshold = parsedThreshold;
|
||||
}
|
||||
|
||||
const result = await checkClawhubReputation(skillSlug, version, threshold);
|
||||
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
|
||||
if (!result.safe) {
|
||||
process.exit(43);
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
}
|
||||
@@ -1,229 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawnSync } from "node:child_process";
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { checkClawhubReputation } from "./check_clawhub_reputation.mjs";
|
||||
|
||||
const EXIT_ADVISORY_CONFIRM_REQUIRED = 42;
|
||||
const EXIT_REPUTATION_CONFIRM_REQUIRED = 43;
|
||||
|
||||
function printUsage() {
|
||||
process.stderr.write(
|
||||
[
|
||||
"Usage:",
|
||||
" node scripts/enhanced_guarded_install.mjs --skill <skill-name> [--version <version>] [--confirm-advisory] [--confirm-reputation] [--dry-run] [--reputation-threshold <score>]",
|
||||
"",
|
||||
"Examples:",
|
||||
" node scripts/enhanced_guarded_install.mjs --skill helper-plus --version 1.0.1",
|
||||
" node scripts/enhanced_guarded_install.mjs --skill helper-plus --version 1.0.1 --confirm-advisory --confirm-reputation",
|
||||
" node scripts/enhanced_guarded_install.mjs --skill suspicious-skill --reputation-threshold 80",
|
||||
"",
|
||||
"Exit codes:",
|
||||
" 0 success / no advisory or reputation block",
|
||||
" 42 advisory matched and second confirmation is required",
|
||||
" 43 reputation warning and second confirmation is required",
|
||||
" 1 error",
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
// Parse and validate CLAWHUB_REPUTATION_THRESHOLD environment variable
|
||||
let defaultThreshold = 70;
|
||||
const envThreshold = process.env.CLAWHUB_REPUTATION_THRESHOLD;
|
||||
|
||||
if (envThreshold !== undefined && envThreshold !== "") {
|
||||
const parsedEnv = parseInt(envThreshold, 10);
|
||||
if (Number.isNaN(parsedEnv) || parsedEnv < 0 || parsedEnv > 100) {
|
||||
throw new Error(
|
||||
`Invalid CLAWHUB_REPUTATION_THRESHOLD environment variable: "${envThreshold}". Must be between 0 and 100.`
|
||||
);
|
||||
}
|
||||
defaultThreshold = parsedEnv;
|
||||
}
|
||||
|
||||
const parsed = {
|
||||
skill: "",
|
||||
version: "",
|
||||
confirmAdvisory: false,
|
||||
confirmReputation: false,
|
||||
dryRun: false,
|
||||
reputationThreshold: defaultThreshold,
|
||||
};
|
||||
|
||||
for (let i = 0; i < argv.length; i += 1) {
|
||||
const token = argv[i];
|
||||
|
||||
if (token === "--skill") {
|
||||
parsed.skill = String(argv[i + 1] ?? "").trim();
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
if (token === "--version") {
|
||||
parsed.version = String(argv[i + 1] ?? "").trim();
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
if (token === "--confirm-advisory") {
|
||||
parsed.confirmAdvisory = true;
|
||||
continue;
|
||||
}
|
||||
if (token === "--confirm-reputation") {
|
||||
parsed.confirmReputation = true;
|
||||
continue;
|
||||
}
|
||||
if (token === "--dry-run") {
|
||||
parsed.dryRun = true;
|
||||
continue;
|
||||
}
|
||||
if (token === "--reputation-threshold") {
|
||||
parsed.reputationThreshold = parseInt(String(argv[i + 1] ?? "70"), 10);
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
if (token === "--help" || token === "-h") {
|
||||
printUsage();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
throw new Error(`Unknown argument: ${token}`);
|
||||
}
|
||||
|
||||
if (!parsed.skill) {
|
||||
throw new Error("Missing required argument: --skill");
|
||||
}
|
||||
// Must start with alphanumeric, then can contain hyphens (matches check_clawhub_reputation.mjs validation)
|
||||
if (!/^[a-z0-9][a-z0-9-]*$/.test(parsed.skill)) {
|
||||
throw new Error("Invalid --skill value. Must start with a letter or digit, followed by lowercase letters, digits, and hyphens.");
|
||||
}
|
||||
if (parsed.version && !/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?(?:\+[a-zA-Z0-9.-]+)?$/.test(parsed.version)) {
|
||||
throw new Error(
|
||||
"Invalid --version value. Must be semantic version format (e.g., 1.2.3, 1.2.3-beta.1, 1.2.3+build.45)."
|
||||
);
|
||||
}
|
||||
if (parsed.reputationThreshold < 0 || parsed.reputationThreshold > 100 || Number.isNaN(parsed.reputationThreshold)) {
|
||||
throw new Error("Invalid --reputation-threshold value. Must be between 0 and 100.");
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
function buildOriginalArgs(argv) {
|
||||
// Filter out reputation-specific arguments that the original script doesn't understand
|
||||
const originalArgs = [];
|
||||
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
const token = argv[i];
|
||||
|
||||
if (token === "--confirm-reputation" || token === "--reputation-threshold") {
|
||||
// Skip reputation-specific flags
|
||||
if (token === "--reputation-threshold" && i + 1 < argv.length) {
|
||||
// Also skip the value associated with --reputation-threshold
|
||||
i += 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
originalArgs.push(token);
|
||||
}
|
||||
|
||||
return originalArgs;
|
||||
}
|
||||
|
||||
async function runOriginalGuardedInstall(args) {
|
||||
// Find the original guarded_skill_install.mjs from clawsec-suite
|
||||
const suiteDir = path.join(os.homedir(), ".openclaw", "skills", "clawsec-suite");
|
||||
const originalScript = path.join(suiteDir, "scripts", "guarded_skill_install.mjs");
|
||||
|
||||
try {
|
||||
await fs.access(originalScript);
|
||||
} catch {
|
||||
throw new Error(`Original guarded_skill_install.mjs not found at ${originalScript}. Is clawsec-suite installed?`);
|
||||
}
|
||||
|
||||
// Pass through environment without modification
|
||||
// The original guarded_skill_install.mjs handles --confirm-advisory properly
|
||||
const child = spawnSync(
|
||||
"node",
|
||||
[originalScript, ...args.originalArgs],
|
||||
{
|
||||
stdio: "inherit",
|
||||
env: process.env,
|
||||
cwd: suiteDir,
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
exitCode: child.status ?? 1,
|
||||
signal: child.signal,
|
||||
};
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const cliArgs = process.argv.slice(2);
|
||||
const args = parseArgs(cliArgs);
|
||||
|
||||
// Build args for original script (excluding reputation-specific args)
|
||||
args.originalArgs = buildOriginalArgs(cliArgs);
|
||||
|
||||
// Step 1: Check reputation (unless already confirmed)
|
||||
if (!args.confirmReputation) {
|
||||
console.log(`Checking ClawHub reputation for ${args.skill}${args.version ? `@${args.version}` : ""}...`);
|
||||
|
||||
const reputationResult = await checkClawhubReputation(args.skill, args.version, args.reputationThreshold);
|
||||
|
||||
if (!reputationResult.safe) {
|
||||
console.error("\n" + "=".repeat(80));
|
||||
console.error("REPUTATION WARNING");
|
||||
console.error("=".repeat(80));
|
||||
console.error(`Skill "${args.skill}" has low reputation score: ${reputationResult.score}/100`);
|
||||
console.error(`Threshold: ${args.reputationThreshold}/100`);
|
||||
console.error("");
|
||||
|
||||
if (reputationResult.warnings.length > 0) {
|
||||
console.error("Warnings:");
|
||||
reputationResult.warnings.forEach(w => console.error(` • ${w}`));
|
||||
console.error("");
|
||||
}
|
||||
|
||||
if (reputationResult.virustotal) {
|
||||
console.error("VirusTotal Code Insight flags:");
|
||||
reputationResult.virustotal.forEach(v => console.error(` • ${v}`));
|
||||
console.error("");
|
||||
}
|
||||
|
||||
console.error("To install despite reputation warning, run with --confirm-reputation flag:");
|
||||
console.error(` node ${process.argv[1]} --skill ${args.skill}${args.version ? ` --version ${args.version}` : ""} --confirm-reputation`);
|
||||
console.error("");
|
||||
console.error("=".repeat(80));
|
||||
|
||||
process.exit(EXIT_REPUTATION_CONFIRM_REQUIRED);
|
||||
}
|
||||
|
||||
console.log(`✓ Reputation check passed: ${reputationResult.score}/100`);
|
||||
} else {
|
||||
console.log(`⚠️ Reputation confirmation override enabled for ${args.skill}`);
|
||||
}
|
||||
|
||||
// Step 2: Run original guarded installer (handles advisory checks)
|
||||
console.log("\nRunning advisory checks...");
|
||||
const result = await runOriginalGuardedInstall(args);
|
||||
|
||||
if (result.exitCode !== 0 && result.exitCode !== EXIT_ADVISORY_CONFIRM_REQUIRED) {
|
||||
process.exit(result.exitCode);
|
||||
}
|
||||
|
||||
// If we get here, either success (0) or advisory confirmation required (42)
|
||||
process.exit(result.exitCode);
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error:", error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||