mirror of
https://github.com/prompt-security/clawsec.git
synced 2026-06-13 13:38:03 +03:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c3129183a5 |
@@ -1,2 +1,2 @@
|
||||
ruff==0.15.13
|
||||
ruff==0.15.12
|
||||
bandit==1.9.4
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
name: Archive GitHub Traffic
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '17 3 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: traffic-archive
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
TRAFFIC_ARCHIVE_BRANCH: traffic-archive
|
||||
TRAFFIC_ARCHIVE_DIR: ../traffic-archive/traffic
|
||||
|
||||
jobs:
|
||||
archive:
|
||||
name: Capture traffic snapshot
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Prepare archive branch
|
||||
env:
|
||||
ARCHIVE_PUSH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
server="${GITHUB_SERVER_URL#https://}"
|
||||
archive_remote="https://x-access-token:${ARCHIVE_PUSH_TOKEN}@${server}/${GITHUB_REPOSITORY}.git"
|
||||
|
||||
if git ls-remote --exit-code --heads "${archive_remote}" "${TRAFFIC_ARCHIVE_BRANCH}" >/dev/null 2>&1; then
|
||||
git clone --branch "${TRAFFIC_ARCHIVE_BRANCH}" --depth 1 "${archive_remote}" ../traffic-archive
|
||||
else
|
||||
git init -b "${TRAFFIC_ARCHIVE_BRANCH}" ../traffic-archive
|
||||
git -C ../traffic-archive remote add origin "${archive_remote}"
|
||||
fi
|
||||
|
||||
mkdir -p "${TRAFFIC_ARCHIVE_DIR}"
|
||||
|
||||
- name: Collect traffic
|
||||
env:
|
||||
GH_TRAFFIC_TOKEN: ${{ secrets.TRAFFIC_ARCHIVE_TOKEN || github.token }}
|
||||
GITHUB_REPOSITORY: ${{ github.repository }}
|
||||
run: node scripts/archive-github-traffic.mjs --archive-dir "${TRAFFIC_ARCHIVE_DIR}"
|
||||
|
||||
- name: Commit archive
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
cd ../traffic-archive
|
||||
git add traffic/archive.json traffic/summary.json
|
||||
git rm --ignore-unmatch traffic/README.md
|
||||
|
||||
if git diff --cached --quiet; then
|
||||
echo "No traffic archive changes."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git commit -m "chore(traffic): archive repository traffic $(date -u +%F)"
|
||||
git push origin HEAD:${TRAFFIC_ARCHIVE_BRANCH}
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
- windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
@@ -83,7 +83,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
@@ -93,37 +93,12 @@ jobs:
|
||||
- name: Check for outdated deps
|
||||
run: npm outdated || true
|
||||
|
||||
advisory-feed-tests:
|
||||
name: Advisory Feed Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
- name: GHSA Without CVE Feed Tests
|
||||
run: node scripts/test-ghsa-without-cve-feed.mjs
|
||||
- name: GHSA Poll Workflow Tests
|
||||
run: node scripts/test-ghsa-poll-workflow.mjs
|
||||
- name: NVD GHSA Consolidation Workflow Tests
|
||||
run: node scripts/test-nvd-ghsa-consolidation-workflow.mjs
|
||||
- name: NVD + GHSA Pipeline Dry Run
|
||||
run: node scripts/test-nvd-ghsa-pipeline-dry-run.mjs
|
||||
- name: Skill Release Workflow Tests
|
||||
run: node scripts/test-skill-release-workflow.mjs
|
||||
- name: Deploy Pages Advisory Checksums Tests
|
||||
run: node scripts/test-deploy-pages-checksums.mjs
|
||||
- name: GitHub Traffic Archive Tests
|
||||
run: node scripts/test-github-traffic-archive.mjs
|
||||
|
||||
clawsec-suite-tests:
|
||||
name: ClawSec Suite Verification Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
@@ -148,7 +123,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4
|
||||
uses: github/codeql-action/init@c10b8064de6f491fea524254123dbe5e09572f13 # v4
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
config-file: ./.github/codeql/codeql-config.yml
|
||||
@@ -38,4 +38,4 @@ jobs:
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4
|
||||
uses: github/codeql-action/analyze@c10b8064de6f491fea524254123dbe5e09572f13 # v4
|
||||
|
||||
@@ -273,7 +273,7 @@ jobs:
|
||||
- name: Create Pull Request
|
||||
if: steps.parse.outputs.already_exists != 'true'
|
||||
id: create-pr
|
||||
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
|
||||
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 }}
|
||||
@@ -302,7 +302,7 @@ jobs:
|
||||
|
||||
- name: Comment on issue
|
||||
if: steps.parse.outputs.already_exists != 'true'
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||
with:
|
||||
github-token: ${{ secrets.POLL_NVD_CVES_PAT }}
|
||||
script: |
|
||||
@@ -328,7 +328,7 @@ jobs:
|
||||
|
||||
- name: Comment if already exists
|
||||
if: steps.parse.outputs.already_exists == 'true'
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||
with:
|
||||
github-token: ${{ secrets.POLL_NVD_CVES_PAT }}
|
||||
script: |
|
||||
|
||||
@@ -183,36 +183,16 @@ jobs:
|
||||
done
|
||||
|
||||
# Build skill entry for index
|
||||
SKILL_DATA=$(jq -c --arg tag "$TAG" '
|
||||
. as $skill |
|
||||
def object_or_empty($value):
|
||||
if ($value | type) == "object" then $value else {} end;
|
||||
def object_field($name):
|
||||
object_or_empty($skill[$name]?);
|
||||
def platform_meta:
|
||||
($skill.platform as $platform
|
||||
| if ($platform | type) == "string" then object_or_empty($skill[$platform]?)
|
||||
else {}
|
||||
end);
|
||||
def platform_list:
|
||||
([]
|
||||
+ (if ($skill.platforms | type) == "array" then $skill.platforms else [] end)
|
||||
+ (if ($skill.platform | type) == "string" then [$skill.platform] else [] end)
|
||||
+ (["openclaw", "hermes", "nanoclaw", "picoclaw"] | map(select((object_field(.) | length) > 0))))
|
||||
| map(select(type == "string") | ascii_downcase)
|
||||
| unique;
|
||||
{
|
||||
id: .name,
|
||||
name: .name,
|
||||
version: .version,
|
||||
description: .description,
|
||||
emoji: (platform_meta.emoji // object_field("openclaw").emoji // object_field("hermes").emoji // object_field("nanoclaw").emoji // object_field("picoclaw").emoji // "📦"),
|
||||
category: (platform_meta.category // object_field("openclaw").category // object_field("hermes").category // object_field("nanoclaw").category // object_field("picoclaw").category // "utility"),
|
||||
platforms: platform_list,
|
||||
trust: .trust.level,
|
||||
tag: $tag
|
||||
}
|
||||
' "$MIRROR_DIR/skill.json")
|
||||
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
|
||||
@@ -249,51 +229,16 @@ jobs:
|
||||
set -euo pipefail
|
||||
mkdir -p public/advisories
|
||||
cp advisories/feed.json public/advisories/feed.json
|
||||
if [ -f advisories/ghsa-without-cve.json ]; then
|
||||
cp advisories/ghsa-without-cve.json public/advisories/ghsa-without-cve.json
|
||||
fi
|
||||
echo "Copied advisory feed to public/advisories/"
|
||||
cat public/advisories/feed.json | jq '.advisories | length' | xargs -I {} echo "Feed contains {} advisories"
|
||||
if [ -f public/advisories/ghsa-without-cve.json ]; then
|
||||
cat public/advisories/ghsa-without-cve.json | jq '.advisories | length' | xargs -I {} echo "GHSA provisional feed contains {} advisories"
|
||||
fi
|
||||
|
||||
- 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 provisional GHSA feed and verify
|
||||
if: hashFiles('public/advisories/ghsa-without-cve.json') != ''
|
||||
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/ghsa-without-cve.json
|
||||
signature_file: public/advisories/ghsa-without-cve.json.sig
|
||||
|
||||
- name: Generate advisory checksums manifest
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
FILES_JSON="{}"
|
||||
ADVISORY_ARTIFACTS=(public/advisories/*.json public/advisories/*.json.sig)
|
||||
for file in "${ADVISORY_ARTIFACTS[@]}"; do
|
||||
[ -e "$file" ] || continue
|
||||
REL_PATH="${file#public/}"
|
||||
FILE_SHA=$(sha256sum "$file" | awk '{print $1}')
|
||||
FILE_SIZE=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file")
|
||||
FILES_JSON=$(jq \
|
||||
--arg path "$REL_PATH" \
|
||||
--arg sha "$FILE_SHA" \
|
||||
--argjson size "$FILE_SIZE" \
|
||||
'. + {($path): {sha256: $sha, size: $size, path: $path, url: ("https://clawsec.prompt.security/" + $path)}}' \
|
||||
<<< "$FILES_JSON")
|
||||
done
|
||||
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)
|
||||
@@ -307,19 +252,36 @@ jobs:
|
||||
--arg version "1.1.0" \
|
||||
--arg generated "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||
--arg repo "${{ github.repository }}" \
|
||||
--argjson files "$FILES_JSON" \
|
||||
--arg sha "$FEED_SHA" \
|
||||
--argjson size "$FEED_SIZE" \
|
||||
'{
|
||||
schema_version: $schema_version,
|
||||
algorithm: $algorithm,
|
||||
version: $version,
|
||||
generated_at: $generated,
|
||||
repository: $repo,
|
||||
files: $files
|
||||
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:
|
||||
@@ -352,11 +314,11 @@ jobs:
|
||||
- name: Show signed advisory artifacts
|
||||
run: |
|
||||
echo "Signed advisory artifacts:"
|
||||
ls -la public/advisories/*.json*
|
||||
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@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
@@ -405,16 +367,6 @@ jobs:
|
||||
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/advisories/ghsa-without-cve.json" ]; then
|
||||
mkdir -p "$MIRROR_LATEST_DIR/advisories"
|
||||
cp "public/advisories/ghsa-without-cve.json" "$MIRROR_LATEST_DIR/advisories/ghsa-without-cve.json"
|
||||
cp "public/advisories/ghsa-without-cve.json" "$MIRROR_LATEST_DIR/ghsa-without-cve.json"
|
||||
fi
|
||||
if [ -f "public/advisories/ghsa-without-cve.json.sig" ]; then
|
||||
mkdir -p "$MIRROR_LATEST_DIR/advisories"
|
||||
cp "public/advisories/ghsa-without-cve.json.sig" "$MIRROR_LATEST_DIR/advisories/ghsa-without-cve.json.sig"
|
||||
cp "public/advisories/ghsa-without-cve.json.sig" "$MIRROR_LATEST_DIR/ghsa-without-cve.json.sig"
|
||||
fi
|
||||
if [ -f "public/checksums.json" ]; then
|
||||
cp "public/checksums.json" "$MIRROR_LATEST_DIR/checksums.json"
|
||||
fi
|
||||
@@ -454,10 +406,10 @@ jobs:
|
||||
run: touch dist/.nojekyll
|
||||
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
|
||||
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
|
||||
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
|
||||
with:
|
||||
path: ./dist
|
||||
|
||||
|
||||
@@ -27,26 +27,14 @@ jobs:
|
||||
set -euo pipefail
|
||||
mkdir -p public/advisories
|
||||
cp advisories/feed.json public/advisories/feed.json
|
||||
if [ -f advisories/ghsa-without-cve.json ]; then
|
||||
cp advisories/ghsa-without-cve.json public/advisories/ghsa-without-cve.json
|
||||
fi
|
||||
|
||||
- name: Generate advisory checksums manifest
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
FILES_JSON="{}"
|
||||
for file in public/advisories/*.json; do
|
||||
REL_PATH="${file#public/}"
|
||||
FILE_SHA=$(sha256sum "$file" | awk '{print $1}')
|
||||
FILE_SIZE=$(stat -c%s "$file" 2>/dev/null || stat -f%z "$file")
|
||||
FILES_JSON=$(jq \
|
||||
--arg path "$REL_PATH" \
|
||||
--arg sha "$FILE_SHA" \
|
||||
--argjson size "$FILE_SIZE" \
|
||||
'. + {($path): {sha256: $sha, size: $size, path: $path, url: ("https://clawsec.prompt.security/" + $path)}}' \
|
||||
<<< "$FILES_JSON")
|
||||
done
|
||||
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" \
|
||||
@@ -54,14 +42,22 @@ jobs:
|
||||
--arg version "1.1.0" \
|
||||
--arg generated "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||
--arg repo "${{ github.repository }}" \
|
||||
--argjson files "$FILES_JSON" \
|
||||
--arg sha "$FEED_SHA" \
|
||||
--argjson size "$FEED_SIZE" \
|
||||
'{
|
||||
schema_version: $schema_version,
|
||||
algorithm: $algorithm,
|
||||
version: $version,
|
||||
generated_at: $generated,
|
||||
repository: $repo,
|
||||
files: $files
|
||||
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
|
||||
@@ -85,14 +81,6 @@ jobs:
|
||||
signature_file: public/advisories/feed.json.sig
|
||||
public_key_output: public/signing-public.pem
|
||||
|
||||
- name: Sign provisional GHSA feed and verify
|
||||
if: hashFiles('public/advisories/ghsa-without-cve.json') != ''
|
||||
uses: ./.github/actions/sign-and-verify
|
||||
with:
|
||||
private_key: ${{ steps.test_key.outputs.private_key }}
|
||||
input_file: public/advisories/ghsa-without-cve.json
|
||||
signature_file: public/advisories/ghsa-without-cve.json.sig
|
||||
|
||||
- name: Sign checksums and verify
|
||||
uses: ./.github/actions/sign-and-verify
|
||||
with:
|
||||
@@ -101,7 +89,7 @@ jobs:
|
||||
signature_file: public/checksums.sig
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
@@ -119,8 +107,5 @@ jobs:
|
||||
set -euo pipefail
|
||||
test -f dist/index.html
|
||||
test -f public/advisories/feed.json.sig
|
||||
if [ -f public/advisories/ghsa-without-cve.json ]; then
|
||||
test -f public/advisories/ghsa-without-cve.json.sig
|
||||
fi
|
||||
test -f public/checksums.sig
|
||||
test -f public/signing-public.pem
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
name: Poll GHSA Without CVE
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions: read-all
|
||||
|
||||
concurrency:
|
||||
group: poll-ghsa-without-cve
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
FEED_PATH: advisories/feed.json
|
||||
FEED_SIG_PATH: advisories/feed.json.sig
|
||||
GHSA_FEED_PATH: advisories/ghsa-without-cve.json
|
||||
GHSA_FEED_SIG_PATH: advisories/ghsa-without-cve.json.sig
|
||||
SKILL_FEED_PATH: skills/clawsec-feed/advisories/feed.json
|
||||
SKILL_FEED_SIG_PATH: skills/clawsec-feed/advisories/feed.json.sig
|
||||
|
||||
jobs:
|
||||
poll-and-update:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
|
||||
- name: Run GHSA feed tests
|
||||
run: node scripts/test-ghsa-without-cve-feed.mjs
|
||||
|
||||
- name: Poll GitHub Security Advisories
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
node scripts/ghsa-without-cve-feed.mjs \
|
||||
--output "$GHSA_FEED_PATH" \
|
||||
--consolidated-feed "$FEED_PATH" \
|
||||
--existing-feed "$GHSA_FEED_PATH" \
|
||||
--nvd-feed "$FEED_PATH" \
|
||||
--stale-after-days 60
|
||||
|
||||
- name: Sync consolidated feed to clawsec-feed skill
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p "$(dirname "$SKILL_FEED_PATH")"
|
||||
cp "$FEED_PATH" "$SKILL_FEED_PATH"
|
||||
|
||||
- name: Detect feed changes
|
||||
id: changes
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
GHSA_CHANGED=false
|
||||
AGENT_CHANGED=false
|
||||
|
||||
if ! git diff --quiet -- "$GHSA_FEED_PATH" || [ ! -f "$GHSA_FEED_SIG_PATH" ]; then
|
||||
GHSA_CHANGED=true
|
||||
fi
|
||||
|
||||
if ! git diff --quiet -- "$FEED_PATH" "$SKILL_FEED_PATH" || [ ! -f "$FEED_SIG_PATH" ] || [ ! -f "$SKILL_FEED_SIG_PATH" ]; then
|
||||
AGENT_CHANGED=true
|
||||
fi
|
||||
|
||||
echo "ghsa_changed=$GHSA_CHANGED" >> "$GITHUB_OUTPUT"
|
||||
echo "agent_changed=$AGENT_CHANGED" >> "$GITHUB_OUTPUT"
|
||||
|
||||
if [ "$GHSA_CHANGED" = "true" ] || [ "$AGENT_CHANGED" = "true" ]; then
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Sign GHSA feed and verify
|
||||
if: steps.changes.outputs.ghsa_changed == '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.GHSA_FEED_PATH }}
|
||||
signature_file: ${{ env.GHSA_FEED_SIG_PATH }}
|
||||
|
||||
- name: Sign consolidated agent feed and verify
|
||||
if: steps.changes.outputs.agent_changed == '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 consolidated signature to clawsec-feed skill
|
||||
if: steps.changes.outputs.agent_changed == 'true'
|
||||
run: cp "$FEED_SIG_PATH" "$SKILL_FEED_SIG_PATH"
|
||||
|
||||
- name: Create Pull Request
|
||||
if: steps.changes.outputs.changed == 'true'
|
||||
id: create-pr
|
||||
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
|
||||
with:
|
||||
token: ${{ github.token }}
|
||||
branch: automated/ghsa-without-cve-feed
|
||||
delete-branch: true
|
||||
title: 'chore: update provisional GHSA advisory feed'
|
||||
body: |
|
||||
## Summary
|
||||
Updates the provisional GHSA advisory feed and the consolidated agent advisory feed.
|
||||
|
||||
- Feed: `${{ env.GHSA_FEED_PATH }}`
|
||||
- Agent feed: `${{ env.FEED_PATH }}`
|
||||
- Stale threshold: 60 days without a CVE
|
||||
- Statuses: `active`, `matured`, `stale`
|
||||
|
||||
---
|
||||
*This PR was automatically generated by the GHSA-without-CVE polling workflow.*
|
||||
commit-message: |
|
||||
chore: update provisional GHSA advisory feed
|
||||
|
||||
Poll public GitHub Security Advisories without CVE identifiers.
|
||||
add-paths: |
|
||||
${{ env.FEED_PATH }}
|
||||
${{ env.FEED_SIG_PATH }}
|
||||
${{ env.GHSA_FEED_PATH }}
|
||||
${{ env.GHSA_FEED_SIG_PATH }}
|
||||
${{ env.SKILL_FEED_PATH }}
|
||||
${{ env.SKILL_FEED_SIG_PATH }}
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
set -euo pipefail
|
||||
echo "## GHSA Without CVE Poll Summary" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "| Metric | Value |" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "|--------|-------|" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "| Feed changed | ${{ steps.changes.outputs.changed }} |" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "| Agent feed changed | ${{ steps.changes.outputs.agent_changed }} |" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "| GHSA source feed changed | ${{ steps.changes.outputs.ghsa_changed }} |" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "| Feed path | $GHSA_FEED_PATH |" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "| Agent feed path | $FEED_PATH |" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "| Total advisories | $(jq '.advisories | length' "$GHSA_FEED_PATH") |" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "| Active | $(jq '[.advisories[] | select(.status == "active")] | length' "$GHSA_FEED_PATH") |" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "| Matured | $(jq '[.advisories[] | select(.status == "matured")] | length' "$GHSA_FEED_PATH") |" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "| Stale | $(jq '[.advisories[] | select(.status == "stale")] | length' "$GHSA_FEED_PATH") |" >> "$GITHUB_STEP_SUMMARY"
|
||||
if [ -n "${{ steps.create-pr.outputs.pull-request-url }}" ]; then
|
||||
echo "" >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "Upserted PR: ${{ steps.create-pr.outputs.pull-request-url }}" >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
@@ -21,8 +21,6 @@ concurrency:
|
||||
env:
|
||||
FEED_PATH: advisories/feed.json
|
||||
FEED_SIG_PATH: advisories/feed.json.sig
|
||||
GHSA_FEED_PATH: advisories/ghsa-without-cve.json
|
||||
GHSA_FEED_SIG_PATH: advisories/ghsa-without-cve.json.sig
|
||||
SKILL_FEED_PATH: skills/clawsec-feed/advisories/feed.json
|
||||
SKILL_FEED_SIG_PATH: skills/clawsec-feed/advisories/feed.json.sig
|
||||
|
||||
@@ -219,9 +217,6 @@ jobs:
|
||||
KEYWORDS_PATTERN="$(nvd_keyword_pattern)"
|
||||
GITHUB_PATTERN="$(nvd_github_ref_pattern)"
|
||||
CPE_PATTERN="$(nvd_cpe_pattern)"
|
||||
# Export concise project keyword groups for PR body + workflow summary steps
|
||||
KEYWORDS="$(nvd_summary_keywords)"
|
||||
echo "KEYWORDS=$KEYWORDS" >> "$GITHUB_ENV"
|
||||
|
||||
# Combine all fetched CVEs
|
||||
echo '{"vulnerabilities":[]}' > tmp/combined.json
|
||||
@@ -403,7 +398,7 @@ jobs:
|
||||
| (
|
||||
(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)
|
||||
+ (if ($blob | test("github\\.com/softwarepub/hermes|github\\.com/nousresearch/hermes-agent|cpe:2\\.3:a:software-metadata\\.pub:hermes|\\bhermes workflow\\b|\\bhermes-agent\\b|software publication with rich metadata")) then ["hermes@*"] else [] end)
|
||||
+ (if ($blob | test("github\\.com/softwarepub/hermes|cpe:2\\.3:a:software-metadata\\.pub:hermes|\\bhermes workflow\\b|software publication with rich metadata")) then ["hermes@*"] else [] end)
|
||||
+ (if ($blob | test("github\\.com/[^/]+/picoclaw|\\bpicoclaw\\b|cpe:2\\.3:[aho]:[^:]*:picoclaw(?::|$)")) then ["picoclaw@*"] else [] end)
|
||||
)
|
||||
);
|
||||
@@ -645,7 +640,7 @@ jobs:
|
||||
| (
|
||||
(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)
|
||||
+ (if ($blob | test("github\\.com/softwarepub/hermes|github\\.com/nousresearch/hermes-agent|cpe:2\\.3:a:software-metadata\\.pub:hermes|\\bhermes workflow\\b|\\bhermes-agent\\b|software publication with rich metadata")) then ["hermes@*"] else [] end)
|
||||
+ (if ($blob | test("github\\.com/softwarepub/hermes|cpe:2\\.3:a:software-metadata\\.pub:hermes|\\bhermes workflow\\b|software publication with rich metadata")) then ["hermes@*"] else [] end)
|
||||
+ (if ($blob | test("github\\.com/[^/]+/picoclaw|\\bpicoclaw\\b|cpe:2\\.3:[aho]:[^:]*:picoclaw(?::|$)")) then ["picoclaw@*"] else [] end)
|
||||
)
|
||||
);
|
||||
@@ -835,54 +830,8 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Poll GHSA without CVE and consolidate feed
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
node scripts/ghsa-without-cve-feed.mjs \
|
||||
--output "$GHSA_FEED_PATH" \
|
||||
--consolidated-feed "$FEED_PATH" \
|
||||
--existing-feed "$GHSA_FEED_PATH" \
|
||||
--nvd-feed "$FEED_PATH" \
|
||||
--stale-after-days 60
|
||||
|
||||
mkdir -p "$(dirname "$SKILL_FEED_PATH")"
|
||||
cp "$FEED_PATH" "$SKILL_FEED_PATH"
|
||||
|
||||
- name: Detect advisory feed changes
|
||||
id: feed_changes
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
NVD_CHANGED=false
|
||||
GHSA_CHANGED=false
|
||||
AGENT_CHANGED=false
|
||||
|
||||
if [ "${{ steps.transform.outputs.new_count }}" != "0" ] || [ "${{ steps.updates.outputs.update_count }}" != "0" ]; then
|
||||
NVD_CHANGED=true
|
||||
fi
|
||||
|
||||
if ! git diff --quiet -- "$GHSA_FEED_PATH" || [ ! -f "$GHSA_FEED_SIG_PATH" ]; then
|
||||
GHSA_CHANGED=true
|
||||
fi
|
||||
|
||||
if ! git diff --quiet -- "$FEED_PATH" "$SKILL_FEED_PATH" || [ ! -f "$FEED_SIG_PATH" ] || [ ! -f "$SKILL_FEED_SIG_PATH" ]; then
|
||||
AGENT_CHANGED=true
|
||||
fi
|
||||
|
||||
echo "nvd_changed=$NVD_CHANGED" >> "$GITHUB_OUTPUT"
|
||||
echo "ghsa_changed=$GHSA_CHANGED" >> "$GITHUB_OUTPUT"
|
||||
echo "agent_changed=$AGENT_CHANGED" >> "$GITHUB_OUTPUT"
|
||||
|
||||
if [ "$GHSA_CHANGED" = "true" ] || [ "$AGENT_CHANGED" = "true" ]; then
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Guard dependency manifests from NVD updates
|
||||
if: steps.feed_changes.outputs.changed == 'true'
|
||||
if: steps.transform.outputs.new_count != '0' || steps.updates.outputs.update_count != '0'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
@@ -899,17 +848,8 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Sign GHSA feed and verify
|
||||
if: steps.feed_changes.outputs.ghsa_changed == '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.GHSA_FEED_PATH }}
|
||||
signature_file: ${{ env.GHSA_FEED_SIG_PATH }}
|
||||
|
||||
- name: Sign advisory feed and verify
|
||||
if: steps.feed_changes.outputs.agent_changed == 'true'
|
||||
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 }}
|
||||
@@ -921,18 +861,18 @@ jobs:
|
||||
${{ env.SKILL_FEED_PATH }}
|
||||
|
||||
- name: Sync advisory signature to skill feed
|
||||
if: steps.feed_changes.outputs.agent_changed == 'true'
|
||||
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.feed_changes.outputs.changed == 'true'
|
||||
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.feed_changes.outputs.changed == 'true'
|
||||
if: steps.transform.outputs.new_count != '0' || steps.updates.outputs.update_count != '0'
|
||||
id: upsert-pr
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
@@ -941,14 +881,9 @@ jobs:
|
||||
|
||||
BRANCH_PREFIX="automated/nvd-cve-update"
|
||||
PR_COMMENT="Superseded by newer automated NVD advisory update."
|
||||
TITLE="chore: update NVD/GHSA advisories - ${{ steps.transform.outputs.new_count }} NVD new, ${{ steps.updates.outputs.update_count }} NVD updated"
|
||||
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 and GHSA advisory feeds.\nKeywords: ${{ env.KEYWORDS }}\nPoll window: ${{ steps.dates.outputs.start_date }} to ${{ steps.dates.outputs.end_date }}'
|
||||
|
||||
GHSA_TOTAL="$(jq '.advisories | length' "$GHSA_FEED_PATH")"
|
||||
GHSA_ACTIVE="$(jq '[.advisories[] | select(.status == "active")] | length' "$GHSA_FEED_PATH")"
|
||||
GHSA_MATURED="$(jq '[.advisories[] | select(.status == "matured")] | length' "$GHSA_FEED_PATH")"
|
||||
GHSA_STALE="$(jq '[.advisories[] | select(.status == "stale")] | length' "$GHSA_FEED_PATH")"
|
||||
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)"
|
||||
@@ -959,19 +894,16 @@ jobs:
|
||||
BODY_FILE="$(mktemp)"
|
||||
cat > "$BODY_FILE" <<EOF
|
||||
## Summary
|
||||
Automated update from NVD CVE and GHSA advisory feeds.
|
||||
Automated update from NVD CVE feed.
|
||||
|
||||
- **Mode:** ${MODE}
|
||||
- **New NVD advisories:** ${{ steps.transform.outputs.new_count }}
|
||||
- **Updated NVD advisories:** ${{ steps.updates.outputs.update_count }}
|
||||
- **GHSA source feed changed:** ${{ steps.feed_changes.outputs.ghsa_changed }}
|
||||
- **Consolidated agent feed changed:** ${{ steps.feed_changes.outputs.agent_changed }}
|
||||
- **GHSA provisional advisories:** ${GHSA_TOTAL} total (${GHSA_ACTIVE} active, ${GHSA_MATURED} matured, ${GHSA_STALE} stale)
|
||||
- **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 with GHSA consolidation.*
|
||||
*This PR was automatically generated by the NVD CVE polling workflow.*
|
||||
EOF
|
||||
|
||||
PR_LIST_JSON="$(
|
||||
@@ -1018,7 +950,7 @@ jobs:
|
||||
git fetch origin main
|
||||
git checkout -B "$TARGET_BRANCH" origin/main
|
||||
|
||||
git add "$FEED_PATH" "$FEED_SIG_PATH" "$GHSA_FEED_PATH" "$GHSA_FEED_SIG_PATH" "$SKILL_FEED_PATH" "$SKILL_FEED_SIG_PATH"
|
||||
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
|
||||
@@ -1055,10 +987,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EXPECTED_HEAD_SHA="$(git rev-parse HEAD)"
|
||||
DISPATCHED_AT="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
|
||||
echo "Dispatching CodeQL for branch: $BRANCH (head: $EXPECTED_HEAD_SHA, dispatched_at: $DISPATCHED_AT)"
|
||||
echo "Dispatching CodeQL for branch: $BRANCH"
|
||||
gh workflow run codeql.yml --ref "$BRANCH"
|
||||
|
||||
RUN_ID=""
|
||||
@@ -1067,13 +996,8 @@ jobs:
|
||||
--workflow "CodeQL" \
|
||||
--branch "$BRANCH" \
|
||||
--event workflow_dispatch \
|
||||
--limit 50 \
|
||||
--json databaseId,createdAt,headSha \
|
||||
--jq --arg since "$DISPATCHED_AT" --arg sha "$EXPECTED_HEAD_SHA" '
|
||||
map(select(.createdAt >= $since and .headSha == $sha))
|
||||
| sort_by(.createdAt)
|
||||
| last
|
||||
| .databaseId // empty')
|
||||
--json databaseId,createdAt \
|
||||
--jq 'sort_by(.createdAt) | last | .databaseId // empty')
|
||||
if [ -n "$RUN_ID" ]; then
|
||||
break
|
||||
fi
|
||||
@@ -1081,13 +1005,7 @@ jobs:
|
||||
done
|
||||
|
||||
if [ -z "$RUN_ID" ]; then
|
||||
echo "::error::Unable to locate dispatched CodeQL run for branch $BRANCH after $DISPATCHED_AT (head: $EXPECTED_HEAD_SHA)"
|
||||
gh run list \
|
||||
--workflow "CodeQL" \
|
||||
--branch "$BRANCH" \
|
||||
--event workflow_dispatch \
|
||||
--limit 5 \
|
||||
--json databaseId,createdAt,headSha,status,conclusion || true
|
||||
echo "::error::Unable to locate dispatched CodeQL run for branch $BRANCH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1112,9 +1030,6 @@ jobs:
|
||||
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
|
||||
echo "| GHSA source feed changed | ${{ steps.feed_changes.outputs.ghsa_changed }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Consolidated agent feed changed | ${{ steps.feed_changes.outputs.agent_changed }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| GHSA provisional advisories | $(jq '.advisories | length' "$GHSA_FEED_PATH") |" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
if [ "${{ steps.transform.outputs.new_count }}" != "0" ]; then
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
@@ -84,6 +84,6 @@ jobs:
|
||||
# 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@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
|
||||
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4.35.1
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
@@ -6,7 +6,8 @@ on:
|
||||
- '*-v[0-9]*.[0-9]*.[0-9]*'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'skills/**'
|
||||
- 'skills/*/skill.json'
|
||||
- 'skills/*/SKILL.md'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
@@ -38,7 +39,7 @@ jobs:
|
||||
- name: Verify signing key consistency (repo + docs)
|
||||
run: ./scripts/ci/verify_signing_key_consistency.sh
|
||||
|
||||
- name: Validate version parity for changed skills
|
||||
- name: Validate version parity for bumped skills
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
@@ -78,15 +79,12 @@ jobs:
|
||||
}
|
||||
|
||||
touched_skills_file="$(mktemp)"
|
||||
git diff --name-only "${BASE_SHA}...${HEAD_SHA}" -- \
|
||||
'skills/*/**' \
|
||||
':(exclude)skills/*/test/**' \
|
||||
':(exclude)skills/*/tests/**' \
|
||||
git diff --name-only "${BASE_SHA}...${HEAD_SHA}" -- 'skills/*/skill.json' 'skills/*/SKILL.md' \
|
||||
| awk -F/ 'NF >= 3 {print $1 "/" $2}' \
|
||||
| sort -u > "${touched_skills_file}"
|
||||
|
||||
if [ ! -s "${touched_skills_file}" ]; then
|
||||
echo "No release-relevant skill package files changed in this PR."
|
||||
echo "No skill metadata files changed in this PR."
|
||||
rm -f "${touched_skills_file}"
|
||||
exit 0
|
||||
fi
|
||||
@@ -131,8 +129,6 @@ jobs:
|
||||
continue
|
||||
fi
|
||||
|
||||
checked_skills=$((checked_skills + 1))
|
||||
|
||||
json_version_changed=false
|
||||
md_version_changed=false
|
||||
|
||||
@@ -145,11 +141,11 @@ jobs:
|
||||
fi
|
||||
|
||||
if [ "${json_version_changed}" != "true" ] && [ "${md_version_changed}" != "true" ]; then
|
||||
echo "::error file=${skill_dir}::Changed skill package has no version bump. Update skill.json and SKILL.md versions and add CHANGELOG.md release notes."
|
||||
failures=$((failures + 1))
|
||||
echo "No version bump detected for ${skill_dir}; skipping."
|
||||
continue
|
||||
fi
|
||||
|
||||
checked_skills=$((checked_skills + 1))
|
||||
echo "Version bump detected for ${skill_dir} (skill.json changed: ${json_version_changed}, SKILL.md changed: ${md_version_changed})"
|
||||
|
||||
if [ ! -f "${json_path}" ]; then
|
||||
@@ -379,26 +375,6 @@ jobs:
|
||||
failures=0
|
||||
mkdir -p dist/dry-run
|
||||
|
||||
normalize_release_path() {
|
||||
local path="$1"
|
||||
path="${path//\\//}"
|
||||
while [[ "$path" == ./* ]]; do
|
||||
path="${path#./}"
|
||||
done
|
||||
while [[ "$path" == *//* ]]; do
|
||||
path="${path//\/\//\/}"
|
||||
done
|
||||
if [[ -z "$path" || "$path" == /* || "$path" == [A-Za-z]:* || "$path" == ".." || "$path" == ../* || "$path" == */.. || "$path" == */../* ]]; then
|
||||
return 1
|
||||
fi
|
||||
printf '%s\n' "$path"
|
||||
}
|
||||
|
||||
is_test_release_path() {
|
||||
local lower="${1,,}"
|
||||
[[ "$lower" == test/* || "$lower" == tests/* || "$lower" == */test/* || "$lower" == */tests/* ]]
|
||||
}
|
||||
|
||||
while IFS= read -r skill_dir; do
|
||||
json_path="${skill_dir}/skill.json"
|
||||
md_path="${skill_dir}/SKILL.md"
|
||||
@@ -501,17 +477,8 @@ jobs:
|
||||
temp_sbom_file="$(mktemp)"
|
||||
jq -r '.sbom.files[].path' "${json_path}" > "${temp_sbom_file}"
|
||||
|
||||
while IFS= read -r raw_file; do
|
||||
[ -z "${raw_file}" ] && continue
|
||||
if ! file="$(normalize_release_path "${raw_file}")"; then
|
||||
echo "::error file=${json_path}::SBOM references unsafe file path: ${raw_file}"
|
||||
failures=$((failures + 1))
|
||||
continue
|
||||
fi
|
||||
if is_test_release_path "${file}"; then
|
||||
echo " [Dry-run] Skipping test-only release file: ${file}"
|
||||
continue
|
||||
fi
|
||||
while IFS= read -r file; do
|
||||
[ -z "${file}" ] && continue
|
||||
full_path="${skill_dir}/${file}"
|
||||
if [ -f "${full_path}" ]; then
|
||||
mkdir -p "${inner_dir}/$(dirname "${file}")"
|
||||
@@ -534,17 +501,9 @@ jobs:
|
||||
echo " [Dry-run] Removed test signatures from release staging"
|
||||
fi
|
||||
|
||||
# --- Verify staged runtime import closure before archiving ---
|
||||
python3 scripts/ci/verify_skill_release_import_closure.py "${inner_dir}"
|
||||
|
||||
# --- Create zip preserving directory structure ---
|
||||
zip_name="${skill_name}-v${version}.zip"
|
||||
(cd "${staging_dir}" && zip -qr "${OLDPWD}/${out_assets}/${zip_name}" .)
|
||||
if unzip -Z1 "${out_assets}/${zip_name}" | grep -Eiq '(^|/)(test|tests)/'; then
|
||||
echo "::error::Dry-run release archive contains test-only files: ${zip_name}"
|
||||
unzip -Z1 "${out_assets}/${zip_name}" | grep -Ei '(^|/)(test|tests)/' || true
|
||||
failures=$((failures + 1))
|
||||
fi
|
||||
|
||||
# --- Clean up test artifacts from source directory ---
|
||||
if [ -d "${skill_dir}/advisories" ]; then
|
||||
@@ -556,14 +515,8 @@ jobs:
|
||||
|
||||
# --- Generate checksums.json via jq ---
|
||||
files_json="{}"
|
||||
while IFS= read -r raw_file; do
|
||||
[ -z "${raw_file}" ] && continue
|
||||
if ! file="$(normalize_release_path "${raw_file}")"; then
|
||||
continue
|
||||
fi
|
||||
if is_test_release_path "${file}"; then
|
||||
continue
|
||||
fi
|
||||
while IFS= read -r file; do
|
||||
[ -z "${file}" ] && continue
|
||||
full_path="${skill_dir}/${file}"
|
||||
if [ -f "${full_path}" ]; then
|
||||
sha256="$(sha256sum "${full_path}" | awk '{print $1}')"
|
||||
@@ -662,8 +615,6 @@ jobs:
|
||||
version: ${{ steps.parse.outputs.version }}
|
||||
skill_path: ${{ steps.parse.outputs.skill_path }}
|
||||
publishable: ${{ steps.publishable.outputs.publishable }}
|
||||
openclaw_skill: ${{ steps.publishable.outputs.openclaw_skill }}
|
||||
publish_clawhub: ${{ steps.publishable.outputs.publish_clawhub }}
|
||||
steps:
|
||||
- name: Parse tag
|
||||
id: parse
|
||||
@@ -735,39 +686,26 @@ jobs:
|
||||
echo "SKILL.md version validated: $MD_VERSION"
|
||||
fi
|
||||
else
|
||||
echo "::error::Missing required SKILL.md: $SKILL_PATH/SKILL.md"
|
||||
exit 1
|
||||
echo "No SKILL.md found, skipping frontmatter validation"
|
||||
fi
|
||||
|
||||
- name: Detect publishability and install defaults
|
||||
- name: Detect publishability
|
||||
id: publishable
|
||||
run: |
|
||||
SKILL_PATH="${{ steps.parse.outputs.skill_path }}"
|
||||
INTERNAL=$(jq -r 'if (.openclaw | type) == "object" then (.openclaw.internal // false) else false end' "$SKILL_PATH/skill.json")
|
||||
|
||||
OPENCLAW_SKILL=false
|
||||
if jq -e '(.openclaw | type == "object") and ((.openclaw | length) > 0)' "$SKILL_PATH/skill.json" >/dev/null; then
|
||||
OPENCLAW_SKILL=true
|
||||
fi
|
||||
INTERNAL=$(jq -r '.openclaw.internal // false' "$SKILL_PATH/skill.json")
|
||||
|
||||
PUBLISHABLE=true
|
||||
if [ "$INTERNAL" = "true" ]; then
|
||||
PUBLISHABLE=false
|
||||
echo "Skill marked internal=true; will skip ClawHub publishing."
|
||||
fi
|
||||
|
||||
PUBLISH_CLAWHUB=false
|
||||
if [ "$PUBLISHABLE" = "true" ]; then
|
||||
PUBLISH_CLAWHUB=true
|
||||
echo "Skill marked internal=true; will skip ClawHub publish."
|
||||
fi
|
||||
|
||||
echo "internal=${INTERNAL}" >> $GITHUB_OUTPUT
|
||||
echo "openclaw_skill=${OPENCLAW_SKILL}" >> $GITHUB_OUTPUT
|
||||
echo "publish_clawhub=${PUBLISH_CLAWHUB}" >> $GITHUB_OUTPUT
|
||||
echo "publishable=${PUBLISHABLE}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
@@ -850,26 +788,6 @@ jobs:
|
||||
|
||||
mkdir -p release-assets
|
||||
|
||||
normalize_release_path() {
|
||||
local path="$1"
|
||||
path="${path//\\//}"
|
||||
while [[ "$path" == ./* ]]; do
|
||||
path="${path#./}"
|
||||
done
|
||||
while [[ "$path" == *//* ]]; do
|
||||
path="${path//\/\//\/}"
|
||||
done
|
||||
if [[ -z "$path" || "$path" == /* || "$path" == [A-Za-z]:* || "$path" == ".." || "$path" == ../* || "$path" == */.. || "$path" == */../* ]]; then
|
||||
return 1
|
||||
fi
|
||||
printf '%s\n' "$path"
|
||||
}
|
||||
|
||||
is_test_release_path() {
|
||||
local lower="${1,,}"
|
||||
[[ "$lower" == test/* || "$lower" == tests/* || "$lower" == */test/* || "$lower" == */tests/* ]]
|
||||
}
|
||||
|
||||
# --- Stage SBOM files preserving directory structure ---
|
||||
STAGING_DIR="$(mktemp -d)"
|
||||
INNER_DIR="$STAGING_DIR/$SKILL_NAME"
|
||||
@@ -877,16 +795,8 @@ jobs:
|
||||
TEMPFILE="$(mktemp)"
|
||||
jq -r '.sbom.files[].path' "$SKILL_PATH/skill.json" > "$TEMPFILE"
|
||||
|
||||
while IFS= read -r raw_file; do
|
||||
[ -z "$raw_file" ] && continue
|
||||
if ! file="$(normalize_release_path "$raw_file")"; then
|
||||
echo "::error file=$SKILL_PATH/skill.json::SBOM references unsafe file path: $raw_file"
|
||||
exit 1
|
||||
fi
|
||||
if is_test_release_path "$file"; then
|
||||
echo "Skipping test-only release file: $file"
|
||||
continue
|
||||
fi
|
||||
while IFS= read -r file; do
|
||||
[ -z "$file" ] && continue
|
||||
FULL_PATH="$SKILL_PATH/$file"
|
||||
if [ -f "$FULL_PATH" ]; then
|
||||
mkdir -p "$INNER_DIR/$(dirname "$file")"
|
||||
@@ -899,28 +809,14 @@ jobs:
|
||||
|
||||
cp "$SKILL_PATH/skill.json" "$INNER_DIR/skill.json"
|
||||
|
||||
# --- Verify staged runtime import closure before archiving ---
|
||||
python3 scripts/ci/verify_skill_release_import_closure.py "$INNER_DIR"
|
||||
|
||||
# --- Create zip preserving directory structure ---
|
||||
ZIP_NAME="${SKILL_NAME}-v${VERSION}.zip"
|
||||
(cd "$STAGING_DIR" && zip -qr "$OLDPWD/release-assets/$ZIP_NAME" .)
|
||||
if unzip -Z1 "release-assets/$ZIP_NAME" | grep -Eiq '(^|/)(test|tests)/'; then
|
||||
echo "::error::Release archive contains test-only files: $ZIP_NAME"
|
||||
unzip -Z1 "release-assets/$ZIP_NAME" | grep -Ei '(^|/)(test|tests)/' || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Generate checksums.json via jq ---
|
||||
FILES_JSON="{}"
|
||||
while IFS= read -r raw_file; do
|
||||
[ -z "$raw_file" ] && continue
|
||||
if ! file="$(normalize_release_path "$raw_file")"; then
|
||||
continue
|
||||
fi
|
||||
if is_test_release_path "$file"; then
|
||||
continue
|
||||
fi
|
||||
while IFS= read -r file; do
|
||||
[ -z "$file" ] && continue
|
||||
FULL_PATH="$SKILL_PATH/$file"
|
||||
if [ -f "$FULL_PATH" ]; then
|
||||
SHA256=$(sha256sum "$FULL_PATH" | awk '{print $1}')
|
||||
@@ -1050,71 +946,6 @@ jobs:
|
||||
echo "EOF"
|
||||
} >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build quick install instructions
|
||||
id: install
|
||||
run: |
|
||||
set -euo pipefail
|
||||
SKILL_NAME="${{ steps.parse.outputs.skill_name }}"
|
||||
VERSION="${{ steps.parse.outputs.version }}"
|
||||
REPO="${{ github.repository }}"
|
||||
TAG="${{ github.ref_name }}"
|
||||
|
||||
{
|
||||
echo "quick_install<<INSTALL_EOF"
|
||||
|
||||
if [ "${{ steps.publishable.outputs.publish_clawhub }}" = "true" ] && [ "${{ steps.publishable.outputs.openclaw_skill }}" = "true" ]; then
|
||||
cat <<EOF
|
||||
### Quick Install
|
||||
|
||||
**Via ClawHub (recommended):**
|
||||
\`\`\`bash
|
||||
npx clawhub@latest install ${SKILL_NAME}
|
||||
\`\`\`
|
||||
|
||||
**If you already have \`clawsec-suite\` installed:**
|
||||
Ask your agent to pull \`${SKILL_NAME}\` from the ClawSec catalog and it will handle setup and verification automatically.
|
||||
EOF
|
||||
else
|
||||
cat <<EOF
|
||||
### Quick Install
|
||||
|
||||
**GitHub release artifact (recommended):**
|
||||
Ask your agent to read the published skill instructions from this GitHub release and follow them:
|
||||
|
||||
https://github.com/${REPO}/releases/download/${TAG}/SKILL.md
|
||||
|
||||
Or download them locally:
|
||||
\`\`\`bash
|
||||
curl -sLO https://github.com/${REPO}/releases/download/${TAG}/SKILL.md
|
||||
\`\`\`
|
||||
EOF
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
|
||||
**Manual download with verification:**
|
||||
\`\`\`bash
|
||||
# 1. Download the release archive, checksums, and signing material
|
||||
curl -sLO https://github.com/${REPO}/releases/download/${TAG}/${SKILL_NAME}-v${VERSION}.zip
|
||||
curl -sLO https://github.com/${REPO}/releases/download/${TAG}/checksums.json
|
||||
curl -sLO https://github.com/${REPO}/releases/download/${TAG}/checksums.sig
|
||||
curl -sLO https://github.com/${REPO}/releases/download/${TAG}/signing-public.pem
|
||||
|
||||
# 2. Verify the checksums manifest signature (Ed25519)
|
||||
openssl base64 -d -A -in checksums.sig -out checksums.sig.bin
|
||||
openssl pkeyutl -verify -rawin -pubin -inkey signing-public.pem -sigfile checksums.sig.bin -in checksums.json
|
||||
|
||||
# 3. Verify archive checksum from the signed manifest
|
||||
echo "\$(jq -r '.archive.sha256' checksums.json) ${SKILL_NAME}-v${VERSION}.zip" | sha256sum -c
|
||||
|
||||
# 4. Extract (creates ${SKILL_NAME}/ directory)
|
||||
unzip ${SKILL_NAME}-v${VERSION}.zip
|
||||
\`\`\`
|
||||
EOF
|
||||
|
||||
echo "INSTALL_EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
|
||||
with:
|
||||
@@ -1126,7 +957,34 @@ jobs:
|
||||
|
||||
${{ steps.changelog.outputs.changelog }}
|
||||
|
||||
${{ steps.install.outputs.quick_install }}
|
||||
### Quick Install
|
||||
|
||||
**Via clawhub (recommended):**
|
||||
```bash
|
||||
npx clawhub@latest install ${{ steps.parse.outputs.skill_name }}
|
||||
```
|
||||
|
||||
**If you already have `clawsec-suite` installed:**
|
||||
Ask your agent to pull `${{ steps.parse.outputs.skill_name }}` from the ClawSec catalog and it will handle setup and verification automatically.
|
||||
|
||||
**Manual download with verification:**
|
||||
```bash
|
||||
# 1. Download the release archive, checksums, and signing material
|
||||
curl -sLO https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/${{ steps.parse.outputs.skill_name }}-v${{ steps.parse.outputs.version }}.zip
|
||||
curl -sLO https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/checksums.json
|
||||
curl -sLO https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/checksums.sig
|
||||
curl -sLO https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/signing-public.pem
|
||||
|
||||
# 2. Verify the checksums manifest signature (Ed25519)
|
||||
openssl base64 -d -A -in checksums.sig -out checksums.sig.bin
|
||||
openssl pkeyutl -verify -rawin -pubin -inkey signing-public.pem -sigfile checksums.sig.bin -in checksums.json
|
||||
|
||||
# 3. Verify archive checksum from the signed manifest
|
||||
echo "$(jq -r '.archive.sha256' checksums.json) ${{ steps.parse.outputs.skill_name }}-v${{ steps.parse.outputs.version }}.zip" | sha256sum -c
|
||||
|
||||
# 4. Extract (creates ${{ steps.parse.outputs.skill_name }}/ directory)
|
||||
unzip ${{ steps.parse.outputs.skill_name }}-v${{ steps.parse.outputs.version }}.zip
|
||||
```
|
||||
|
||||
### Verification
|
||||
|
||||
@@ -1203,28 +1061,28 @@ jobs:
|
||||
CLAWHUB_TOKEN: ${{ secrets.CLAWHUB_TOKEN }}
|
||||
steps:
|
||||
- name: Check if publishable
|
||||
if: needs.release-tag.outputs.publish_clawhub != 'true'
|
||||
if: needs.release-tag.outputs.publishable != 'true'
|
||||
run: |
|
||||
echo "Skill is not eligible for ClawHub publishing; skipping"
|
||||
echo "Skill marked as internal, skipping ClawHub publish"
|
||||
exit 0
|
||||
|
||||
- name: Checkout
|
||||
if: needs.release-tag.outputs.publish_clawhub == 'true'
|
||||
if: needs.release-tag.outputs.publishable == 'true'
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Setup Node
|
||||
if: needs.release-tag.outputs.publish_clawhub == 'true'
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
if: needs.release-tag.outputs.publishable == 'true'
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install clawhub CLI
|
||||
if: needs.release-tag.outputs.publish_clawhub == 'true' && env.CLAWHUB_TOKEN != ''
|
||||
if: needs.release-tag.outputs.publishable == 'true' && env.CLAWHUB_TOKEN != ''
|
||||
run: npm install -g clawhub@${CLAWHUB_CLI_VERSION}
|
||||
|
||||
- name: Patch clawhub publish payload workaround
|
||||
# Temporary: clawhub@0.7.0 publish payload is missing acceptLicenseTerms.
|
||||
if: needs.release-tag.outputs.publish_clawhub == 'true' && env.CLAWHUB_TOKEN != ''
|
||||
if: needs.release-tag.outputs.publishable == 'true' && env.CLAWHUB_TOKEN != ''
|
||||
run: |
|
||||
node <<'NODE'
|
||||
const { execSync } = require("node:child_process");
|
||||
@@ -1267,7 +1125,7 @@ jobs:
|
||||
NODE
|
||||
|
||||
- name: Login to ClawHub
|
||||
if: needs.release-tag.outputs.publish_clawhub == 'true' && env.CLAWHUB_TOKEN != ''
|
||||
if: needs.release-tag.outputs.publishable == 'true' && env.CLAWHUB_TOKEN != ''
|
||||
run: |
|
||||
set -euo pipefail
|
||||
SITE=${CLAWHUB_SITE:-https://clawhub.ai}
|
||||
@@ -1278,7 +1136,7 @@ jobs:
|
||||
clawhub login --token "$CLAWHUB_TOKEN" --site "$SITE" --no-input
|
||||
|
||||
- name: Guard duplicate ClawHub version
|
||||
if: needs.release-tag.outputs.publish_clawhub == 'true' && env.CLAWHUB_TOKEN != ''
|
||||
if: needs.release-tag.outputs.publishable == 'true' && env.CLAWHUB_TOKEN != ''
|
||||
run: |
|
||||
set -euo pipefail
|
||||
SITE=${CLAWHUB_SITE:-https://clawhub.ai}
|
||||
@@ -1308,7 +1166,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Publish to ClawHub
|
||||
if: needs.release-tag.outputs.publish_clawhub == 'true' && env.CLAWHUB_TOKEN != ''
|
||||
if: needs.release-tag.outputs.publishable == 'true' && env.CLAWHUB_TOKEN != ''
|
||||
run: |
|
||||
set -euo pipefail
|
||||
SITE=${CLAWHUB_SITE:-https://clawhub.ai}
|
||||
@@ -1382,7 +1240,7 @@ jobs:
|
||||
id: publishable
|
||||
run: |
|
||||
SKILL_PATH="${{ steps.parse.outputs.skill_path }}"
|
||||
INTERNAL=$(jq -r 'if (.openclaw | type) == "object" then (.openclaw.internal // false) else false end' "$SKILL_PATH/skill.json")
|
||||
INTERNAL=$(jq -r '.openclaw.internal // false' "$SKILL_PATH/skill.json")
|
||||
|
||||
if [ "$INTERNAL" = "true" ]; then
|
||||
echo "::error::Skill is marked internal and cannot be published to ClawHub"
|
||||
@@ -1392,7 +1250,7 @@ jobs:
|
||||
echo "Skill is publishable to ClawHub"
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
cff-version: 1.2.0
|
||||
message: "If you use ClawSec in research or security tooling, please cite it as below."
|
||||
title: "ClawSec"
|
||||
version: "0.1.0"
|
||||
date-released: "2026-05-26"
|
||||
abstract: >-
|
||||
ClawSec is a security skill suite for AI agent platforms. It provides
|
||||
advisory monitoring, cryptographic signature verification, guarded skill
|
||||
installation, file integrity checks, and platform-specific security
|
||||
capabilities for OpenClaw, NanoClaw, Hermes, and Picoclaw deployments.
|
||||
type: software
|
||||
license: "AGPL-3.0-or-later"
|
||||
url: "https://clawsec.prompt.security/"
|
||||
repository-code: "https://github.com/prompt-security/clawsec"
|
||||
keywords:
|
||||
- ai-security
|
||||
- agent-security
|
||||
- prompt-injection
|
||||
- security-advisories
|
||||
- software-supply-chain
|
||||
- integrity-verification
|
||||
- openclaw
|
||||
- nanoclaw
|
||||
- hermes
|
||||
- picoclaw
|
||||
authors:
|
||||
- given-names: David
|
||||
family-names: Abutbul
|
||||
affiliation: "Prompt Security"
|
||||
orcid: "https://orcid.org/0009-0001-7883-3593"
|
||||
@@ -50,26 +50,20 @@ ClawSec is a **complete security skill suite for AI agent platforms**. It provid
|
||||
|
||||
### Skill Feature Matrix
|
||||
|
||||
| Skill name | supported platform| security feed verification| config drift | agent self pen testing| supply-chain install verification | runtime traffic monitoring |
|
||||
|---|---|---|---|---|---|---|
|
||||
| claw-release | OpenClaw | No | No | No | Yes | No |
|
||||
| clawsec-clawhub-checker | OpenClaw + clawsec-suite integration | No | No | No | Yes | No |
|
||||
| clawsec-feed | OpenClaw | Yes | No | No | Yes | No |
|
||||
| clawsec-nanoclaw | NanoClaw | Yes | Yes | Yes | Yes | No |
|
||||
| clawsec-scanner | OpenClaw | Yes | No | Yes | Yes | No |
|
||||
| clawsec-suite | OpenClaw | Yes | Yes | No | Yes | No |
|
||||
| clawtributor | OpenClaw | Yes | No | No | No | No |
|
||||
| hermes-attestation-guardian | Hermes | Yes (signed advisory feed verification) | Yes | No | Limited (advisory preflight gating only; no artifact signature/provenance install verification) | No |
|
||||
| hermes-traffic-guardian | Hermes | No | Planned posture export only | No | No | Spec baseline |
|
||||
| nanoclaw-traffic-guardian | NanoClaw | No | No | No | No | Spec baseline |
|
||||
| openclaw-audit-watchdog | OpenClaw | No | No | Yes | No | No |
|
||||
| openclaw-traffic-guardian | OpenClaw | No | No | No | No | Spec baseline |
|
||||
| picoclaw-security-guardian | Picoclaw | Yes | Yes | No | Yes | No |
|
||||
| picoclaw-self-pen-testing | Picoclaw | No | No | Yes | No | No |
|
||||
| picoclaw-traffic-guardian | Picoclaw | No | Planned profile export only | No | No | Spec baseline |
|
||||
| soul-guardian | OpenClaw | No | Yes | No | No | No |
|
||||
|
||||
`Spec baseline` means the skill folder, metadata, frontmatter, and implementation contract exist, but runtime proxy code is intentionally left for platform-specific builders.
|
||||
| Skill name | supported platform| security feed verification| config drift | agent self pen testing| supply-chain install verification |
|
||||
|---|---|---|---|---|---|
|
||||
| claw-release | OpenClaw | No | No | No | Yes |
|
||||
| clawsec-clawhub-checker | OpenClaw + clawsec-suite integration | No | No | No | Yes |
|
||||
| clawsec-feed | OpenClaw | Yes | No | No | Yes |
|
||||
| clawsec-nanoclaw | NanoClaw | Yes | Yes | Yes | Yes |
|
||||
| clawsec-scanner | OpenClaw | Yes | No | Yes | Yes |
|
||||
| clawsec-suite | OpenClaw | Yes | Yes | No | Yes |
|
||||
| clawtributor | OpenClaw | Yes | No | No | No |
|
||||
| hermes-attestation-guardian | Hermes | Yes (signed advisory feed verification) | Yes | No | Limited (advisory preflight gating only; no artifact signature/provenance install verification) |
|
||||
| openclaw-audit-watchdog | OpenClaw | No | No | Yes | No |
|
||||
| picoclaw-security-guardian | Picoclaw | Yes | Yes | No | Yes |
|
||||
| picoclaw-self-pen-testing | Picoclaw | No | No | Yes | No |
|
||||
| soul-guardian | OpenClaw | No | Yes | No | No |
|
||||
|
||||
### Core Capabilities
|
||||
|
||||
@@ -78,7 +72,6 @@ ClawSec is a **complete security skill suite for AI agent platforms**. It provid
|
||||
- **📡 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
|
||||
- **Runtime Traffic Monitoring Baselines** - Platform-specific specs for opt-in proxy inspection, exfiltration detection, and inbound injection detection
|
||||
- **Health Checks** - Automated updates and integrity verification for all installed skills
|
||||
|
||||
---
|
||||
|
||||
+23
-9591
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
v+PiWmjIkY6zdIyI9xJX0l0aTy0Azp1+LoZR6qaiDZJnXFuSBX4Sw/x5tMdTb0xSbqdDTJOZwwWI8coPVepzBw==
|
||||
TM7Tf3QwZIe8TlC325reeArX+/z2xMrjOC0CdZa2I2Zta5L2y2KWbD+Z3VangNu6/ZEaajN4VwwZUAUd5AaNDA==
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
SCkRaPMF6IYDwZuR7/JJXxpB7A7ebuMvLqK827uWX0yfEJr7l2gyLpxvHsEpWJDzE4gchxd5yqJx5qF/yqNwAg==
|
||||
@@ -2,19 +2,16 @@ import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { ArrowRight } from 'lucide-react';
|
||||
import type { SkillMetadata } from '../types';
|
||||
import { getPlatformDescriptor } from '../utils/advisoryPlatforms';
|
||||
|
||||
interface SkillCardProps {
|
||||
skill: SkillMetadata;
|
||||
}
|
||||
|
||||
export const SkillCard: React.FC<SkillCardProps> = ({ skill }) => {
|
||||
const platforms = Array.isArray(skill.platforms) ? skill.platforms.slice(0, 4) : [];
|
||||
|
||||
return (
|
||||
<Link
|
||||
to={`/skills/${skill.id}`}
|
||||
className="group block bg-clawd-800 border border-clawd-700 rounded-lg p-5 hover:border-clawd-accent/30 hover:bg-clawd-800/80 transition-all duration-200"
|
||||
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>
|
||||
@@ -30,23 +27,6 @@ export const SkillCard: React.FC<SkillCardProps> = ({ skill }) => {
|
||||
{skill.description}
|
||||
</p>
|
||||
|
||||
{platforms.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1.5 mb-4" aria-label="Recommended platforms">
|
||||
{platforms.map((platform) => {
|
||||
const descriptor = getPlatformDescriptor(platform);
|
||||
|
||||
return (
|
||||
<span
|
||||
key={platform}
|
||||
className={`text-[11px] leading-none px-2 py-1 rounded-md ${descriptor.classes}`}
|
||||
>
|
||||
{descriptor.label}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<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">
|
||||
|
||||
Generated
+29
-29
@@ -13,18 +13,18 @@
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.5",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-router-dom": "^7.16.0",
|
||||
"react-router-dom": "^7.13.1",
|
||||
"remark-gfm": "^4.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "~9.39.4",
|
||||
"@types/node": "^25.8.0",
|
||||
"@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",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"fast-check": "^4.7.0",
|
||||
"typescript": "~5.9.3",
|
||||
"vite": "^7.3.2"
|
||||
@@ -1362,13 +1362,13 @@
|
||||
"integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA=="
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "25.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.8.0.tgz",
|
||||
"integrity": "sha512-TCFSk8IZh+iLX1xtksoBVtdmgL+1IX0fC9BeU4QqFSuNdN/K+HUlhqOzEmSYYpZUVsLYcPqc9KX+60iDuninSQ==",
|
||||
"version": "25.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.4.0.tgz",
|
||||
"integrity": "sha512-9wLpoeWuBlcbBpOY3XmzSTG3oscB6xjBEEtn+pYXTfhyXhIxC5FsBer2KTopBlvKEiW9l13po9fq+SJY/5lkhw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": ">=7.24.0 <7.24.7"
|
||||
"undici-types": "~7.18.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/react": {
|
||||
@@ -1997,11 +1997,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "5.0.6",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
|
||||
"integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz",
|
||||
"integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^4.0.2"
|
||||
},
|
||||
@@ -2705,9 +2704,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-react-hooks": {
|
||||
"version": "7.0.1",
|
||||
"integrity": "sha512-O0d0m04evaNzEPoSW+59Mezf8Qt0InfgGIBJnpC0h3NH/WjUAR7BIKUfysC6todmtiZ/A0oUVS8Gce0WhBrHsA==",
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-7.1.1.tgz",
|
||||
"integrity": "sha512-f2I7Gw6JbvCexzIInuSbZpfdQ44D7iqdWX01FKLvrPgqxoE7oMj8clOfto8U6vYiz4yd5oKu39rRSVOe1zRu0g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.24.4",
|
||||
"@babel/parser": "^7.24.4",
|
||||
@@ -2719,7 +2720,7 @@
|
||||
"node": ">=18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0"
|
||||
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 || ^10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-react/node_modules/semver": {
|
||||
@@ -4653,13 +4654,12 @@
|
||||
]
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "10.2.5",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz",
|
||||
"integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==",
|
||||
"version": "10.2.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.4.tgz",
|
||||
"integrity": "sha512-oRjTw/97aTBN0RHbYCdtF1MQfvusSIBQM0IZEgzl6426+8jSC0nF1a/GmnVLpfB9yyr6g6FTqWqiZVbxrtaCIg==",
|
||||
"dev": true,
|
||||
"license": "BlueOak-1.0.0",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^5.0.5"
|
||||
"brace-expansion": "^5.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
@@ -5075,9 +5075,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-router": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.16.0.tgz",
|
||||
"integrity": "sha512-wArC8lVyJb3+jM9OpDyW6hLCizACWkvQR/sSGqSs+o5uEXEtGlqdZ4v8hENR3Jad6i+LRkK93q/+bQAcvl6V1A==",
|
||||
"version": "7.13.1",
|
||||
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.13.1.tgz",
|
||||
"integrity": "sha512-td+xP4X2/6BJvZoX6xw++A2DdEi++YypA69bJUV5oVvqf6/9/9nNlD70YO1e9d3MyamJEBQFEzk6mbfDYbqrSA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cookie": "^1.0.1",
|
||||
@@ -5097,12 +5097,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-router-dom": {
|
||||
"version": "7.16.0",
|
||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.16.0.tgz",
|
||||
"integrity": "sha512-kMUAbimWB5FVbF4Bce4bJsiKJWLIUHq/mEG8+CFDnCSgltptBiG5nguducmsJeGKytlCvQud9Qhzpn49iduTlA==",
|
||||
"version": "7.13.1",
|
||||
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.13.1.tgz",
|
||||
"integrity": "sha512-UJnV3Rxc5TgUPJt2KJpo1Jpy0OKQr0AjgbZzBFjaPJcFOb2Y8jA5H3LT8HUJAiRLlWrEXWHbF1Z4SCZaQjWDHw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"react-router": "7.16.0"
|
||||
"react-router": "7.13.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
@@ -5816,9 +5816,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "7.24.6",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
|
||||
"integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
|
||||
"version": "7.18.2",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz",
|
||||
"integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
|
||||
+5
-5
@@ -23,18 +23,18 @@
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.5",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-router-dom": "^7.16.0",
|
||||
"react-router-dom": "^7.13.1",
|
||||
"remark-gfm": "^4.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "~9.39.4",
|
||||
"@types/node": "^25.8.0",
|
||||
"@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",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"fast-check": "^4.7.0",
|
||||
"typescript": "~5.9.3",
|
||||
"vite": "^7.3.2"
|
||||
@@ -42,8 +42,8 @@
|
||||
"overrides": {
|
||||
"ajv": "6.14.0",
|
||||
"balanced-match": "4.0.3",
|
||||
"brace-expansion": "5.0.6",
|
||||
"minimatch": "10.2.5",
|
||||
"brace-expansion": "5.0.5",
|
||||
"minimatch": "10.2.4",
|
||||
"picomatch": "4.0.4"
|
||||
}
|
||||
}
|
||||
|
||||
+8
-57
@@ -5,12 +5,8 @@ import Markdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import { Footer } from '../components/Footer';
|
||||
import type { SkillJson, SkillChecksums } from '../types';
|
||||
import { getPlatformDescriptor } from '../utils/advisoryPlatforms';
|
||||
import { defaultMarkdownComponents } from '../utils/markdownComponents';
|
||||
import { stripFrontmatter } from '../utils/markdownHelpers.mjs';
|
||||
import { getRecommendedSkillPlatforms, resolveSkillPlatformMetadata } from '../utils/skillPlatforms';
|
||||
|
||||
const RELEASE_REPO_URL = 'https://github.com/prompt-security/clawsec';
|
||||
|
||||
const isProbablyHtmlDocument = (text: string): boolean => {
|
||||
const start = text.trimStart().slice(0, 200).toLowerCase();
|
||||
@@ -125,29 +121,10 @@ export const SkillDetail: React.FC = () => {
|
||||
setTimeout(() => setCopied(null), 2000);
|
||||
};
|
||||
|
||||
const releaseTag = skillData ? `${skillData.name}-v${skillData.version}` : '';
|
||||
const skillInstructionsUrl = releaseTag
|
||||
? `${RELEASE_REPO_URL}/releases/download/${releaseTag}/SKILL.md`
|
||||
: '';
|
||||
|
||||
const recommendedPlatforms = useMemo(
|
||||
() => (skillData ? getRecommendedSkillPlatforms(skillData) : []),
|
||||
[skillData]
|
||||
);
|
||||
|
||||
const isOpenClawSkill = recommendedPlatforms.includes('openclaw');
|
||||
|
||||
const installCommand = skillData
|
||||
? isOpenClawSkill
|
||||
? `npx clawhub@latest install ${skillData.name}`
|
||||
: `curl -sLO ${skillInstructionsUrl}`
|
||||
? `npx clawhub@latest install ${skillData.name}`
|
||||
: '';
|
||||
|
||||
const installLabel = isOpenClawSkill ? 'Via ClawHub' : 'Via SKILL.md instructions';
|
||||
const installHelp = isOpenClawSkill
|
||||
? 'Recommended for OpenClaw-compatible skills.'
|
||||
: 'Pull the published instruction file and follow the platform-specific setup steps.';
|
||||
|
||||
const releasePageUrl = useMemo(() => {
|
||||
if (!skillData) return '';
|
||||
|
||||
@@ -157,7 +134,7 @@ export const SkillDetail: React.FC = () => {
|
||||
const [owner, repo] = url.pathname.split('/').filter(Boolean);
|
||||
if (owner && repo) {
|
||||
const repoBase = `${url.origin}/${owner}/${repo.replace(/\\.git$/, '')}`;
|
||||
return `${repoBase}/releases/tag/${releaseTag}`;
|
||||
return `${repoBase}/releases/tag/${skillData.name}-v${skillData.version}`;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
@@ -165,17 +142,7 @@ export const SkillDetail: React.FC = () => {
|
||||
}
|
||||
|
||||
return skillData.homepage;
|
||||
}, [releaseTag, skillData]);
|
||||
|
||||
const platformMetadata = useMemo(
|
||||
() => (skillData ? resolveSkillPlatformMetadata(skillData) : null),
|
||||
[skillData]
|
||||
);
|
||||
|
||||
const triggers = useMemo(() => {
|
||||
if (!platformMetadata || !Array.isArray(platformMetadata.triggers)) return [];
|
||||
return platformMetadata.triggers;
|
||||
}, [platformMetadata]);
|
||||
}, [skillData]);
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
@@ -213,26 +180,14 @@ export const SkillDetail: React.FC = () => {
|
||||
{/* 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">{platformMetadata?.emoji || '📦'}</span>
|
||||
<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>
|
||||
{recommendedPlatforms.slice(0, 4).map((platform) => {
|
||||
const descriptor = getPlatformDescriptor(platform);
|
||||
|
||||
return (
|
||||
<span
|
||||
key={platform}
|
||||
className={`text-xs px-2 py-0.5 rounded-md ${descriptor.classes}`}
|
||||
>
|
||||
{descriptor.label}
|
||||
</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">
|
||||
{platformMetadata?.category || 'utility'}
|
||||
{skillData.openclaw?.category || 'utility'}
|
||||
</span>
|
||||
*/}
|
||||
</div>
|
||||
@@ -263,10 +218,6 @@ export const SkillDetail: React.FC = () => {
|
||||
<Download size={20} />
|
||||
Quick Install
|
||||
</h2>
|
||||
<div>
|
||||
<p className="text-sm font-medium text-white">{installLabel}</p>
|
||||
<p className="text-sm text-gray-400">{installHelp}</p>
|
||||
</div>
|
||||
<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}
|
||||
@@ -388,16 +339,16 @@ export const SkillDetail: React.FC = () => {
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<dt className="text-gray-500">Category</dt>
|
||||
<dd className="text-white">{platformMetadata?.category || 'utility'}</dd>
|
||||
<dd className="text-white">{skillData.openclaw?.category}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{triggers.length > 0 && (
|
||||
{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">
|
||||
{triggers.slice(0, 8).map((trigger) => (
|
||||
{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"
|
||||
|
||||
@@ -1,486 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { promises as fs } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const REPO_ROOT = path.resolve(__dirname, '..');
|
||||
const API_ROOT = 'https://api.github.com';
|
||||
const GITHUB_API_VERSION = '2022-11-28';
|
||||
const ARCHIVE_VERSION = 1;
|
||||
const DAY_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
const SUMMARY_WINDOWS = [
|
||||
['last_14_days', 14],
|
||||
['last_30_days', 30],
|
||||
['last_90_days', 90],
|
||||
['last_365_days', 365],
|
||||
];
|
||||
|
||||
const toIsoString = (value, label) => {
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
throw new Error(`Invalid ${label}: ${value}`);
|
||||
}
|
||||
return date.toISOString();
|
||||
};
|
||||
|
||||
const toDailyTimestamp = (value) => `${toIsoString(value, 'traffic timestamp').slice(0, 10)}T00:00:00Z`;
|
||||
const toDateKey = (value) => toIsoString(value, 'capture timestamp').slice(0, 10);
|
||||
|
||||
const toNonNegativeInteger = (value, label) => {
|
||||
const number = Number(value);
|
||||
if (!Number.isFinite(number) || number < 0) {
|
||||
throw new Error(`Invalid ${label}: ${value}`);
|
||||
}
|
||||
return Math.trunc(number);
|
||||
};
|
||||
|
||||
const toRequiredString = (value, label) => {
|
||||
if (typeof value !== 'string') {
|
||||
throw new Error(`${label} must be a non-empty string`);
|
||||
}
|
||||
|
||||
const trimmed = value.trim();
|
||||
if (!trimmed) {
|
||||
throw new Error(`${label} must be a non-empty string`);
|
||||
}
|
||||
|
||||
return trimmed;
|
||||
};
|
||||
|
||||
const normalizeRepository = (repo) => {
|
||||
const normalized = String(repo || '').trim();
|
||||
if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(normalized)) {
|
||||
throw new Error(`Repository must be in owner/name form, received: ${repo || '(empty)'}`);
|
||||
}
|
||||
return normalized;
|
||||
};
|
||||
|
||||
const normalizeDailyEntries = (entries, label) => {
|
||||
if (!Array.isArray(entries)) {
|
||||
throw new Error(`${label} must be an array`);
|
||||
}
|
||||
|
||||
return entries
|
||||
.map((entry) => ({
|
||||
timestamp: toDailyTimestamp(entry.timestamp),
|
||||
count: toNonNegativeInteger(entry.count, `${label}.count`),
|
||||
uniques: toNonNegativeInteger(entry.uniques, `${label}.uniques`),
|
||||
}))
|
||||
.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
|
||||
};
|
||||
|
||||
const normalizeReferrers = (entries) => {
|
||||
if (!Array.isArray(entries)) {
|
||||
throw new Error('referrers must be an array');
|
||||
}
|
||||
|
||||
return entries.map((entry) => ({
|
||||
referrer: toRequiredString(entry.referrer, 'referrers.referrer'),
|
||||
count: toNonNegativeInteger(entry.count, 'referrers.count'),
|
||||
uniques: toNonNegativeInteger(entry.uniques, 'referrers.uniques'),
|
||||
}));
|
||||
};
|
||||
|
||||
const normalizePaths = (entries) => {
|
||||
if (!Array.isArray(entries)) {
|
||||
throw new Error('paths must be an array');
|
||||
}
|
||||
|
||||
return entries.map((entry) => ({
|
||||
path: toRequiredString(entry.path, 'paths.path'),
|
||||
title: toRequiredString(entry.title, 'paths.title'),
|
||||
count: toNonNegativeInteger(entry.count, 'paths.count'),
|
||||
uniques: toNonNegativeInteger(entry.uniques, 'paths.uniques'),
|
||||
}));
|
||||
};
|
||||
|
||||
const upsertByKey = (existing, incoming, key) => {
|
||||
const entriesByKey = new Map();
|
||||
|
||||
for (const entry of existing || []) {
|
||||
entriesByKey.set(entry[key], entry);
|
||||
}
|
||||
for (const entry of incoming || []) {
|
||||
entriesByKey.set(entry[key], entry);
|
||||
}
|
||||
|
||||
return [...entriesByKey.values()].sort((a, b) => String(a[key]).localeCompare(String(b[key])));
|
||||
};
|
||||
|
||||
const latestEntry = (entries) => {
|
||||
if (!entries?.length) {
|
||||
return null;
|
||||
}
|
||||
return entries[entries.length - 1];
|
||||
};
|
||||
|
||||
const sumSeries = (entries) => entries.reduce(
|
||||
(totals, entry) => ({
|
||||
count: totals.count + entry.count,
|
||||
sum_daily_uniques: totals.sum_daily_uniques + entry.uniques,
|
||||
}),
|
||||
{ count: 0, sum_daily_uniques: 0 },
|
||||
);
|
||||
|
||||
const startOfUtcDay = (date) => Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
||||
|
||||
const summarizeWindow = (entries, days, now) => {
|
||||
const cutoff = new Date(startOfUtcDay(now) - ((days - 1) * DAY_MS));
|
||||
const filtered = entries.filter((entry) => new Date(entry.timestamp) >= cutoff);
|
||||
const totals = sumSeries(filtered);
|
||||
|
||||
return {
|
||||
days,
|
||||
count: totals.count,
|
||||
sum_daily_uniques: totals.sum_daily_uniques,
|
||||
unique_semantics: 'sum_of_daily_uniques',
|
||||
first_date: filtered[0]?.timestamp.slice(0, 10) ?? null,
|
||||
last_date: filtered.at(-1)?.timestamp.slice(0, 10) ?? null,
|
||||
};
|
||||
};
|
||||
|
||||
const summarizeAllTime = (entries) => {
|
||||
const totals = sumSeries(entries);
|
||||
|
||||
return {
|
||||
count: totals.count,
|
||||
sum_daily_uniques: totals.sum_daily_uniques,
|
||||
unique_semantics: 'sum_of_daily_uniques',
|
||||
first_date: entries[0]?.timestamp.slice(0, 10) ?? null,
|
||||
last_date: entries.at(-1)?.timestamp.slice(0, 10) ?? null,
|
||||
};
|
||||
};
|
||||
|
||||
const normalizeExistingArchive = (archive, repository, capturedAt) => {
|
||||
if (!archive) {
|
||||
return {
|
||||
version: ARCHIVE_VERSION,
|
||||
repository,
|
||||
archive_started_at: capturedAt,
|
||||
updated_at: capturedAt,
|
||||
daily: {
|
||||
views: [],
|
||||
clones: [],
|
||||
},
|
||||
snapshots: {
|
||||
referrers: [],
|
||||
paths: [],
|
||||
},
|
||||
captures: [],
|
||||
};
|
||||
}
|
||||
|
||||
if (archive.repository && archive.repository !== repository) {
|
||||
throw new Error(`Archive repository mismatch: ${archive.repository} != ${repository}`);
|
||||
}
|
||||
|
||||
return {
|
||||
version: ARCHIVE_VERSION,
|
||||
repository,
|
||||
archive_started_at: archive.archive_started_at || capturedAt,
|
||||
updated_at: archive.updated_at || capturedAt,
|
||||
daily: {
|
||||
views: normalizeDailyEntries(archive.daily?.views || [], 'daily.views'),
|
||||
clones: normalizeDailyEntries(archive.daily?.clones || [], 'daily.clones'),
|
||||
},
|
||||
snapshots: {
|
||||
referrers: (archive.snapshots?.referrers || []).map((snapshot) => ({
|
||||
captured_at: toIsoString(snapshot.captured_at, 'referrer snapshot timestamp'),
|
||||
date: snapshot.date || toDateKey(snapshot.captured_at),
|
||||
entries: normalizeReferrers(snapshot.entries || []),
|
||||
})),
|
||||
paths: (archive.snapshots?.paths || []).map((snapshot) => ({
|
||||
captured_at: toIsoString(snapshot.captured_at, 'path snapshot timestamp'),
|
||||
date: snapshot.date || toDateKey(snapshot.captured_at),
|
||||
entries: normalizePaths(snapshot.entries || []),
|
||||
})),
|
||||
},
|
||||
captures: (archive.captures || []).map((capture) => ({
|
||||
captured_at: toIsoString(capture.captured_at, 'capture timestamp'),
|
||||
date: capture.date || toDateKey(capture.captured_at),
|
||||
views_window: {
|
||||
count: toNonNegativeInteger(capture.views_window?.count || 0, 'captures.views_window.count'),
|
||||
uniques: toNonNegativeInteger(capture.views_window?.uniques || 0, 'captures.views_window.uniques'),
|
||||
},
|
||||
clones_window: {
|
||||
count: toNonNegativeInteger(capture.clones_window?.count || 0, 'captures.clones_window.count'),
|
||||
uniques: toNonNegativeInteger(capture.clones_window?.uniques || 0, 'captures.clones_window.uniques'),
|
||||
},
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
||||
export const mergeTrafficArchive = (existingArchive, snapshot) => {
|
||||
const repository = normalizeRepository(snapshot.repository);
|
||||
const capturedAt = toIsoString(snapshot.captured_at, 'capture timestamp');
|
||||
const captureDate = toDateKey(capturedAt);
|
||||
const archive = normalizeExistingArchive(existingArchive, repository, capturedAt);
|
||||
|
||||
const views = normalizeDailyEntries(snapshot.views?.views || [], 'views');
|
||||
const clones = normalizeDailyEntries(snapshot.clones?.clones || [], 'clones');
|
||||
const referrerSnapshot = {
|
||||
captured_at: capturedAt,
|
||||
date: captureDate,
|
||||
entries: normalizeReferrers(snapshot.referrers || []),
|
||||
};
|
||||
const pathSnapshot = {
|
||||
captured_at: capturedAt,
|
||||
date: captureDate,
|
||||
entries: normalizePaths(snapshot.paths || []),
|
||||
};
|
||||
const capture = {
|
||||
captured_at: capturedAt,
|
||||
date: captureDate,
|
||||
views_window: {
|
||||
count: toNonNegativeInteger(snapshot.views?.count ?? sumSeries(views).count, 'views.count'),
|
||||
uniques: toNonNegativeInteger(snapshot.views?.uniques ?? sumSeries(views).sum_daily_uniques, 'views.uniques'),
|
||||
},
|
||||
clones_window: {
|
||||
count: toNonNegativeInteger(snapshot.clones?.count ?? sumSeries(clones).count, 'clones.count'),
|
||||
uniques: toNonNegativeInteger(snapshot.clones?.uniques ?? sumSeries(clones).sum_daily_uniques, 'clones.uniques'),
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
...archive,
|
||||
updated_at: capturedAt,
|
||||
daily: {
|
||||
views: upsertByKey(archive.daily.views, views, 'timestamp'),
|
||||
clones: upsertByKey(archive.daily.clones, clones, 'timestamp'),
|
||||
},
|
||||
snapshots: {
|
||||
referrers: upsertByKey(archive.snapshots.referrers, [referrerSnapshot], 'date'),
|
||||
paths: upsertByKey(archive.snapshots.paths, [pathSnapshot], 'date'),
|
||||
},
|
||||
captures: upsertByKey(archive.captures, [capture], 'date'),
|
||||
};
|
||||
};
|
||||
|
||||
export const buildTrafficSummary = (archive, options = {}) => {
|
||||
const now = new Date(options.now || new Date().toISOString());
|
||||
if (Number.isNaN(now.getTime())) {
|
||||
throw new Error(`Invalid summary date: ${options.now}`);
|
||||
}
|
||||
|
||||
const views = archive.daily?.views || [];
|
||||
const clones = archive.daily?.clones || [];
|
||||
const buildMetrics = (entries) => {
|
||||
const metrics = Object.fromEntries(SUMMARY_WINDOWS.map(([key, days]) => [
|
||||
key,
|
||||
summarizeWindow(entries, days, now),
|
||||
]));
|
||||
metrics.all_time = summarizeAllTime(entries);
|
||||
return metrics;
|
||||
};
|
||||
|
||||
return {
|
||||
version: ARCHIVE_VERSION,
|
||||
repository: archive.repository,
|
||||
generated_at: now.toISOString(),
|
||||
archive_started_at: archive.archive_started_at || null,
|
||||
updated_at: archive.updated_at || null,
|
||||
source: {
|
||||
api: 'GitHub REST repository traffic endpoints',
|
||||
retention_limit: 'GitHub exposes roughly the last 14 days; this archive keeps daily snapshots long term.',
|
||||
unique_semantics: 'GitHub daily unique values are retained as sum_daily_uniques for longer windows, not deduplicated visitors.',
|
||||
},
|
||||
metrics: {
|
||||
views: buildMetrics(views),
|
||||
clones: buildMetrics(clones),
|
||||
},
|
||||
daily: {
|
||||
views,
|
||||
clones,
|
||||
},
|
||||
latest_snapshots: {
|
||||
referrers: latestEntry(archive.snapshots?.referrers || []),
|
||||
paths: latestEntry(archive.snapshots?.paths || []),
|
||||
},
|
||||
snapshot_counts: {
|
||||
referrers: archive.snapshots?.referrers?.length || 0,
|
||||
paths: archive.snapshots?.paths?.length || 0,
|
||||
captures: archive.captures?.length || 0,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const fetchJson = async ({ repo, token, pathname, fetchImpl }) => {
|
||||
const url = new URL(pathname, API_ROOT);
|
||||
const response = await fetchImpl(url, {
|
||||
headers: {
|
||||
Accept: 'application/vnd.github+json',
|
||||
Authorization: `Bearer ${token}`,
|
||||
'User-Agent': 'clawsec-traffic-archive',
|
||||
'X-GitHub-Api-Version': GITHUB_API_VERSION,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const body = await response.text().catch(() => '');
|
||||
const suffix = body ? ` ${body.slice(0, 500)}` : '';
|
||||
throw new Error(`GitHub traffic API request failed for ${repo}: ${url.pathname}${url.search} returned ${response.status}.${suffix}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const fetchGitHubTraffic = async ({
|
||||
repo,
|
||||
token,
|
||||
capturedAt = new Date().toISOString(),
|
||||
fetchImpl = globalThis.fetch,
|
||||
}) => {
|
||||
const repository = normalizeRepository(repo);
|
||||
if (!token) {
|
||||
throw new Error('A GitHub token is required to read repository traffic.');
|
||||
}
|
||||
if (typeof fetchImpl !== 'function') {
|
||||
throw new Error('fetch is not available in this Node runtime.');
|
||||
}
|
||||
|
||||
const encodedRepo = repository.split('/').map(encodeURIComponent).join('/');
|
||||
const request = (pathname) => fetchJson({
|
||||
repo: repository,
|
||||
token,
|
||||
pathname: `/repos/${encodedRepo}${pathname}`,
|
||||
fetchImpl,
|
||||
});
|
||||
|
||||
const [views, clones, referrers, paths] = await Promise.all([
|
||||
request('/traffic/views?per=day'),
|
||||
request('/traffic/clones?per=day'),
|
||||
request('/traffic/popular/referrers'),
|
||||
request('/traffic/popular/paths'),
|
||||
]);
|
||||
|
||||
return {
|
||||
repository,
|
||||
captured_at: toIsoString(capturedAt, 'capture timestamp'),
|
||||
views,
|
||||
clones,
|
||||
referrers,
|
||||
paths,
|
||||
};
|
||||
};
|
||||
|
||||
const readJsonIfPresent = async (file) => {
|
||||
try {
|
||||
return JSON.parse(await fs.readFile(file, 'utf8'));
|
||||
} catch (error) {
|
||||
if (error?.code === 'ENOENT') {
|
||||
return undefined;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const writeTextAtomic = async (file, content) => {
|
||||
const dir = path.dirname(file);
|
||||
const tempFile = path.join(dir, `.${path.basename(file)}.${process.pid}.${Date.now()}.tmp`);
|
||||
let handle;
|
||||
|
||||
await fs.mkdir(dir, { recursive: true });
|
||||
|
||||
try {
|
||||
handle = await fs.open(tempFile, 'w');
|
||||
await handle.writeFile(content, 'utf8');
|
||||
await handle.sync();
|
||||
await handle.close();
|
||||
handle = undefined;
|
||||
await fs.rename(tempFile, file);
|
||||
} catch (error) {
|
||||
if (handle) {
|
||||
await handle.close().catch(() => {});
|
||||
}
|
||||
await fs.unlink(tempFile).catch(() => {});
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
export const writeJson = async (file, value) => {
|
||||
await writeTextAtomic(file, `${JSON.stringify(value, null, 2)}\n`);
|
||||
};
|
||||
|
||||
const parseArgs = (args) => {
|
||||
const options = {};
|
||||
for (let index = 0; index < args.length; index += 1) {
|
||||
const arg = args[index];
|
||||
if (arg === '--archive-dir') {
|
||||
options.archiveDir = args[index + 1];
|
||||
index += 1;
|
||||
} else if (arg === '--repo') {
|
||||
options.repo = args[index + 1];
|
||||
index += 1;
|
||||
} else if (arg === '--captured-at') {
|
||||
options.capturedAt = args[index + 1];
|
||||
index += 1;
|
||||
} else if (arg === '--help' || arg === '-h') {
|
||||
options.help = true;
|
||||
} else {
|
||||
throw new Error(`Unknown argument: ${arg}`);
|
||||
}
|
||||
}
|
||||
return options;
|
||||
};
|
||||
|
||||
const printHelp = () => {
|
||||
console.log(`Usage: node scripts/archive-github-traffic.mjs [options]
|
||||
|
||||
Options:
|
||||
--archive-dir <dir> Directory that will receive archive.json and summary.json.
|
||||
--repo <owner/repo> Repository to archive. Defaults to GITHUB_REPOSITORY.
|
||||
--captured-at <iso> Override capture time for tests or backfills.
|
||||
`);
|
||||
};
|
||||
|
||||
const main = async () => {
|
||||
const options = parseArgs(process.argv.slice(2));
|
||||
if (options.help) {
|
||||
printHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
const archiveDir = path.resolve(
|
||||
REPO_ROOT,
|
||||
options.archiveDir || process.env.TRAFFIC_ARCHIVE_DIR || 'traffic',
|
||||
);
|
||||
const archiveFile = path.join(archiveDir, 'archive.json');
|
||||
const summaryFile = path.join(archiveDir, 'summary.json');
|
||||
const repository = normalizeRepository(options.repo || process.env.GITHUB_REPOSITORY);
|
||||
const token = process.env.GH_TRAFFIC_TOKEN
|
||||
|| process.env.TRAFFIC_ARCHIVE_TOKEN
|
||||
|| process.env.GITHUB_TOKEN
|
||||
|| process.env.GH_TOKEN;
|
||||
const capturedAt = options.capturedAt || new Date().toISOString();
|
||||
|
||||
const snapshot = await fetchGitHubTraffic({
|
||||
repo: repository,
|
||||
token,
|
||||
capturedAt,
|
||||
});
|
||||
const existingArchive = await readJsonIfPresent(archiveFile);
|
||||
const archive = mergeTrafficArchive(existingArchive, snapshot);
|
||||
const summary = buildTrafficSummary(archive, { now: archive.updated_at });
|
||||
|
||||
await writeJson(archiveFile, archive);
|
||||
await writeJson(summaryFile, summary);
|
||||
|
||||
console.log(`Archived GitHub traffic for ${repository} at ${archive.updated_at}`);
|
||||
console.log(`Daily views retained: ${archive.daily.views.length}`);
|
||||
console.log(`Daily clones retained: ${archive.daily.clones.length}`);
|
||||
console.log(`Referrer snapshots retained: ${archive.snapshots.referrers.length}`);
|
||||
console.log(`Path snapshots retained: ${archive.snapshots.paths.length}`);
|
||||
};
|
||||
|
||||
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||
try {
|
||||
await main();
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
console.error(`Failed to archive GitHub traffic: ${message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _load_module():
|
||||
module_path = Path(__file__).with_name("verify_skill_release_import_closure.py")
|
||||
spec = importlib.util.spec_from_file_location("verify_skill_release_import_closure", module_path)
|
||||
if spec is None or spec.loader is None:
|
||||
raise RuntimeError(f"Unable to load {module_path}")
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
sys.modules[spec.name] = module
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
class VerifySkillReleaseImportClosureTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
cls.module = _load_module()
|
||||
|
||||
def test_empty_directory_does_not_satisfy_relative_import(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
root = Path(tmpdir)
|
||||
(root / "runtime-lib").mkdir()
|
||||
(root / "main.mjs").write_text("import './runtime-lib';\n", encoding="utf-8")
|
||||
|
||||
failures = self.module.verify_import_closure(root)
|
||||
|
||||
self.assertEqual(len(failures), 1)
|
||||
self.assertIn("main.mjs imports ./runtime-lib", failures[0])
|
||||
|
||||
def test_directory_import_requires_index_file(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
root = Path(tmpdir)
|
||||
runtime_lib = root / "runtime-lib"
|
||||
runtime_lib.mkdir()
|
||||
(runtime_lib / "index.mjs").write_text("export {};\n", encoding="utf-8")
|
||||
(root / "main.mjs").write_text("import './runtime-lib';\n", encoding="utf-8")
|
||||
|
||||
failures = self.module.verify_import_closure(root)
|
||||
|
||||
self.assertEqual(failures, [])
|
||||
|
||||
def test_ts_source_accepts_js_import_specifier(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
root = Path(tmpdir)
|
||||
(root / "types.ts").write_text("export type Value = string;\n", encoding="utf-8")
|
||||
(root / "main.ts").write_text("import type { Value } from './types.js';\n", encoding="utf-8")
|
||||
|
||||
failures = self.module.verify_import_closure(root)
|
||||
|
||||
self.assertEqual(failures, [])
|
||||
|
||||
def test_comment_import_examples_are_ignored(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
root = Path(tmpdir)
|
||||
(root / "main.ts").write_text(
|
||||
"/*\n"
|
||||
" * Example integration:\n"
|
||||
" * import { Missing } from '../external/project/file';\n"
|
||||
" */\n"
|
||||
"export {};\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
failures = self.module.verify_import_closure(root)
|
||||
|
||||
self.assertEqual(failures, [])
|
||||
|
||||
def test_url_string_does_not_hide_following_relative_import(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
root = Path(tmpdir)
|
||||
(root / "main.ts").write_text(
|
||||
'const feedUrl = "https://example.test/feed.json"; import value from "./missing.js";\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
failures = self.module.verify_import_closure(root)
|
||||
|
||||
self.assertEqual(len(failures), 1)
|
||||
self.assertIn("main.ts imports ./missing.js", failures[0])
|
||||
|
||||
def test_remote_import_spec_survives_comment_stripping(self) -> None:
|
||||
source = 'import remote from "https://example.test/module.mjs";\n'
|
||||
stripped = self.module.strip_js_ts_comments(source)
|
||||
|
||||
specs = [match.group("spec") for match in self.module.IMPORT_RE.finditer(stripped)]
|
||||
|
||||
self.assertEqual(specs, ["https://example.test/module.mjs"])
|
||||
|
||||
def test_remote_runtime_import_is_rejected(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
root = Path(tmpdir)
|
||||
(root / "main.mjs").write_text(
|
||||
'import remote from "https://example.test/module.mjs";\n',
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
failures = self.module.verify_import_closure(root)
|
||||
|
||||
self.assertEqual(len(failures), 1)
|
||||
self.assertIn("remote runtime import https://example.test/module.mjs", failures[0])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -71,14 +71,3 @@ if [[ "$CANONICAL_FPR" != "$DOC_EXPECTED_FPR" ]]; then
|
||||
fi
|
||||
|
||||
echo "All signing key references are consistent: $CANONICAL_FPR"
|
||||
|
||||
while IFS= read -r skill_md; do
|
||||
while IFS= read -r doc_fpr; do
|
||||
if [[ "$doc_fpr" != "$CANONICAL_FPR" ]]; then
|
||||
echo "ERROR: $skill_md RELEASE_PUBKEY_SHA256 ($doc_fpr) != canonical fingerprint ($CANONICAL_FPR)" >&2
|
||||
exit 1
|
||||
fi
|
||||
done < <(awk -F'"' '/RELEASE_PUBKEY_SHA256=/{print $2}' "$skill_md")
|
||||
done < <(find skills -mindepth 2 -maxdepth 2 -name SKILL.md -print | sort)
|
||||
|
||||
echo "All skill doc RELEASE_PUBKEY_SHA256 references match the canonical signing key."
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify staged skill release JS/TS imports are self-contained.
|
||||
|
||||
The skill release workflow builds archives from `skill.json.sbom.files`. If a
|
||||
runtime helper exists in the repo but is omitted from the SBOM, the staged
|
||||
release can contain files whose relative imports point at missing files or
|
||||
remote runtime imports. This script checks the staged payload, not the source
|
||||
tree, so it catches exactly what would ship.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
IMPORT_RE = re.compile(
|
||||
r"(?:"
|
||||
r"\bimport\s+(?:type\s+)?(?:[^'\";]+?\s+from\s+)?"
|
||||
r"|\bexport\s+(?:type\s+)?[^'\";]+?\s+from\s+"
|
||||
r"|\bimport\s*\(\s*"
|
||||
r"|\brequire\s*\(\s*"
|
||||
r")"
|
||||
r"['\"](?P<spec>(?:\.{1,2}/|https?://)[^'\"]+)['\"]",
|
||||
re.MULTILINE,
|
||||
)
|
||||
|
||||
SOURCE_SUFFIXES = {".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"}
|
||||
RESOLUTION_SUFFIXES = ["", ".mjs", ".js", ".cjs", ".mts", ".ts", ".cts", ".json"]
|
||||
INDEX_FILENAMES = ["index.mjs", "index.js", "index.cjs", "index.mts", "index.ts", "index.cts", "index.json"]
|
||||
TS_IMPORTER_SUFFIXES = {".ts", ".mts", ".cts"}
|
||||
JS_TO_TS_SUFFIX = {".js": ".ts", ".mjs": ".mts", ".cjs": ".cts"}
|
||||
|
||||
|
||||
def strip_js_ts_comments(text: str) -> str:
|
||||
stripped: list[str] = []
|
||||
state = "code"
|
||||
i = 0
|
||||
|
||||
while i < len(text):
|
||||
char = text[i]
|
||||
next_char = text[i + 1] if i + 1 < len(text) else ""
|
||||
|
||||
if state == "line_comment":
|
||||
if char in "\r\n":
|
||||
stripped.append(char)
|
||||
state = "code"
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if state == "block_comment":
|
||||
if char == "*" and next_char == "/":
|
||||
state = "code"
|
||||
i += 2
|
||||
continue
|
||||
if char in "\r\n":
|
||||
stripped.append(char)
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if state in {"single", "double", "template"}:
|
||||
stripped.append(char)
|
||||
if char == "\\" and i + 1 < len(text):
|
||||
stripped.append(text[i + 1])
|
||||
i += 2
|
||||
continue
|
||||
if (state == "single" and char == "'") or (state == "double" and char == '"') or (
|
||||
state == "template" and char == "`"
|
||||
):
|
||||
state = "code"
|
||||
i += 1
|
||||
continue
|
||||
|
||||
if char == "/" and next_char == "/":
|
||||
stripped.append(" ")
|
||||
state = "line_comment"
|
||||
i += 2
|
||||
continue
|
||||
if char == "/" and next_char == "*":
|
||||
stripped.append(" ")
|
||||
state = "block_comment"
|
||||
i += 2
|
||||
continue
|
||||
|
||||
stripped.append(char)
|
||||
if char == "'":
|
||||
state = "single"
|
||||
elif char == '"':
|
||||
state = "double"
|
||||
elif char == "`":
|
||||
state = "template"
|
||||
i += 1
|
||||
|
||||
return "".join(stripped)
|
||||
|
||||
|
||||
def is_remote_spec(spec: str) -> bool:
|
||||
return spec.startswith(("http://", "https://"))
|
||||
|
||||
|
||||
def candidate_paths(importer: Path, spec: str) -> list[Path]:
|
||||
base = (importer.parent / spec).resolve()
|
||||
candidates = [base]
|
||||
if importer.suffix in TS_IMPORTER_SUFFIXES and base.suffix in JS_TO_TS_SUFFIX:
|
||||
candidates.append(base.with_suffix(JS_TO_TS_SUFFIX[base.suffix]))
|
||||
candidates.extend(base.with_suffix(suffix) for suffix in RESOLUTION_SUFFIXES if suffix and base.suffix == "")
|
||||
candidates.extend(base / name for name in INDEX_FILENAMES)
|
||||
return candidates
|
||||
|
||||
|
||||
def is_within(path: Path, root: Path) -> bool:
|
||||
try:
|
||||
path.resolve().relative_to(root)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
def is_resolved_file(candidate: Path, root: Path) -> bool:
|
||||
return candidate.is_file() and is_within(candidate, root)
|
||||
|
||||
|
||||
def verify_import_closure(root: Path) -> list[str]:
|
||||
root = root.resolve()
|
||||
failures: list[str] = []
|
||||
|
||||
for source in sorted(p for p in root.rglob("*") if p.is_file() and p.suffix in SOURCE_SUFFIXES):
|
||||
text = source.read_text(encoding="utf-8", errors="ignore")
|
||||
text = strip_js_ts_comments(text)
|
||||
for match in IMPORT_RE.finditer(text):
|
||||
spec = match.group("spec")
|
||||
rel_source = source.relative_to(root).as_posix()
|
||||
if is_remote_spec(spec):
|
||||
failures.append(f"{rel_source} imports remote runtime import {spec}")
|
||||
continue
|
||||
|
||||
candidates = candidate_paths(source, spec)
|
||||
if any(is_resolved_file(candidate, root) for candidate in candidates):
|
||||
continue
|
||||
|
||||
display_target = (source.parent / spec).resolve()
|
||||
try:
|
||||
rel_target = display_target.relative_to(root).as_posix()
|
||||
except ValueError:
|
||||
rel_target = str(display_target)
|
||||
failures.append(f"{rel_source} imports {spec} but {rel_target} is absent from staged release")
|
||||
|
||||
return failures
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("staged_skill_dir", type=Path, help="Staged skill payload directory, e.g. $INNER_DIR")
|
||||
args = parser.parse_args()
|
||||
|
||||
root = args.staged_skill_dir
|
||||
if not root.is_dir():
|
||||
print(f"error: staged skill directory not found: {root}", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
failures = verify_import_closure(root)
|
||||
if failures:
|
||||
print("Release import-closure check failed:", file=sys.stderr)
|
||||
for failure in failures:
|
||||
print(f" - {failure}", file=sys.stderr)
|
||||
print("Add the missing runtime file(s) to skill.json sbom.files or remove the stale import.", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
print(f"Release import-closure check OK: {root}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -45,23 +45,18 @@ keyword|NanoClaw
|
||||
keyword|WhatsApp-bot
|
||||
keyword|baileys
|
||||
keyword|hermes workflow
|
||||
keyword|hermes-agent
|
||||
keyword|Picoclaw
|
||||
virtualMatchString|cpe:2.3:a:software-metadata.pub:hermes
|
||||
virtualMatchString|cpe:2.3:a:picoclaw:picoclaw
|
||||
EOF
|
||||
}
|
||||
|
||||
nvd_summary_keywords() {
|
||||
echo 'openclaw, nanoclaw, hermes, picoclaw'
|
||||
}
|
||||
|
||||
nvd_keyword_pattern() {
|
||||
echo 'OpenClaw|clawdbot|Moltbot|openclaw|NanoClaw|nanoclaw|WhatsApp-bot|baileys|HERMES workflow|hermes-agent|software publication with rich metadata|Picoclaw|picoclaw'
|
||||
echo 'OpenClaw|clawdbot|Moltbot|openclaw|NanoClaw|nanoclaw|WhatsApp-bot|baileys|HERMES workflow|software publication with rich metadata|Picoclaw|picoclaw'
|
||||
}
|
||||
|
||||
nvd_github_ref_pattern() {
|
||||
echo 'github\.com/openclaw/openclaw|github\.com/qwibitai/nanoclaw|github\.com/softwarepub/hermes|github\.com/nousresearch/hermes-agent|github\.com/[^/]+/picoclaw'
|
||||
echo 'github\.com/openclaw/openclaw|github\.com/qwibitai/nanoclaw|github\.com/softwarepub/hermes|github\.com/[^/]+/picoclaw'
|
||||
}
|
||||
|
||||
nvd_cpe_pattern() {
|
||||
|
||||
@@ -1,514 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { existsSync } from 'node:fs';
|
||||
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
||||
import { dirname } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
export const DEFAULT_REPOSITORIES = [
|
||||
'openclaw/openclaw',
|
||||
'qwibitai/nanoclaw',
|
||||
'softwarepub/hermes',
|
||||
'nousresearch/hermes-agent',
|
||||
'sipeed/picoclaw',
|
||||
];
|
||||
|
||||
export const DEFAULT_STALE_AFTER_DAYS = 60;
|
||||
export const FEED_VERSION = '0.1.0';
|
||||
|
||||
const PLATFORM_BY_REPOSITORY = new Map([
|
||||
['openclaw/openclaw', 'openclaw'],
|
||||
['qwibitai/nanoclaw', 'nanoclaw'],
|
||||
['softwarepub/hermes', 'hermes'],
|
||||
['nousresearch/hermes-agent', 'hermes'],
|
||||
['sipeed/picoclaw', 'picoclaw'],
|
||||
]);
|
||||
|
||||
const CWE_TYPE_BY_ID = new Map([
|
||||
['CWE-22', 'path_traversal'],
|
||||
['CWE-78', 'os_command_injection'],
|
||||
['CWE-79', 'cross_site_scripting'],
|
||||
['CWE-94', 'code_injection'],
|
||||
['CWE-200', 'exposure_of_sensitive_information'],
|
||||
['CWE-284', 'improper_access_control'],
|
||||
['CWE-287', 'improper_authentication'],
|
||||
['CWE-306', 'missing_authentication_for_critical_function'],
|
||||
['CWE-352', 'cross_site_request_forgery'],
|
||||
['CWE-400', 'uncontrolled_resource_consumption'],
|
||||
['CWE-502', 'deserialization_of_untrusted_data'],
|
||||
['CWE-862', 'missing_authorization'],
|
||||
['CWE-863', 'incorrect_authorization'],
|
||||
['CWE-918', 'server_side_request_forgery'],
|
||||
]);
|
||||
|
||||
function cleanText(value) {
|
||||
return String(value ?? '')
|
||||
.replace(/\r/g, '')
|
||||
.replace(/```[\s\S]*?```/g, ' ')
|
||||
.replace(/`([^`]+)`/g, '$1')
|
||||
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')
|
||||
.replace(/^#+\s+/gm, '')
|
||||
.replace(/[*_>]/g, '')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
}
|
||||
|
||||
function daysBetween(startIso, endIso) {
|
||||
const start = Date.parse(startIso);
|
||||
const end = Date.parse(endIso);
|
||||
if (!Number.isFinite(start) || !Number.isFinite(end) || end < start) {
|
||||
return 0;
|
||||
}
|
||||
return Math.floor((end - start) / 86_400_000);
|
||||
}
|
||||
|
||||
function toArray(value) {
|
||||
return Array.isArray(value) ? value : [];
|
||||
}
|
||||
|
||||
function uniqueStrings(values) {
|
||||
return [...new Set(values.filter((value) => typeof value === 'string' && value.length > 0))];
|
||||
}
|
||||
|
||||
export function inferPlatforms(repository) {
|
||||
const known = PLATFORM_BY_REPOSITORY.get(String(repository).toLowerCase());
|
||||
return known ? [known] : [];
|
||||
}
|
||||
|
||||
function nextLinkFromHeader(linkHeader) {
|
||||
if (!linkHeader) {
|
||||
return null;
|
||||
}
|
||||
for (const part of linkHeader.split(',')) {
|
||||
const match = part.trim().match(/^<([^>]+)>;\s*rel="next"$/);
|
||||
if (match) {
|
||||
return match[1];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function affectedFromVulnerabilities(advisory, platforms) {
|
||||
const affected = toArray(advisory.vulnerabilities).flatMap((vulnerability) => {
|
||||
const packageName = vulnerability?.package?.name;
|
||||
const versionRange = vulnerability?.vulnerable_version_range;
|
||||
if (!packageName) {
|
||||
return [];
|
||||
}
|
||||
return [`${packageName}@${versionRange || '*'}`];
|
||||
});
|
||||
|
||||
if (affected.length > 0) {
|
||||
return uniqueStrings(affected);
|
||||
}
|
||||
|
||||
return platforms.length > 0 ? platforms.map((platform) => `${platform}@*`) : [];
|
||||
}
|
||||
|
||||
function patchedFromVulnerabilities(advisory) {
|
||||
return uniqueStrings(
|
||||
toArray(advisory.vulnerabilities).flatMap((vulnerability) => {
|
||||
const packageName = vulnerability?.package?.name;
|
||||
const patchedVersions = vulnerability?.patched_versions;
|
||||
if (!packageName || !patchedVersions) {
|
||||
return [];
|
||||
}
|
||||
return [`${packageName}@${patchedVersions}`];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
function githubAdvisoryUrl(advisory) {
|
||||
return advisory.html_url || advisory.url || `https://github.com/advisories/${advisory.ghsa_id}`;
|
||||
}
|
||||
|
||||
function resolveCveId(advisory, cveIdByGhsa) {
|
||||
return advisory.cve_id || cveIdByGhsa.get(advisory.ghsa_id) || null;
|
||||
}
|
||||
|
||||
export function normalizeGhsaAdvisory(
|
||||
advisory,
|
||||
{
|
||||
now,
|
||||
repository,
|
||||
staleAfterDays = DEFAULT_STALE_AFTER_DAYS,
|
||||
cveId = advisory.cve_id || null,
|
||||
},
|
||||
) {
|
||||
const platforms = inferPlatforms(repository);
|
||||
const published = advisory.published_at || advisory.created_at || advisory.updated_at || now;
|
||||
const ageDays = daysBetween(published, now);
|
||||
const stale = !cveId && ageDays >= staleAfterDays;
|
||||
const status = cveId ? 'matured' : stale ? 'stale' : 'active';
|
||||
const cweIds = uniqueStrings(toArray(advisory.cwe_ids));
|
||||
const cvss = advisory.cvss || advisory.cvss_severities?.cvss_v3 || {};
|
||||
const ghsaUrl = githubAdvisoryUrl(advisory);
|
||||
const affected = affectedFromVulnerabilities(advisory, platforms);
|
||||
const patched = patchedFromVulnerabilities(advisory);
|
||||
const title = cleanText(advisory.summary) || advisory.ghsa_id;
|
||||
const description = cleanText(advisory.description) || title;
|
||||
|
||||
return {
|
||||
id: advisory.ghsa_id,
|
||||
ghsa_id: advisory.ghsa_id,
|
||||
cve_id: cveId,
|
||||
status,
|
||||
stale,
|
||||
stale_after_days: staleAfterDays,
|
||||
severity: advisory.severity || 'medium',
|
||||
type: CWE_TYPE_BY_ID.get(cweIds[0]) || 'github_security_advisory',
|
||||
nvd_category_id: cweIds[0] || null,
|
||||
title,
|
||||
description,
|
||||
affected,
|
||||
patched,
|
||||
platforms,
|
||||
action: cveId
|
||||
? `Track ${cveId} in the canonical CVE advisory feed and verify affected components.`
|
||||
: 'Review the GitHub Security Advisory and update affected components; no CVE is assigned yet.',
|
||||
published,
|
||||
updated: advisory.updated_at || published,
|
||||
references: uniqueStrings([ghsaUrl, cveId ? `https://nvd.nist.gov/vuln/detail/${cveId}` : null]),
|
||||
source: 'GitHub Security Advisory',
|
||||
repository,
|
||||
github_advisory_url: ghsaUrl,
|
||||
nvd_url: cveId ? `https://nvd.nist.gov/vuln/detail/${cveId}` : null,
|
||||
cvss_score: cvss.score ?? null,
|
||||
cvss_vector: cvss.vector_string ?? null,
|
||||
cwe_ids: cweIds,
|
||||
credits: uniqueStrings(toArray(advisory.credits).map((credit) => credit?.login)),
|
||||
aliases: uniqueStrings([advisory.ghsa_id, cveId]),
|
||||
};
|
||||
}
|
||||
|
||||
function ghsaToCveMapFromNvdFeed(nvdFeed) {
|
||||
const map = new Map();
|
||||
for (const advisory of toArray(nvdFeed?.advisories)) {
|
||||
const cveId = advisory?.id;
|
||||
if (typeof cveId !== 'string' || !cveId.startsWith('CVE-')) {
|
||||
continue;
|
||||
}
|
||||
const references = toArray(advisory.references).join('\n');
|
||||
for (const match of references.matchAll(/GHSA-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}/gi)) {
|
||||
map.set(match[0], cveId);
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
function equivalentAdvisories(left, right) {
|
||||
return JSON.stringify(left ?? []) === JSON.stringify(right ?? []);
|
||||
}
|
||||
|
||||
function isCveId(value) {
|
||||
return typeof value === 'string' && /^CVE-\d{4}-\d{4,}$/i.test(value);
|
||||
}
|
||||
|
||||
function ghsaIdentifier(entry) {
|
||||
if (typeof entry?.ghsa_id === 'string' && entry.ghsa_id.length > 0) {
|
||||
return entry.ghsa_id.toLowerCase();
|
||||
}
|
||||
if (/^GHSA-/i.test(String(entry?.id || ''))) {
|
||||
return String(entry.id).toLowerCase();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function refreshExistingEntry(entry, { now, staleAfterDays, cveIdByGhsa }) {
|
||||
const cveId = entry.cve_id || cveIdByGhsa.get(entry.ghsa_id || entry.id) || null;
|
||||
const ageDays = daysBetween(entry.published, now);
|
||||
const stale = !cveId && ageDays >= staleAfterDays;
|
||||
return {
|
||||
...entry,
|
||||
cve_id: cveId,
|
||||
status: cveId ? 'matured' : stale ? 'stale' : 'active',
|
||||
stale,
|
||||
stale_after_days: staleAfterDays,
|
||||
references: uniqueStrings([
|
||||
...toArray(entry.references),
|
||||
cveId ? `https://nvd.nist.gov/vuln/detail/${cveId}` : null,
|
||||
]),
|
||||
nvd_url: cveId ? `https://nvd.nist.gov/vuln/detail/${cveId}` : null,
|
||||
aliases: uniqueStrings([...(entry.aliases || []), entry.ghsa_id || entry.id, cveId]),
|
||||
};
|
||||
}
|
||||
|
||||
export function buildConsolidatedAdvisoryFeed({ canonicalFeed = {}, ghsaFeed = {}, now }) {
|
||||
const canonicalFeedEntries = toArray(canonicalFeed.advisories);
|
||||
const canonicalCveIds = new Set(canonicalFeedEntries.map((entry) => entry?.id).filter(isCveId));
|
||||
const replacementGhsaIds = new Set(toArray(ghsaFeed.advisories).map(ghsaIdentifier).filter(Boolean));
|
||||
const canonicalEntries = canonicalFeedEntries.filter((entry) => {
|
||||
const ghsaId = ghsaIdentifier(entry);
|
||||
if (!ghsaId) {
|
||||
return true;
|
||||
}
|
||||
if (entry?.cve_id && canonicalCveIds.has(entry.cve_id)) {
|
||||
return false;
|
||||
}
|
||||
return !replacementGhsaIds.has(ghsaId);
|
||||
});
|
||||
const ghsaEntries = toArray(ghsaFeed.advisories)
|
||||
.filter((entry) => !(entry?.cve_id && canonicalCveIds.has(entry.cve_id)))
|
||||
.map((entry) => ({
|
||||
...entry,
|
||||
source_feed: 'ghsa-without-cve',
|
||||
}));
|
||||
|
||||
const advisories = [...canonicalEntries, ...ghsaEntries].sort((a, b) => {
|
||||
const published = Date.parse(b.published || '') - Date.parse(a.published || '');
|
||||
if (Number.isFinite(published) && published !== 0) {
|
||||
return published;
|
||||
}
|
||||
return String(a.id || '').localeCompare(String(b.id || ''));
|
||||
});
|
||||
|
||||
return {
|
||||
...canonicalFeed,
|
||||
version: canonicalFeed.version || '1.0.0',
|
||||
updated: canonicalFeed.updated || now,
|
||||
description: canonicalFeed.description || 'Community-driven security advisory feed for ClawSec',
|
||||
advisories,
|
||||
};
|
||||
}
|
||||
|
||||
export function buildGhsaWithoutCveFeed({
|
||||
fetched,
|
||||
existingFeed = {},
|
||||
nvdFeed = {},
|
||||
now,
|
||||
staleAfterDays = DEFAULT_STALE_AFTER_DAYS,
|
||||
}) {
|
||||
const existingEntries = toArray(existingFeed.advisories);
|
||||
const existingIds = new Set(existingEntries.map((entry) => entry.ghsa_id || entry.id));
|
||||
const cveIdByGhsa = ghsaToCveMapFromNvdFeed(nvdFeed);
|
||||
const entriesById = new Map();
|
||||
|
||||
for (const { repository, advisories } of fetched) {
|
||||
for (const advisory of advisories) {
|
||||
const ghsaId = advisory.ghsa_id;
|
||||
if (!ghsaId) {
|
||||
continue;
|
||||
}
|
||||
const cveId = resolveCveId(advisory, cveIdByGhsa);
|
||||
if (cveId && !existingIds.has(ghsaId)) {
|
||||
continue;
|
||||
}
|
||||
entriesById.set(
|
||||
ghsaId,
|
||||
normalizeGhsaAdvisory(advisory, {
|
||||
now,
|
||||
repository,
|
||||
staleAfterDays,
|
||||
cveId,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (const entry of existingEntries) {
|
||||
const ghsaId = entry.ghsa_id || entry.id;
|
||||
if (!ghsaId || entriesById.has(ghsaId)) {
|
||||
continue;
|
||||
}
|
||||
entriesById.set(ghsaId, refreshExistingEntry(entry, { now, staleAfterDays, cveIdByGhsa }));
|
||||
}
|
||||
|
||||
const advisories = [...entriesById.values()].sort((a, b) => {
|
||||
const published = Date.parse(b.published) - Date.parse(a.published);
|
||||
if (published !== 0) {
|
||||
return published;
|
||||
}
|
||||
return a.id.localeCompare(b.id);
|
||||
});
|
||||
|
||||
const updated = equivalentAdvisories(advisories, existingEntries)
|
||||
? existingFeed.updated || now
|
||||
: now;
|
||||
|
||||
return {
|
||||
version: FEED_VERSION,
|
||||
updated,
|
||||
description:
|
||||
'Provisional ClawSec advisory feed for public GitHub Security Advisories that do not yet have CVE identifiers.',
|
||||
stale_after_days: staleAfterDays,
|
||||
semantics: {
|
||||
active: 'GHSA is published and has no CVE identifier yet.',
|
||||
matured: 'GHSA now has a CVE identifier and should be reconciled with the canonical CVE feed.',
|
||||
stale: 'GHSA is older than stale_after_days and still has no CVE identifier.',
|
||||
},
|
||||
sources: DEFAULT_REPOSITORIES.map((repository) => ({
|
||||
repository,
|
||||
platform: inferPlatforms(repository)[0] || 'unknown',
|
||||
url: `https://github.com/${repository}/security/advisories`,
|
||||
})),
|
||||
advisories,
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchGitHubSecurityAdvisories(repository, { token } = {}) {
|
||||
const advisories = [];
|
||||
let url = `https://api.github.com/repos/${repository}/security-advisories?per_page=100`;
|
||||
const seenUrls = new Set();
|
||||
|
||||
while (url) {
|
||||
if (seenUrls.has(url)) {
|
||||
throw new Error(`GitHub advisory pagination loop detected for ${repository}: ${url}`);
|
||||
}
|
||||
seenUrls.add(url);
|
||||
|
||||
const response = await globalThis.fetch(url, {
|
||||
headers: {
|
||||
Accept: 'application/vnd.github+json',
|
||||
'User-Agent': 'clawsec-ghsa-without-cve-poller',
|
||||
'X-GitHub-Api-Version': '2022-11-28',
|
||||
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const message = await response.text();
|
||||
throw new Error(
|
||||
`GitHub advisory fetch failed for ${repository}: HTTP ${response.status} ${message.slice(0, 200)}`,
|
||||
);
|
||||
}
|
||||
|
||||
const pageItems = await response.json();
|
||||
advisories.push(...pageItems);
|
||||
if (!Array.isArray(pageItems)) {
|
||||
break;
|
||||
}
|
||||
url = nextLinkFromHeader(response.headers.get('link'));
|
||||
}
|
||||
return advisories;
|
||||
}
|
||||
|
||||
async function readJsonIfExists(path, fallback) {
|
||||
if (!existsSync(path)) {
|
||||
return fallback;
|
||||
}
|
||||
return JSON.parse(await readFile(path, 'utf8'));
|
||||
}
|
||||
|
||||
async function writeJson(path, value) {
|
||||
await mkdir(dirname(path), { recursive: true });
|
||||
await writeFile(`${path}.tmp`, `${JSON.stringify(value, null, 2)}\n`);
|
||||
await rename(`${path}.tmp`, path);
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
const options = {
|
||||
output: 'advisories/ghsa-without-cve.json',
|
||||
consolidatedFeed: null,
|
||||
existingFeed: null,
|
||||
nvdFeed: 'advisories/feed.json',
|
||||
repositories: [...DEFAULT_REPOSITORIES],
|
||||
staleAfterDays: DEFAULT_STALE_AFTER_DAYS,
|
||||
token: process.env.GITHUB_TOKEN || process.env.GH_TOKEN || '',
|
||||
};
|
||||
|
||||
for (let index = 0; index < argv.length; index += 1) {
|
||||
const arg = argv[index];
|
||||
if (arg === '--output') {
|
||||
options.output = argv[++index];
|
||||
} else if (arg === '--consolidated-feed') {
|
||||
options.consolidatedFeed = argv[++index];
|
||||
} else if (arg === '--existing-feed') {
|
||||
options.existingFeed = argv[++index];
|
||||
} else if (arg === '--nvd-feed') {
|
||||
options.nvdFeed = argv[++index];
|
||||
} else if (arg === '--repo') {
|
||||
options.repositories.push(argv[++index]);
|
||||
} else if (arg === '--only-default-repos') {
|
||||
options.repositories = [...DEFAULT_REPOSITORIES];
|
||||
} else if (arg === '--stale-after-days') {
|
||||
options.staleAfterDays = Number.parseInt(argv[++index], 10);
|
||||
} else if (arg === '--help') {
|
||||
options.help = true;
|
||||
} else {
|
||||
throw new Error(`Unknown argument: ${arg}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (!Number.isInteger(options.staleAfterDays) || options.staleAfterDays < 1) {
|
||||
throw new Error('--stale-after-days must be a positive integer');
|
||||
}
|
||||
|
||||
options.repositories = uniqueStrings(options.repositories.map((repo) => repo.toLowerCase()));
|
||||
options.existingFeed ||= options.output;
|
||||
return options;
|
||||
}
|
||||
|
||||
function printHelp() {
|
||||
console.log(`Usage: node scripts/ghsa-without-cve-feed.mjs [options]
|
||||
|
||||
Options:
|
||||
--output PATH Feed output path (default: advisories/ghsa-without-cve.json)
|
||||
--consolidated-feed PATH Also merge active GHSA advisories into agent-facing feed PATH
|
||||
--existing-feed PATH Existing provisional feed path (default: output path)
|
||||
--nvd-feed PATH Canonical CVE feed path for GHSA-to-CVE reconciliation
|
||||
--repo OWNER/NAME Additional repository to poll
|
||||
--only-default-repos Reset repository list to built-in ClawSec sources
|
||||
--stale-after-days N Mark GHSA-only advisories stale after N days (default: 60)
|
||||
`);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const options = parseArgs(process.argv.slice(2));
|
||||
if (options.help) {
|
||||
printHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
const now = new Date().toISOString().replace(/\.\d{3}Z$/, 'Z');
|
||||
const fetched = [];
|
||||
for (const repository of options.repositories) {
|
||||
const advisories = await fetchGitHubSecurityAdvisories(repository, { token: options.token });
|
||||
console.log(`Fetched ${advisories.length} GitHub Security Advisories from ${repository}`);
|
||||
fetched.push({ repository, advisories });
|
||||
}
|
||||
|
||||
const existingFeed = await readJsonIfExists(options.existingFeed, {});
|
||||
const nvdFeed = await readJsonIfExists(options.nvdFeed, { advisories: [] });
|
||||
const feed = buildGhsaWithoutCveFeed({
|
||||
fetched,
|
||||
existingFeed,
|
||||
nvdFeed,
|
||||
now,
|
||||
staleAfterDays: options.staleAfterDays,
|
||||
});
|
||||
|
||||
await writeJson(options.output, feed);
|
||||
console.log(`Wrote ${feed.advisories.length} provisional GHSA advisories to ${options.output}`);
|
||||
|
||||
if (options.consolidatedFeed) {
|
||||
const canonicalFeed = await readJsonIfExists(options.consolidatedFeed, {
|
||||
version: '1.0.0',
|
||||
advisories: [],
|
||||
});
|
||||
const consolidatedFeed = buildConsolidatedAdvisoryFeed({
|
||||
canonicalFeed,
|
||||
ghsaFeed: feed,
|
||||
now,
|
||||
});
|
||||
await writeJson(options.consolidatedFeed, consolidatedFeed);
|
||||
console.log(
|
||||
`Wrote ${consolidatedFeed.advisories.length} consolidated agent advisories to ${options.consolidatedFeed}`,
|
||||
);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Status counts: ${JSON.stringify(
|
||||
feed.advisories.reduce((counts, advisory) => {
|
||||
counts[advisory.status] = (counts[advisory.status] || 0) + 1;
|
||||
return counts;
|
||||
}, {}),
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
@@ -168,35 +168,15 @@ EOF
|
||||
echo " ✓ Generated: checksums.json"
|
||||
|
||||
# Build skill entry for index
|
||||
SKILL_DATA=$(jq -c --arg tag "$TAG" '
|
||||
. as $skill |
|
||||
def object_or_empty($value):
|
||||
if ($value | type) == "object" then $value else {} end;
|
||||
def object_field($name):
|
||||
object_or_empty($skill[$name]?);
|
||||
def platform_meta:
|
||||
($skill.platform as $platform
|
||||
| if ($platform | type) == "string" then object_or_empty($skill[$platform]?)
|
||||
else {}
|
||||
end);
|
||||
def platform_list:
|
||||
([]
|
||||
+ (if ($skill.platforms | type) == "array" then $skill.platforms else [] end)
|
||||
+ (if ($skill.platform | type) == "string" then [$skill.platform] else [] end)
|
||||
+ (["openclaw", "hermes", "nanoclaw", "picoclaw"] | map(select((object_field(.) | length) > 0))))
|
||||
| map(select(type == "string") | ascii_downcase)
|
||||
| unique;
|
||||
{
|
||||
id: .name,
|
||||
name: .name,
|
||||
version: .version,
|
||||
description: .description,
|
||||
emoji: (platform_meta.emoji // object_field("openclaw").emoji // object_field("hermes").emoji // object_field("nanoclaw").emoji // object_field("picoclaw").emoji // "📦"),
|
||||
category: (platform_meta.category // object_field("openclaw").category // object_field("hermes").category // object_field("nanoclaw").category // object_field("picoclaw").category // "utility"),
|
||||
platforms: platform_list,
|
||||
tag: $tag
|
||||
}
|
||||
' "$SKILL_JSON")
|
||||
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
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
|
||||
const workflowPath = new URL("../.github/workflows/deploy-pages.yml", import.meta.url);
|
||||
const workflow = await readFile(workflowPath, "utf8");
|
||||
|
||||
function stepIndex(name) {
|
||||
const marker = `- name: ${name}`;
|
||||
const index = workflow.indexOf(marker);
|
||||
assert.notEqual(index, -1, `missing workflow step: ${name}`);
|
||||
return index;
|
||||
}
|
||||
|
||||
const signFeedIndex = stepIndex("Sign advisory feed and verify");
|
||||
const signGhsaIndex = stepIndex("Sign provisional GHSA feed and verify");
|
||||
const generateChecksumsIndex = stepIndex("Generate advisory checksums manifest");
|
||||
const signChecksumsIndex = stepIndex("Sign checksums and verify");
|
||||
|
||||
assert.ok(
|
||||
signFeedIndex < generateChecksumsIndex,
|
||||
"advisory checksums manifest must be generated after feed.json.sig is created",
|
||||
);
|
||||
assert.ok(
|
||||
signGhsaIndex < generateChecksumsIndex,
|
||||
"advisory checksums manifest must be generated after ghsa-without-cve.json.sig is created",
|
||||
);
|
||||
assert.ok(
|
||||
generateChecksumsIndex < signChecksumsIndex,
|
||||
"checksums signature must be generated after checksums.json is refreshed",
|
||||
);
|
||||
|
||||
const generateStepBody = workflow.slice(generateChecksumsIndex, signChecksumsIndex);
|
||||
assert.match(
|
||||
generateStepBody,
|
||||
/public\/advisories\/\*\.json\.sig/,
|
||||
"advisory checksums manifest must include detached advisory signatures",
|
||||
);
|
||||
|
||||
const mirrorBlockIndex = workflow.indexOf(
|
||||
"# Mirror advisories feed + signatures at the path referenced by suite docs/heartbeat",
|
||||
);
|
||||
assert.notEqual(mirrorBlockIndex, -1, "missing advisory release mirror block");
|
||||
|
||||
const mirrorBlock = workflow.slice(mirrorBlockIndex, workflow.indexOf("if [ -f \"public/checksums.json\"", mirrorBlockIndex));
|
||||
assert.match(
|
||||
mirrorBlock,
|
||||
/cp "public\/advisories\/ghsa-without-cve\.json" "\$MIRROR_LATEST_DIR\/ghsa-without-cve\.json"/,
|
||||
"GHSA provisional feed must be mirrored at the release-root compatibility path",
|
||||
);
|
||||
assert.match(
|
||||
mirrorBlock,
|
||||
/cp "public\/advisories\/ghsa-without-cve\.json\.sig" "\$MIRROR_LATEST_DIR\/ghsa-without-cve\.json\.sig"/,
|
||||
"GHSA provisional feed signature must be mirrored at the release-root compatibility path",
|
||||
);
|
||||
@@ -1,37 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
const workflowPath = new URL('../.github/workflows/poll-ghsa-without-cve.yml', import.meta.url);
|
||||
const workflow = await readFile(workflowPath, 'utf8');
|
||||
|
||||
assert.match(workflow, /workflow_dispatch:/, 'GHSA poll workflow must remain runnable as a manual fallback');
|
||||
assert.doesNotMatch(
|
||||
workflow,
|
||||
/\n\s+schedule:/,
|
||||
'Scheduled GHSA consolidation belongs to the NVD workflow to avoid duplicate automated feed PRs',
|
||||
);
|
||||
assert.match(
|
||||
workflow,
|
||||
/FEED_PATH:\s+advisories\/feed\.json/,
|
||||
'GHSA poll workflow must know the consolidated agent feed path',
|
||||
);
|
||||
assert.match(
|
||||
workflow,
|
||||
/SKILL_FEED_PATH:\s+skills\/clawsec-feed\/advisories\/feed\.json/,
|
||||
'GHSA poll workflow must sync the consolidated agent feed into clawsec-feed',
|
||||
);
|
||||
assert.match(
|
||||
workflow,
|
||||
/--consolidated-feed "\$FEED_PATH"/,
|
||||
'GHSA poll workflow must merge GHSA advisories into the agent-facing feed',
|
||||
);
|
||||
assert.match(
|
||||
workflow,
|
||||
/input_file: \$\{\{ env\.FEED_PATH \}\}/,
|
||||
'GHSA poll workflow must sign the consolidated agent feed when it changes',
|
||||
);
|
||||
assert.match(
|
||||
workflow,
|
||||
/cp "\$FEED_SIG_PATH" "\$SKILL_FEED_SIG_PATH"/,
|
||||
'GHSA poll workflow must sync consolidated feed signature into clawsec-feed',
|
||||
);
|
||||
@@ -1,425 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import {
|
||||
buildConsolidatedAdvisoryFeed,
|
||||
buildGhsaWithoutCveFeed,
|
||||
fetchGitHubSecurityAdvisories,
|
||||
inferPlatforms,
|
||||
normalizeGhsaAdvisory,
|
||||
} from './ghsa-without-cve-feed.mjs';
|
||||
|
||||
const fixedNow = '2026-05-24T00:00:00Z';
|
||||
|
||||
function advisory(overrides = {}) {
|
||||
return {
|
||||
ghsa_id: 'GHSA-test-1111-2222',
|
||||
cve_id: null,
|
||||
html_url: 'https://github.com/openclaw/openclaw/security/advisories/GHSA-test-1111-2222',
|
||||
summary: 'Workspace bridge allows sandbox escape',
|
||||
description: 'OpenClaw before 2026.4.25 allowed a sandbox escape.',
|
||||
severity: 'high',
|
||||
published_at: '2026-04-24T00:00:00Z',
|
||||
updated_at: '2026-04-25T00:00:00Z',
|
||||
vulnerabilities: [
|
||||
{
|
||||
package: { ecosystem: 'npm', name: 'openclaw' },
|
||||
vulnerable_version_range: '<2026.4.25',
|
||||
patched_versions: '2026.4.25',
|
||||
},
|
||||
],
|
||||
cvss: {
|
||||
vector_string: 'CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H',
|
||||
score: 7.8,
|
||||
},
|
||||
cwe_ids: ['CWE-94'],
|
||||
credits: [{ login: 'researcher', type: 'reporter' }],
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
test('inferPlatforms maps known repositories to feed platforms', () => {
|
||||
assert.deepEqual(inferPlatforms('openclaw/openclaw'), ['openclaw']);
|
||||
assert.deepEqual(inferPlatforms('qwibitai/nanoclaw'), ['nanoclaw']);
|
||||
assert.deepEqual(inferPlatforms('softwarepub/hermes'), ['hermes']);
|
||||
assert.deepEqual(inferPlatforms('sipeed/picoclaw'), ['picoclaw']);
|
||||
});
|
||||
|
||||
test('fetchGitHubSecurityAdvisories follows cursor pagination links', async (t) => {
|
||||
const originalFetch = globalThis.fetch;
|
||||
const nextUrl =
|
||||
'https://api.github.com/repositories/1103012935/security-advisories?per_page=100&after=cursor';
|
||||
const calls = [];
|
||||
|
||||
globalThis.fetch = async (url) => {
|
||||
calls.push(String(url));
|
||||
if (calls.length === 1) {
|
||||
return new globalThis.Response(
|
||||
JSON.stringify(
|
||||
Array.from({ length: 100 }, (_, index) =>
|
||||
advisory({ ghsa_id: `GHSA-page-1111-${String(index).padStart(4, '0')}` }),
|
||||
),
|
||||
),
|
||||
{
|
||||
status: 200,
|
||||
headers: {
|
||||
Link: `<${nextUrl}>; rel="next"`,
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
if (String(url) !== nextUrl) {
|
||||
throw new Error(`unexpected pagination URL: ${url}`);
|
||||
}
|
||||
return new globalThis.Response(JSON.stringify([advisory({ ghsa_id: 'GHSA-next-1111-2222' })]), {
|
||||
status: 200,
|
||||
});
|
||||
};
|
||||
t.after(() => {
|
||||
globalThis.fetch = originalFetch;
|
||||
});
|
||||
|
||||
const advisories = await fetchGitHubSecurityAdvisories('openclaw/openclaw', {
|
||||
token: 'test-token',
|
||||
});
|
||||
|
||||
assert.equal(calls.length, 2);
|
||||
assert.equal(calls[1], nextUrl);
|
||||
assert.equal(advisories.length, 101);
|
||||
assert.equal(advisories.at(-1).ghsa_id, 'GHSA-next-1111-2222');
|
||||
});
|
||||
|
||||
test('normalizeGhsaAdvisory marks fresh GHSA-only advisories active', () => {
|
||||
const normalized = normalizeGhsaAdvisory(advisory(), {
|
||||
now: fixedNow,
|
||||
repository: 'openclaw/openclaw',
|
||||
staleAfterDays: 60,
|
||||
});
|
||||
|
||||
assert.equal(normalized.id, 'GHSA-test-1111-2222');
|
||||
assert.equal(normalized.status, 'active');
|
||||
assert.equal(normalized.cve_id, null);
|
||||
assert.equal(normalized.stale, false);
|
||||
assert.deepEqual(normalized.platforms, ['openclaw']);
|
||||
assert.deepEqual(normalized.affected, ['openclaw@<2026.4.25']);
|
||||
});
|
||||
|
||||
test('normalizeGhsaAdvisory marks old GHSA-only advisories stale after threshold', () => {
|
||||
const normalized = normalizeGhsaAdvisory(
|
||||
advisory({ published_at: '2026-03-01T00:00:00Z' }),
|
||||
{
|
||||
now: fixedNow,
|
||||
repository: 'openclaw/openclaw',
|
||||
staleAfterDays: 60,
|
||||
},
|
||||
);
|
||||
|
||||
assert.equal(normalized.status, 'stale');
|
||||
assert.equal(normalized.stale, true);
|
||||
assert.equal(normalized.cve_id, null);
|
||||
});
|
||||
|
||||
test('normalizeGhsaAdvisory marks existing GHSA entries matured when a CVE appears', () => {
|
||||
const normalized = normalizeGhsaAdvisory(
|
||||
advisory({ cve_id: 'CVE-2026-9999' }),
|
||||
{
|
||||
now: fixedNow,
|
||||
repository: 'openclaw/openclaw',
|
||||
staleAfterDays: 60,
|
||||
},
|
||||
);
|
||||
|
||||
assert.equal(normalized.status, 'matured');
|
||||
assert.equal(normalized.stale, false);
|
||||
assert.equal(normalized.cve_id, 'CVE-2026-9999');
|
||||
assert.equal(normalized.nvd_url, 'https://nvd.nist.gov/vuln/detail/CVE-2026-9999');
|
||||
});
|
||||
|
||||
test('buildGhsaWithoutCveFeed only imports CVE-backed advisories that were already tracked', () => {
|
||||
const existing = {
|
||||
version: '0.1.0',
|
||||
advisories: [
|
||||
normalizeGhsaAdvisory(advisory({ ghsa_id: 'GHSA-old-1111-2222' }), {
|
||||
now: '2026-04-25T00:00:00Z',
|
||||
repository: 'openclaw/openclaw',
|
||||
staleAfterDays: 60,
|
||||
}),
|
||||
],
|
||||
};
|
||||
const fetched = [
|
||||
{
|
||||
repository: 'openclaw/openclaw',
|
||||
advisories: [
|
||||
advisory({ ghsa_id: 'GHSA-new-1111-2222', cve_id: null }),
|
||||
advisory({ ghsa_id: 'GHSA-old-1111-2222', cve_id: 'CVE-2026-1111' }),
|
||||
advisory({ ghsa_id: 'GHSA-cve-only-1111-2222', cve_id: 'CVE-2026-2222' }),
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const feed = buildGhsaWithoutCveFeed({
|
||||
fetched,
|
||||
existingFeed: existing,
|
||||
nvdFeed: { advisories: [] },
|
||||
now: fixedNow,
|
||||
staleAfterDays: 60,
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
feed.advisories.map((entry) => [entry.id, entry.status, entry.cve_id]),
|
||||
[
|
||||
['GHSA-new-1111-2222', 'active', null],
|
||||
['GHSA-old-1111-2222', 'matured', 'CVE-2026-1111'],
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
test('buildGhsaWithoutCveFeed matures tracked GHSAs when the CVE feed references them', () => {
|
||||
const existing = {
|
||||
version: '0.1.0',
|
||||
advisories: [
|
||||
normalizeGhsaAdvisory(advisory({ ghsa_id: 'GHSA-oooo-3333-4444' }), {
|
||||
now: '2026-04-25T00:00:00Z',
|
||||
repository: 'openclaw/openclaw',
|
||||
staleAfterDays: 60,
|
||||
}),
|
||||
],
|
||||
};
|
||||
const feed = buildGhsaWithoutCveFeed({
|
||||
fetched: [
|
||||
{
|
||||
repository: 'openclaw/openclaw',
|
||||
advisories: [advisory({ ghsa_id: 'GHSA-oooo-3333-4444', cve_id: null })],
|
||||
},
|
||||
],
|
||||
existingFeed: existing,
|
||||
nvdFeed: {
|
||||
advisories: [
|
||||
{
|
||||
id: 'CVE-2026-3333',
|
||||
references: [
|
||||
'https://github.com/openclaw/openclaw/security/advisories/GHSA-oooo-3333-4444',
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
now: fixedNow,
|
||||
staleAfterDays: 60,
|
||||
});
|
||||
|
||||
assert.equal(feed.advisories[0].status, 'matured');
|
||||
assert.equal(feed.advisories[0].cve_id, 'CVE-2026-3333');
|
||||
});
|
||||
|
||||
test('buildConsolidatedAdvisoryFeed appends active GHSA advisories without moving the NVD poll cursor', () => {
|
||||
const canonicalFeed = {
|
||||
version: '1.0.0',
|
||||
updated: '2026-05-23T00:00:00Z',
|
||||
description: 'Community-driven security advisory feed for ClawSec',
|
||||
advisories: [
|
||||
{
|
||||
id: 'CVE-2026-1111',
|
||||
severity: 'high',
|
||||
type: 'os_command_injection',
|
||||
title: 'Existing CVE',
|
||||
description: 'Existing CVE advisory',
|
||||
affected: ['openclaw@*'],
|
||||
platforms: ['openclaw'],
|
||||
action: 'Review NVD.',
|
||||
published: '2026-05-01T00:00:00Z',
|
||||
},
|
||||
],
|
||||
};
|
||||
const ghsaFeed = {
|
||||
advisories: [
|
||||
normalizeGhsaAdvisory(advisory({ ghsa_id: 'GHSA-active-1111-2222', cve_id: null }), {
|
||||
now: fixedNow,
|
||||
repository: 'openclaw/openclaw',
|
||||
staleAfterDays: 60,
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
const consolidated = buildConsolidatedAdvisoryFeed({
|
||||
canonicalFeed,
|
||||
ghsaFeed,
|
||||
now: fixedNow,
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
consolidated.advisories.map((entry) => entry.id),
|
||||
['CVE-2026-1111', 'GHSA-active-1111-2222'],
|
||||
);
|
||||
assert.equal(consolidated.updated, canonicalFeed.updated);
|
||||
assert.equal(consolidated.advisories[1].source_feed, 'ghsa-without-cve');
|
||||
});
|
||||
|
||||
test('buildConsolidatedAdvisoryFeed keeps existing GHSA advisories when replacement feed is empty', () => {
|
||||
const canonicalFeed = {
|
||||
version: '1.0.0',
|
||||
updated: '2026-05-23T00:00:00Z',
|
||||
advisories: [
|
||||
{
|
||||
id: 'CVE-2026-1111',
|
||||
published: '2026-05-01T00:00:00Z',
|
||||
},
|
||||
{
|
||||
id: 'GHSA-keep-1111-2222',
|
||||
ghsa_id: 'GHSA-keep-1111-2222',
|
||||
status: 'active',
|
||||
published: '2026-05-02T00:00:00Z',
|
||||
source_feed: 'ghsa-without-cve',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const consolidated = buildConsolidatedAdvisoryFeed({
|
||||
canonicalFeed,
|
||||
ghsaFeed: { advisories: [] },
|
||||
now: fixedNow,
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
consolidated.advisories.map((entry) => entry.id),
|
||||
['GHSA-keep-1111-2222', 'CVE-2026-1111'],
|
||||
);
|
||||
});
|
||||
|
||||
test('buildConsolidatedAdvisoryFeed replaces only matching GHSA canonical entries', () => {
|
||||
const canonicalFeed = {
|
||||
version: '1.0.0',
|
||||
updated: '2026-05-23T00:00:00Z',
|
||||
advisories: [
|
||||
{
|
||||
id: 'GHSA-repl-1111-2222',
|
||||
ghsa_id: 'GHSA-repl-1111-2222',
|
||||
status: 'active',
|
||||
title: 'Old GHSA payload',
|
||||
published: '2026-05-01T00:00:00Z',
|
||||
source_feed: 'ghsa-without-cve',
|
||||
},
|
||||
{
|
||||
id: 'GHSA-keep-3333-4444',
|
||||
ghsa_id: 'GHSA-keep-3333-4444',
|
||||
status: 'active',
|
||||
title: 'Retained GHSA payload',
|
||||
published: '2026-05-02T00:00:00Z',
|
||||
source_feed: 'ghsa-without-cve',
|
||||
},
|
||||
],
|
||||
};
|
||||
const ghsaFeed = {
|
||||
advisories: [
|
||||
{
|
||||
id: 'GHSA-repl-1111-2222',
|
||||
ghsa_id: 'GHSA-repl-1111-2222',
|
||||
status: 'stale',
|
||||
title: 'Replacement GHSA payload',
|
||||
published: '2026-05-03T00:00:00Z',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const consolidated = buildConsolidatedAdvisoryFeed({
|
||||
canonicalFeed,
|
||||
ghsaFeed,
|
||||
now: fixedNow,
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
consolidated.advisories.map((entry) => [entry.id, entry.title, entry.status]),
|
||||
[
|
||||
['GHSA-repl-1111-2222', 'Replacement GHSA payload', 'stale'],
|
||||
['GHSA-keep-3333-4444', 'Retained GHSA payload', 'active'],
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
test('buildConsolidatedAdvisoryFeed drops GHSA duplicate when matching CVE is present', () => {
|
||||
const canonicalFeed = {
|
||||
version: '1.0.0',
|
||||
updated: '2026-05-23T00:00:00Z',
|
||||
advisories: [
|
||||
{
|
||||
id: 'CVE-2026-2222',
|
||||
severity: 'high',
|
||||
type: 'code_injection',
|
||||
title: 'Canonical CVE',
|
||||
description: 'Canonical CVE advisory',
|
||||
affected: ['openclaw@*'],
|
||||
platforms: ['openclaw'],
|
||||
action: 'Review NVD.',
|
||||
published: '2026-05-02T00:00:00Z',
|
||||
},
|
||||
{
|
||||
id: 'GHSA-old-duplicate',
|
||||
ghsa_id: 'GHSA-old-duplicate',
|
||||
cve_id: 'CVE-2026-2222',
|
||||
status: 'matured',
|
||||
source_feed: 'ghsa-without-cve',
|
||||
severity: 'high',
|
||||
type: 'github_security_advisory',
|
||||
title: 'Old duplicate',
|
||||
description: 'Old provisional duplicate',
|
||||
affected: ['openclaw@*'],
|
||||
platforms: ['openclaw'],
|
||||
action: 'Track CVE.',
|
||||
published: '2026-05-01T00:00:00Z',
|
||||
},
|
||||
],
|
||||
};
|
||||
const ghsaFeed = {
|
||||
advisories: [
|
||||
normalizeGhsaAdvisory(
|
||||
advisory({ ghsa_id: 'GHSA-new-duplicate', cve_id: 'CVE-2026-2222' }),
|
||||
{
|
||||
now: fixedNow,
|
||||
repository: 'openclaw/openclaw',
|
||||
staleAfterDays: 60,
|
||||
},
|
||||
),
|
||||
],
|
||||
};
|
||||
|
||||
const consolidated = buildConsolidatedAdvisoryFeed({
|
||||
canonicalFeed,
|
||||
ghsaFeed,
|
||||
now: fixedNow,
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
consolidated.advisories.map((entry) => entry.id),
|
||||
['CVE-2026-2222'],
|
||||
);
|
||||
});
|
||||
|
||||
test('buildConsolidatedAdvisoryFeed keeps matured GHSA until CVE lands in canonical feed', () => {
|
||||
const canonicalFeed = {
|
||||
version: '1.0.0',
|
||||
updated: '2026-05-23T00:00:00Z',
|
||||
advisories: [],
|
||||
};
|
||||
const ghsaFeed = {
|
||||
advisories: [
|
||||
normalizeGhsaAdvisory(
|
||||
advisory({ ghsa_id: 'GHSA-matured-1111-2222', cve_id: 'CVE-2026-4444' }),
|
||||
{
|
||||
now: fixedNow,
|
||||
repository: 'openclaw/openclaw',
|
||||
staleAfterDays: 60,
|
||||
},
|
||||
),
|
||||
],
|
||||
};
|
||||
|
||||
const consolidated = buildConsolidatedAdvisoryFeed({
|
||||
canonicalFeed,
|
||||
ghsaFeed,
|
||||
now: fixedNow,
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
consolidated.advisories.map((entry) => [entry.id, entry.status, entry.cve_id]),
|
||||
[['GHSA-matured-1111-2222', 'matured', 'CVE-2026-4444']],
|
||||
);
|
||||
});
|
||||
@@ -1,241 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdtemp, readdir, readFile } from 'node:fs/promises';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
|
||||
import {
|
||||
buildTrafficSummary,
|
||||
fetchGitHubTraffic,
|
||||
mergeTrafficArchive,
|
||||
writeJson,
|
||||
} from './archive-github-traffic.mjs';
|
||||
|
||||
const TEST_REPOSITORY = 'prompt-security/clawsec';
|
||||
const TEST_CAPTURE_DATE = Date.UTC(2026, 5, 3);
|
||||
|
||||
const utcDay = (offsetFromCaptureDate = 0) => {
|
||||
const date = new Date(TEST_CAPTURE_DATE);
|
||||
date.setUTCDate(date.getUTCDate() + offsetFromCaptureDate);
|
||||
return `${date.toISOString().slice(0, 10)}T00:00:00Z`;
|
||||
};
|
||||
|
||||
const captureAt = ({
|
||||
offsetFromCaptureDate = 0,
|
||||
hour = 3,
|
||||
minute = 17,
|
||||
} = {}) => {
|
||||
const date = new Date(TEST_CAPTURE_DATE);
|
||||
date.setUTCDate(date.getUTCDate() + offsetFromCaptureDate);
|
||||
date.setUTCHours(hour, minute, 0, 0);
|
||||
return date.toISOString();
|
||||
};
|
||||
|
||||
const capturedAt = captureAt();
|
||||
|
||||
test('fetchGitHubTraffic requests the daily GitHub traffic endpoints with auth', async () => {
|
||||
const calls = [];
|
||||
const responses = {
|
||||
[`/repos/${TEST_REPOSITORY}/traffic/views?per=day`]: {
|
||||
count: 30,
|
||||
uniques: 18,
|
||||
views: [{ timestamp: utcDay(-1), count: 30, uniques: 18 }],
|
||||
},
|
||||
[`/repos/${TEST_REPOSITORY}/traffic/clones?per=day`]: {
|
||||
count: 7,
|
||||
uniques: 5,
|
||||
clones: [{ timestamp: utcDay(-1), count: 7, uniques: 5 }],
|
||||
},
|
||||
[`/repos/${TEST_REPOSITORY}/traffic/popular/referrers`]: [
|
||||
{ referrer: 'github.com', count: 12, uniques: 9 },
|
||||
],
|
||||
[`/repos/${TEST_REPOSITORY}/traffic/popular/paths`]: [
|
||||
{ path: `/${TEST_REPOSITORY}`, title: TEST_REPOSITORY, count: 16, uniques: 10 },
|
||||
],
|
||||
};
|
||||
|
||||
const fetchImpl = async (url, options) => {
|
||||
calls.push({ url: String(url), headers: options.headers });
|
||||
const pathname = new URL(url).pathname;
|
||||
const search = new URL(url).search;
|
||||
const payload = responses[`${pathname}${search}`];
|
||||
assert.ok(payload, `unexpected traffic endpoint: ${pathname}${search}`);
|
||||
return new globalThis.Response(JSON.stringify(payload), { status: 200 });
|
||||
};
|
||||
|
||||
const snapshot = await fetchGitHubTraffic({
|
||||
repo: TEST_REPOSITORY,
|
||||
token: 'test-token',
|
||||
capturedAt,
|
||||
fetchImpl,
|
||||
});
|
||||
|
||||
assert.equal(calls.length, 4);
|
||||
assert.ok(calls.every((call) => call.headers.Authorization === 'Bearer test-token'));
|
||||
assert.deepEqual(snapshot.views.views, responses[`/repos/${TEST_REPOSITORY}/traffic/views?per=day`].views);
|
||||
assert.deepEqual(snapshot.clones.clones, responses[`/repos/${TEST_REPOSITORY}/traffic/clones?per=day`].clones);
|
||||
});
|
||||
|
||||
test('mergeTrafficArchive upserts daily views and clones without double-counting overlapping windows', () => {
|
||||
const archive = mergeTrafficArchive(
|
||||
{
|
||||
version: 1,
|
||||
repository: TEST_REPOSITORY,
|
||||
updated_at: captureAt({ offsetFromCaptureDate: -1 }),
|
||||
daily: {
|
||||
views: [
|
||||
{ timestamp: utcDay(-2), count: 10, uniques: 6 },
|
||||
{ timestamp: utcDay(-1), count: 20, uniques: 12 },
|
||||
],
|
||||
clones: [
|
||||
{ timestamp: utcDay(-2), count: 2, uniques: 1 },
|
||||
],
|
||||
},
|
||||
snapshots: {
|
||||
referrers: [],
|
||||
paths: [],
|
||||
},
|
||||
captures: [],
|
||||
},
|
||||
{
|
||||
repository: TEST_REPOSITORY,
|
||||
captured_at: capturedAt,
|
||||
views: {
|
||||
views: [
|
||||
{ timestamp: utcDay(-1), count: 25, uniques: 14 },
|
||||
{ timestamp: utcDay(), count: 35, uniques: 21 },
|
||||
],
|
||||
},
|
||||
clones: {
|
||||
clones: [
|
||||
{ timestamp: utcDay(-1), count: 3, uniques: 2 },
|
||||
{ timestamp: utcDay(), count: 5, uniques: 4 },
|
||||
],
|
||||
},
|
||||
referrers: [{ referrer: 'github.com', count: 12, uniques: 9 }],
|
||||
paths: [{ path: `/${TEST_REPOSITORY}`, title: TEST_REPOSITORY, count: 16, uniques: 10 }],
|
||||
},
|
||||
);
|
||||
|
||||
assert.deepEqual(archive.daily.views, [
|
||||
{ timestamp: utcDay(-2), count: 10, uniques: 6 },
|
||||
{ timestamp: utcDay(-1), count: 25, uniques: 14 },
|
||||
{ timestamp: utcDay(), count: 35, uniques: 21 },
|
||||
]);
|
||||
assert.deepEqual(archive.daily.clones, [
|
||||
{ timestamp: utcDay(-2), count: 2, uniques: 1 },
|
||||
{ timestamp: utcDay(-1), count: 3, uniques: 2 },
|
||||
{ timestamp: utcDay(), count: 5, uniques: 4 },
|
||||
]);
|
||||
});
|
||||
|
||||
test('mergeTrafficArchive keeps one referrer/path snapshot per capture date', () => {
|
||||
const first = mergeTrafficArchive(undefined, {
|
||||
repository: TEST_REPOSITORY,
|
||||
captured_at: capturedAt,
|
||||
views: { views: [] },
|
||||
clones: { clones: [] },
|
||||
referrers: [{ referrer: 'github.com', count: 12, uniques: 9 }],
|
||||
paths: [{ path: `/${TEST_REPOSITORY}`, title: TEST_REPOSITORY, count: 16, uniques: 10 }],
|
||||
});
|
||||
|
||||
const second = mergeTrafficArchive(first, {
|
||||
repository: TEST_REPOSITORY,
|
||||
captured_at: captureAt({ hour: 4, minute: 0 }),
|
||||
views: { views: [] },
|
||||
clones: { clones: [] },
|
||||
referrers: [{ referrer: 'google.com', count: 8, uniques: 6 }],
|
||||
paths: [{ path: `/${TEST_REPOSITORY}/wiki`, title: 'Wiki', count: 11, uniques: 7 }],
|
||||
});
|
||||
|
||||
assert.equal(second.snapshots.referrers.length, 1);
|
||||
assert.equal(second.snapshots.paths.length, 1);
|
||||
assert.deepEqual(second.snapshots.referrers[0].entries, [
|
||||
{ referrer: 'google.com', count: 8, uniques: 6 },
|
||||
]);
|
||||
assert.deepEqual(second.snapshots.paths[0].entries, [
|
||||
{ path: `/${TEST_REPOSITORY}/wiki`, title: 'Wiki', count: 11, uniques: 7 },
|
||||
]);
|
||||
});
|
||||
|
||||
test('mergeTrafficArchive rejects blank referrer and path fields instead of archiving empty strings', () => {
|
||||
assert.throws(
|
||||
() => mergeTrafficArchive(undefined, {
|
||||
repository: TEST_REPOSITORY,
|
||||
captured_at: capturedAt,
|
||||
views: { views: [] },
|
||||
clones: { clones: [] },
|
||||
referrers: [{ count: 12, uniques: 9 }],
|
||||
paths: [],
|
||||
}),
|
||||
/referrers\.referrer must be a non-empty string/,
|
||||
);
|
||||
|
||||
assert.throws(
|
||||
() => mergeTrafficArchive(undefined, {
|
||||
repository: TEST_REPOSITORY,
|
||||
captured_at: capturedAt,
|
||||
views: { views: [] },
|
||||
clones: { clones: [] },
|
||||
referrers: [],
|
||||
paths: [{ path: `/${TEST_REPOSITORY}`, title: ' ', count: 16, uniques: 10 }],
|
||||
}),
|
||||
/paths\.title must be a non-empty string/,
|
||||
);
|
||||
});
|
||||
|
||||
test('writeJson replaces JSON through a same-directory temporary file', async () => {
|
||||
const dir = await mkdtemp(path.join(os.tmpdir(), 'clawsec-traffic-json-'));
|
||||
const file = path.join(dir, 'summary.json');
|
||||
|
||||
await writeJson(file, { version: 1, count: 1 });
|
||||
await writeJson(file, { version: 1, count: 2 });
|
||||
|
||||
assert.equal(await readFile(file, 'utf8'), '{\n "version": 1,\n "count": 2\n}\n');
|
||||
assert.deepEqual(await readdir(dir), ['summary.json']);
|
||||
});
|
||||
|
||||
test('buildTrafficSummary reports count totals and labels summed daily uniques accurately', () => {
|
||||
const archive = mergeTrafficArchive(undefined, {
|
||||
repository: TEST_REPOSITORY,
|
||||
captured_at: capturedAt,
|
||||
views: {
|
||||
views: [
|
||||
{ timestamp: utcDay(-33), count: 100, uniques: 80 },
|
||||
{ timestamp: utcDay(-1), count: 30, uniques: 18 },
|
||||
{ timestamp: utcDay(), count: 40, uniques: 22 },
|
||||
],
|
||||
},
|
||||
clones: {
|
||||
clones: [
|
||||
{ timestamp: utcDay(-1), count: 7, uniques: 5 },
|
||||
{ timestamp: utcDay(), count: 9, uniques: 6 },
|
||||
],
|
||||
},
|
||||
referrers: [],
|
||||
paths: [],
|
||||
});
|
||||
|
||||
const summary = buildTrafficSummary(archive, { now: captureAt({ hour: 12, minute: 0 }) });
|
||||
|
||||
assert.equal(summary.metrics.views.last_30_days.count, 70);
|
||||
assert.equal(summary.metrics.views.last_30_days.sum_daily_uniques, 40);
|
||||
assert.equal(summary.metrics.views.last_30_days.unique_semantics, 'sum_of_daily_uniques');
|
||||
assert.equal(summary.metrics.views.all_time.count, 170);
|
||||
assert.equal(summary.metrics.clones.last_30_days.count, 16);
|
||||
assert.equal(summary.daily.views.length, 3);
|
||||
});
|
||||
|
||||
test('traffic archive workflow uses a daily schedule and a dedicated archive branch', async () => {
|
||||
const workflowPath = new URL('../.github/workflows/archive-traffic.yml', import.meta.url);
|
||||
const workflow = await readFile(workflowPath, 'utf8');
|
||||
|
||||
assert.match(workflow, /cron:\s+'17 3 \* \* \*'/);
|
||||
assert.match(workflow, /TRAFFIC_ARCHIVE_BRANCH:\s+traffic-archive/);
|
||||
assert.match(workflow, /TRAFFIC_ARCHIVE_TOKEN/);
|
||||
assert.match(workflow, /node scripts\/archive-github-traffic\.mjs/);
|
||||
assert.match(workflow, /git add traffic\/archive\.json traffic\/summary\.json/);
|
||||
assert.match(workflow, /git rm --ignore-unmatch traffic\/README\.md/);
|
||||
assert.doesNotMatch(workflow, /git add .*traffic\/README\.md/);
|
||||
assert.match(workflow, /git push origin HEAD:\$\{TRAFFIC_ARCHIVE_BRANCH\}/);
|
||||
});
|
||||
@@ -1,88 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
const workflowPath = new URL('../.github/workflows/poll-nvd-cves.yml', import.meta.url);
|
||||
const workflow = await readFile(workflowPath, 'utf8');
|
||||
const ciWorkflowPath = new URL('../.github/workflows/ci.yml', import.meta.url);
|
||||
const ciWorkflow = await readFile(ciWorkflowPath, 'utf8');
|
||||
|
||||
function requiredIndex(snippet, message) {
|
||||
const index = workflow.indexOf(snippet);
|
||||
assert.notEqual(index, -1, message);
|
||||
return index;
|
||||
}
|
||||
|
||||
assert.match(
|
||||
workflow,
|
||||
/GHSA_FEED_PATH:\s+advisories\/ghsa-without-cve\.json/,
|
||||
'NVD workflow must write the provisional GHSA source feed',
|
||||
);
|
||||
assert.match(
|
||||
workflow,
|
||||
/GHSA_FEED_SIG_PATH:\s+advisories\/ghsa-without-cve\.json\.sig/,
|
||||
'NVD workflow must sign the provisional GHSA source feed',
|
||||
);
|
||||
assert.match(
|
||||
workflow,
|
||||
/node scripts\/ghsa-without-cve-feed\.mjs[\s\S]*--output "\$GHSA_FEED_PATH"[\s\S]*--consolidated-feed "\$FEED_PATH"[\s\S]*--existing-feed "\$GHSA_FEED_PATH"[\s\S]*--nvd-feed "\$FEED_PATH"/,
|
||||
'NVD workflow must merge GHSA advisories into the signed agent feed',
|
||||
);
|
||||
assert.match(
|
||||
workflow,
|
||||
/id: feed_changes[\s\S]*ghsa_changed=\$GHSA_CHANGED[\s\S]*agent_changed=\$AGENT_CHANGED[\s\S]*changed=true/,
|
||||
'NVD workflow must detect GHSA and consolidated agent feed changes separately',
|
||||
);
|
||||
assert.match(
|
||||
workflow,
|
||||
/if: steps\.feed_changes\.outputs\.ghsa_changed == 'true'[\s\S]*input_file: \$\{\{ env\.GHSA_FEED_PATH \}\}[\s\S]*signature_file: \$\{\{ env\.GHSA_FEED_SIG_PATH \}\}/,
|
||||
'NVD workflow must sign the provisional GHSA feed when it changes',
|
||||
);
|
||||
assert.match(
|
||||
workflow,
|
||||
/if: steps\.feed_changes\.outputs\.agent_changed == 'true'[\s\S]*input_file: \$\{\{ env\.FEED_PATH \}\}[\s\S]*signature_file: \$\{\{ env\.FEED_SIG_PATH \}\}/,
|
||||
'NVD workflow must sign the consolidated agent feed when it changes',
|
||||
);
|
||||
assert.match(
|
||||
workflow,
|
||||
/git add "\$FEED_PATH" "\$FEED_SIG_PATH" "\$GHSA_FEED_PATH" "\$GHSA_FEED_SIG_PATH" "\$SKILL_FEED_PATH" "\$SKILL_FEED_SIG_PATH"/,
|
||||
'NVD workflow PR must include both NVD and GHSA feed artifacts',
|
||||
);
|
||||
assert.match(
|
||||
ciWorkflow,
|
||||
/name: NVD \+ GHSA Pipeline Dry Run[\s\S]*node scripts\/test-nvd-ghsa-pipeline-dry-run\.mjs/,
|
||||
'CI must run the deterministic NVD + GHSA pipeline dry run before merge',
|
||||
);
|
||||
|
||||
const updateFeedIndex = requiredIndex('name: Update feed.json', 'NVD workflow must update the CVE feed first');
|
||||
const pollGhsaIndex = requiredIndex(
|
||||
'name: Poll GHSA without CVE and consolidate feed',
|
||||
'NVD workflow must poll GHSA before signing',
|
||||
);
|
||||
const detectChangesIndex = requiredIndex(
|
||||
'name: Detect advisory feed changes',
|
||||
'NVD workflow must detect combined feed changes before signing',
|
||||
);
|
||||
const signGhsaIndex = requiredIndex(
|
||||
'name: Sign GHSA feed and verify',
|
||||
'NVD workflow must sign the GHSA source feed',
|
||||
);
|
||||
const signAgentIndex = requiredIndex(
|
||||
'name: Sign advisory feed and verify',
|
||||
'NVD workflow must sign the consolidated agent feed',
|
||||
);
|
||||
const upsertPrIndex = requiredIndex(
|
||||
'name: Upsert NVD advisory PR',
|
||||
'NVD workflow must upsert a PR for any feed change',
|
||||
);
|
||||
|
||||
assert.ok(
|
||||
updateFeedIndex < pollGhsaIndex,
|
||||
'GHSA consolidation must run after the NVD update step so matured advisories can reconcile against new CVEs',
|
||||
);
|
||||
assert.ok(
|
||||
pollGhsaIndex < detectChangesIndex,
|
||||
'Combined feed change detection must run after GHSA consolidation',
|
||||
);
|
||||
assert.ok(detectChangesIndex < signGhsaIndex, 'GHSA signing must run after change detection');
|
||||
assert.ok(detectChangesIndex < signAgentIndex, 'Agent feed signing must run after change detection');
|
||||
assert.ok(signAgentIndex < upsertPrIndex, 'The PR must be created after feed signing');
|
||||
@@ -1,187 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { generateKeyPairSync, sign, verify } from 'node:crypto';
|
||||
import { mkdtemp, mkdir, readFile, writeFile } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import path from 'node:path';
|
||||
|
||||
import {
|
||||
buildConsolidatedAdvisoryFeed,
|
||||
buildGhsaWithoutCveFeed,
|
||||
normalizeGhsaAdvisory,
|
||||
} from './ghsa-without-cve-feed.mjs';
|
||||
|
||||
const now = '2026-05-24T00:00:00Z';
|
||||
|
||||
function cveAdvisory(overrides = {}) {
|
||||
return {
|
||||
id: 'CVE-2026-1111',
|
||||
severity: 'high',
|
||||
type: 'code_injection',
|
||||
title: 'OpenClaw command execution advisory',
|
||||
description: 'OpenClaw allowed unsafe tool execution in a guarded workspace.',
|
||||
affected: ['openclaw@<2026.5.20'],
|
||||
patched: ['openclaw@2026.5.20'],
|
||||
platforms: ['openclaw'],
|
||||
action: 'Update OpenClaw and verify guarded workspace execution.',
|
||||
published: '2026-05-01T00:00:00Z',
|
||||
updated: '2026-05-01T00:00:00Z',
|
||||
references: ['https://nvd.nist.gov/vuln/detail/CVE-2026-1111'],
|
||||
nvd_url: 'https://nvd.nist.gov/vuln/detail/CVE-2026-1111',
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function ghsaAdvisory(overrides = {}) {
|
||||
return {
|
||||
ghsa_id: 'GHSA-actv-1111-2222',
|
||||
cve_id: null,
|
||||
html_url: 'https://github.com/openclaw/openclaw/security/advisories/GHSA-actv-1111-2222',
|
||||
summary: 'OpenClaw advisory without CVE',
|
||||
description: 'OpenClaw published a public GitHub advisory before CVE assignment.',
|
||||
severity: 'high',
|
||||
published_at: '2026-05-20T00:00:00Z',
|
||||
updated_at: '2026-05-21T00:00:00Z',
|
||||
vulnerabilities: [
|
||||
{
|
||||
package: { ecosystem: 'npm', name: 'openclaw' },
|
||||
vulnerable_version_range: '<2026.5.21',
|
||||
patched_versions: '2026.5.21',
|
||||
},
|
||||
],
|
||||
cvss: {
|
||||
vector_string: 'CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H',
|
||||
score: 7.8,
|
||||
},
|
||||
cwe_ids: ['CWE-94'],
|
||||
credits: [{ login: 'security-researcher', type: 'reporter' }],
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function signBuffer(data, privateKey) {
|
||||
return sign(null, data, privateKey).toString('base64');
|
||||
}
|
||||
|
||||
function verifySignature(data, signature, publicKey) {
|
||||
return verify(null, data, publicKey, Buffer.from(signature, 'base64'));
|
||||
}
|
||||
|
||||
async function writeJson(filePath, value) {
|
||||
await mkdir(path.dirname(filePath), { recursive: true });
|
||||
await writeFile(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
||||
}
|
||||
|
||||
const tempDir = await mkdtemp(path.join(tmpdir(), 'clawsec-nvd-ghsa-ci-dry-run-'));
|
||||
const canonicalFeedPath = path.join(tempDir, 'advisories/feed.json');
|
||||
const ghsaFeedPath = path.join(tempDir, 'advisories/ghsa-without-cve.json');
|
||||
const skillFeedPath = path.join(tempDir, 'skills/clawsec-feed/advisories/feed.json');
|
||||
|
||||
const existingCanonicalFeed = {
|
||||
version: '1.0.0',
|
||||
updated: '2026-05-23T00:00:00Z',
|
||||
description: 'Community-driven security advisory feed for ClawSec',
|
||||
advisories: [
|
||||
cveAdvisory({
|
||||
id: 'CVE-2026-1111',
|
||||
references: [
|
||||
'https://nvd.nist.gov/vuln/detail/CVE-2026-1111',
|
||||
'https://github.com/openclaw/openclaw/security/advisories/GHSA-matd-1111-2222',
|
||||
],
|
||||
}),
|
||||
],
|
||||
};
|
||||
const nvdPollResultFeed = {
|
||||
...existingCanonicalFeed,
|
||||
updated: now,
|
||||
advisories: [
|
||||
cveAdvisory({
|
||||
id: 'CVE-2026-2222',
|
||||
title: 'Fresh NVD advisory from the poll window',
|
||||
published: '2026-05-24T00:00:00Z',
|
||||
updated: '2026-05-24T00:00:00Z',
|
||||
references: [
|
||||
'https://nvd.nist.gov/vuln/detail/CVE-2026-2222',
|
||||
'https://github.com/openclaw/openclaw/security/advisories/GHSA-cvea-1111-2222',
|
||||
],
|
||||
nvd_url: 'https://nvd.nist.gov/vuln/detail/CVE-2026-2222',
|
||||
}),
|
||||
...existingCanonicalFeed.advisories,
|
||||
],
|
||||
};
|
||||
const existingGhsaFeed = {
|
||||
version: '0.1.0',
|
||||
updated: '2026-05-20T00:00:00Z',
|
||||
advisories: [
|
||||
normalizeGhsaAdvisory(ghsaAdvisory({ ghsa_id: 'GHSA-matd-1111-2222' }), {
|
||||
now: '2026-05-20T00:00:00Z',
|
||||
repository: 'openclaw/openclaw',
|
||||
staleAfterDays: 60,
|
||||
}),
|
||||
],
|
||||
};
|
||||
const fetchedGhsaAdvisories = [
|
||||
{
|
||||
repository: 'openclaw/openclaw',
|
||||
advisories: [
|
||||
ghsaAdvisory({ ghsa_id: 'GHSA-actv-1111-2222' }),
|
||||
ghsaAdvisory({ ghsa_id: 'GHSA-matd-1111-2222' }),
|
||||
ghsaAdvisory({ ghsa_id: 'GHSA-cvea-1111-2222', cve_id: 'CVE-2026-2222' }),
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const ghsaFeed = buildGhsaWithoutCveFeed({
|
||||
fetched: fetchedGhsaAdvisories,
|
||||
existingFeed: existingGhsaFeed,
|
||||
nvdFeed: nvdPollResultFeed,
|
||||
now,
|
||||
staleAfterDays: 60,
|
||||
});
|
||||
assert.deepEqual(
|
||||
ghsaFeed.advisories.map((entry) => [entry.id, entry.status, entry.cve_id]),
|
||||
[
|
||||
['GHSA-actv-1111-2222', 'active', null],
|
||||
['GHSA-matd-1111-2222', 'matured', 'CVE-2026-1111'],
|
||||
],
|
||||
'GHSA dry run should retain active GHSA-only advisories and mature tracked GHSAs',
|
||||
);
|
||||
|
||||
const consolidatedFeed = buildConsolidatedAdvisoryFeed({
|
||||
canonicalFeed: nvdPollResultFeed,
|
||||
ghsaFeed,
|
||||
now,
|
||||
});
|
||||
assert.deepEqual(
|
||||
consolidatedFeed.advisories.map((entry) => entry.id),
|
||||
['CVE-2026-2222', 'GHSA-actv-1111-2222', 'CVE-2026-1111'],
|
||||
'Consolidated feed should include NVD CVEs plus active GHSA-only advisories without duplicate matured GHSAs',
|
||||
);
|
||||
assert.equal(consolidatedFeed.advisories[1].source_feed, 'ghsa-without-cve');
|
||||
assert.equal(consolidatedFeed.updated, nvdPollResultFeed.updated);
|
||||
|
||||
await writeJson(canonicalFeedPath, consolidatedFeed);
|
||||
await writeJson(ghsaFeedPath, ghsaFeed);
|
||||
await writeJson(skillFeedPath, consolidatedFeed);
|
||||
|
||||
const { privateKey, publicKey } = generateKeyPairSync('ed25519');
|
||||
const canonicalFeedBytes = await readFile(canonicalFeedPath);
|
||||
const ghsaFeedBytes = await readFile(ghsaFeedPath);
|
||||
const skillFeedBytes = await readFile(skillFeedPath);
|
||||
const canonicalSignature = signBuffer(canonicalFeedBytes, privateKey);
|
||||
const ghsaSignature = signBuffer(ghsaFeedBytes, privateKey);
|
||||
|
||||
await writeFile(`${canonicalFeedPath}.sig`, `${canonicalSignature}\n`);
|
||||
await writeFile(`${ghsaFeedPath}.sig`, `${ghsaSignature}\n`);
|
||||
await writeFile(`${skillFeedPath}.sig`, `${canonicalSignature}\n`);
|
||||
|
||||
assert.deepEqual(skillFeedBytes, canonicalFeedBytes, 'skill advisory feed must match the signed agent feed');
|
||||
assert.ok(
|
||||
verifySignature(canonicalFeedBytes, canonicalSignature, publicKey),
|
||||
'canonical consolidated feed signature must verify',
|
||||
);
|
||||
assert.ok(verifySignature(skillFeedBytes, canonicalSignature, publicKey), 'skill feed signature must verify');
|
||||
assert.ok(verifySignature(ghsaFeedBytes, ghsaSignature, publicKey), 'GHSA source feed signature must verify');
|
||||
|
||||
console.log(
|
||||
`NVD + GHSA dry run passed: ${consolidatedFeed.advisories.length} consolidated advisories, ${ghsaFeed.advisories.length} GHSA source advisories, signatures verified.`,
|
||||
);
|
||||
@@ -1,29 +0,0 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
const workflowPath = new URL('../.github/workflows/skill-release.yml', import.meta.url);
|
||||
const workflow = await readFile(workflowPath, 'utf8');
|
||||
|
||||
assert.match(
|
||||
workflow,
|
||||
/pull_request:[\s\S]*paths:[\s\S]*- 'skills\/\*\*'/,
|
||||
'Skill release workflow must run when any skill package file changes',
|
||||
);
|
||||
|
||||
assert.match(
|
||||
workflow,
|
||||
/git diff --name-only "\$\{BASE_SHA\}\.\.\.\$\{HEAD_SHA\}" --[\s\S]*'skills\/\*\/\*\*'[\s\S]*':\(exclude\)skills\/\*\/test\/\*\*'[\s\S]*':\(exclude\)skills\/\*\/tests\/\*\*'/,
|
||||
'Skill release validation must ignore test-only skill changes while inspecting release-relevant skill files',
|
||||
);
|
||||
|
||||
assert.doesNotMatch(
|
||||
workflow,
|
||||
/No version bump detected for \$\{skill_dir\}; skipping\./,
|
||||
'Changed skill directories without a version bump must fail validation instead of being skipped',
|
||||
);
|
||||
|
||||
assert.match(
|
||||
workflow,
|
||||
/::error file=\$\{skill_dir\}::Changed skill package has no version bump\./,
|
||||
'Skill release validation must emit an explicit missing-version-bump error',
|
||||
);
|
||||
@@ -1,10 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [0.0.3] - 2026-05-14
|
||||
|
||||
### Security
|
||||
- Added explicit signed release artifact verification instructions for standalone installs, including `checksums.json`, `checksums.sig`, `signing-public.pem`, archive hash verification, and `SKILL.md`/`skill.json` checksum checks.
|
||||
|
||||
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/),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: claw-release
|
||||
version: 0.0.3
|
||||
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}}
|
||||
@@ -26,86 +26,6 @@ Internal tool for releasing skills and managing the ClawSec catalog.
|
||||
- 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
|
||||
|
||||
|
||||
## Release Artifact Verification
|
||||
|
||||
For standalone installs, verify the signed release manifest before trusting `SKILL.md`, `skill.json`, or the archive. The `skill.json` file is the package metadata/SBOM source, and the release pipeline signs `checksums.json` with the ClawSec release key.
|
||||
|
||||
```bash
|
||||
set -euo pipefail
|
||||
|
||||
SKILL_NAME="claw-release"
|
||||
VERSION="0.0.3"
|
||||
REPO="prompt-security/clawsec"
|
||||
TAG="${SKILL_NAME}-v${VERSION}"
|
||||
BASE="https://github.com/${REPO}/releases/download/${TAG}"
|
||||
ZIP_NAME="${SKILL_NAME}-v${VERSION}.zip"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
RELEASE_PUBKEY_SHA256="711424e4535f84093fefb024cd1ca4ec87439e53907b305b79a631d5befba9c8"
|
||||
|
||||
curl -fsSL "$BASE/checksums.json" -o "$TMP_DIR/checksums.json"
|
||||
curl -fsSL "$BASE/checksums.sig" -o "$TMP_DIR/checksums.sig"
|
||||
curl -fsSL "$BASE/signing-public.pem" -o "$TMP_DIR/signing-public.pem"
|
||||
curl -fsSL "$BASE/$ZIP_NAME" -o "$TMP_DIR/$ZIP_NAME"
|
||||
curl -fsSL "$BASE/SKILL.md" -o "$TMP_DIR/SKILL.md"
|
||||
curl -fsSL "$BASE/skill.json" -o "$TMP_DIR/skill.json"
|
||||
|
||||
ACTUAL_PUBKEY_SHA256="$(openssl pkey -pubin -in "$TMP_DIR/signing-public.pem" -outform DER | shasum -a 256 | awk '{print $1}')"
|
||||
if [ "$ACTUAL_PUBKEY_SHA256" != "$RELEASE_PUBKEY_SHA256" ]; then
|
||||
echo "ERROR: signing-public.pem fingerprint mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openssl base64 -d -A -in "$TMP_DIR/checksums.sig" -out "$TMP_DIR/checksums.sig.bin"
|
||||
openssl pkeyutl -verify -rawin -pubin \
|
||||
-inkey "$TMP_DIR/signing-public.pem" \
|
||||
-sigfile "$TMP_DIR/checksums.sig.bin" \
|
||||
-in "$TMP_DIR/checksums.json" >/dev/null
|
||||
|
||||
hash_file() {
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$1" | awk '{print $1}'
|
||||
else
|
||||
sha256sum "$1" | awk '{print $1}'
|
||||
fi
|
||||
}
|
||||
|
||||
verify_manifest_file() {
|
||||
asset="$1"
|
||||
path="$2"
|
||||
expected="$(jq -r --arg asset "$asset" '.files[$asset].sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected" ]; then
|
||||
echo "ERROR: checksums.json missing $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual="$(hash_file "$path")"
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "ERROR: checksum mismatch for $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
expected_archive="$(jq -r '.archive.sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected_archive" ]; then
|
||||
echo "ERROR: checksums.json missing archive.sha256" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual_archive="$(hash_file "$TMP_DIR/$ZIP_NAME")"
|
||||
if [ "$actual_archive" != "$expected_archive" ]; then
|
||||
echo "ERROR: archive checksum mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
verify_manifest_file "SKILL.md" "$TMP_DIR/SKILL.md"
|
||||
verify_manifest_file "skill.json" "$TMP_DIR/skill.json"
|
||||
|
||||
echo "Signed release manifest, archive, SKILL.md, and skill.json verified."
|
||||
```
|
||||
|
||||
Only install or extract the archive after this verification succeeds.
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| Release Type | Command | Tag Format |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "claw-release",
|
||||
"version": "0.0.3",
|
||||
"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",
|
||||
|
||||
@@ -1,18 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [0.0.5] - 2026-06-07
|
||||
|
||||
### Security
|
||||
- Treat explicit malicious ClawHub and VirusTotal verdicts as blocking signals regardless of the numeric reputation score.
|
||||
|
||||
## [0.0.4] - 2026-05-13
|
||||
|
||||
### Security
|
||||
- Added explicit signed release artifact verification instructions for standalone installs, including `checksums.json`, `checksums.sig`, `signing-public.pem`, archive hash verification, and `SKILL.md`/`skill.json` checksum checks.
|
||||
|
||||
### Changed
|
||||
- Re-release skill payload metadata after excluding test-only files from release SBOMs and archives.
|
||||
|
||||
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/),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: clawsec-clawhub-checker
|
||||
version: 0.0.5
|
||||
version: 0.0.3
|
||||
description: ClawHub reputation checker for clawsec-suite. Adds a standalone reputation gate before guarded skill installation.
|
||||
homepage: https://clawsec.prompt.security
|
||||
clawdis:
|
||||
@@ -45,86 +45,6 @@ Optional preflight check (validates local paths and prints recommended command):
|
||||
node ~/.openclaw/skills/clawsec-clawhub-checker/scripts/setup_reputation_hook.mjs
|
||||
```
|
||||
|
||||
|
||||
## Release Artifact Verification
|
||||
|
||||
For standalone installs, verify the signed release manifest before trusting `SKILL.md`, `skill.json`, or the archive. The `skill.json` file is the package metadata/SBOM source, and the release pipeline signs `checksums.json` with the ClawSec release key.
|
||||
|
||||
```bash
|
||||
set -euo pipefail
|
||||
|
||||
SKILL_NAME="clawsec-clawhub-checker"
|
||||
VERSION="0.0.4"
|
||||
REPO="prompt-security/clawsec"
|
||||
TAG="${SKILL_NAME}-v${VERSION}"
|
||||
BASE="https://github.com/${REPO}/releases/download/${TAG}"
|
||||
ZIP_NAME="${SKILL_NAME}-v${VERSION}.zip"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
RELEASE_PUBKEY_SHA256="711424e4535f84093fefb024cd1ca4ec87439e53907b305b79a631d5befba9c8"
|
||||
|
||||
curl -fsSL "$BASE/checksums.json" -o "$TMP_DIR/checksums.json"
|
||||
curl -fsSL "$BASE/checksums.sig" -o "$TMP_DIR/checksums.sig"
|
||||
curl -fsSL "$BASE/signing-public.pem" -o "$TMP_DIR/signing-public.pem"
|
||||
curl -fsSL "$BASE/$ZIP_NAME" -o "$TMP_DIR/$ZIP_NAME"
|
||||
curl -fsSL "$BASE/SKILL.md" -o "$TMP_DIR/SKILL.md"
|
||||
curl -fsSL "$BASE/skill.json" -o "$TMP_DIR/skill.json"
|
||||
|
||||
ACTUAL_PUBKEY_SHA256="$(openssl pkey -pubin -in "$TMP_DIR/signing-public.pem" -outform DER | shasum -a 256 | awk '{print $1}')"
|
||||
if [ "$ACTUAL_PUBKEY_SHA256" != "$RELEASE_PUBKEY_SHA256" ]; then
|
||||
echo "ERROR: signing-public.pem fingerprint mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openssl base64 -d -A -in "$TMP_DIR/checksums.sig" -out "$TMP_DIR/checksums.sig.bin"
|
||||
openssl pkeyutl -verify -rawin -pubin \
|
||||
-inkey "$TMP_DIR/signing-public.pem" \
|
||||
-sigfile "$TMP_DIR/checksums.sig.bin" \
|
||||
-in "$TMP_DIR/checksums.json" >/dev/null
|
||||
|
||||
hash_file() {
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$1" | awk '{print $1}'
|
||||
else
|
||||
sha256sum "$1" | awk '{print $1}'
|
||||
fi
|
||||
}
|
||||
|
||||
verify_manifest_file() {
|
||||
asset="$1"
|
||||
path="$2"
|
||||
expected="$(jq -r --arg asset "$asset" '.files[$asset].sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected" ]; then
|
||||
echo "ERROR: checksums.json missing $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual="$(hash_file "$path")"
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "ERROR: checksum mismatch for $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
expected_archive="$(jq -r '.archive.sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected_archive" ]; then
|
||||
echo "ERROR: checksums.json missing archive.sha256" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual_archive="$(hash_file "$TMP_DIR/$ZIP_NAME")"
|
||||
if [ "$actual_archive" != "$expected_archive" ]; then
|
||||
echo "ERROR: archive checksum mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
verify_manifest_file "SKILL.md" "$TMP_DIR/SKILL.md"
|
||||
verify_manifest_file "skill.json" "$TMP_DIR/skill.json"
|
||||
|
||||
echo "Signed release manifest, archive, SKILL.md, and skill.json verified."
|
||||
```
|
||||
|
||||
Only install or extract the archive after this verification succeeds.
|
||||
|
||||
## Usage
|
||||
|
||||
Run the enhanced installer directly from this skill:
|
||||
|
||||
@@ -35,12 +35,6 @@ function blockOnMissingScannerData(result, warning) {
|
||||
result.blocked = true;
|
||||
}
|
||||
|
||||
function blockOnMaliciousScannerData(result, warning) {
|
||||
result.warnings.push(warning);
|
||||
result.score = 0;
|
||||
result.blocked = true;
|
||||
}
|
||||
|
||||
function parseJson(raw, label, warnings) {
|
||||
try {
|
||||
return JSON.parse(raw);
|
||||
@@ -64,10 +58,7 @@ function maybeApplyVersionSecuritySignals(result, versionDetails) {
|
||||
return;
|
||||
}
|
||||
|
||||
const securityStatus = typeof security.status === "string" ? security.status.toLowerCase() : "";
|
||||
if (securityStatus === "malicious") {
|
||||
blockOnMaliciousScannerData(result, "ClawHub static moderation marked the version as malicious");
|
||||
} else if (securityStatus === "suspicious") {
|
||||
if (typeof security.status === "string" && security.status.toLowerCase() === "suspicious") {
|
||||
result.warnings.push("ClawHub static moderation marked the version as suspicious");
|
||||
result.score -= 30;
|
||||
}
|
||||
@@ -91,15 +82,7 @@ function maybeApplyVersionSecuritySignals(result, versionDetails) {
|
||||
"";
|
||||
const normalizedStatus = vtStatus.toLowerCase();
|
||||
|
||||
if (normalizedStatus === "malicious") {
|
||||
result.virustotal.push("ClawHub VirusTotal scan returned malicious");
|
||||
blockOnMaliciousScannerData(result, "ClawHub VirusTotal scan returned malicious");
|
||||
|
||||
const vtSummary = typeof vt.analysis === "string" ? vt.analysis.trim() : "";
|
||||
if (vtSummary) {
|
||||
result.virustotal.push(vtSummary.split("\n")[0]);
|
||||
}
|
||||
} else if (normalizedStatus === "suspicious") {
|
||||
if (normalizedStatus === "suspicious") {
|
||||
result.virustotal.push("ClawHub VirusTotal scan returned suspicious");
|
||||
result.score -= 40;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clawsec-clawhub-checker",
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.3",
|
||||
"description": "ClawHub reputation checker for clawsec-suite. Adds a standalone reputation gate before guarded skill installation.",
|
||||
"author": "abutbul",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
@@ -52,6 +52,16 @@
|
||||
"path": "CHANGELOG.md",
|
||||
"required": true,
|
||||
"description": "Version history and release notes"
|
||||
},
|
||||
{
|
||||
"path": "test/reputation_check.test.mjs",
|
||||
"required": false,
|
||||
"description": "Test suite for reputation checking functionality"
|
||||
},
|
||||
{
|
||||
"path": "test/setup_reputation_hook.test.mjs",
|
||||
"required": false,
|
||||
"description": "Regression coverage for setup preflight behavior"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
*/
|
||||
|
||||
import { fileURLToPath } from "node:url";
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
@@ -60,37 +58,6 @@ function runScript(scriptPath, args, env) {
|
||||
});
|
||||
}
|
||||
|
||||
async function createMockClawhub(payload) {
|
||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawhub-reputation-test-"));
|
||||
const binDir = path.join(tmpDir, "bin");
|
||||
const mockPath = path.join(binDir, "clawhub");
|
||||
await fs.mkdir(binDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
mockPath,
|
||||
`#!/usr/bin/env node
|
||||
const payload = ${JSON.stringify(JSON.stringify(payload))};
|
||||
const command = process.argv[2] || "";
|
||||
if (command === "inspect") {
|
||||
process.stdout.write(payload);
|
||||
process.exit(0);
|
||||
}
|
||||
if (command === "search") {
|
||||
process.stdout.write("name\\nmock-skill\\nother-skill\\n");
|
||||
process.exit(0);
|
||||
}
|
||||
process.stderr.write("unexpected clawhub command: " + process.argv.slice(2).join(" ") + "\\n");
|
||||
process.exit(2);
|
||||
`,
|
||||
"utf8",
|
||||
);
|
||||
await fs.chmod(mockPath, 0o755);
|
||||
|
||||
return {
|
||||
env: { PATH: `${binDir}:${process.env.PATH}` },
|
||||
cleanup: async () => fs.rm(tmpDir, { recursive: true, force: true }),
|
||||
};
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Test: Invalid skill slug is rejected (command injection prevention)
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -241,59 +208,6 @@ async function testPreReleaseVersionAccepted() {
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Test: Explicit malicious scanner verdict blocks regardless of score
|
||||
// -----------------------------------------------------------------------------
|
||||
async function testMaliciousVirusTotalVerdictBlocks() {
|
||||
const testName = "reputation_check: malicious VirusTotal verdict blocks install";
|
||||
const now = Date.now();
|
||||
const mock = await createMockClawhub({
|
||||
skill: {
|
||||
createdAt: now - (120 * 24 * 60 * 60 * 1000),
|
||||
updatedAt: now - (2 * 24 * 60 * 60 * 1000),
|
||||
stats: { downloads: 1000 },
|
||||
},
|
||||
owner: { handle: "trusted-publisher" },
|
||||
version: {
|
||||
security: {
|
||||
status: "clean",
|
||||
scanners: {
|
||||
vt: {
|
||||
normalizedStatus: "malicious",
|
||||
analysis: "malicious verdict from scanner",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
const result = await runScript(CHECKER_SCRIPT, ['malicious-skill', '1.0.0', '70'], mock.env);
|
||||
let parsed;
|
||||
try {
|
||||
parsed = JSON.parse(result.stdout);
|
||||
} catch {
|
||||
fail(testName, `Could not parse output: ${result.stdout}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
result.code === 43 &&
|
||||
parsed.safe === false &&
|
||||
parsed.warnings.some((w) => w.toLowerCase().includes("malicious")) &&
|
||||
parsed.virustotal.some((v) => v.toLowerCase().includes("malicious"))
|
||||
) {
|
||||
pass(testName);
|
||||
} else {
|
||||
fail(testName, `Expected malicious verdict to block, got code ${result.code}: ${JSON.stringify(parsed)}`);
|
||||
}
|
||||
} catch (error) {
|
||||
fail(testName, error);
|
||||
} finally {
|
||||
await mock.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Test: CLI entrypoint guard works when script path is relative
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -497,7 +411,6 @@ async function runTests() {
|
||||
await testUppercaseSlugRejected();
|
||||
await testEmptySlugShowsUsage();
|
||||
await testPreReleaseVersionAccepted();
|
||||
await testMaliciousVirusTotalVerdictBlocks();
|
||||
await testRelativePathCliEntrypointWorks();
|
||||
await testInvalidThresholdRejected();
|
||||
await testEnhancedInstallerRejectsInvalidSkill();
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [0.0.8] - 2026-05-24
|
||||
|
||||
### Changed
|
||||
- Documented the consolidated signed advisory feed as the default feed for NVD CVEs, approved community advisories, and provisional GHSA-without-CVE records.
|
||||
|
||||
## [0.0.7] - 2026-05-14
|
||||
|
||||
### Security
|
||||
- Added explicit signed release artifact verification instructions for standalone installs, including `checksums.json`, `checksums.sig`, `signing-public.pem`, archive hash verification, and `SKILL.md`/`skill.json` checksum checks.
|
||||
|
||||
All notable changes to the ClawSec Feed skill will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: clawsec-feed
|
||||
version: 0.0.8
|
||||
version: 0.0.6
|
||||
description: Security advisory feed package for OpenClaw-related threats and vulnerabilities. The upstream feed is updated daily; local automation is handled by clawsec-suite or the operator.
|
||||
homepage: https://clawsec.prompt.security
|
||||
metadata: {"openclaw":{"emoji":"📡","category":"security"}}
|
||||
@@ -14,7 +14,7 @@ clawdis:
|
||||
|
||||
Security advisory feed monitoring for AI agents. Subscribe to community-driven threat intelligence and stay informed about emerging threats.
|
||||
|
||||
The default `feed.json` is the consolidated agent feed. It includes NVD CVEs, approved community advisories, and provisional GitHub Security Advisories that do not have CVE IDs yet.
|
||||
This feed is automatically updated daily with CVEs related to OpenClaw and Moltbot from the NIST National Vulnerability Database (NVD).
|
||||
|
||||
## Operational Notes
|
||||
|
||||
@@ -81,86 +81,6 @@ Once you have this skill file, proceed to **[Deploy ClawSec Feed](#deploy-clawse
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Release Artifact Verification
|
||||
|
||||
For standalone installs, verify the signed release manifest before trusting `SKILL.md`, `skill.json`, or the archive. The `skill.json` file is the package metadata/SBOM source, and the release pipeline signs `checksums.json` with the ClawSec release key.
|
||||
|
||||
```bash
|
||||
set -euo pipefail
|
||||
|
||||
SKILL_NAME="clawsec-feed"
|
||||
VERSION="0.0.8"
|
||||
REPO="prompt-security/clawsec"
|
||||
TAG="${SKILL_NAME}-v${VERSION}"
|
||||
BASE="https://github.com/${REPO}/releases/download/${TAG}"
|
||||
ZIP_NAME="${SKILL_NAME}-v${VERSION}.zip"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
RELEASE_PUBKEY_SHA256="711424e4535f84093fefb024cd1ca4ec87439e53907b305b79a631d5befba9c8"
|
||||
|
||||
curl -fsSL "$BASE/checksums.json" -o "$TMP_DIR/checksums.json"
|
||||
curl -fsSL "$BASE/checksums.sig" -o "$TMP_DIR/checksums.sig"
|
||||
curl -fsSL "$BASE/signing-public.pem" -o "$TMP_DIR/signing-public.pem"
|
||||
curl -fsSL "$BASE/$ZIP_NAME" -o "$TMP_DIR/$ZIP_NAME"
|
||||
curl -fsSL "$BASE/SKILL.md" -o "$TMP_DIR/SKILL.md"
|
||||
curl -fsSL "$BASE/skill.json" -o "$TMP_DIR/skill.json"
|
||||
|
||||
ACTUAL_PUBKEY_SHA256="$(openssl pkey -pubin -in "$TMP_DIR/signing-public.pem" -outform DER | shasum -a 256 | awk '{print $1}')"
|
||||
if [ "$ACTUAL_PUBKEY_SHA256" != "$RELEASE_PUBKEY_SHA256" ]; then
|
||||
echo "ERROR: signing-public.pem fingerprint mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openssl base64 -d -A -in "$TMP_DIR/checksums.sig" -out "$TMP_DIR/checksums.sig.bin"
|
||||
openssl pkeyutl -verify -rawin -pubin \
|
||||
-inkey "$TMP_DIR/signing-public.pem" \
|
||||
-sigfile "$TMP_DIR/checksums.sig.bin" \
|
||||
-in "$TMP_DIR/checksums.json" >/dev/null
|
||||
|
||||
hash_file() {
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$1" | awk '{print $1}'
|
||||
else
|
||||
sha256sum "$1" | awk '{print $1}'
|
||||
fi
|
||||
}
|
||||
|
||||
verify_manifest_file() {
|
||||
asset="$1"
|
||||
path="$2"
|
||||
expected="$(jq -r --arg asset "$asset" '.files[$asset].sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected" ]; then
|
||||
echo "ERROR: checksums.json missing $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual="$(hash_file "$path")"
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "ERROR: checksum mismatch for $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
expected_archive="$(jq -r '.archive.sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected_archive" ]; then
|
||||
echo "ERROR: checksums.json missing archive.sha256" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual_archive="$(hash_file "$TMP_DIR/$ZIP_NAME")"
|
||||
if [ "$actual_archive" != "$expected_archive" ]; then
|
||||
echo "ERROR: archive checksum mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
verify_manifest_file "SKILL.md" "$TMP_DIR/SKILL.md"
|
||||
verify_manifest_file "skill.json" "$TMP_DIR/skill.json"
|
||||
|
||||
echo "Signed release manifest, archive, SKILL.md, and skill.json verified."
|
||||
```
|
||||
|
||||
Only install or extract the archive after this verification succeeds.
|
||||
|
||||
## Deploy ClawSec Feed
|
||||
|
||||
Installation steps:
|
||||
@@ -783,7 +703,7 @@ fi
|
||||
|
||||
| Variable | Description | Default |
|
||||
|----------|-------------|---------|
|
||||
| `CLAWSEC_FEED_URL` | Custom advisory feed URL | Consolidated signed feed |
|
||||
| `CLAWSEC_FEED_URL` | Custom advisory feed URL | Raw GitHub (`main` branch) |
|
||||
| `CLAWSEC_INSTALL_DIR` | Installation directory | `~/.openclaw/skills/clawsec-feed` |
|
||||
|
||||
---
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
v+PiWmjIkY6zdIyI9xJX0l0aTy0Azp1+LoZR6qaiDZJnXFuSBX4Sw/x5tMdTb0xSbqdDTJOZwwWI8coPVepzBw==
|
||||
TM7Tf3QwZIe8TlC325reeArX+/z2xMrjOC0CdZa2I2Zta5L2y2KWbD+Z3VangNu6/ZEaajN4VwwZUAUd5AaNDA==
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clawsec-feed",
|
||||
"version": "0.0.8",
|
||||
"version": "0.0.6",
|
||||
"description": "Security advisory feed monitoring for AI agents. Subscribe to community-driven threat intelligence.",
|
||||
"author": "prompt-security",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
|
||||
@@ -1,22 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [0.0.7] - 2026-06-07
|
||||
|
||||
### Security
|
||||
- Added comparator range support for NanoClaw advisory matching and fail-closed handling for malformed affected specifiers.
|
||||
- Added strict integrity IPC request ID validation and result path containment before host-side result writes.
|
||||
|
||||
## [0.0.6] - 2026-05-24
|
||||
|
||||
### Changed
|
||||
- Documented that NanoClaw consumes the consolidated signed advisory feed containing NVD CVEs, approved community advisories, and provisional GHSA-without-CVE records.
|
||||
- Added advisory metadata typing for GHSA lifecycle fields used by the consolidated feed.
|
||||
|
||||
## [0.0.5] - 2026-05-14
|
||||
|
||||
### Security
|
||||
- Added explicit signed release artifact verification instructions for standalone installs, including `checksums.json`, `checksums.sig`, `signing-public.pem`, archive hash verification, and `SKILL.md`/`skill.json` checksum checks.
|
||||
|
||||
All notable changes to the ClawSec NanoClaw compatibility skill will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: clawsec-nanoclaw
|
||||
version: 0.0.7
|
||||
version: 0.0.4
|
||||
description: Use when checking for security vulnerabilities in NanoClaw skills, before installing new skills, or when asked about security advisories affecting the bot
|
||||
---
|
||||
|
||||
@@ -183,8 +183,6 @@ if (advisory.exploitability_score === 'high' || advisory.severity === 'critical'
|
||||
|
||||
**Feed Source**: https://clawsec.prompt.security/advisories/feed.json
|
||||
|
||||
This signed feed is consolidated. NanoClaw receives NVD CVEs, approved community advisories, and provisional GHSA-without-CVE advisories through the same default URL.
|
||||
|
||||
**Update Frequency**: Every 6 hours (automatic)
|
||||
|
||||
**Signature Verification**: Ed25519 signed feeds
|
||||
@@ -200,83 +198,3 @@ See [INSTALL.md](./INSTALL.md) for setup and [docs/](./docs/) for advanced usage
|
||||
- Alerts to supply chain attacks in dependencies
|
||||
- Provides actionable remediation steps
|
||||
- Zero false positives (curated feed only)
|
||||
|
||||
|
||||
## Release Artifact Verification
|
||||
|
||||
For standalone installs, verify the signed release manifest before trusting `SKILL.md`, `skill.json`, or the archive. The `skill.json` file is the package metadata/SBOM source, and the release pipeline signs `checksums.json` with the ClawSec release key.
|
||||
|
||||
```bash
|
||||
set -euo pipefail
|
||||
|
||||
SKILL_NAME="clawsec-nanoclaw"
|
||||
VERSION="0.0.6"
|
||||
REPO="prompt-security/clawsec"
|
||||
TAG="${SKILL_NAME}-v${VERSION}"
|
||||
BASE="https://github.com/${REPO}/releases/download/${TAG}"
|
||||
ZIP_NAME="${SKILL_NAME}-v${VERSION}.zip"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
RELEASE_PUBKEY_SHA256="711424e4535f84093fefb024cd1ca4ec87439e53907b305b79a631d5befba9c8"
|
||||
|
||||
curl -fsSL "$BASE/checksums.json" -o "$TMP_DIR/checksums.json"
|
||||
curl -fsSL "$BASE/checksums.sig" -o "$TMP_DIR/checksums.sig"
|
||||
curl -fsSL "$BASE/signing-public.pem" -o "$TMP_DIR/signing-public.pem"
|
||||
curl -fsSL "$BASE/$ZIP_NAME" -o "$TMP_DIR/$ZIP_NAME"
|
||||
curl -fsSL "$BASE/SKILL.md" -o "$TMP_DIR/SKILL.md"
|
||||
curl -fsSL "$BASE/skill.json" -o "$TMP_DIR/skill.json"
|
||||
|
||||
ACTUAL_PUBKEY_SHA256="$(openssl pkey -pubin -in "$TMP_DIR/signing-public.pem" -outform DER | shasum -a 256 | awk '{print $1}')"
|
||||
if [ "$ACTUAL_PUBKEY_SHA256" != "$RELEASE_PUBKEY_SHA256" ]; then
|
||||
echo "ERROR: signing-public.pem fingerprint mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openssl base64 -d -A -in "$TMP_DIR/checksums.sig" -out "$TMP_DIR/checksums.sig.bin"
|
||||
openssl pkeyutl -verify -rawin -pubin \
|
||||
-inkey "$TMP_DIR/signing-public.pem" \
|
||||
-sigfile "$TMP_DIR/checksums.sig.bin" \
|
||||
-in "$TMP_DIR/checksums.json" >/dev/null
|
||||
|
||||
hash_file() {
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$1" | awk '{print $1}'
|
||||
else
|
||||
sha256sum "$1" | awk '{print $1}'
|
||||
fi
|
||||
}
|
||||
|
||||
verify_manifest_file() {
|
||||
asset="$1"
|
||||
path="$2"
|
||||
expected="$(jq -r --arg asset "$asset" '.files[$asset].sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected" ]; then
|
||||
echo "ERROR: checksums.json missing $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual="$(hash_file "$path")"
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "ERROR: checksum mismatch for $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
expected_archive="$(jq -r '.archive.sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected_archive" ]; then
|
||||
echo "ERROR: checksums.json missing archive.sha256" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual_archive="$(hash_file "$TMP_DIR/$ZIP_NAME")"
|
||||
if [ "$actual_archive" != "$expected_archive" ]; then
|
||||
echo "ERROR: archive checksum mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
verify_manifest_file "SKILL.md" "$TMP_DIR/SKILL.md"
|
||||
verify_manifest_file "skill.json" "$TMP_DIR/skill.json"
|
||||
|
||||
echo "Signed release manifest, archive, SKILL.md, and skill.json verified."
|
||||
```
|
||||
|
||||
Only install or extract the archive after this verification succeeds.
|
||||
|
||||
@@ -11,9 +11,6 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { IntegrityMonitor } from '../guardian/integrity-monitor';
|
||||
|
||||
const RESULT_DIR = '/workspace/ipc/clawsec_results';
|
||||
const REQUEST_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
||||
|
||||
// ============================================================================
|
||||
// Integrity Service (Singleton)
|
||||
// ============================================================================
|
||||
@@ -87,21 +84,15 @@ export async function handleIntegrityIpc(
|
||||
logger: any
|
||||
): Promise<void> {
|
||||
const { type, requestId, groupFolder: _groupFolder } = task;
|
||||
const validatedRequestId = validateRequestId(requestId);
|
||||
|
||||
if (!validatedRequestId) {
|
||||
logger.warn({ type, requestId }, 'Invalid integrity IPC request id');
|
||||
return;
|
||||
}
|
||||
|
||||
const safeTask = { ...task, requestId: validatedRequestId };
|
||||
|
||||
if (!deps.integrityService) {
|
||||
logger.warn({ task }, 'IntegrityService not available');
|
||||
writeResult(validatedRequestId, {
|
||||
success: false,
|
||||
error: 'IntegrityService not initialized'
|
||||
});
|
||||
if (requestId) {
|
||||
writeResult(requestId, {
|
||||
success: false,
|
||||
error: 'IntegrityService not initialized'
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -112,29 +103,31 @@ export async function handleIntegrityIpc(
|
||||
await service.initialize();
|
||||
} catch (error) {
|
||||
logger.error({ error }, 'Failed to initialize IntegrityService');
|
||||
writeResult(validatedRequestId, {
|
||||
success: false,
|
||||
error: `Initialization failed: ${error instanceof Error ? error.message : String(error)}`
|
||||
});
|
||||
if (requestId) {
|
||||
writeResult(requestId, {
|
||||
success: false,
|
||||
error: `Initialization failed: ${error instanceof Error ? error.message : String(error)}`
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 'integrity_check':
|
||||
await handleIntegrityCheck(safeTask, service, logger);
|
||||
await handleIntegrityCheck(task, service, logger);
|
||||
break;
|
||||
|
||||
case 'integrity_approve':
|
||||
await handleIntegrityApprove(safeTask, service, logger);
|
||||
await handleIntegrityApprove(task, service, logger);
|
||||
break;
|
||||
|
||||
case 'integrity_status':
|
||||
await handleIntegrityStatus(safeTask, service, logger);
|
||||
await handleIntegrityStatus(task, service, logger);
|
||||
break;
|
||||
|
||||
case 'integrity_verify_audit':
|
||||
await handleIntegrityVerifyAudit(safeTask, service, logger);
|
||||
await handleIntegrityVerifyAudit(task, service, logger);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -287,40 +280,15 @@ async function handleIntegrityVerifyAudit(
|
||||
// Helper Functions
|
||||
// ============================================================================
|
||||
|
||||
function validateRequestId(requestId: unknown): string | null {
|
||||
if (typeof requestId !== 'string') return null;
|
||||
const normalized = requestId.trim();
|
||||
if (!REQUEST_ID_PATTERN.test(normalized)) return null;
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function resolveResultPath(requestId: string): string {
|
||||
const safeRequestId = validateRequestId(requestId);
|
||||
if (!safeRequestId) {
|
||||
throw new Error('Invalid integrity IPC request id');
|
||||
}
|
||||
|
||||
const resultDir = RESULT_DIR;
|
||||
const normalizedResultDir = path.resolve(resultDir);
|
||||
const resultPath = path.resolve(normalizedResultDir, `${safeRequestId}.json`);
|
||||
const relativePath = path.relative(normalizedResultDir, resultPath);
|
||||
|
||||
if (relativePath.startsWith('..') || path.isAbsolute(relativePath)) {
|
||||
throw new Error('Integrity IPC result path escapes result directory');
|
||||
}
|
||||
|
||||
return resultPath;
|
||||
}
|
||||
|
||||
function writeResult(requestId: string, result: any): void {
|
||||
const resultPath = resolveResultPath(requestId);
|
||||
const resultDir = path.dirname(resultPath);
|
||||
const resultDir = '/workspace/ipc/clawsec_results';
|
||||
|
||||
// Ensure directory exists
|
||||
if (!fs.existsSync(resultDir)) {
|
||||
fs.mkdirSync(resultDir, { recursive: true });
|
||||
}
|
||||
|
||||
const resultPath = path.join(resultDir, `${requestId}.json`);
|
||||
fs.writeFileSync(resultPath, JSON.stringify(result, null, 2));
|
||||
}
|
||||
|
||||
|
||||
@@ -86,146 +86,39 @@ export function versionMatches(version: string, versionSpec: string): boolean {
|
||||
if (v === spec) return true;
|
||||
|
||||
// Parse semver components
|
||||
type ParsedVersion = {
|
||||
major: number;
|
||||
minor: number;
|
||||
patch: number;
|
||||
prerelease: string[];
|
||||
};
|
||||
|
||||
const semverPattern = String.raw`v?\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?`;
|
||||
const semverRegex = new RegExp(
|
||||
String.raw`^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$`
|
||||
);
|
||||
|
||||
const parseVersion = (ver: string): ParsedVersion | null => {
|
||||
const match = ver.match(semverRegex);
|
||||
if (!match) return null;
|
||||
|
||||
return {
|
||||
major: parseInt(match[1], 10),
|
||||
minor: parseInt(match[2], 10),
|
||||
patch: parseInt(match[3], 10),
|
||||
prerelease: match[4] ? match[4].split('.') : [],
|
||||
};
|
||||
};
|
||||
|
||||
const comparePrereleaseIdentifiers = (left: string, right: string): number => {
|
||||
const leftIsNumeric = /^\d+$/.test(left);
|
||||
const rightIsNumeric = /^\d+$/.test(right);
|
||||
|
||||
if (leftIsNumeric && rightIsNumeric) {
|
||||
const leftValue = parseInt(left, 10);
|
||||
const rightValue = parseInt(right, 10);
|
||||
if (leftValue > rightValue) return 1;
|
||||
if (leftValue < rightValue) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (leftIsNumeric) return -1;
|
||||
if (rightIsNumeric) return 1;
|
||||
if (left > right) return 1;
|
||||
if (left < right) return -1;
|
||||
return 0;
|
||||
};
|
||||
|
||||
const compareVersions = (left: ParsedVersion, right: ParsedVersion): number => {
|
||||
if (left.major > right.major) return 1;
|
||||
if (left.major < right.major) return -1;
|
||||
if (left.minor > right.minor) return 1;
|
||||
if (left.minor < right.minor) return -1;
|
||||
if (left.patch > right.patch) return 1;
|
||||
if (left.patch < right.patch) return -1;
|
||||
|
||||
if (left.prerelease.length === 0 && right.prerelease.length === 0) return 0;
|
||||
if (left.prerelease.length === 0) return 1;
|
||||
if (right.prerelease.length === 0) return -1;
|
||||
|
||||
const identifierCount = Math.max(left.prerelease.length, right.prerelease.length);
|
||||
for (let index = 0; index < identifierCount; index += 1) {
|
||||
const leftIdentifier = left.prerelease[index];
|
||||
const rightIdentifier = right.prerelease[index];
|
||||
|
||||
if (leftIdentifier === undefined) return -1;
|
||||
if (rightIdentifier === undefined) return 1;
|
||||
|
||||
const comparison = comparePrereleaseIdentifiers(leftIdentifier, rightIdentifier);
|
||||
if (comparison !== 0) return comparison;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
const evaluateComparator = (comparator: string): boolean => {
|
||||
const match = comparator.trim().match(new RegExp(`^(<=|>=|<|>|=)?\\s*(${semverPattern})$`));
|
||||
if (!match) return false;
|
||||
|
||||
const operator = match[1] || '=';
|
||||
const comparatorParts = parseVersion(match[2]);
|
||||
if (!comparatorParts) return false;
|
||||
|
||||
const comparison = compareVersions(vParts, comparatorParts);
|
||||
if (operator === '<') return comparison < 0;
|
||||
if (operator === '<=') return comparison <= 0;
|
||||
if (operator === '>') return comparison > 0;
|
||||
if (operator === '>=') return comparison >= 0;
|
||||
return comparison === 0;
|
||||
};
|
||||
|
||||
const extractComparatorTokens = (range: string): string[] | null => {
|
||||
const tokenPattern = new RegExp(`(?:<=|>=|<|>|=)?\\s*${semverPattern}`, 'g');
|
||||
const tokens: string[] = [];
|
||||
let cursor = 0;
|
||||
let match = tokenPattern.exec(range);
|
||||
|
||||
while (match) {
|
||||
const gap = range.slice(cursor, match.index);
|
||||
if (!/^[\s,]*$/.test(gap)) return null;
|
||||
|
||||
tokens.push(match[0].trim());
|
||||
cursor = match.index + match[0].length;
|
||||
match = tokenPattern.exec(range);
|
||||
}
|
||||
|
||||
if (!/^[\s,]*$/.test(range.slice(cursor))) return null;
|
||||
return tokens.length > 0 ? tokens : null;
|
||||
const parseVersion = (ver: string): number[] => {
|
||||
const match = ver.match(/^(\d+)\.(\d+)\.(\d+)/);
|
||||
if (!match) return [];
|
||||
return [parseInt(match[1], 10), parseInt(match[2], 10), parseInt(match[3], 10)];
|
||||
};
|
||||
|
||||
const vParts = parseVersion(v);
|
||||
if (!vParts) return true;
|
||||
|
||||
if (/(?:<=|>=|<|>|=)/.test(spec)) {
|
||||
const comparatorTokens = extractComparatorTokens(spec);
|
||||
if (!comparatorTokens) return false;
|
||||
return comparatorTokens.every((token) => evaluateComparator(token));
|
||||
}
|
||||
|
||||
const specParts = parseVersion(spec.replace(/^[~^]/, ''));
|
||||
if (!specParts) return true;
|
||||
|
||||
if (vParts.length === 0 || specParts.length === 0) return false;
|
||||
|
||||
// Caret range (^1.2.3): compatible with 1.x.x where x >= 2.3
|
||||
if (spec.startsWith('^')) {
|
||||
const upperBound =
|
||||
specParts.major > 0
|
||||
? { major: specParts.major + 1, minor: 0, patch: 0, prerelease: [] }
|
||||
: specParts.minor > 0
|
||||
? { major: 0, minor: specParts.minor + 1, patch: 0, prerelease: [] }
|
||||
: { major: 0, minor: 0, patch: specParts.patch + 1, prerelease: [] };
|
||||
|
||||
return compareVersions(vParts, specParts) >= 0 && compareVersions(vParts, upperBound) < 0;
|
||||
if (vParts[0] !== specParts[0]) return false;
|
||||
if (vParts[0] === 0) {
|
||||
// ^0.2.3 means 0.2.x where x >= 3
|
||||
if (vParts[1] !== specParts[1]) return false;
|
||||
return vParts[2] >= specParts[2];
|
||||
}
|
||||
// ^1.2.3 means 1.x.x where x.x >= 2.3
|
||||
if (vParts[1] > specParts[1]) return true;
|
||||
if (vParts[1] < specParts[1]) return false;
|
||||
return vParts[2] >= specParts[2];
|
||||
}
|
||||
|
||||
// Tilde range (~1.2.3): patch-level compatibility (1.2.x where x >= 3)
|
||||
if (spec.startsWith('~')) {
|
||||
const upperBound = { major: specParts.major, minor: specParts.minor + 1, patch: 0, prerelease: [] };
|
||||
return compareVersions(vParts, specParts) >= 0 && compareVersions(vParts, upperBound) < 0;
|
||||
if (vParts[0] !== specParts[0]) return false;
|
||||
if (vParts[1] !== specParts[1]) return false;
|
||||
return vParts[2] >= specParts[2];
|
||||
}
|
||||
|
||||
if (new RegExp(`^${semverPattern}$`).test(spec)) {
|
||||
return compareVersions(vParts, specParts) === 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,11 +5,6 @@
|
||||
|
||||
export interface Advisory {
|
||||
id: string;
|
||||
ghsa_id?: string;
|
||||
cve_id?: string | null;
|
||||
status?: 'active' | 'matured' | 'stale' | string;
|
||||
stale?: boolean;
|
||||
source_feed?: string;
|
||||
severity: 'critical' | 'high' | 'medium' | 'low';
|
||||
type: 'vulnerable_skill' | 'malicious_skill' | 'prompt_injection' | string;
|
||||
title: string;
|
||||
@@ -19,10 +14,7 @@ export interface Advisory {
|
||||
published: string;
|
||||
references: string[];
|
||||
cvss_score?: number;
|
||||
cvss_vector?: string | null;
|
||||
nvd_url?: string;
|
||||
github_advisory_url?: string;
|
||||
platforms?: string[];
|
||||
exploitability_score?: 'high' | 'medium' | 'low' | 'unknown';
|
||||
exploitability_rationale?: string;
|
||||
source?: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clawsec-nanoclaw",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.4",
|
||||
"description": "ClawSec security suite for NanoClaw - Advisory feed monitoring, MCP tools for vulnerability checking, and Ed25519 signature verification for containerized WhatsApp bot agents",
|
||||
"author": "prompt-security",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import ts from 'typescript';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
import vm from 'node:vm';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
@@ -14,45 +12,6 @@ function readSkillFile(relativePath) {
|
||||
return fs.readFileSync(path.join(SKILL_ROOT, relativePath), 'utf8');
|
||||
}
|
||||
|
||||
function extractFunctionSource(source, functionName) {
|
||||
const marker = `export function ${functionName}`;
|
||||
const start = source.indexOf(marker);
|
||||
assert.notEqual(start, -1, `missing ${functionName} export`);
|
||||
|
||||
const bodyStart = source.indexOf('{', start);
|
||||
assert.notEqual(bodyStart, -1, `missing ${functionName} body`);
|
||||
|
||||
let depth = 0;
|
||||
for (let index = bodyStart; index < source.length; index += 1) {
|
||||
const char = source[index];
|
||||
if (char === '{') depth += 1;
|
||||
if (char === '}') depth -= 1;
|
||||
if (depth === 0) {
|
||||
return source.slice(start, index + 1).replace('export ', '');
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`unterminated ${functionName} body`);
|
||||
}
|
||||
|
||||
function loadVersionMatcher() {
|
||||
const source = readSkillFile('lib/advisories.ts');
|
||||
const fnSource = extractFunctionSource(source, 'versionMatches');
|
||||
const js = ts.transpileModule(
|
||||
`${fnSource}\nglobalThis.versionMatches = versionMatches;`,
|
||||
{
|
||||
compilerOptions: {
|
||||
module: ts.ModuleKind.ESNext,
|
||||
target: ts.ScriptTarget.ES2022,
|
||||
},
|
||||
}
|
||||
).outputText;
|
||||
|
||||
const context = { globalThis: {} };
|
||||
vm.runInNewContext(js, context);
|
||||
return context.globalThis.versionMatches;
|
||||
}
|
||||
|
||||
test('signature verifier enforces pinned key and path policy', () => {
|
||||
const source = readSkillFile('host-services/skill-signature-handler.ts');
|
||||
|
||||
@@ -96,39 +55,3 @@ test('integrity targets and baselines use normalized absolute paths', () => {
|
||||
assert.ok(source.includes('const normalizedFilePath = path.resolve(filePath);'), 'status/approval lookups must normalize file paths');
|
||||
assert.ok(source.includes('normalizedFiles[path.resolve(filePath)] = baseline;'), 'loaded baselines must be normalized to absolute keys');
|
||||
});
|
||||
|
||||
test('advisory matcher handles comparator ranges and fails closed on malformed specs', () => {
|
||||
const versionMatches = loadVersionMatcher();
|
||||
|
||||
assert.equal(versionMatches('2026.4.20', '<2026.5.18'), true, 'less-than comparator must match vulnerable versions');
|
||||
assert.equal(versionMatches('2026.5.18', '<2026.5.18'), false, 'less-than comparator must exclude patched versions');
|
||||
assert.equal(versionMatches('2026.5.18', '<=2026.5.18'), true, 'less-than-or-equal comparator must match boundary versions');
|
||||
assert.equal(versionMatches('1.4.0', '>=1.2.0 <2.0.0'), true, 'composite comparator ranges must match all clauses');
|
||||
assert.equal(versionMatches('2.0.0', '>=1.2.0 <2.0.0'), false, 'composite comparator ranges must reject failed clauses');
|
||||
assert.equal(versionMatches('0.0.2', '<= 0.0.2'), true, 'spaced comparators must match boundary versions');
|
||||
assert.equal(versionMatches('0.0.3', '<= 0.0.2'), false, 'spaced comparators must reject versions outside range');
|
||||
assert.equal(versionMatches('1.2.3', '>= 1.0.0 <'), false, 'partially parsed comparator ranges must not match everything');
|
||||
assert.equal(versionMatches('1.2.3', 'not-a-range'), true, 'unparseable advisory specifiers must fail closed');
|
||||
});
|
||||
|
||||
test('advisory matcher preserves semver prerelease precedence', () => {
|
||||
const versionMatches = loadVersionMatcher();
|
||||
|
||||
assert.equal(versionMatches('1.2.3-beta.1', '1.2.3'), false, 'prereleases must not collapse into releases');
|
||||
assert.equal(versionMatches('1.2.3-beta.1', '=1.2.3'), false, 'explicit equality must honor prerelease data');
|
||||
assert.equal(versionMatches('1.2.3-beta.1', '<1.2.3'), true, 'prereleases must compare lower than releases');
|
||||
assert.equal(versionMatches('1.2.3', '>1.2.3-beta.1'), true, 'releases must compare higher than prereleases');
|
||||
assert.equal(versionMatches('1.2.3-beta.2', '<1.2.3-beta.10'), true, 'numeric prerelease identifiers must compare numerically');
|
||||
assert.equal(versionMatches('1.2.3+build.1', '=1.2.3+build.2'), true, 'build metadata must not affect precedence');
|
||||
assert.equal(versionMatches('1.2.3-beta.1', '^1.2.3'), false, 'caret lower bounds must honor prerelease precedence');
|
||||
assert.equal(versionMatches('1.2.3-beta.1', '~1.2.3'), false, 'tilde lower bounds must honor prerelease precedence');
|
||||
});
|
||||
|
||||
test('integrity IPC result writer validates request ids and result path containment', () => {
|
||||
const source = readSkillFile('host-services/integrity-handler.ts');
|
||||
|
||||
assert.ok(source.includes('validateRequestId(requestId)'), 'writeResult must validate request ids before writing');
|
||||
assert.ok(source.includes('resolveResultPath(requestId)'), 'writeResult must resolve result paths through a boundary helper');
|
||||
assert.ok(source.includes('path.resolve(resultDir)'), 'result directory must be normalized before containment checks');
|
||||
assert.ok(source.includes('path.relative(normalizedResultDir, resultPath)'), 'result path must be compared relative to the intended directory');
|
||||
});
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [0.0.4] - 2026-06-07
|
||||
|
||||
### Security
|
||||
- Replaced DAST target hook execution with static hook source inspection so scanner runs never import, transpile, or invoke untrusted handler code.
|
||||
|
||||
## [0.0.3] - 2026-05-13
|
||||
|
||||
### Changed
|
||||
- Re-release skill payload metadata after excluding test-only files from release SBOMs and archives.
|
||||
|
||||
All notable changes to the ClawSec Scanner will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: clawsec-scanner
|
||||
version: 0.0.4
|
||||
description: Automated vulnerability scanner for agent platforms. Performs dependency scanning (npm audit, pip-audit), multi-database CVE lookup (OSV, NVD, GitHub Advisory), SAST analysis (Semgrep, Bandit), and agent-specific static hook inspection for OpenClaw hooks.
|
||||
version: 0.0.2
|
||||
description: Automated vulnerability scanner for agent platforms. Performs dependency scanning (npm audit, pip-audit), multi-database CVE lookup (OSV, NVD, GitHub Advisory), SAST analysis (Semgrep, Bandit), and agent-specific DAST hook execution testing for OpenClaw hooks.
|
||||
homepage: https://clawsec.prompt.security
|
||||
clawdis:
|
||||
emoji: "🔍"
|
||||
@@ -16,7 +16,7 @@ Comprehensive security scanner for agent platforms that automates vulnerability
|
||||
- **Dependency Scanning**: Analyzes npm and Python dependencies using `npm audit` and `pip-audit` with structured JSON output parsing
|
||||
- **CVE Database Integration**: Queries OSV (primary), NVD 2.0, and GitHub Advisory Database for vulnerability enrichment
|
||||
- **SAST Analysis**: Static code analysis using Semgrep (JavaScript/TypeScript) and Bandit (Python) to detect hardcoded secrets, command injection, path traversal, and unsafe deserialization
|
||||
- **DAST Framework**: Agent-specific static analysis of OpenClaw hook metadata and handler source without importing or invoking target code
|
||||
- **DAST Framework**: Agent-specific dynamic analysis with real OpenClaw hook execution harness (malicious input, timeout, output bounds, event mutation safety)
|
||||
- **Unified Reporting**: Consolidated vulnerability reports with severity classification and remediation guidance
|
||||
- **Continuous Monitoring**: OpenClaw hook integration for automated periodic scanning
|
||||
|
||||
@@ -43,8 +43,8 @@ The scanner orchestrates four complementary scan types to provide comprehensive
|
||||
- Identifies: hardcoded secrets (API keys, tokens), command injection (`eval`, `exec`), path traversal, unsafe deserialization
|
||||
|
||||
4. **Dynamic Analysis (DAST)**
|
||||
- Static hook inspection for OpenClaw hook handlers discovered from `HOOK.md` metadata
|
||||
- Verifies coverage and source-level risk signals without importing, transpiling, or invoking target handlers
|
||||
- Real hook execution harness for OpenClaw hook handlers discovered from `HOOK.md` metadata
|
||||
- Verifies: malicious input resilience, timeout behavior, output amplification bounds, and core event mutation safety
|
||||
- Note: Traditional web DAST tools (ZAP, Burp) do not apply to agent platforms - this provides agent-specific testing
|
||||
|
||||
### Unified Reporting
|
||||
@@ -248,8 +248,8 @@ scripts/runner.sh # Orchestration layer
|
||||
├── scan_dependencies.mjs # npm audit + pip-audit
|
||||
├── query_cve_databases.mjs # OSV/NVD/GitHub API queries
|
||||
├── sast_analyzer.mjs # Semgrep + Bandit static analysis
|
||||
├── dast_runner.mjs # Static hook inspection orchestration
|
||||
└── dast_hook_executor.mjs # Static hook source inspection helper
|
||||
├── dast_runner.mjs # Dynamic security testing orchestration
|
||||
└── dast_hook_executor.mjs # Isolated real hook execution harness
|
||||
|
||||
lib/
|
||||
├── report.mjs # Result aggregation and formatting
|
||||
@@ -326,10 +326,10 @@ proc.on('close', code => {
|
||||
- Requires Python 3.8+ runtime
|
||||
- Alternative: use Docker image `returntocorp/semgrep`
|
||||
|
||||
**"DAST static coverage finding"**
|
||||
- The DAST harness does not execute target hook handlers.
|
||||
- JavaScript and TypeScript hook files are read as source and reported with `info`-level static coverage findings.
|
||||
- Review any listed static signals manually when deciding whether a hook needs deeper sandboxed testing.
|
||||
**"TypeScript hook not executable in DAST harness"**
|
||||
- The DAST harness executes real hook handlers and transpiles `handler.ts` files when a TypeScript compiler is available
|
||||
- Install TypeScript in the scanner environment: `npm install -D typescript` (or provide `handler.js`/`handler.mjs`)
|
||||
- Without a compiler, scanner reports an `info`-level coverage finding instead of a high-severity vulnerability
|
||||
|
||||
**"Concurrent scan detected"**
|
||||
- Lockfile exists: `/tmp/clawsec-scanner.lock`
|
||||
@@ -371,7 +371,7 @@ done
|
||||
node test/dependency_scanner.test.mjs # Dependency scanning
|
||||
node test/cve_integration.test.mjs # CVE database APIs
|
||||
node test/sast_engine.test.mjs # Static analysis
|
||||
node test/dast_harness.test.mjs # DAST static hook inspection
|
||||
node test/dast_harness.test.mjs # DAST harness execution
|
||||
```
|
||||
|
||||
### Linting
|
||||
@@ -456,11 +456,11 @@ npx clawhub@latest install clawsec-suite
|
||||
|
||||
## Roadmap
|
||||
|
||||
### v0.0.4 (Current)
|
||||
### v0.0.2 (Current)
|
||||
- [x] Dependency scanning (npm audit, pip-audit)
|
||||
- [x] CVE database integration (OSV, NVD, GitHub Advisory)
|
||||
- [x] SAST analysis (Semgrep, Bandit)
|
||||
- [x] Static OpenClaw hook inspection for DAST without target code execution
|
||||
- [x] Real OpenClaw hook execution harness for DAST
|
||||
- [x] Unified JSON reporting
|
||||
- [x] OpenClaw hook integration
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ function buildAlertMessage(report: ScanReport, format: string): string {
|
||||
}
|
||||
|
||||
const handler = async (event: HookEvent, _context: HookContext): Promise<void> => {
|
||||
// Preserve the legacy DAST guard so older scanner harnesses cannot recurse.
|
||||
// DAST harness mode executes hook handlers directly; skip recursive scanner runs.
|
||||
if (process.env.CLAWSEC_DAST_HARNESS === "1" || _context?.dastMode === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { createRequire } from "node:module";
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
function parseArgs(argv) {
|
||||
const parsed = {
|
||||
@@ -45,9 +47,26 @@ function parseArgs(argv) {
|
||||
throw new Error("Missing required --handler");
|
||||
}
|
||||
|
||||
if (!parsed.eventB64) {
|
||||
throw new Error("Missing required --event");
|
||||
}
|
||||
|
||||
if (!parsed.contextB64) {
|
||||
throw new Error("Missing required --context");
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
function decodeBase64Json(value, label) {
|
||||
try {
|
||||
const decoded = Buffer.from(value, "base64").toString("utf8");
|
||||
return JSON.parse(decoded);
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to decode ${label}: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function fileExists(filePath) {
|
||||
try {
|
||||
await fs.access(filePath);
|
||||
@@ -57,7 +76,69 @@ async function fileExists(filePath) {
|
||||
}
|
||||
}
|
||||
|
||||
async function readHookSource(handlerPath) {
|
||||
async function loadTypeScriptCompiler() {
|
||||
if (process.env.CLAWSEC_DAST_DISABLE_TYPESCRIPT === "1") {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const imported = await import("typescript");
|
||||
return imported.default || imported;
|
||||
} catch {
|
||||
// Ignore and try require path next.
|
||||
}
|
||||
|
||||
try {
|
||||
const req = createRequire(import.meta.url);
|
||||
return req("typescript");
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function importTypeScriptModule(tsPath) {
|
||||
const tsCompiler = await loadTypeScriptCompiler();
|
||||
if (!tsCompiler || typeof tsCompiler.transpileModule !== "function") {
|
||||
throw new Error(
|
||||
`Cannot execute TypeScript hook (${tsPath}): typescript compiler not available. ` +
|
||||
"Install 'typescript' or provide a JavaScript handler file.",
|
||||
);
|
||||
}
|
||||
|
||||
const source = await fs.readFile(tsPath, "utf8");
|
||||
const transpiled = tsCompiler.transpileModule(source, {
|
||||
compilerOptions: {
|
||||
module: tsCompiler.ModuleKind.ESNext,
|
||||
target: tsCompiler.ScriptTarget.ES2022,
|
||||
moduleResolution: tsCompiler.ModuleResolutionKind.NodeNext,
|
||||
esModuleInterop: true,
|
||||
sourceMap: false,
|
||||
inlineSourceMap: false,
|
||||
declaration: false,
|
||||
},
|
||||
fileName: tsPath,
|
||||
reportDiagnostics: false,
|
||||
});
|
||||
|
||||
const tempFile = path.join(
|
||||
path.dirname(tsPath),
|
||||
`.clawsec-dast-${path.basename(tsPath, ".ts")}-${process.pid}-${Date.now()}.mjs`,
|
||||
);
|
||||
|
||||
await fs.writeFile(tempFile, transpiled.outputText, "utf8");
|
||||
|
||||
try {
|
||||
return await import(`${pathToFileURL(tempFile).href}?ts=${Date.now()}`);
|
||||
} finally {
|
||||
try {
|
||||
await fs.unlink(tempFile);
|
||||
} catch {
|
||||
// best-effort cleanup
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function loadHookModule(handlerPath) {
|
||||
const fullPath = path.resolve(handlerPath);
|
||||
const exists = await fileExists(fullPath);
|
||||
if (!exists) {
|
||||
@@ -65,71 +146,120 @@ async function readHookSource(handlerPath) {
|
||||
}
|
||||
|
||||
const ext = path.extname(fullPath).toLowerCase();
|
||||
const allowedExtensions = new Set([".cjs", ".js", ".mjs", ".ts"]);
|
||||
if (!allowedExtensions.has(ext)) {
|
||||
throw new Error(`Unsupported hook handler extension: ${ext || "(none)"}`);
|
||||
|
||||
if (ext === ".ts") {
|
||||
return importTypeScriptModule(fullPath);
|
||||
}
|
||||
|
||||
const source = await fs.readFile(fullPath, "utf8");
|
||||
return { fullPath, ext, source };
|
||||
return import(`${pathToFileURL(fullPath).href}?v=${Date.now()}`);
|
||||
}
|
||||
|
||||
function detectHandlerExport(source, exportName) {
|
||||
function resolveHandlerExport(mod, exportName) {
|
||||
if (exportName && exportName !== "default") {
|
||||
const escaped = exportName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
return new RegExp(`export\\s+(?:async\\s+)?function\\s+${escaped}\\b|export\\s*\\{[^}]*\\b${escaped}\\b`, "m").test(source);
|
||||
if (typeof mod?.[exportName] === "function") {
|
||||
return mod[exportName];
|
||||
}
|
||||
throw new Error(`Hook export '${exportName}' is not a function`);
|
||||
}
|
||||
|
||||
return (
|
||||
/\bexport\s+default\b/m.test(source) ||
|
||||
/\bexport\s+(?:async\s+)?function\s+handler\b/m.test(source) ||
|
||||
/\bmodule\.exports\s*=|\bexports\.handler\s*=/m.test(source)
|
||||
);
|
||||
if (typeof mod?.default === "function") {
|
||||
return mod.default;
|
||||
}
|
||||
|
||||
if (typeof mod?.handler === "function") {
|
||||
return mod.handler;
|
||||
}
|
||||
|
||||
throw new Error("Hook module does not export a handler function");
|
||||
}
|
||||
|
||||
function collectRiskSignals(source) {
|
||||
const rules = [
|
||||
["child_process", /\bchild_process\b|\bfrom\s+["']node:child_process["']|\brequire\(["']child_process["']\)/m],
|
||||
["dynamic-import", /\bimport\s*\(/m],
|
||||
["eval", /\beval\s*\(|\bnew\s+Function\s*\(/m],
|
||||
["shell-command", /\b(?:exec|spawn|execFile|fork)\s*\(/m],
|
||||
["environment-access", /\bprocess\.env\b/m],
|
||||
];
|
||||
|
||||
const signals = [];
|
||||
for (const [name, pattern] of rules) {
|
||||
if (pattern.test(source)) {
|
||||
signals.push(name);
|
||||
function normalizeTimestamp(event) {
|
||||
const timestamp = event?.timestamp;
|
||||
if (typeof timestamp === "string" || typeof timestamp === "number") {
|
||||
const parsed = new Date(timestamp);
|
||||
if (!Number.isNaN(parsed.getTime())) {
|
||||
event.timestamp = parsed;
|
||||
}
|
||||
}
|
||||
return signals;
|
||||
}
|
||||
|
||||
function summarizeMessages(messages) {
|
||||
if (!Array.isArray(messages)) {
|
||||
return {
|
||||
count: 0,
|
||||
charCount: 0,
|
||||
};
|
||||
}
|
||||
|
||||
let charCount = 0;
|
||||
|
||||
for (const message of messages) {
|
||||
if (typeof message === "string") {
|
||||
charCount += message.length;
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
charCount += JSON.stringify(message).length;
|
||||
} catch {
|
||||
charCount += 0;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
count: messages.length,
|
||||
charCount,
|
||||
};
|
||||
}
|
||||
|
||||
function coreEventShape(event) {
|
||||
return {
|
||||
type: event?.type ?? null,
|
||||
action: event?.action ?? null,
|
||||
sessionKey: event?.sessionKey ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const args = parseArgs(process.argv.slice(2));
|
||||
const event = decodeBase64Json(args.eventB64, "event payload");
|
||||
const context = decodeBase64Json(args.contextB64, "context payload");
|
||||
|
||||
normalizeTimestamp(event);
|
||||
|
||||
const startedAt = Date.now();
|
||||
const before = coreEventShape(event);
|
||||
|
||||
try {
|
||||
const inspected = await readHookSource(args.handler);
|
||||
const mod = await loadHookModule(args.handler);
|
||||
const handler = resolveHandlerExport(mod, args.exportName);
|
||||
|
||||
await handler(event, context);
|
||||
|
||||
const after = coreEventShape(event);
|
||||
const messageSummary = summarizeMessages(event?.messages);
|
||||
|
||||
const payload = {
|
||||
ok: true,
|
||||
static_only: true,
|
||||
duration_ms: Date.now() - startedAt,
|
||||
handler_path: inspected.fullPath,
|
||||
handler_extension: inspected.ext,
|
||||
source_bytes: Buffer.byteLength(inspected.source, "utf8"),
|
||||
source_lines: inspected.source.split(/\r?\n/).length,
|
||||
handler_export_declared: detectHandlerExport(inspected.source, args.exportName),
|
||||
risk_signals: collectRiskSignals(inspected.source),
|
||||
core_before: before,
|
||||
core_after: after,
|
||||
messages_count: messageSummary.count,
|
||||
messages_char_count: messageSummary.charCount,
|
||||
};
|
||||
|
||||
process.stdout.write(JSON.stringify(payload));
|
||||
} catch (error) {
|
||||
const after = coreEventShape(event);
|
||||
const messageSummary = summarizeMessages(event?.messages);
|
||||
|
||||
const payload = {
|
||||
ok: false,
|
||||
static_only: true,
|
||||
duration_ms: Date.now() - startedAt,
|
||||
core_before: before,
|
||||
core_after: after,
|
||||
messages_count: messageSummary.count,
|
||||
messages_char_count: messageSummary.charCount,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
};
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ import { getTimestamp } from "../lib/utils.mjs";
|
||||
*/
|
||||
|
||||
const DEFAULT_TIMEOUT_MS = 30000;
|
||||
const MAX_OUTPUT_MESSAGES = 25;
|
||||
const MAX_OUTPUT_CHARS = 20000;
|
||||
const SKIP_DIR_NAMES = new Set([
|
||||
".git",
|
||||
".github",
|
||||
@@ -36,6 +38,17 @@ const SKIP_DIR_NAMES = new Set([
|
||||
".openclaw",
|
||||
]);
|
||||
|
||||
const MALICIOUS_PAYLOADS = [
|
||||
"<script>alert('XSS')</script>",
|
||||
"'; DROP TABLE users; --",
|
||||
"; rm -rf /",
|
||||
"$(whoami)",
|
||||
"..\\..\\..\\windows\\system32\\config\\sam",
|
||||
"../../../etc/passwd",
|
||||
"test\0malicious",
|
||||
"A".repeat(200000),
|
||||
];
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const HOOK_EXECUTOR_PATH = path.join(__dirname, "dast_hook_executor.mjs");
|
||||
@@ -307,6 +320,43 @@ export async function discoverHooks(targetPath) {
|
||||
return hooks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} eventKey
|
||||
* @returns {{type: string, action: string}}
|
||||
*/
|
||||
function splitEventKey(eventKey) {
|
||||
const parts = String(eventKey ?? "").split(":");
|
||||
const type = parts.shift() || "command";
|
||||
const action = parts.join(":") || "new";
|
||||
return { type, action };
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} eventKey
|
||||
* @param {string} payload
|
||||
* @param {string} targetPath
|
||||
* @returns {Record<string, unknown>}
|
||||
*/
|
||||
export function buildEvent(eventKey, payload, targetPath) {
|
||||
const { type, action } = splitEventKey(eventKey);
|
||||
|
||||
return {
|
||||
type,
|
||||
action,
|
||||
sessionKey: "clawsec-dast-session",
|
||||
timestamp: new Date().toISOString(),
|
||||
messages: [],
|
||||
context: {
|
||||
content: payload,
|
||||
transcript: payload,
|
||||
workspaceDir: path.resolve(targetPath),
|
||||
channelId: "dast-harness",
|
||||
commandSource: "dast",
|
||||
bootstrapFiles: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} HarnessInvocationResult
|
||||
* @property {boolean} timedOut
|
||||
@@ -318,24 +368,33 @@ export async function discoverHooks(targetPath) {
|
||||
|
||||
/**
|
||||
* @param {HookDescriptor} hook
|
||||
* @param {Record<string, unknown>} event
|
||||
* @param {Record<string, unknown>} context
|
||||
* @param {number} timeoutMs
|
||||
* @returns {Promise<HarnessInvocationResult>}
|
||||
*/
|
||||
async function inspectHookHandler(hook, timeoutMs) {
|
||||
async function invokeHookHarness(hook, event, context, timeoutMs) {
|
||||
const encodedEvent = Buffer.from(JSON.stringify(event), "utf8").toString("base64");
|
||||
const encodedContext = Buffer.from(JSON.stringify(context), "utf8").toString("base64");
|
||||
|
||||
const args = [
|
||||
HOOK_EXECUTOR_PATH,
|
||||
"--handler",
|
||||
hook.handlerPath,
|
||||
"--export",
|
||||
hook.exportName || "default",
|
||||
"--event",
|
||||
encodedEvent,
|
||||
"--context",
|
||||
encodedContext,
|
||||
];
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const proc = spawn("node", args, {
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
env: {
|
||||
PATH: process.env.PATH || "",
|
||||
CLAWSEC_DAST_STATIC_INSPECTION: "1",
|
||||
...process.env,
|
||||
CLAWSEC_DAST_HARNESS: "1",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -403,33 +462,31 @@ function isObject(value) {
|
||||
|
||||
/**
|
||||
* @param {unknown} parsed
|
||||
* @returns {{ok: boolean, error: string, staticOnly: boolean, riskSignals: string[], handlerExportDeclared: boolean}}
|
||||
* @returns {{ok: boolean, error: string, messagesCount: number, messagesCharCount: number, coreAfter: Record<string, unknown>}}
|
||||
*/
|
||||
function normalizeStaticPayload(parsed) {
|
||||
function normalizeHarnessPayload(parsed) {
|
||||
if (!isObject(parsed)) {
|
||||
return {
|
||||
ok: false,
|
||||
error: "Harness output is not an object",
|
||||
staticOnly: false,
|
||||
riskSignals: [],
|
||||
handlerExportDeclared: false,
|
||||
messagesCount: 0,
|
||||
messagesCharCount: 0,
|
||||
coreAfter: {},
|
||||
};
|
||||
}
|
||||
|
||||
const ok = parsed.ok === true;
|
||||
const error = typeof parsed.error === "string" ? parsed.error : "";
|
||||
const staticOnly = parsed.static_only === true;
|
||||
const riskSignals = Array.isArray(parsed.risk_signals)
|
||||
? parsed.risk_signals.filter((signal) => typeof signal === "string")
|
||||
: [];
|
||||
const handlerExportDeclared = parsed.handler_export_declared === true;
|
||||
const messagesCount = Number(parsed.messages_count ?? 0) || 0;
|
||||
const messagesCharCount = Number(parsed.messages_char_count ?? 0) || 0;
|
||||
const coreAfter = isObject(parsed.core_after) ? parsed.core_after : {};
|
||||
|
||||
return {
|
||||
ok,
|
||||
error,
|
||||
staticOnly,
|
||||
riskSignals,
|
||||
handlerExportDeclared,
|
||||
messagesCount,
|
||||
messagesCharCount,
|
||||
coreAfter,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -445,6 +502,19 @@ function slug(input) {
|
||||
.slice(0, 60);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} reason
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isHarnessCapabilityError(reason) {
|
||||
const normalized = String(reason ?? "").toLowerCase();
|
||||
return (
|
||||
normalized.includes("typescript compiler not available")
|
||||
|| normalized.includes("does not export a handler function")
|
||||
|| normalized.includes("is not a function")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Vulnerability[]} bucket
|
||||
* @param {string} id
|
||||
@@ -471,74 +541,178 @@ function pushHookVulnerability(bucket, id, severity, hook, eventKey, title, desc
|
||||
|
||||
/**
|
||||
* @param {HookDescriptor} hook
|
||||
* @param {string} _targetPath
|
||||
* @param {string} targetPath
|
||||
* @param {number} timeoutMs
|
||||
* @returns {Promise<Vulnerability[]>}
|
||||
*/
|
||||
async function evaluateHook(hook, _targetPath, timeoutMs) {
|
||||
async function evaluateHook(hook, targetPath, timeoutMs) {
|
||||
const findings = [];
|
||||
const invocationTimeoutMs = Math.max(1000, timeoutMs);
|
||||
// Static inspection depends only on the handler source/export, so reuse it for all hook events.
|
||||
const inspection = await inspectHookHandler(hook, invocationTimeoutMs);
|
||||
|
||||
for (const eventKey of hook.events) {
|
||||
if (inspection.timedOut) {
|
||||
const safeEvent = buildEvent(eventKey, "safe baseline input", targetPath);
|
||||
const safeContext = {
|
||||
skillPath: hook.hookDir,
|
||||
agentPlatform: "openclaw",
|
||||
dastMode: true,
|
||||
targetPath: path.resolve(targetPath),
|
||||
event: eventKey,
|
||||
};
|
||||
|
||||
const safeResult = await invokeHookHarness(hook, safeEvent, safeContext, invocationTimeoutMs);
|
||||
|
||||
if (safeResult.timedOut) {
|
||||
pushHookVulnerability(
|
||||
findings,
|
||||
`DAST-STATIC-TIMEOUT-${slug(`${hook.name}-${eventKey}`)}`,
|
||||
`DAST-TIMEOUT-${slug(`${hook.name}-${eventKey}`)}`,
|
||||
"high",
|
||||
hook,
|
||||
eventKey,
|
||||
"Hook times out under baseline input",
|
||||
`Hook execution exceeded ${invocationTimeoutMs}ms for event '${eventKey}' under safe baseline input.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (safeResult.parseError) {
|
||||
pushHookVulnerability(
|
||||
findings,
|
||||
`DAST-HARNESS-${slug(`${hook.name}-${eventKey}`)}`,
|
||||
"medium",
|
||||
hook,
|
||||
eventKey,
|
||||
"Hook static inspection timed out",
|
||||
`Static hook inspection exceeded ${invocationTimeoutMs}ms for event '${eventKey}'. Target code was not executed.`,
|
||||
"Hook harness output invalid",
|
||||
`Could not parse harness output for event '${eventKey}': ${safeResult.parseError}. stderr: ${safeResult.stderr || "(empty)"}`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inspection.parseError) {
|
||||
const normalizedSafe = normalizeHarnessPayload(safeResult.parsed);
|
||||
if (!normalizedSafe.ok) {
|
||||
const reason = normalizedSafe.error || safeResult.stderr || "unknown error";
|
||||
|
||||
if (isHarnessCapabilityError(reason)) {
|
||||
pushHookVulnerability(
|
||||
findings,
|
||||
`DAST-COVERAGE-${slug(`${hook.name}-${eventKey}`)}`,
|
||||
"info",
|
||||
hook,
|
||||
eventKey,
|
||||
"Hook not executable in local DAST harness",
|
||||
`DAST harness could not execute hook for event '${eventKey}' due to runtime capability limits: ${reason}`,
|
||||
);
|
||||
} else {
|
||||
pushHookVulnerability(
|
||||
findings,
|
||||
`DAST-CRASH-${slug(`${hook.name}-${eventKey}`)}`,
|
||||
"high",
|
||||
hook,
|
||||
eventKey,
|
||||
"Hook throws on baseline input",
|
||||
`Hook execution failed for event '${eventKey}' under safe baseline input: ${reason}`,
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
const mutationObserved =
|
||||
normalizedSafe.coreAfter.type !== safeEvent.type ||
|
||||
normalizedSafe.coreAfter.action !== safeEvent.action ||
|
||||
normalizedSafe.coreAfter.sessionKey !== safeEvent.sessionKey;
|
||||
|
||||
if (mutationObserved) {
|
||||
pushHookVulnerability(
|
||||
findings,
|
||||
`DAST-STATIC-HARNESS-${slug(`${hook.name}-${eventKey}`)}`,
|
||||
`DAST-MUTATION-${slug(`${hook.name}-${eventKey}`)}`,
|
||||
"low",
|
||||
hook,
|
||||
eventKey,
|
||||
"Hook mutates core event identity fields",
|
||||
`Hook changed one or more of type/action/sessionKey for event '${eventKey}'. This can cause routing side effects in OpenClaw hooks.`,
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
normalizedSafe.messagesCount > MAX_OUTPUT_MESSAGES ||
|
||||
normalizedSafe.messagesCharCount > MAX_OUTPUT_CHARS
|
||||
) {
|
||||
pushHookVulnerability(
|
||||
findings,
|
||||
`DAST-OUTPUT-${slug(`${hook.name}-${eventKey}`)}`,
|
||||
"medium",
|
||||
hook,
|
||||
eventKey,
|
||||
"Hook static inspection output invalid",
|
||||
`Could not parse static inspection output for event '${eventKey}': ${inspection.parseError}. stderr: ${inspection.stderr || "(empty)"}`,
|
||||
"Hook output exceeds safe bounds",
|
||||
`Hook generated ${normalizedSafe.messagesCount} messages and ${normalizedSafe.messagesCharCount} chars for baseline input. Limits: ${MAX_OUTPUT_MESSAGES} messages / ${MAX_OUTPUT_CHARS} chars.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
const normalized = normalizeStaticPayload(inspection.parsed);
|
||||
if (!normalized.ok || !normalized.staticOnly) {
|
||||
const reason = normalized.error || inspection.stderr || "unknown static inspection error";
|
||||
const maliciousFailures = [];
|
||||
const maliciousTimeouts = [];
|
||||
|
||||
for (const payload of MALICIOUS_PAYLOADS) {
|
||||
const event = buildEvent(eventKey, payload, targetPath);
|
||||
const context = {
|
||||
...safeContext,
|
||||
payloadLength: payload.length,
|
||||
};
|
||||
|
||||
const result = await invokeHookHarness(hook, event, context, invocationTimeoutMs);
|
||||
|
||||
if (result.timedOut) {
|
||||
maliciousTimeouts.push(`len=${payload.length}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (result.parseError) {
|
||||
maliciousFailures.push(`parse-error(${result.parseError})`);
|
||||
continue;
|
||||
}
|
||||
|
||||
const normalized = normalizeHarnessPayload(result.parsed);
|
||||
if (!normalized.ok) {
|
||||
maliciousFailures.push(normalized.error || "execution-error");
|
||||
}
|
||||
|
||||
if (
|
||||
normalized.messagesCount > MAX_OUTPUT_MESSAGES ||
|
||||
normalized.messagesCharCount > MAX_OUTPUT_CHARS
|
||||
) {
|
||||
pushHookVulnerability(
|
||||
findings,
|
||||
`DAST-OUTPUT-${slug(`${hook.name}-${eventKey}`)}-${payload.length}`,
|
||||
"medium",
|
||||
hook,
|
||||
eventKey,
|
||||
"Hook output amplification under malicious input",
|
||||
`Hook generated ${normalized.messagesCount} messages and ${normalized.messagesCharCount} chars for payload length ${payload.length}.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (maliciousTimeouts.length > 0) {
|
||||
pushHookVulnerability(
|
||||
findings,
|
||||
`DAST-STATIC-COVERAGE-${slug(`${hook.name}-${eventKey}`)}`,
|
||||
"info",
|
||||
`DAST-MALICIOUS-TIMEOUT-${slug(`${hook.name}-${eventKey}`)}`,
|
||||
"high",
|
||||
hook,
|
||||
eventKey,
|
||||
"Hook not executed during DAST static inspection",
|
||||
`DAST did not execute hook code for event '${eventKey}'. Static inspection failed with: ${reason}`,
|
||||
"Hook times out on malicious input",
|
||||
`Hook exceeded ${invocationTimeoutMs}ms for malicious payloads (${maliciousTimeouts.slice(0, 3).join(", ")}${maliciousTimeouts.length > 3 ? `, +${maliciousTimeouts.length - 3} more` : ""}).`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
const signalSuffix = normalized.riskSignals.length > 0
|
||||
? ` Static signals observed: ${normalized.riskSignals.join(", ")}.`
|
||||
: "";
|
||||
const exportSuffix = normalized.handlerExportDeclared
|
||||
? ""
|
||||
: " The configured handler export was not obvious from static source inspection.";
|
||||
|
||||
pushHookVulnerability(
|
||||
findings,
|
||||
`DAST-STATIC-COVERAGE-${slug(`${hook.name}-${eventKey}`)}`,
|
||||
"info",
|
||||
hook,
|
||||
eventKey,
|
||||
"Hook inspected statically without executing target code",
|
||||
`DAST inspected the hook source for event '${eventKey}' without importing, transpiling, or invoking the handler.${signalSuffix}${exportSuffix}`,
|
||||
);
|
||||
if (maliciousFailures.length > 0) {
|
||||
pushHookVulnerability(
|
||||
findings,
|
||||
`DAST-MALICIOUS-CRASH-${slug(`${hook.name}-${eventKey}`)}`,
|
||||
"high",
|
||||
hook,
|
||||
eventKey,
|
||||
"Hook crashes on malicious input",
|
||||
`Hook raised unhandled errors for malicious payloads. Sample errors: ${maliciousFailures.slice(0, 3).join(" | ")}${maliciousFailures.length > 3 ? ` (+${maliciousFailures.length - 3} more)` : ""}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return findings;
|
||||
@@ -604,6 +778,8 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
export { MALICIOUS_PAYLOADS };
|
||||
|
||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
main();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "clawsec-scanner",
|
||||
"version": "0.0.4",
|
||||
"description": "Automated vulnerability scanner for agent platforms. Performs dependency scanning (npm audit, pip-audit), multi-database CVE lookup (OSV, NVD, GitHub Advisory), SAST analysis (Semgrep, Bandit), and agent-specific static hook inspection for OpenClaw hooks.",
|
||||
"version": "0.0.2",
|
||||
"description": "Automated vulnerability scanner for agent platforms. Performs dependency scanning (npm audit, pip-audit), multi-database CVE lookup (OSV, NVD, GitHub Advisory), SAST analysis (Semgrep, Bandit), and agent-specific DAST hook execution testing for OpenClaw hooks.",
|
||||
"author": "prompt-security",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"homepage": "https://clawsec.prompt.security/",
|
||||
@@ -57,12 +57,12 @@
|
||||
{
|
||||
"path": "scripts/dast_runner.mjs",
|
||||
"required": true,
|
||||
"description": "Static OpenClaw hook inspection harness that does not execute target handlers"
|
||||
"description": "Dynamic analysis harness executing OpenClaw hook handlers with malicious-input and timeout checks"
|
||||
},
|
||||
{
|
||||
"path": "scripts/dast_hook_executor.mjs",
|
||||
"required": true,
|
||||
"description": "Static hook source inspection helper used by DAST without importing target handlers"
|
||||
"description": "Isolated hook execution helper used by DAST for real OpenClaw harness testing"
|
||||
},
|
||||
{
|
||||
"path": "scripts/setup_scanner_hook.mjs",
|
||||
@@ -93,6 +93,26 @@
|
||||
"path": "hooks/clawsec-scanner-hook/handler.ts",
|
||||
"required": false,
|
||||
"description": "OpenClaw hook handler for periodic vulnerability scanning"
|
||||
},
|
||||
{
|
||||
"path": "test/dependency_scanner.test.mjs",
|
||||
"required": false,
|
||||
"description": "Unit tests for dependency scanning (npm audit, pip-audit)"
|
||||
},
|
||||
{
|
||||
"path": "test/cve_integration.test.mjs",
|
||||
"required": false,
|
||||
"description": "Integration tests for CVE database API queries"
|
||||
},
|
||||
{
|
||||
"path": "test/sast_engine.test.mjs",
|
||||
"required": false,
|
||||
"description": "Unit tests for SAST analysis (Semgrep, Bandit)"
|
||||
},
|
||||
{
|
||||
"path": "test/dast_harness.test.mjs",
|
||||
"required": false,
|
||||
"description": "DAST harness tests for real hook execution and malicious-input failure detection"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -89,13 +89,8 @@ metadata: { "openclaw": { "events": [${eventsLiteral}] } }
|
||||
await fs.writeFile(path.join(hookDir, handlerFile), handlerSource, "utf8");
|
||||
}
|
||||
|
||||
async function writeExecutable(filePath, content) {
|
||||
await fs.writeFile(filePath, content, "utf8");
|
||||
await fs.chmod(filePath, 0o755);
|
||||
}
|
||||
|
||||
async function testSafeHookIsInspectedWithoutExecution() {
|
||||
const testName = "DAST harness: inspects hooks without executing target code";
|
||||
async function testSafeHookExecutesAndDoesNotReportMisleadingHigh() {
|
||||
const testName = "DAST harness: executes real hook and reports no misleading high findings";
|
||||
const tmp = await createTempDir();
|
||||
|
||||
try {
|
||||
@@ -130,20 +125,19 @@ export default handler;
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
|
||||
const noHighSummary =
|
||||
const cleanSummary =
|
||||
result.report?.summary?.critical === 0
|
||||
&& result.report?.summary?.high === 0
|
||||
&& result.report?.summary?.medium === 0
|
||||
&& result.report?.summary?.low === 0;
|
||||
const hasStaticCoverageInfo = Array.isArray(result.report?.vulnerabilities)
|
||||
&& result.report.vulnerabilities.some((v) => String(v.id || "").includes("DAST-STATIC-COVERAGE"));
|
||||
&& result.report?.summary?.low === 0
|
||||
&& result.report?.summary?.info === 0;
|
||||
|
||||
if (result.code === 0 && !markerExists && noHighSummary && hasStaticCoverageInfo) {
|
||||
if (result.code === 0 && markerExists && cleanSummary) {
|
||||
pass(testName);
|
||||
} else {
|
||||
fail(
|
||||
testName,
|
||||
`Expected exit=0, markerExists=false, static coverage info, and no high findings. Got exit=${result.code}, markerExists=${markerExists}, summary=${JSON.stringify(result.report?.summary)} findings=${JSON.stringify(result.report?.vulnerabilities || [])} stderr=${result.stderr}`,
|
||||
`Expected exit=0, markerExists=true, clean summary. Got exit=${result.code}, markerExists=${markerExists}, summary=${JSON.stringify(result.report?.summary)} stderr=${result.stderr}`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -153,24 +147,18 @@ export default handler;
|
||||
}
|
||||
}
|
||||
|
||||
async function testMaliciousHandlerIsNotExecutedForPayloadChecks() {
|
||||
const testName = "DAST harness: malicious payload checks do not execute hook code";
|
||||
async function testMaliciousCrashProducesHighFinding() {
|
||||
const testName = "DAST harness: malicious input crash is reported as high";
|
||||
const tmp = await createTempDir();
|
||||
|
||||
try {
|
||||
const targetPath = path.join(tmp.path, "skill");
|
||||
const hookDir = path.join(targetPath, "hooks", "crashy-hook");
|
||||
const markerFile = path.join(hookDir, "executed.marker");
|
||||
|
||||
await writeHookFixture(
|
||||
hookDir,
|
||||
'"message:preprocessed"',
|
||||
`import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
fs.writeFileSync(path.join(path.dirname(new URL(import.meta.url).pathname), "executed.marker"), "top-level");
|
||||
|
||||
const handler = async (event) => {
|
||||
`const handler = async (event) => {
|
||||
const payload = String(event?.context?.content || "");
|
||||
if (payload.includes("<script>")) {
|
||||
throw new Error("Unhandled payload path");
|
||||
@@ -182,21 +170,16 @@ export default handler;
|
||||
);
|
||||
|
||||
const result = await runDast(targetPath, 2500);
|
||||
const markerExists = await fs
|
||||
.access(markerFile)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
const noHigh = Number(result.report?.summary?.high || 0) === 0
|
||||
&& Number(result.report?.summary?.critical || 0) === 0;
|
||||
const hasStaticCoverageInfo = Array.isArray(result.report?.vulnerabilities)
|
||||
&& result.report.vulnerabilities.some((v) => String(v.id || "").includes("DAST-STATIC-COVERAGE"));
|
||||
const hasHigh = Number(result.report?.summary?.high || 0) > 0;
|
||||
const hasCrashFinding = Array.isArray(result.report?.vulnerabilities)
|
||||
&& result.report.vulnerabilities.some((v) => String(v.id || "").includes("DAST-MALICIOUS-CRASH"));
|
||||
|
||||
if (result.code === 0 && !markerExists && noHigh && hasStaticCoverageInfo) {
|
||||
if (result.code === 1 && hasHigh && hasCrashFinding) {
|
||||
pass(testName);
|
||||
} else {
|
||||
fail(
|
||||
testName,
|
||||
`Expected static inspection without marker/high findings. Got exit=${result.code}, markerExists=${markerExists}, summary=${JSON.stringify(result.report?.summary)}, findings=${JSON.stringify(result.report?.vulnerabilities || [])}`,
|
||||
`Expected exit=1 and malicious crash high finding. Got exit=${result.code}, summary=${JSON.stringify(result.report?.summary)}, findings=${JSON.stringify(result.report?.vulnerabilities || [])}`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -206,8 +189,8 @@ export default handler;
|
||||
}
|
||||
}
|
||||
|
||||
async function testTypeScriptHookIsStaticallyInspectedWithoutCompiler() {
|
||||
const testName = "DAST harness: TypeScript hooks are statically inspected without compiler execution";
|
||||
async function testMissingTypeScriptCompilerIsCoverageInfo() {
|
||||
const testName = "DAST harness: missing TypeScript compiler reports coverage info, not high";
|
||||
const tmp = await createTempDir();
|
||||
|
||||
try {
|
||||
@@ -237,7 +220,7 @@ export default handler;
|
||||
const noHigh = Number(result.report?.summary?.high || 0) === 0
|
||||
&& Number(result.report?.summary?.critical || 0) === 0;
|
||||
const hasCoverageInfo = Array.isArray(result.report?.vulnerabilities)
|
||||
&& result.report.vulnerabilities.some((v) => String(v.id || "").includes("DAST-STATIC-COVERAGE"));
|
||||
&& result.report.vulnerabilities.some((v) => String(v.id || "").includes("DAST-COVERAGE"));
|
||||
const hasInfoCount = Number(result.report?.summary?.info || 0) > 0;
|
||||
|
||||
if (result.code === 0 && noHigh && hasCoverageInfo && hasInfoCount) {
|
||||
@@ -255,76 +238,10 @@ export default handler;
|
||||
}
|
||||
}
|
||||
|
||||
async function testStaticInspectionRunsOncePerHook() {
|
||||
const testName = "DAST harness: static inspection runs once per hook across events";
|
||||
const tmp = await createTempDir();
|
||||
|
||||
try {
|
||||
const targetPath = path.join(tmp.path, "skill");
|
||||
const hookDir = path.join(targetPath, "hooks", "multi-event-hook");
|
||||
const binDir = path.join(tmp.path, "bin");
|
||||
const nodeLogPath = path.join(tmp.path, "node-invocations.log");
|
||||
|
||||
await writeHookFixture(
|
||||
hookDir,
|
||||
'"agent:bootstrap", "command:new", "message:preprocessed"',
|
||||
`export default async function handler() {
|
||||
return;
|
||||
}
|
||||
`,
|
||||
);
|
||||
|
||||
await fs.mkdir(binDir, { recursive: true });
|
||||
await writeExecutable(
|
||||
path.join(binDir, "node"),
|
||||
`#!${process.execPath}
|
||||
import fs from "node:fs";
|
||||
import { spawnSync } from "node:child_process";
|
||||
|
||||
fs.appendFileSync(${JSON.stringify(nodeLogPath)}, JSON.stringify(process.argv.slice(2)) + "\\n");
|
||||
const result = spawnSync(${JSON.stringify(process.execPath)}, process.argv.slice(2), {
|
||||
env: process.env,
|
||||
stdio: ["ignore", "inherit", "inherit"],
|
||||
});
|
||||
process.exit(result.status ?? 1);
|
||||
`,
|
||||
);
|
||||
|
||||
const result = await runDast(targetPath, 2500, {
|
||||
PATH: `${binDir}:${process.env.PATH}`,
|
||||
});
|
||||
|
||||
const log = await fs.readFile(nodeLogPath, "utf8");
|
||||
const invocations = log
|
||||
.trim()
|
||||
.split("\n")
|
||||
.filter(Boolean)
|
||||
.map((line) => JSON.parse(line));
|
||||
const executorCount = invocations.filter((args) => String(args[0] || "").endsWith("dast_hook_executor.mjs")).length;
|
||||
const staticCoverageCount = Array.isArray(result.report?.vulnerabilities)
|
||||
? result.report.vulnerabilities.filter((v) => String(v.id || "").includes("DAST-STATIC-COVERAGE")).length
|
||||
: 0;
|
||||
|
||||
if (result.code === 0 && executorCount === 1 && staticCoverageCount === 3) {
|
||||
pass(testName);
|
||||
} else {
|
||||
fail(
|
||||
testName,
|
||||
`Expected one executor spawn and three per-event findings. Got exit=${result.code}, executorCount=${executorCount}, staticCoverageCount=${staticCoverageCount}, invocations=${JSON.stringify(invocations)}`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
fail(testName, error);
|
||||
} finally {
|
||||
await tmp.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await testSafeHookIsInspectedWithoutExecution();
|
||||
await testMaliciousHandlerIsNotExecutedForPayloadChecks();
|
||||
await testTypeScriptHookIsStaticallyInspectedWithoutCompiler();
|
||||
await testStaticInspectionRunsOncePerHook();
|
||||
await testSafeHookExecutesAndDoesNotReportMisleadingHigh();
|
||||
await testMaliciousCrashProducesHighFinding();
|
||||
await testMissingTypeScriptCompilerIsCoverageInfo();
|
||||
|
||||
report();
|
||||
exitWithResults();
|
||||
|
||||
@@ -5,19 +5,6 @@ All notable changes to the ClawSec Suite 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.1.9] - 2026-05-24
|
||||
|
||||
### Changed
|
||||
|
||||
- Documented the remote advisory feed as a consolidated feed containing NVD CVEs, approved community advisories, and provisional GHSA-without-CVE records.
|
||||
- Added advisory guardian type coverage for GHSA lifecycle metadata used by the consolidated feed.
|
||||
|
||||
## [0.1.8] - 2026-05-16
|
||||
|
||||
### Fixed
|
||||
|
||||
- Added the advisory scope and suppression runtime helpers to `skill.json` SBOM metadata so release archives include every file required by the advisory guardian hook.
|
||||
|
||||
## [0.1.7] - 2026-04-16
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: clawsec-suite
|
||||
version: 0.1.9
|
||||
version: 0.1.7
|
||||
description: ClawSec suite manager with embedded advisory-feed monitoring, cryptographic signature verification, approval-gated malicious-skill response, and guided setup for additional security skills.
|
||||
homepage: https://clawsec.prompt.security
|
||||
clawdis:
|
||||
@@ -28,7 +28,7 @@ This means `clawsec-suite` can:
|
||||
## Included vs Optional Protections
|
||||
|
||||
### Built into clawsec-suite
|
||||
- Embedded consolidated advisory feed seed file: `advisories/feed.json`
|
||||
- Embedded feed seed file: `advisories/feed.json`
|
||||
- Portable heartbeat workflow in `HEARTBEAT.md`
|
||||
- Advisory polling + state tracking + affected-skill checks
|
||||
- OpenClaw advisory guardian hook package: `hooks/clawsec-advisory-guardian/`
|
||||
@@ -200,8 +200,7 @@ This enforces:
|
||||
|
||||
The embedded feed logic uses these defaults:
|
||||
|
||||
- Remote consolidated feed URL: `https://clawsec.prompt.security/advisories/feed.json`
|
||||
- Feed contents: NVD CVEs, approved community advisories, and provisional GHSA-without-CVE advisories.
|
||||
- Remote feed URL: `https://clawsec.prompt.security/advisories/feed.json`
|
||||
- Remote feed signature URL: `${CLAWSEC_FEED_URL}.sig` (override with `CLAWSEC_FEED_SIG_URL`)
|
||||
- Remote checksums manifest URL: sibling `checksums.json` (override with `CLAWSEC_FEED_CHECKSUMS_URL`)
|
||||
- Local seed fallback: `~/.openclaw/skills/clawsec-suite/advisories/feed.json`
|
||||
|
||||
@@ -6,11 +6,6 @@ export type HookEvent = {
|
||||
|
||||
export type Advisory = {
|
||||
id?: string;
|
||||
ghsa_id?: string;
|
||||
cve_id?: string | null;
|
||||
status?: string;
|
||||
stale?: boolean;
|
||||
source_feed?: string;
|
||||
severity?: string;
|
||||
type?: string;
|
||||
application?: string | string[];
|
||||
@@ -20,10 +15,6 @@ export type Advisory = {
|
||||
published?: string;
|
||||
updated?: string;
|
||||
affected?: string[];
|
||||
platforms?: string[];
|
||||
references?: string[];
|
||||
nvd_url?: string | null;
|
||||
github_advisory_url?: string;
|
||||
};
|
||||
|
||||
export type FeedPayload = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clawsec-suite",
|
||||
"version": "0.1.9",
|
||||
"version": "0.1.7",
|
||||
"description": "ClawSec suite manager with embedded advisory-feed monitoring, cryptographic signature verification, approval-gated malicious-skill response, and guided setup for additional security skills.",
|
||||
"author": "prompt-security",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
@@ -85,11 +85,6 @@
|
||||
"required": true,
|
||||
"description": "Shared semver parsing and version matching logic"
|
||||
},
|
||||
{
|
||||
"path": "hooks/clawsec-advisory-guardian/lib/advisory_scope.mjs",
|
||||
"required": true,
|
||||
"description": "Advisory application-scope filtering helper for OpenClaw-facing flows"
|
||||
},
|
||||
{
|
||||
"path": "hooks/clawsec-advisory-guardian/lib/feed.mjs",
|
||||
"required": true,
|
||||
@@ -115,11 +110,6 @@
|
||||
"required": true,
|
||||
"description": "Advisory-to-skill matching and alert message generation"
|
||||
},
|
||||
{
|
||||
"path": "hooks/clawsec-advisory-guardian/lib/suppression.mjs",
|
||||
"required": true,
|
||||
"description": "Advisory suppression loading and matching helpers"
|
||||
},
|
||||
{
|
||||
"path": "scripts/setup_advisory_hook.mjs",
|
||||
"required": true,
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [0.0.6] - 2026-05-14
|
||||
|
||||
### Security
|
||||
- Added explicit signed release artifact verification instructions for standalone installs, including `checksums.json`, `checksums.sig`, `signing-public.pem`, archive hash verification, and `SKILL.md`/`skill.json` checksum checks.
|
||||
|
||||
All notable changes to Clawtributor will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: clawtributor
|
||||
version: 0.0.6
|
||||
version: 0.0.5
|
||||
description: Community incident reporting for AI agents. Contribute to collective security by reporting threats.
|
||||
homepage: https://clawsec.prompt.security
|
||||
metadata: {"openclaw":{"emoji":"🤝","category":"security"}}
|
||||
@@ -44,86 +44,6 @@ I will keep reports local unless you explicitly approve submission.
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Release Artifact Verification
|
||||
|
||||
For standalone installs, verify the signed release manifest before trusting `SKILL.md`, `skill.json`, or the archive. The `skill.json` file is the package metadata/SBOM source, and the release pipeline signs `checksums.json` with the ClawSec release key.
|
||||
|
||||
```bash
|
||||
set -euo pipefail
|
||||
|
||||
SKILL_NAME="clawtributor"
|
||||
VERSION="0.0.6"
|
||||
REPO="prompt-security/clawsec"
|
||||
TAG="${SKILL_NAME}-v${VERSION}"
|
||||
BASE="https://github.com/${REPO}/releases/download/${TAG}"
|
||||
ZIP_NAME="${SKILL_NAME}-v${VERSION}.zip"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
RELEASE_PUBKEY_SHA256="711424e4535f84093fefb024cd1ca4ec87439e53907b305b79a631d5befba9c8"
|
||||
|
||||
curl -fsSL "$BASE/checksums.json" -o "$TMP_DIR/checksums.json"
|
||||
curl -fsSL "$BASE/checksums.sig" -o "$TMP_DIR/checksums.sig"
|
||||
curl -fsSL "$BASE/signing-public.pem" -o "$TMP_DIR/signing-public.pem"
|
||||
curl -fsSL "$BASE/$ZIP_NAME" -o "$TMP_DIR/$ZIP_NAME"
|
||||
curl -fsSL "$BASE/SKILL.md" -o "$TMP_DIR/SKILL.md"
|
||||
curl -fsSL "$BASE/skill.json" -o "$TMP_DIR/skill.json"
|
||||
|
||||
ACTUAL_PUBKEY_SHA256="$(openssl pkey -pubin -in "$TMP_DIR/signing-public.pem" -outform DER | shasum -a 256 | awk '{print $1}')"
|
||||
if [ "$ACTUAL_PUBKEY_SHA256" != "$RELEASE_PUBKEY_SHA256" ]; then
|
||||
echo "ERROR: signing-public.pem fingerprint mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openssl base64 -d -A -in "$TMP_DIR/checksums.sig" -out "$TMP_DIR/checksums.sig.bin"
|
||||
openssl pkeyutl -verify -rawin -pubin \
|
||||
-inkey "$TMP_DIR/signing-public.pem" \
|
||||
-sigfile "$TMP_DIR/checksums.sig.bin" \
|
||||
-in "$TMP_DIR/checksums.json" >/dev/null
|
||||
|
||||
hash_file() {
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$1" | awk '{print $1}'
|
||||
else
|
||||
sha256sum "$1" | awk '{print $1}'
|
||||
fi
|
||||
}
|
||||
|
||||
verify_manifest_file() {
|
||||
asset="$1"
|
||||
path="$2"
|
||||
expected="$(jq -r --arg asset "$asset" '.files[$asset].sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected" ]; then
|
||||
echo "ERROR: checksums.json missing $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual="$(hash_file "$path")"
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "ERROR: checksum mismatch for $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
expected_archive="$(jq -r '.archive.sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected_archive" ]; then
|
||||
echo "ERROR: checksums.json missing archive.sha256" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual_archive="$(hash_file "$TMP_DIR/$ZIP_NAME")"
|
||||
if [ "$actual_archive" != "$expected_archive" ]; then
|
||||
echo "ERROR: archive checksum mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
verify_manifest_file "SKILL.md" "$TMP_DIR/SKILL.md"
|
||||
verify_manifest_file "skill.json" "$TMP_DIR/skill.json"
|
||||
|
||||
echo "Signed release manifest, archive, SKILL.md, and skill.json verified."
|
||||
```
|
||||
|
||||
Only install or extract the archive after this verification succeeds.
|
||||
|
||||
## What Clawtributor Does
|
||||
|
||||
### Community-Driven Security Reporting
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clawtributor",
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.5",
|
||||
"description": "Community incident reporting for AI agents. Contribute to collective security by reporting threats.",
|
||||
"author": "prompt-security",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
|
||||
@@ -1,23 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [0.1.3] - 2026-05-24
|
||||
|
||||
### Changed
|
||||
- Documented that the default signed advisory feed is consolidated and may include NVD CVEs, approved community advisories, and provisional GHSA-without-CVE records while Hermes matching remains package-scoped.
|
||||
|
||||
## [0.1.2] - 2026-05-15
|
||||
|
||||
### Fixed
|
||||
- Included `lib/semver.mjs` and `lib/cron.mjs` in the release SBOM so signed archives contain every runtime library imported by shipped scripts.
|
||||
|
||||
## [0.1.1] - 2026-05-13
|
||||
|
||||
### Security
|
||||
- Added explicit signed release artifact verification instructions for standalone installs, including `checksums.json`, `checksums.sig`, `signing-public.pem`, archive hash verification, and `SKILL.md`/`skill.json` checksum checks.
|
||||
|
||||
### Changed
|
||||
- Re-release skill payload metadata after excluding test-only files from release SBOMs and archives.
|
||||
|
||||
## [0.1.0] - 2026-04-21
|
||||
|
||||
- Added mandatory release verification gate guidance before install: `checksums.json`, `checksums.sig`, and pinned signing public-key fingerprint.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: hermes-attestation-guardian
|
||||
version: 0.1.3
|
||||
version: 0.1.0
|
||||
description: Hermes-only runtime security attestation and drift detection skill for operator-managed Hermes infrastructure.
|
||||
homepage: https://clawsec.prompt.security
|
||||
hermes:
|
||||
@@ -15,90 +15,42 @@ IMPORTANT SCOPE:
|
||||
- This skill targets Hermes infrastructure only (CLI/Gateway/profile-managed deployments).
|
||||
- This skill is not an OpenClaw runtime hook package.
|
||||
|
||||
|
||||
## Release Artifact Verification
|
||||
|
||||
For standalone installs, verify the signed release manifest before trusting `SKILL.md`, `skill.json`, or the archive. The `skill.json` file is the package metadata/SBOM source, and the release pipeline signs `checksums.json` with the ClawSec release key.
|
||||
|
||||
```bash
|
||||
set -euo pipefail
|
||||
|
||||
SKILL_NAME="hermes-attestation-guardian"
|
||||
VERSION="0.1.3"
|
||||
REPO="prompt-security/clawsec"
|
||||
TAG="${SKILL_NAME}-v${VERSION}"
|
||||
BASE="https://github.com/${REPO}/releases/download/${TAG}"
|
||||
ZIP_NAME="${SKILL_NAME}-v${VERSION}.zip"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
RELEASE_PUBKEY_SHA256="711424e4535f84093fefb024cd1ca4ec87439e53907b305b79a631d5befba9c8"
|
||||
|
||||
curl -fsSL "$BASE/checksums.json" -o "$TMP_DIR/checksums.json"
|
||||
curl -fsSL "$BASE/checksums.sig" -o "$TMP_DIR/checksums.sig"
|
||||
curl -fsSL "$BASE/signing-public.pem" -o "$TMP_DIR/signing-public.pem"
|
||||
curl -fsSL "$BASE/$ZIP_NAME" -o "$TMP_DIR/$ZIP_NAME"
|
||||
curl -fsSL "$BASE/SKILL.md" -o "$TMP_DIR/SKILL.md"
|
||||
curl -fsSL "$BASE/skill.json" -o "$TMP_DIR/skill.json"
|
||||
|
||||
ACTUAL_PUBKEY_SHA256="$(openssl pkey -pubin -in "$TMP_DIR/signing-public.pem" -outform DER | shasum -a 256 | awk '{print $1}')"
|
||||
if [ "$ACTUAL_PUBKEY_SHA256" != "$RELEASE_PUBKEY_SHA256" ]; then
|
||||
echo "ERROR: signing-public.pem fingerprint mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openssl base64 -d -A -in "$TMP_DIR/checksums.sig" -out "$TMP_DIR/checksums.sig.bin"
|
||||
openssl pkeyutl -verify -rawin -pubin \
|
||||
-inkey "$TMP_DIR/signing-public.pem" \
|
||||
-sigfile "$TMP_DIR/checksums.sig.bin" \
|
||||
-in "$TMP_DIR/checksums.json" >/dev/null
|
||||
|
||||
hash_file() {
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$1" | awk '{print $1}'
|
||||
else
|
||||
sha256sum "$1" | awk '{print $1}'
|
||||
fi
|
||||
}
|
||||
|
||||
verify_manifest_file() {
|
||||
asset="$1"
|
||||
path="$2"
|
||||
expected="$(jq -r --arg asset "$asset" '.files[$asset].sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected" ]; then
|
||||
echo "ERROR: checksums.json missing $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual="$(hash_file "$path")"
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "ERROR: checksum mismatch for $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
expected_archive="$(jq -r '.archive.sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected_archive" ]; then
|
||||
echo "ERROR: checksums.json missing archive.sha256" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual_archive="$(hash_file "$TMP_DIR/$ZIP_NAME")"
|
||||
if [ "$actual_archive" != "$expected_archive" ]; then
|
||||
echo "ERROR: archive checksum mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
verify_manifest_file "SKILL.md" "$TMP_DIR/SKILL.md"
|
||||
verify_manifest_file "skill.json" "$TMP_DIR/skill.json"
|
||||
|
||||
echo "Signed release manifest, archive, SKILL.md, and skill.json verified."
|
||||
```
|
||||
|
||||
Only install or extract the archive after this verification succeeds.
|
||||
|
||||
## Goal
|
||||
|
||||
Generate deterministic Hermes posture attestations, verify them with fail-closed integrity checks, and compare baseline drift using stable severity mapping.
|
||||
|
||||
## Mandatory release verification gate (before install)
|
||||
|
||||
Before treating any release install instructions as valid, verify all three inputs:
|
||||
|
||||
1) `checksums.json`
|
||||
2) `checksums.sig`
|
||||
3) pinned signing public-key fingerprint
|
||||
|
||||
```bash
|
||||
BASE="https://github.com/prompt-security/clawsec/releases/download/hermes-attestation-guardian-v0.1.0"
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
curl -fsSL "$BASE/checksums.json" -o "$TMP/checksums.json"
|
||||
curl -fsSL "$BASE/checksums.sig" -o "$TMP/checksums.sig"
|
||||
curl -fsSL "$BASE/signing-public.pem" -o "$TMP/signing-public.pem"
|
||||
|
||||
[ -s "$TMP/checksums.json" ] || { echo "ERROR: missing checksums.json" >&2; exit 1; }
|
||||
[ -s "$TMP/checksums.sig" ] || { echo "ERROR: missing checksums.sig" >&2; exit 1; }
|
||||
|
||||
EXPECTED_PUBKEY_SHA256="711424e4535f84093fefb024cd1ca4ec87439e53907b305b79a631d5befba9c8"
|
||||
ACTUAL_PUBKEY_SHA256="$(openssl pkey -pubin -in "$TMP/signing-public.pem" -outform DER | sha256sum | awk '{print $1}')"
|
||||
[ "$ACTUAL_PUBKEY_SHA256" = "$EXPECTED_PUBKEY_SHA256" ] || {
|
||||
echo "ERROR: signing-public.pem fingerprint mismatch" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
openssl base64 -d -A -in "$TMP/checksums.sig" -out "$TMP/checksums.sig.bin"
|
||||
openssl pkeyutl -verify -rawin -pubin -inkey "$TMP/signing-public.pem" \
|
||||
-sigfile "$TMP/checksums.sig.bin" -in "$TMP/checksums.json" >/dev/null
|
||||
```
|
||||
|
||||
## Hermes guard trust policy note
|
||||
|
||||
When installing from community sources, configure Hermes guard to use signature-aware trust (trusted signer fingerprint allowlist) rather than source-name-only trust. Unknown signer fingerprints should stay on community policy, and invalid signatures must remain blocked.
|
||||
@@ -207,8 +159,6 @@ Severity messages are emitted as INFO / WARNING / CRITICAL style lines.
|
||||
|
||||
## Advisory feed override knobs
|
||||
|
||||
The default signed advisory feed is consolidated: it can contain NVD CVEs, approved community advisories, and provisional GHSA-without-CVE records. Hermes matching still gates on affected package names and supported version ranges.
|
||||
|
||||
- Source selection: `HERMES_ADVISORY_FEED_SOURCE=auto|remote|local`
|
||||
- Remote artifacts: `HERMES_ADVISORY_FEED_URL`, `HERMES_ADVISORY_FEED_SIG_URL`, `HERMES_ADVISORY_FEED_CHECKSUMS_URL`, `HERMES_ADVISORY_FEED_CHECKSUMS_SIG_URL`
|
||||
- Local artifacts: `HERMES_LOCAL_ADVISORY_FEED`, `HERMES_LOCAL_ADVISORY_FEED_SIG`, `HERMES_LOCAL_ADVISORY_FEED_CHECKSUMS`, `HERMES_LOCAL_ADVISORY_FEED_CHECKSUMS_SIG`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hermes-attestation-guardian",
|
||||
"version": "0.1.3",
|
||||
"version": "0.1.0",
|
||||
"description": "Hermes-only runtime security attestation and drift detection skill. Generates deterministic posture artifacts, verifies integrity fail-closed, and classifies baseline drift severity.",
|
||||
"author": "prompt-security",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
@@ -46,16 +46,6 @@
|
||||
"required": true,
|
||||
"description": "Hermes-native advisory feed verification and state helpers"
|
||||
},
|
||||
{
|
||||
"path": "lib/semver.mjs",
|
||||
"required": true,
|
||||
"description": "Advisory version-range parsing and matching helpers"
|
||||
},
|
||||
{
|
||||
"path": "lib/cron.mjs",
|
||||
"required": true,
|
||||
"description": "Shared managed cron block and cadence helpers"
|
||||
},
|
||||
{
|
||||
"path": "scripts/generate_attestation.mjs",
|
||||
"required": true,
|
||||
@@ -90,6 +80,46 @@
|
||||
"path": "scripts/setup_advisory_check_cron.mjs",
|
||||
"required": true,
|
||||
"description": "Optional recurring schedule setup for Hermes guarded advisory checks"
|
||||
},
|
||||
{
|
||||
"path": "test/attestation_schema.test.mjs",
|
||||
"required": false,
|
||||
"description": "Schema and determinism tests"
|
||||
},
|
||||
{
|
||||
"path": "test/attestation_diff.test.mjs",
|
||||
"required": false,
|
||||
"description": "Diff and severity mapping tests"
|
||||
},
|
||||
{
|
||||
"path": "test/attestation_cli.test.mjs",
|
||||
"required": false,
|
||||
"description": "Generator/verifier CLI behavior tests"
|
||||
},
|
||||
{
|
||||
"path": "test/setup_attestation_cron.test.mjs",
|
||||
"required": false,
|
||||
"description": "Hermes-only cron setup tests"
|
||||
},
|
||||
{
|
||||
"path": "test/setup_advisory_check_cron.test.mjs",
|
||||
"required": false,
|
||||
"description": "Hermes-only guarded advisory cron setup tests"
|
||||
},
|
||||
{
|
||||
"path": "test/feed_verification.test.mjs",
|
||||
"required": false,
|
||||
"description": "Advisory feed signature/checksum verification behavior tests"
|
||||
},
|
||||
{
|
||||
"path": "test/guarded_skill_verify.test.mjs",
|
||||
"required": false,
|
||||
"description": "Advisory-aware guarded verification gate behavior tests"
|
||||
},
|
||||
{
|
||||
"path": "test/hermes_attestation_sandbox_regression.sh",
|
||||
"required": false,
|
||||
"description": "Sandboxed end-to-end regression harness for install and verification paths"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## [0.0.1-beta2] - 2026-05-13
|
||||
|
||||
### Security
|
||||
- Added explicit signed release artifact verification instructions for standalone installs, including `checksums.json`, `checksums.sig`, `signing-public.pem`, archive hash verification, and `SKILL.md`/`skill.json` checksum checks.
|
||||
|
||||
### Changed
|
||||
- Re-release skill payload metadata after excluding test-only files from release SBOMs and archives.
|
||||
|
||||
## [0.0.1-beta1] - 2026-05-10
|
||||
|
||||
- Added baseline skill metadata, frontmatter, and implementation specification.
|
||||
- Reserved folder structure for Hermes traffic-monitoring runtime code, posture export, and tests.
|
||||
- Beta release notes: this release is a scaffold/spec baseline and does not yet ship active runtime proxy interception.
|
||||
- Beta release notes: defaults remain non-invasive (no automatic traffic mutation or enforcement enabled by default).
|
||||
@@ -1,18 +0,0 @@
|
||||
# Hermes Traffic Guardian
|
||||
|
||||
Baseline skill for Hermes runtime traffic monitoring.
|
||||
|
||||
This package is intentionally a spec scaffold. Builders should add the Hermes-specific monitor implementation here while preserving the safety contract in `SKILL.md` and `SPEC.md`.
|
||||
|
||||
## Intended Capability
|
||||
|
||||
- detect outbound secret exfiltration in Hermes HTTP/HTTPS traffic
|
||||
- detect inbound command-injection and tool-abuse payloads
|
||||
- write redacted local JSONL findings
|
||||
- export monitor posture for `hermes-attestation-guardian`
|
||||
- provide explicit start, stop, status, and log-query commands
|
||||
|
||||
## Builder Notes
|
||||
|
||||
Keep runtime ownership in this skill. `hermes-attestation-guardian` should only attest this skill's state, config, and output fingerprints.
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
---
|
||||
name: hermes-traffic-guardian
|
||||
version: 0.0.1-beta2
|
||||
description: Hermes runtime traffic monitoring baseline for opt-in proxy inspection, egress detection, and attestation-aware traffic posture.
|
||||
homepage: https://clawsec.prompt.security
|
||||
author: prompt-security
|
||||
license: AGPL-3.0-or-later
|
||||
hermes:
|
||||
emoji: "TG"
|
||||
requires:
|
||||
bins: [node, python3]
|
||||
---
|
||||
|
||||
# Hermes Traffic Guardian
|
||||
|
||||
This is a baseline specification skill. It intentionally does not ship a proxy or runtime implementation yet.
|
||||
|
||||
|
||||
## Release Artifact Verification
|
||||
|
||||
For standalone installs, verify the signed release manifest before trusting `SKILL.md`, `skill.json`, or the archive. The `skill.json` file is the package metadata/SBOM source, and the release pipeline signs `checksums.json` with the ClawSec release key.
|
||||
|
||||
```bash
|
||||
set -euo pipefail
|
||||
|
||||
SKILL_NAME="hermes-traffic-guardian"
|
||||
VERSION="0.0.1-beta2"
|
||||
REPO="prompt-security/clawsec"
|
||||
TAG="${SKILL_NAME}-v${VERSION}"
|
||||
BASE="https://github.com/${REPO}/releases/download/${TAG}"
|
||||
ZIP_NAME="${SKILL_NAME}-v${VERSION}.zip"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
RELEASE_PUBKEY_SHA256="711424e4535f84093fefb024cd1ca4ec87439e53907b305b79a631d5befba9c8"
|
||||
|
||||
curl -fsSL "$BASE/checksums.json" -o "$TMP_DIR/checksums.json"
|
||||
curl -fsSL "$BASE/checksums.sig" -o "$TMP_DIR/checksums.sig"
|
||||
curl -fsSL "$BASE/signing-public.pem" -o "$TMP_DIR/signing-public.pem"
|
||||
curl -fsSL "$BASE/$ZIP_NAME" -o "$TMP_DIR/$ZIP_NAME"
|
||||
curl -fsSL "$BASE/SKILL.md" -o "$TMP_DIR/SKILL.md"
|
||||
curl -fsSL "$BASE/skill.json" -o "$TMP_DIR/skill.json"
|
||||
|
||||
ACTUAL_PUBKEY_SHA256="$(openssl pkey -pubin -in "$TMP_DIR/signing-public.pem" -outform DER | shasum -a 256 | awk '{print $1}')"
|
||||
if [ "$ACTUAL_PUBKEY_SHA256" != "$RELEASE_PUBKEY_SHA256" ]; then
|
||||
echo "ERROR: signing-public.pem fingerprint mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openssl base64 -d -A -in "$TMP_DIR/checksums.sig" -out "$TMP_DIR/checksums.sig.bin"
|
||||
openssl pkeyutl -verify -rawin -pubin \
|
||||
-inkey "$TMP_DIR/signing-public.pem" \
|
||||
-sigfile "$TMP_DIR/checksums.sig.bin" \
|
||||
-in "$TMP_DIR/checksums.json" >/dev/null
|
||||
|
||||
hash_file() {
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$1" | awk '{print $1}'
|
||||
else
|
||||
sha256sum "$1" | awk '{print $1}'
|
||||
fi
|
||||
}
|
||||
|
||||
verify_manifest_file() {
|
||||
asset="$1"
|
||||
path="$2"
|
||||
expected="$(jq -r --arg asset "$asset" '.files[$asset].sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected" ]; then
|
||||
echo "ERROR: checksums.json missing $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual="$(hash_file "$path")"
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "ERROR: checksum mismatch for $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
expected_archive="$(jq -r '.archive.sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected_archive" ]; then
|
||||
echo "ERROR: checksums.json missing archive.sha256" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual_archive="$(hash_file "$TMP_DIR/$ZIP_NAME")"
|
||||
if [ "$actual_archive" != "$expected_archive" ]; then
|
||||
echo "ERROR: archive checksum mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
verify_manifest_file "SKILL.md" "$TMP_DIR/SKILL.md"
|
||||
verify_manifest_file "skill.json" "$TMP_DIR/skill.json"
|
||||
|
||||
echo "Signed release manifest, archive, SKILL.md, and skill.json verified."
|
||||
```
|
||||
|
||||
Only install or extract the archive after this verification succeeds.
|
||||
|
||||
## Scope
|
||||
|
||||
Builders should use this skill as the Hermes landing zone for runtime traffic monitoring:
|
||||
|
||||
- operator-scoped HTTP proxy inspection
|
||||
- optional HTTPS inspection with per-process CA trust
|
||||
- outbound exfiltration detection
|
||||
- inbound injection detection
|
||||
- redacted local threat logs
|
||||
- status export for `hermes-attestation-guardian`
|
||||
|
||||
Do not add proxy runtime ownership to `hermes-attestation-guardian`. That skill should attest this monitor's status and configuration, not run it.
|
||||
|
||||
## Safety Contract
|
||||
|
||||
- Opt-in only.
|
||||
- Detect-and-log by default.
|
||||
- No automatic system CA installation.
|
||||
- No global proxy environment changes.
|
||||
- No blocking in the first implementation.
|
||||
- Redact secrets before logs, summaries, or attestation-linked outputs.
|
||||
- Keep all state under `HERMES_TRAFFIC_GUARDIAN_HOME` or `$HERMES_HOME/security/traffic-guardian`.
|
||||
|
||||
## Builder Entry Points
|
||||
|
||||
Read `SPEC.md` before implementing. Use the placeholder folders as follows:
|
||||
|
||||
| Path | Intended use |
|
||||
|---|---|
|
||||
| `lib/` | Detector rules, redaction, posture export, report formatting |
|
||||
| `scripts/` | Start, stop, status, config validation, log query, attestation export helpers |
|
||||
| `test/` | Unit tests, proxy fixture tests, redaction tests, attestation export tests |
|
||||
|
||||
## Required First Implementation Behavior
|
||||
|
||||
1. Validate config without starting the proxy.
|
||||
2. Start monitor in foreground or explicit background mode.
|
||||
3. Scope proxy environment variables to the target Hermes service or CLI process.
|
||||
4. Inspect HTTP request/response text up to a bounded byte limit.
|
||||
5. Support optional HTTPS MITM only when the operator supplies per-process trust configuration.
|
||||
6. Emit JSONL findings with redacted snippets.
|
||||
7. Export a small posture JSON file that `hermes-attestation-guardian` can include as a trust anchor or watched file.
|
||||
|
||||
## Out of Scope for v0.0.1 Implementation
|
||||
|
||||
- automatic system trust-store mutation
|
||||
- transparent network interception
|
||||
- default blocking
|
||||
- sending traffic to external services
|
||||
- collecting full request/response bodies
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
# Hermes Traffic Guardian Specification
|
||||
|
||||
## Goal
|
||||
|
||||
Provide Hermes with opt-in runtime traffic monitoring that observes Hermes HTTP/HTTPS traffic for exfiltration and injection signals and exports monitor posture for attestation.
|
||||
|
||||
## Required Architecture
|
||||
|
||||
Implement three layers:
|
||||
|
||||
1. Detector core
|
||||
- normalized finding schema
|
||||
- pattern registry
|
||||
- snippet redaction
|
||||
- deduplication
|
||||
- JSONL report writer
|
||||
|
||||
2. Hermes adapter
|
||||
- lifecycle commands for start, stop, status, and threats
|
||||
- process-scoped proxy environment guidance
|
||||
- posture export compatible with `hermes-attestation-guardian`
|
||||
|
||||
3. Operator interface
|
||||
- safe setup text
|
||||
- explicit per-process proxy export commands
|
||||
- CA fingerprint display when HTTPS inspection is enabled
|
||||
|
||||
## Finding Schema
|
||||
|
||||
Findings must be JSON objects with these fields:
|
||||
|
||||
```json
|
||||
{
|
||||
"schema_version": "clawsec-traffic-finding/v1",
|
||||
"platform": "hermes",
|
||||
"direction": "outbound",
|
||||
"protocol": "http",
|
||||
"threat_type": "EXFIL",
|
||||
"pattern": "ai_api_key",
|
||||
"severity": "high",
|
||||
"source": "127.0.0.1",
|
||||
"dest": "api.example.com:443",
|
||||
"snippet": "[REDACTED]",
|
||||
"timestamp": "2026-04-26T00:00:00.000Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Posture Export Schema
|
||||
|
||||
The first implementation must write a small posture file for attestation:
|
||||
|
||||
```json
|
||||
{
|
||||
"schema_version": "clawsec-traffic-posture/v1",
|
||||
"platform": "hermes",
|
||||
"monitor_status": "running",
|
||||
"mode": "detect",
|
||||
"https_inspection": false,
|
||||
"ca_fingerprint_sha256": null,
|
||||
"config_sha256": "hex",
|
||||
"finding_log_sha256": "hex",
|
||||
"generated_at": "2026-04-26T00:00:00.000Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Minimum Detection Set
|
||||
|
||||
Outbound EXFIL:
|
||||
|
||||
- AI API keys
|
||||
- AWS access key IDs
|
||||
- private key PEM markers
|
||||
- SSH key file paths
|
||||
- sensitive Unix file paths
|
||||
- dotenv and cloud credential paths
|
||||
|
||||
Inbound INJECTION:
|
||||
|
||||
- pipe-to-shell commands
|
||||
- shell exec flags
|
||||
- reverse shell command shapes
|
||||
- destructive remove commands
|
||||
- SSH authorized-key injection shapes
|
||||
|
||||
## Safety Requirements
|
||||
|
||||
- Default mode is detect-and-log.
|
||||
- Blocking mode must not exist in the first implementation.
|
||||
- Snippets must be redacted before persistence.
|
||||
- Maximum scan bytes must be configurable and bounded.
|
||||
- CA trust must be per-process by default.
|
||||
- System trust-store instructions must require explicit operator confirmation and must never run automatically.
|
||||
|
||||
## Tests Required Before Release
|
||||
|
||||
- detector unit tests for each pattern
|
||||
- redaction tests proving secrets are not persisted
|
||||
- proxy fixture tests for HTTP request and response inspection
|
||||
- no-false-positive tests for common benign traffic
|
||||
- lifecycle tests for stale PID/state cleanup
|
||||
- posture export schema and digest tests
|
||||
- compatibility tests showing `hermes-attestation-guardian` can watch or hash the posture export
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
{
|
||||
"name": "hermes-traffic-guardian",
|
||||
"version": "0.0.1-beta2",
|
||||
"description": "Hermes runtime traffic monitoring baseline for opt-in proxy inspection, egress detection, and attestation-aware traffic posture.",
|
||||
"author": "prompt-security",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"homepage": "https://clawsec.prompt.security/",
|
||||
"platform": "hermes",
|
||||
"keywords": [
|
||||
"security",
|
||||
"hermes",
|
||||
"traffic-monitoring",
|
||||
"egress",
|
||||
"exfiltration",
|
||||
"injection",
|
||||
"proxy",
|
||||
"mitm",
|
||||
"attestation",
|
||||
"runtime"
|
||||
],
|
||||
"sbom": {
|
||||
"files": [
|
||||
{
|
||||
"path": "SKILL.md",
|
||||
"required": true,
|
||||
"description": "Hermes traffic guardian skill instructions and operating model"
|
||||
},
|
||||
{
|
||||
"path": "README.md",
|
||||
"required": true,
|
||||
"description": "Human-oriented overview and builder handoff notes"
|
||||
},
|
||||
{
|
||||
"path": "CHANGELOG.md",
|
||||
"required": true,
|
||||
"description": "Version history and baseline release notes"
|
||||
},
|
||||
{
|
||||
"path": "SPEC.md",
|
||||
"required": true,
|
||||
"description": "Implementation specification for Hermes runtime traffic monitoring"
|
||||
},
|
||||
{
|
||||
"path": "lib/.gitkeep",
|
||||
"required": false,
|
||||
"description": "Placeholder for shared detector, posture, and report code"
|
||||
},
|
||||
{
|
||||
"path": "scripts/.gitkeep",
|
||||
"required": false,
|
||||
"description": "Placeholder for lifecycle, status, and attestation export scripts"
|
||||
}
|
||||
]
|
||||
},
|
||||
"hermes": {
|
||||
"emoji": "TG",
|
||||
"category": "security",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"node",
|
||||
"python3"
|
||||
]
|
||||
},
|
||||
"runtime": {
|
||||
"required_env": [],
|
||||
"optional_env": [
|
||||
"HERMES_TRAFFIC_GUARDIAN_HOME",
|
||||
"HERMES_TRAFFIC_GUARDIAN_CONFIG",
|
||||
"HERMES_TRAFFIC_GUARDIAN_MODE",
|
||||
"HERMES_TRAFFIC_GUARDIAN_PROXY_URL",
|
||||
"HERMES_TRAFFIC_GUARDIAN_CA_BUNDLE",
|
||||
"HERMES_TRAFFIC_GUARDIAN_LOG_DIR",
|
||||
"HERMES_TRAFFIC_GUARDIAN_MAX_SCAN_BYTES",
|
||||
"HERMES_TRAFFIC_GUARDIAN_REDACT_SNIPPETS",
|
||||
"HERMES_TRAFFIC_GUARDIAN_ATTESTATION_OUTPUT"
|
||||
]
|
||||
},
|
||||
"capabilities": {
|
||||
"runtime_traffic_monitoring": "spec_baseline",
|
||||
"http_proxy_inspection": "planned",
|
||||
"https_mitm_inspection": "planned_optional",
|
||||
"egress_exfiltration_detection": "planned",
|
||||
"inbound_injection_detection": "planned",
|
||||
"attestation_export": "planned",
|
||||
"blocking": "future_version"
|
||||
},
|
||||
"execution": {
|
||||
"always": false,
|
||||
"persistence": "Spec baseline only. Builders must keep monitoring opt-in and scheduler-free unless an operator explicitly applies one.",
|
||||
"network_egress": "Future runtime will proxy operator-scoped Hermes traffic. No runtime network behavior is implemented in v0.0.1."
|
||||
},
|
||||
"operator_review": [
|
||||
"Do not merge proxy runtime into hermes-attestation-guardian.",
|
||||
"Export traffic-monitor status for hermes-attestation-guardian to attest, but keep runtime ownership in this skill.",
|
||||
"Do not install a system-wide CA automatically.",
|
||||
"Default to detect-and-log mode; blocking is out of scope for v0.0.1 implementation.",
|
||||
"Redact secret snippets before writing logs or attestation-linked summaries."
|
||||
],
|
||||
"triggers": [
|
||||
"hermes traffic guardian",
|
||||
"hermes traffic monitoring",
|
||||
"monitor hermes egress",
|
||||
"inspect hermes http traffic",
|
||||
"attest hermes traffic monitor"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## [0.0.1-beta2] - 2026-05-13
|
||||
|
||||
### Security
|
||||
- Added explicit signed release artifact verification instructions for standalone installs, including `checksums.json`, `checksums.sig`, `signing-public.pem`, archive hash verification, and `SKILL.md`/`skill.json` checksum checks.
|
||||
|
||||
### Changed
|
||||
- Re-release skill payload metadata after excluding test-only files from release SBOMs and archives.
|
||||
|
||||
## [0.0.1-beta1] - 2026-05-10
|
||||
|
||||
- Added baseline skill metadata, frontmatter, and implementation specification.
|
||||
- Reserved folder structure for NanoClaw host services, MCP tools, detector code, and tests.
|
||||
- Beta release notes: this release is a scaffold/spec baseline and does not yet ship active runtime proxy interception.
|
||||
- Beta release notes: host-service and MCP contracts are defined, but detection/enforcement behavior is not active by default.
|
||||
@@ -1,18 +0,0 @@
|
||||
# NanoClaw Traffic Guardian
|
||||
|
||||
Baseline skill for NanoClaw runtime traffic monitoring.
|
||||
|
||||
This package is intentionally a spec scaffold. Builders should add the NanoClaw-specific host-service, IPC, and MCP implementation here while preserving the safety contract in `SKILL.md` and `SPEC.md`.
|
||||
|
||||
## Intended Capability
|
||||
|
||||
- detect outbound secret exfiltration in NanoClaw host-managed traffic
|
||||
- detect inbound command-injection and tool-abuse payloads
|
||||
- keep CA private key material outside the container
|
||||
- expose redacted status/findings through MCP tools
|
||||
- provide explicit host-side lifecycle controls
|
||||
|
||||
## Builder Notes
|
||||
|
||||
Follow the existing `clawsec-nanoclaw` pattern: host services own privileged operations, while MCP tools expose bounded requests and redacted responses.
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
---
|
||||
name: nanoclaw-traffic-guardian
|
||||
version: 0.0.1-beta2
|
||||
description: NanoClaw runtime traffic monitoring baseline for host-side proxy inspection with container-safe MCP and IPC status surfaces.
|
||||
homepage: https://clawsec.prompt.security
|
||||
author: prompt-security
|
||||
license: AGPL-3.0-or-later
|
||||
nanoclaw:
|
||||
requires:
|
||||
node: ">=18.0.0"
|
||||
---
|
||||
|
||||
# NanoClaw Traffic Guardian
|
||||
|
||||
This is a baseline specification skill. It intentionally does not ship a proxy or runtime implementation yet.
|
||||
|
||||
|
||||
## Release Artifact Verification
|
||||
|
||||
For standalone installs, verify the signed release manifest before trusting `SKILL.md`, `skill.json`, or the archive. The `skill.json` file is the package metadata/SBOM source, and the release pipeline signs `checksums.json` with the ClawSec release key.
|
||||
|
||||
```bash
|
||||
set -euo pipefail
|
||||
|
||||
SKILL_NAME="nanoclaw-traffic-guardian"
|
||||
VERSION="0.0.1-beta2"
|
||||
REPO="prompt-security/clawsec"
|
||||
TAG="${SKILL_NAME}-v${VERSION}"
|
||||
BASE="https://github.com/${REPO}/releases/download/${TAG}"
|
||||
ZIP_NAME="${SKILL_NAME}-v${VERSION}.zip"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
RELEASE_PUBKEY_SHA256="711424e4535f84093fefb024cd1ca4ec87439e53907b305b79a631d5befba9c8"
|
||||
|
||||
curl -fsSL "$BASE/checksums.json" -o "$TMP_DIR/checksums.json"
|
||||
curl -fsSL "$BASE/checksums.sig" -o "$TMP_DIR/checksums.sig"
|
||||
curl -fsSL "$BASE/signing-public.pem" -o "$TMP_DIR/signing-public.pem"
|
||||
curl -fsSL "$BASE/$ZIP_NAME" -o "$TMP_DIR/$ZIP_NAME"
|
||||
curl -fsSL "$BASE/SKILL.md" -o "$TMP_DIR/SKILL.md"
|
||||
curl -fsSL "$BASE/skill.json" -o "$TMP_DIR/skill.json"
|
||||
|
||||
ACTUAL_PUBKEY_SHA256="$(openssl pkey -pubin -in "$TMP_DIR/signing-public.pem" -outform DER | shasum -a 256 | awk '{print $1}')"
|
||||
if [ "$ACTUAL_PUBKEY_SHA256" != "$RELEASE_PUBKEY_SHA256" ]; then
|
||||
echo "ERROR: signing-public.pem fingerprint mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openssl base64 -d -A -in "$TMP_DIR/checksums.sig" -out "$TMP_DIR/checksums.sig.bin"
|
||||
openssl pkeyutl -verify -rawin -pubin \
|
||||
-inkey "$TMP_DIR/signing-public.pem" \
|
||||
-sigfile "$TMP_DIR/checksums.sig.bin" \
|
||||
-in "$TMP_DIR/checksums.json" >/dev/null
|
||||
|
||||
hash_file() {
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$1" | awk '{print $1}'
|
||||
else
|
||||
sha256sum "$1" | awk '{print $1}'
|
||||
fi
|
||||
}
|
||||
|
||||
verify_manifest_file() {
|
||||
asset="$1"
|
||||
path="$2"
|
||||
expected="$(jq -r --arg asset "$asset" '.files[$asset].sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected" ]; then
|
||||
echo "ERROR: checksums.json missing $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual="$(hash_file "$path")"
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "ERROR: checksum mismatch for $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
expected_archive="$(jq -r '.archive.sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected_archive" ]; then
|
||||
echo "ERROR: checksums.json missing archive.sha256" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual_archive="$(hash_file "$TMP_DIR/$ZIP_NAME")"
|
||||
if [ "$actual_archive" != "$expected_archive" ]; then
|
||||
echo "ERROR: archive checksum mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
verify_manifest_file "SKILL.md" "$TMP_DIR/SKILL.md"
|
||||
verify_manifest_file "skill.json" "$TMP_DIR/skill.json"
|
||||
|
||||
echo "Signed release manifest, archive, SKILL.md, and skill.json verified."
|
||||
```
|
||||
|
||||
Only install or extract the archive after this verification succeeds.
|
||||
|
||||
## Scope
|
||||
|
||||
Builders should use this skill as the NanoClaw landing zone for runtime traffic monitoring:
|
||||
|
||||
- host-side HTTP proxy inspection
|
||||
- optional HTTPS inspection with host-held CA material
|
||||
- outbound exfiltration detection
|
||||
- inbound injection detection
|
||||
- redacted local threat logs
|
||||
- MCP tools for status, findings, and config checks
|
||||
- IPC handlers for container-safe host communication
|
||||
|
||||
Prefer this as an optional companion to `clawsec-nanoclaw`, not as a mandatory extension of the existing advisory/signature/integrity suite.
|
||||
|
||||
## Safety Contract
|
||||
|
||||
- Opt-in only.
|
||||
- Detect-and-log by default.
|
||||
- No automatic system CA installation.
|
||||
- No CA private key access from the container.
|
||||
- No blocking in the first implementation.
|
||||
- Redact secrets before logs or MCP responses.
|
||||
- Keep all state under `NANOCLAW_TRAFFIC_GUARDIAN_HOME` or the host-managed NanoClaw security data directory.
|
||||
|
||||
## Builder Entry Points
|
||||
|
||||
Read `SPEC.md` before implementing. Use the placeholder folders as follows:
|
||||
|
||||
| Path | Intended use |
|
||||
|---|---|
|
||||
| `lib/` | Detector rules, redaction, types, report formatting |
|
||||
| `host-services/` | Host-side proxy lifecycle, log access, IPC handlers |
|
||||
| `mcp-tools/` | Container-side MCP tools for status and findings |
|
||||
| `test/` | Unit tests, host/container IPC tests, redaction tests |
|
||||
|
||||
## Required First Implementation Behavior
|
||||
|
||||
1. Validate config without starting the proxy.
|
||||
2. Start monitor through a host-managed lifecycle path.
|
||||
3. Keep CA key material on the host side.
|
||||
4. Inspect HTTP request/response text up to a bounded byte limit.
|
||||
5. Support optional HTTPS MITM only when the operator supplies per-runtime trust configuration.
|
||||
6. Emit JSONL findings with redacted snippets.
|
||||
7. Expose MCP tools that return status and redacted findings only.
|
||||
|
||||
## Out of Scope for v0.0.1 Implementation
|
||||
|
||||
- automatic system trust-store mutation
|
||||
- transparent network interception
|
||||
- default blocking
|
||||
- sending traffic to external services
|
||||
- exposing raw request/response bodies to the container
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
# NanoClaw Traffic Guardian Specification
|
||||
|
||||
## Goal
|
||||
|
||||
Provide NanoClaw with opt-in runtime traffic monitoring that observes host-managed NanoClaw traffic for exfiltration and injection signals while preserving container isolation.
|
||||
|
||||
## Required Architecture
|
||||
|
||||
Implement four layers:
|
||||
|
||||
1. Detector core
|
||||
- normalized finding schema
|
||||
- pattern registry
|
||||
- snippet redaction
|
||||
- deduplication
|
||||
- JSONL report writer
|
||||
|
||||
2. Host service
|
||||
- proxy lifecycle
|
||||
- CA key ownership
|
||||
- log storage
|
||||
- config validation
|
||||
- IPC task handling
|
||||
|
||||
3. MCP tool surface
|
||||
- `clawsec_traffic_status`
|
||||
- `clawsec_traffic_findings`
|
||||
- `clawsec_traffic_check_config`
|
||||
|
||||
4. Operator interface
|
||||
- safe setup text
|
||||
- explicit host/container proxy wiring guidance
|
||||
- CA fingerprint display when HTTPS inspection is enabled
|
||||
|
||||
## Finding Schema
|
||||
|
||||
Findings must be JSON objects with these fields:
|
||||
|
||||
```json
|
||||
{
|
||||
"schema_version": "clawsec-traffic-finding/v1",
|
||||
"platform": "nanoclaw",
|
||||
"direction": "outbound",
|
||||
"protocol": "http",
|
||||
"threat_type": "EXFIL",
|
||||
"pattern": "ai_api_key",
|
||||
"severity": "high",
|
||||
"source": "127.0.0.1",
|
||||
"dest": "api.example.com:443",
|
||||
"snippet": "[REDACTED]",
|
||||
"timestamp": "2026-04-26T00:00:00.000Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Minimum Detection Set
|
||||
|
||||
Outbound EXFIL:
|
||||
|
||||
- AI API keys
|
||||
- AWS access key IDs
|
||||
- private key PEM markers
|
||||
- SSH key file paths
|
||||
- sensitive Unix file paths
|
||||
- dotenv and cloud credential paths
|
||||
- WhatsApp session or credential path markers when NanoClaw exposes stable names
|
||||
|
||||
Inbound INJECTION:
|
||||
|
||||
- pipe-to-shell commands
|
||||
- shell exec flags
|
||||
- reverse shell command shapes
|
||||
- destructive remove commands
|
||||
- SSH authorized-key injection shapes
|
||||
|
||||
## Safety Requirements
|
||||
|
||||
- Default mode is detect-and-log.
|
||||
- Blocking mode must not exist in the first implementation.
|
||||
- Snippets must be redacted before persistence and before MCP responses.
|
||||
- Maximum scan bytes must be configurable and bounded.
|
||||
- CA private key material must stay host-side.
|
||||
- System trust-store instructions must require explicit operator confirmation and must never run automatically.
|
||||
|
||||
## Tests Required Before Release
|
||||
|
||||
- detector unit tests for each pattern
|
||||
- redaction tests proving secrets are not persisted or returned through MCP
|
||||
- host-service lifecycle tests
|
||||
- IPC timeout and malformed-task tests
|
||||
- MCP schema tests
|
||||
- proxy fixture tests for HTTP request and response inspection
|
||||
- no-false-positive tests for common benign traffic
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
{
|
||||
"name": "nanoclaw-traffic-guardian",
|
||||
"version": "0.0.1-beta2",
|
||||
"description": "NanoClaw runtime traffic monitoring baseline for host-side proxy inspection with container-safe MCP and IPC status surfaces.",
|
||||
"author": "prompt-security",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"homepage": "https://clawsec.prompt.security/",
|
||||
"platform": "nanoclaw",
|
||||
"keywords": [
|
||||
"security",
|
||||
"nanoclaw",
|
||||
"traffic-monitoring",
|
||||
"egress",
|
||||
"exfiltration",
|
||||
"injection",
|
||||
"proxy",
|
||||
"mitm",
|
||||
"mcp",
|
||||
"container"
|
||||
],
|
||||
"sbom": {
|
||||
"files": [
|
||||
{
|
||||
"path": "SKILL.md",
|
||||
"required": true,
|
||||
"description": "NanoClaw traffic guardian skill instructions and operating model"
|
||||
},
|
||||
{
|
||||
"path": "README.md",
|
||||
"required": true,
|
||||
"description": "Human-oriented overview and builder handoff notes"
|
||||
},
|
||||
{
|
||||
"path": "CHANGELOG.md",
|
||||
"required": true,
|
||||
"description": "Version history and baseline release notes"
|
||||
},
|
||||
{
|
||||
"path": "SPEC.md",
|
||||
"required": true,
|
||||
"description": "Implementation specification for NanoClaw runtime traffic monitoring"
|
||||
},
|
||||
{
|
||||
"path": "lib/.gitkeep",
|
||||
"required": false,
|
||||
"description": "Placeholder for shared detector, type, and report code"
|
||||
},
|
||||
{
|
||||
"path": "host-services/.gitkeep",
|
||||
"required": false,
|
||||
"description": "Placeholder for host-side monitor lifecycle and IPC handlers"
|
||||
},
|
||||
{
|
||||
"path": "mcp-tools/.gitkeep",
|
||||
"required": false,
|
||||
"description": "Placeholder for container-side MCP tool definitions"
|
||||
}
|
||||
]
|
||||
},
|
||||
"capabilities": [
|
||||
"Spec baseline for host-side runtime traffic monitoring",
|
||||
"MCP status and findings query surface",
|
||||
"Container-safe host/container IPC boundary",
|
||||
"Optional HTTPS inspection with explicit per-runtime trust",
|
||||
"Redacted local threat logging"
|
||||
],
|
||||
"nanoclaw": {
|
||||
"mcp_tools": [
|
||||
"clawsec_traffic_status",
|
||||
"clawsec_traffic_findings",
|
||||
"clawsec_traffic_check_config"
|
||||
],
|
||||
"requires": {
|
||||
"node": ">=18.0.0",
|
||||
"nanoclaw": ">=0.1.0"
|
||||
},
|
||||
"runtime": {
|
||||
"required_env": [],
|
||||
"optional_env": [
|
||||
"NANOCLAW_TRAFFIC_GUARDIAN_HOME",
|
||||
"NANOCLAW_TRAFFIC_GUARDIAN_CONFIG",
|
||||
"NANOCLAW_TRAFFIC_GUARDIAN_MODE",
|
||||
"NANOCLAW_TRAFFIC_GUARDIAN_PROXY_URL",
|
||||
"NANOCLAW_TRAFFIC_GUARDIAN_CA_BUNDLE",
|
||||
"NANOCLAW_TRAFFIC_GUARDIAN_LOG_DIR",
|
||||
"NANOCLAW_TRAFFIC_GUARDIAN_MAX_SCAN_BYTES",
|
||||
"NANOCLAW_TRAFFIC_GUARDIAN_REDACT_SNIPPETS"
|
||||
]
|
||||
},
|
||||
"capabilities": {
|
||||
"runtime_traffic_monitoring": "spec_baseline",
|
||||
"http_proxy_inspection": "planned",
|
||||
"https_mitm_inspection": "planned_optional",
|
||||
"egress_exfiltration_detection": "planned",
|
||||
"inbound_injection_detection": "planned",
|
||||
"mcp_status_tools": "planned",
|
||||
"blocking": "future_version"
|
||||
},
|
||||
"execution": {
|
||||
"always": false,
|
||||
"persistence": "Spec baseline only. Builders must keep host-side monitoring opt-in and avoid container persistence without explicit operator action.",
|
||||
"network_egress": "Future runtime will proxy operator-scoped NanoClaw/WhatsApp-bot traffic. No runtime network behavior is implemented in v0.0.1."
|
||||
},
|
||||
"operator_review": [
|
||||
"Keep proxy runtime on the host side when possible; expose only status and findings into the container.",
|
||||
"Do not grant container code access to CA private key material.",
|
||||
"Do not install a system-wide CA automatically.",
|
||||
"Default to detect-and-log mode; blocking is out of scope for v0.0.1 implementation.",
|
||||
"Redact secret snippets before writing logs or exposing MCP responses."
|
||||
],
|
||||
"integration": {
|
||||
"mcp_tools_dir": "mcp-tools/",
|
||||
"host_services_dir": "host-services/",
|
||||
"result_channel": "/workspace/ipc/clawsec_results"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [0.1.6] - 2026-05-16
|
||||
|
||||
### Fixed
|
||||
- Added `scripts/load_suppression_config.mjs` to `skill.json` SBOM metadata so release archives include the helper imported by `scripts/render_report.mjs`.
|
||||
|
||||
## [0.1.5] - 2026-05-14
|
||||
|
||||
### Security
|
||||
- Added explicit signed release artifact verification instructions for standalone installs, including `checksums.json`, `checksums.sig`, `signing-public.pem`, archive hash verification, and `SKILL.md`/`skill.json` checksum checks.
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: openclaw-audit-watchdog
|
||||
version: 0.1.6
|
||||
version: 0.1.4
|
||||
description: Automated daily security audits for OpenClaw agents with DM delivery and optional email reporting. Runs deep audits, creates or updates a recurring cron job, and sends formatted reports to configured recipients.
|
||||
homepage: https://clawsec.prompt.security
|
||||
metadata:
|
||||
@@ -65,86 +65,6 @@ Continue below for standalone installation instructions.
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Release Artifact Verification
|
||||
|
||||
For standalone installs, verify the signed release manifest before trusting `SKILL.md`, `skill.json`, or the archive. The `skill.json` file is the package metadata/SBOM source, and the release pipeline signs `checksums.json` with the ClawSec release key.
|
||||
|
||||
```bash
|
||||
set -euo pipefail
|
||||
|
||||
SKILL_NAME="openclaw-audit-watchdog"
|
||||
VERSION="0.1.6"
|
||||
REPO="prompt-security/clawsec"
|
||||
TAG="${SKILL_NAME}-v${VERSION}"
|
||||
BASE="https://github.com/${REPO}/releases/download/${TAG}"
|
||||
ZIP_NAME="${SKILL_NAME}-v${VERSION}.zip"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
RELEASE_PUBKEY_SHA256="711424e4535f84093fefb024cd1ca4ec87439e53907b305b79a631d5befba9c8"
|
||||
|
||||
curl -fsSL "$BASE/checksums.json" -o "$TMP_DIR/checksums.json"
|
||||
curl -fsSL "$BASE/checksums.sig" -o "$TMP_DIR/checksums.sig"
|
||||
curl -fsSL "$BASE/signing-public.pem" -o "$TMP_DIR/signing-public.pem"
|
||||
curl -fsSL "$BASE/$ZIP_NAME" -o "$TMP_DIR/$ZIP_NAME"
|
||||
curl -fsSL "$BASE/SKILL.md" -o "$TMP_DIR/SKILL.md"
|
||||
curl -fsSL "$BASE/skill.json" -o "$TMP_DIR/skill.json"
|
||||
|
||||
ACTUAL_PUBKEY_SHA256="$(openssl pkey -pubin -in "$TMP_DIR/signing-public.pem" -outform DER | shasum -a 256 | awk '{print $1}')"
|
||||
if [ "$ACTUAL_PUBKEY_SHA256" != "$RELEASE_PUBKEY_SHA256" ]; then
|
||||
echo "ERROR: signing-public.pem fingerprint mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openssl base64 -d -A -in "$TMP_DIR/checksums.sig" -out "$TMP_DIR/checksums.sig.bin"
|
||||
openssl pkeyutl -verify -rawin -pubin \
|
||||
-inkey "$TMP_DIR/signing-public.pem" \
|
||||
-sigfile "$TMP_DIR/checksums.sig.bin" \
|
||||
-in "$TMP_DIR/checksums.json" >/dev/null
|
||||
|
||||
hash_file() {
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$1" | awk '{print $1}'
|
||||
else
|
||||
sha256sum "$1" | awk '{print $1}'
|
||||
fi
|
||||
}
|
||||
|
||||
verify_manifest_file() {
|
||||
asset="$1"
|
||||
path="$2"
|
||||
expected="$(jq -r --arg asset "$asset" '.files[$asset].sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected" ]; then
|
||||
echo "ERROR: checksums.json missing $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual="$(hash_file "$path")"
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "ERROR: checksum mismatch for $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
expected_archive="$(jq -r '.archive.sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected_archive" ]; then
|
||||
echo "ERROR: checksums.json missing archive.sha256" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual_archive="$(hash_file "$TMP_DIR/$ZIP_NAME")"
|
||||
if [ "$actual_archive" != "$expected_archive" ]; then
|
||||
echo "ERROR: archive checksum mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
verify_manifest_file "SKILL.md" "$TMP_DIR/SKILL.md"
|
||||
verify_manifest_file "skill.json" "$TMP_DIR/skill.json"
|
||||
|
||||
echo "Signed release manifest, archive, SKILL.md, and skill.json verified."
|
||||
```
|
||||
|
||||
Only install or extract the archive after this verification succeeds.
|
||||
|
||||
## Operational requirements
|
||||
|
||||
Required runtime:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openclaw-audit-watchdog",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.4",
|
||||
"description": "Automated daily security audits for OpenClaw agents with DM delivery and optional email reporting. Creates or updates an unattended cron job and sends formatted reports to configured recipients.",
|
||||
"author": "prompt-security",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
@@ -52,11 +52,6 @@
|
||||
"required": false,
|
||||
"description": "SMTP delivery (Node.js)"
|
||||
},
|
||||
{
|
||||
"path": "scripts/load_suppression_config.mjs",
|
||||
"required": false,
|
||||
"description": "Suppression configuration loading and path normalization used by report rendering"
|
||||
},
|
||||
{
|
||||
"path": "scripts/setup_cron.mjs",
|
||||
"required": false,
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## [0.0.1-beta2] - 2026-05-13
|
||||
|
||||
### Security
|
||||
- Added explicit signed release artifact verification instructions for standalone installs, including `checksums.json`, `checksums.sig`, `signing-public.pem`, archive hash verification, and `SKILL.md`/`skill.json` checksum checks.
|
||||
|
||||
### Changed
|
||||
- Re-release skill payload metadata after excluding test-only files from release SBOMs and archives.
|
||||
|
||||
## [0.0.1-beta1] - 2026-05-10
|
||||
|
||||
- Added baseline skill metadata, frontmatter, and implementation specification.
|
||||
- Reserved folder structure for OpenClaw traffic-monitoring runtime code, hook integration, and tests.
|
||||
- Beta release notes: this release is a scaffold/spec baseline and does not yet ship active runtime proxy interception.
|
||||
- Beta release notes: defaults remain non-invasive (no automatic traffic mutation or enforcement enabled by default).
|
||||
@@ -1,18 +0,0 @@
|
||||
# OpenClaw Traffic Guardian
|
||||
|
||||
Baseline skill for OpenClaw runtime traffic monitoring.
|
||||
|
||||
This package is intentionally a spec scaffold. Builders should add the OpenClaw-specific monitor implementation here while preserving the safety contract in `SKILL.md` and `SPEC.md`.
|
||||
|
||||
## Intended Capability
|
||||
|
||||
- detect outbound secret exfiltration in agent HTTP/HTTPS traffic
|
||||
- detect inbound command-injection and tool-abuse payloads
|
||||
- write redacted local JSONL findings
|
||||
- provide explicit start, stop, status, and log-query commands
|
||||
- integrate with `clawsec-suite` as an optional add-on
|
||||
|
||||
## Builder Notes
|
||||
|
||||
Use `SPEC.md` as the implementation contract. Keep runtime changes opt-in and scoped to the OpenClaw process being monitored.
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
---
|
||||
name: openclaw-traffic-guardian
|
||||
version: 0.0.1-beta2
|
||||
description: OpenClaw runtime traffic monitoring baseline for opt-in HTTP/HTTPS proxy inspection, egress detection, and inbound injection detection.
|
||||
homepage: https://clawsec.prompt.security
|
||||
author: prompt-security
|
||||
license: AGPL-3.0-or-later
|
||||
clawdis:
|
||||
emoji: "TG"
|
||||
requires:
|
||||
bins: [node, python3]
|
||||
---
|
||||
|
||||
# OpenClaw Traffic Guardian
|
||||
|
||||
This is a baseline specification skill. It intentionally does not ship a proxy or runtime implementation yet.
|
||||
|
||||
|
||||
## Release Artifact Verification
|
||||
|
||||
For standalone installs, verify the signed release manifest before trusting `SKILL.md`, `skill.json`, or the archive. The `skill.json` file is the package metadata/SBOM source, and the release pipeline signs `checksums.json` with the ClawSec release key.
|
||||
|
||||
```bash
|
||||
set -euo pipefail
|
||||
|
||||
SKILL_NAME="openclaw-traffic-guardian"
|
||||
VERSION="0.0.1-beta2"
|
||||
REPO="prompt-security/clawsec"
|
||||
TAG="${SKILL_NAME}-v${VERSION}"
|
||||
BASE="https://github.com/${REPO}/releases/download/${TAG}"
|
||||
ZIP_NAME="${SKILL_NAME}-v${VERSION}.zip"
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
RELEASE_PUBKEY_SHA256="711424e4535f84093fefb024cd1ca4ec87439e53907b305b79a631d5befba9c8"
|
||||
|
||||
curl -fsSL "$BASE/checksums.json" -o "$TMP_DIR/checksums.json"
|
||||
curl -fsSL "$BASE/checksums.sig" -o "$TMP_DIR/checksums.sig"
|
||||
curl -fsSL "$BASE/signing-public.pem" -o "$TMP_DIR/signing-public.pem"
|
||||
curl -fsSL "$BASE/$ZIP_NAME" -o "$TMP_DIR/$ZIP_NAME"
|
||||
curl -fsSL "$BASE/SKILL.md" -o "$TMP_DIR/SKILL.md"
|
||||
curl -fsSL "$BASE/skill.json" -o "$TMP_DIR/skill.json"
|
||||
|
||||
ACTUAL_PUBKEY_SHA256="$(openssl pkey -pubin -in "$TMP_DIR/signing-public.pem" -outform DER | shasum -a 256 | awk '{print $1}')"
|
||||
if [ "$ACTUAL_PUBKEY_SHA256" != "$RELEASE_PUBKEY_SHA256" ]; then
|
||||
echo "ERROR: signing-public.pem fingerprint mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
openssl base64 -d -A -in "$TMP_DIR/checksums.sig" -out "$TMP_DIR/checksums.sig.bin"
|
||||
openssl pkeyutl -verify -rawin -pubin \
|
||||
-inkey "$TMP_DIR/signing-public.pem" \
|
||||
-sigfile "$TMP_DIR/checksums.sig.bin" \
|
||||
-in "$TMP_DIR/checksums.json" >/dev/null
|
||||
|
||||
hash_file() {
|
||||
if command -v shasum >/dev/null 2>&1; then
|
||||
shasum -a 256 "$1" | awk '{print $1}'
|
||||
else
|
||||
sha256sum "$1" | awk '{print $1}'
|
||||
fi
|
||||
}
|
||||
|
||||
verify_manifest_file() {
|
||||
asset="$1"
|
||||
path="$2"
|
||||
expected="$(jq -r --arg asset "$asset" '.files[$asset].sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected" ]; then
|
||||
echo "ERROR: checksums.json missing $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual="$(hash_file "$path")"
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "ERROR: checksum mismatch for $asset" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
expected_archive="$(jq -r '.archive.sha256 // empty' "$TMP_DIR/checksums.json")"
|
||||
if [ -z "$expected_archive" ]; then
|
||||
echo "ERROR: checksums.json missing archive.sha256" >&2
|
||||
exit 1
|
||||
fi
|
||||
actual_archive="$(hash_file "$TMP_DIR/$ZIP_NAME")"
|
||||
if [ "$actual_archive" != "$expected_archive" ]; then
|
||||
echo "ERROR: archive checksum mismatch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
verify_manifest_file "SKILL.md" "$TMP_DIR/SKILL.md"
|
||||
verify_manifest_file "skill.json" "$TMP_DIR/skill.json"
|
||||
|
||||
echo "Signed release manifest, archive, SKILL.md, and skill.json verified."
|
||||
```
|
||||
|
||||
Only install or extract the archive after this verification succeeds.
|
||||
|
||||
## Scope
|
||||
|
||||
Builders should use this skill as the OpenClaw landing zone for runtime traffic monitoring:
|
||||
|
||||
- operator-scoped HTTP proxy inspection
|
||||
- optional HTTPS inspection with per-process CA trust
|
||||
- outbound exfiltration detection
|
||||
- inbound injection detection
|
||||
- redacted local threat logs
|
||||
- optional OpenClaw hook/status integration
|
||||
|
||||
Do not merge this capability into `clawsec-scanner`, `openclaw-audit-watchdog`, or `soul-guardian`. Those skills have different trust boundaries and safety contracts.
|
||||
|
||||
## Safety Contract
|
||||
|
||||
- Opt-in only.
|
||||
- Detect-and-log by default.
|
||||
- No automatic system CA installation.
|
||||
- No global `HTTP_PROXY` or `HTTPS_PROXY` changes.
|
||||
- No blocking in the first implementation.
|
||||
- Redact secrets before logs or conversation alerts.
|
||||
- Keep all state under `OPENCLAW_TRAFFIC_GUARDIAN_HOME` or `~/.openclaw/security/clawsec/traffic-guardian`.
|
||||
|
||||
## Builder Entry Points
|
||||
|
||||
Read `SPEC.md` before implementing. Use the placeholder folders as follows:
|
||||
|
||||
| Path | Intended use |
|
||||
|---|---|
|
||||
| `lib/` | Detector rules, redaction, event schema, report formatting |
|
||||
| `scripts/` | Start, stop, status, config validation, log query helpers |
|
||||
| `hooks/openclaw-traffic-guardian-hook/` | Optional OpenClaw hook/status integration |
|
||||
| `test/` | Unit tests, proxy fixture tests, redaction tests, process-scope tests |
|
||||
|
||||
## Required First Implementation Behavior
|
||||
|
||||
1. Validate config without starting the proxy.
|
||||
2. Start monitor in foreground or explicit background mode.
|
||||
3. Scope proxy environment variables to the target OpenClaw process.
|
||||
4. Inspect HTTP request/response text up to a bounded byte limit.
|
||||
5. Support optional HTTPS MITM only when the operator supplies per-process trust configuration.
|
||||
6. Emit JSONL findings with redacted snippets.
|
||||
7. Provide a `status` command that reports mode, listener, CA fingerprint if present, and last findings.
|
||||
|
||||
## Out of Scope for v0.0.1 Implementation
|
||||
|
||||
- automatic system trust-store mutation
|
||||
- transparent network interception
|
||||
- default blocking
|
||||
- sending traffic to external services
|
||||
- collecting full request/response bodies
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
# OpenClaw Traffic Guardian Specification
|
||||
|
||||
## Goal
|
||||
|
||||
Provide OpenClaw with opt-in runtime traffic monitoring that observes agent HTTP/HTTPS traffic for exfiltration and injection signals without changing global host networking.
|
||||
|
||||
## Required Architecture
|
||||
|
||||
Implement three layers:
|
||||
|
||||
1. Detector core
|
||||
- normalized finding schema
|
||||
- pattern registry
|
||||
- snippet redaction
|
||||
- deduplication
|
||||
- JSONL report writer
|
||||
|
||||
2. OpenClaw adapter
|
||||
- lifecycle commands for start, stop, status, and threats
|
||||
- process-scoped proxy environment guidance
|
||||
- optional hook/status integration under `hooks/openclaw-traffic-guardian-hook/`
|
||||
|
||||
3. Operator interface
|
||||
- safe setup text
|
||||
- explicit per-process proxy export commands
|
||||
- CA fingerprint display when HTTPS inspection is enabled
|
||||
|
||||
## Finding Schema
|
||||
|
||||
Findings must be JSON objects with these fields:
|
||||
|
||||
```json
|
||||
{
|
||||
"schema_version": "clawsec-traffic-finding/v1",
|
||||
"platform": "openclaw",
|
||||
"direction": "outbound",
|
||||
"protocol": "http",
|
||||
"threat_type": "EXFIL",
|
||||
"pattern": "ai_api_key",
|
||||
"severity": "high",
|
||||
"source": "127.0.0.1",
|
||||
"dest": "api.example.com:443",
|
||||
"snippet": "[REDACTED]",
|
||||
"timestamp": "2026-04-26T00:00:00.000Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Minimum Detection Set
|
||||
|
||||
Outbound EXFIL:
|
||||
|
||||
- AI API keys
|
||||
- AWS access key IDs
|
||||
- private key PEM markers
|
||||
- SSH key file paths
|
||||
- sensitive Unix file paths
|
||||
- dotenv and cloud credential paths
|
||||
|
||||
Inbound INJECTION:
|
||||
|
||||
- pipe-to-shell commands
|
||||
- shell exec flags
|
||||
- reverse shell command shapes
|
||||
- destructive remove commands
|
||||
- SSH authorized-key injection shapes
|
||||
|
||||
## Safety Requirements
|
||||
|
||||
- Default mode is detect-and-log.
|
||||
- Blocking mode must not exist in the first implementation.
|
||||
- Snippets must be redacted before persistence.
|
||||
- Maximum scan bytes must be configurable and bounded.
|
||||
- CA trust must be per-process by default.
|
||||
- System trust-store instructions must require explicit operator confirmation and must never run automatically.
|
||||
|
||||
## Tests Required Before Release
|
||||
|
||||
- detector unit tests for each pattern
|
||||
- redaction tests proving secrets are not persisted
|
||||
- proxy fixture tests for HTTP request and response inspection
|
||||
- no-false-positive tests for common benign traffic
|
||||
- lifecycle tests for stale PID/state cleanup
|
||||
- status output tests
|
||||
- OpenClaw hook integration tests if hook files are added
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
{
|
||||
"name": "openclaw-traffic-guardian",
|
||||
"version": "0.0.1-beta2",
|
||||
"description": "OpenClaw runtime traffic monitoring baseline for opt-in HTTP/HTTPS proxy inspection, egress detection, and inbound injection detection.",
|
||||
"author": "prompt-security",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"homepage": "https://clawsec.prompt.security/",
|
||||
"platform": "openclaw",
|
||||
"keywords": [
|
||||
"security",
|
||||
"openclaw",
|
||||
"traffic-monitoring",
|
||||
"egress",
|
||||
"exfiltration",
|
||||
"injection",
|
||||
"proxy",
|
||||
"mitm",
|
||||
"runtime"
|
||||
],
|
||||
"sbom": {
|
||||
"files": [
|
||||
{
|
||||
"path": "SKILL.md",
|
||||
"required": true,
|
||||
"description": "OpenClaw traffic guardian skill instructions and operating model"
|
||||
},
|
||||
{
|
||||
"path": "README.md",
|
||||
"required": true,
|
||||
"description": "Human-oriented overview and builder handoff notes"
|
||||
},
|
||||
{
|
||||
"path": "CHANGELOG.md",
|
||||
"required": true,
|
||||
"description": "Version history and baseline release notes"
|
||||
},
|
||||
{
|
||||
"path": "SPEC.md",
|
||||
"required": true,
|
||||
"description": "Implementation specification for OpenClaw runtime traffic monitoring"
|
||||
},
|
||||
{
|
||||
"path": "lib/.gitkeep",
|
||||
"required": false,
|
||||
"description": "Placeholder for shared detector and report code"
|
||||
},
|
||||
{
|
||||
"path": "scripts/.gitkeep",
|
||||
"required": false,
|
||||
"description": "Placeholder for proxy lifecycle and status scripts"
|
||||
},
|
||||
{
|
||||
"path": "hooks/openclaw-traffic-guardian-hook/.gitkeep",
|
||||
"required": false,
|
||||
"description": "Placeholder for optional OpenClaw hook integration"
|
||||
}
|
||||
]
|
||||
},
|
||||
"openclaw": {
|
||||
"emoji": "TG",
|
||||
"category": "security",
|
||||
"requires": {
|
||||
"bins": [
|
||||
"node",
|
||||
"python3"
|
||||
]
|
||||
},
|
||||
"runtime": {
|
||||
"required_env": [],
|
||||
"optional_env": [
|
||||
"OPENCLAW_TRAFFIC_GUARDIAN_HOME",
|
||||
"OPENCLAW_TRAFFIC_GUARDIAN_CONFIG",
|
||||
"OPENCLAW_TRAFFIC_GUARDIAN_MODE",
|
||||
"OPENCLAW_TRAFFIC_GUARDIAN_PROXY_URL",
|
||||
"OPENCLAW_TRAFFIC_GUARDIAN_CA_BUNDLE",
|
||||
"OPENCLAW_TRAFFIC_GUARDIAN_LOG_DIR",
|
||||
"OPENCLAW_TRAFFIC_GUARDIAN_MAX_SCAN_BYTES",
|
||||
"OPENCLAW_TRAFFIC_GUARDIAN_REDACT_SNIPPETS"
|
||||
]
|
||||
},
|
||||
"capabilities": {
|
||||
"runtime_traffic_monitoring": "spec_baseline",
|
||||
"http_proxy_inspection": "planned",
|
||||
"https_mitm_inspection": "planned_optional",
|
||||
"egress_exfiltration_detection": "planned",
|
||||
"inbound_injection_detection": "planned",
|
||||
"blocking": "future_version"
|
||||
},
|
||||
"execution": {
|
||||
"always": false,
|
||||
"persistence": "Spec baseline only. Builders must keep monitoring opt-in and avoid installing persistent hooks or schedulers without explicit operator action.",
|
||||
"network_egress": "Future runtime will proxy operator-scoped agent traffic. No runtime network behavior is implemented in v0.0.1."
|
||||
},
|
||||
"operator_review": [
|
||||
"Do not install a system-wide CA automatically.",
|
||||
"Default to detect-and-log mode; blocking is out of scope for v0.0.1 implementation.",
|
||||
"Scope HTTP_PROXY/HTTPS_PROXY to the OpenClaw process being monitored.",
|
||||
"Redact secret snippets before writing logs or sending conversation alerts.",
|
||||
"Integrate with clawsec-suite as an optional add-on, not a default install."
|
||||
],
|
||||
"triggers": [
|
||||
"openclaw traffic guardian",
|
||||
"openclaw traffic monitoring",
|
||||
"monitor openclaw egress",
|
||||
"inspect openclaw http traffic",
|
||||
"detect openclaw exfiltration"
|
||||
]
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user