mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
- registry.schema.json: describe .metadata.json store format (version, entries map with full field set) instead of old registry.yaml format - Red team scripts: add write_store_meta helper, replace sidecar writes with centralized store writes in phase3 (integrity) and phase5 (advanced)
68 lines
2.7 KiB
Bash
68 lines
2.7 KiB
Bash
# Phase 3 — CONTENT INTEGRITY (hash pinning)
|
|
# Sourced by red_team_test.sh; requires _helpers.sh
|
|
|
|
phase "PHASE 3 — CONTENT INTEGRITY"
|
|
|
|
INTEGRITY_DIR="$SOURCE_DIR/integrity-skill"
|
|
|
|
# ── TC-25: Clean skill with correct hashes → no findings ──────
|
|
|
|
info "TC-25: clean skill passes integrity check"
|
|
create_skill "$INTEGRITY_DIR" "# Integrity test
|
|
Safe content for hash verification."
|
|
|
|
SKILL_HASH=$(shasum -a 256 "$INTEGRITY_DIR/SKILL.md" | awk '{print $1}')
|
|
|
|
write_store_meta "$SOURCE_DIR" "integrity-skill" \
|
|
"{\"source\":\"test/integrity\",\"type\":\"local\",\"installed_at\":\"2026-01-01T00:00:00Z\",\"file_hashes\":{\"SKILL.md\":\"sha256:$SKILL_HASH\"}}"
|
|
|
|
ss_capture audit integrity-skill --format json
|
|
HAS_INTEGRITY=false
|
|
echo "$SS_OUTPUT" | jq -e '.results[0].findings[] | select(.pattern | startswith("content-"))' >/dev/null 2>&1 && HAS_INTEGRITY=true
|
|
if [ "$HAS_INTEGRITY" = false ]; then
|
|
pass "TC-25: clean skill with correct hashes passes"
|
|
else
|
|
fail "TC-25: unexpected integrity finding"
|
|
fi
|
|
|
|
# ── TC-26: Tamper file → content-tampered (MEDIUM) ────────────
|
|
|
|
info "TC-26: tampered file detected"
|
|
cat > "$INTEGRITY_DIR/SKILL.md" <<SKILL_EOF
|
|
---
|
|
name: integrity-skill
|
|
---
|
|
# Integrity test
|
|
MODIFIED — this content does not match the pinned hash.
|
|
SKILL_EOF
|
|
|
|
ss_capture audit integrity-skill --format json
|
|
assert_finding "TC-26: content-tampered detected as MEDIUM" "$SS_OUTPUT" "content-tampered" "MEDIUM"
|
|
|
|
# ── TC-27: Missing pinned file → content-missing (LOW) ────────
|
|
|
|
info "TC-27: missing pinned file detected"
|
|
create_skill "$INTEGRITY_DIR" "# Integrity test
|
|
Safe content for hash verification."
|
|
SKILL_HASH=$(shasum -a 256 "$INTEGRITY_DIR/SKILL.md" | awk '{print $1}')
|
|
|
|
write_store_meta "$SOURCE_DIR" "integrity-skill" \
|
|
"{\"source\":\"test/integrity\",\"type\":\"local\",\"installed_at\":\"2026-01-01T00:00:00Z\",\"file_hashes\":{\"SKILL.md\":\"sha256:$SKILL_HASH\",\"extras.md\":\"sha256:0000000000000000000000000000000000000000000000000000000000000000\"}}"
|
|
|
|
ss_capture audit integrity-skill --format json
|
|
assert_finding "TC-27: content-missing detected as LOW" "$SS_OUTPUT" "content-missing" "LOW"
|
|
|
|
# ── TC-28: Unexpected file → content-unexpected (LOW) ─────────
|
|
|
|
info "TC-28: unexpected file detected"
|
|
write_store_meta "$SOURCE_DIR" "integrity-skill" \
|
|
"{\"source\":\"test/integrity\",\"type\":\"local\",\"installed_at\":\"2026-01-01T00:00:00Z\",\"file_hashes\":{\"SKILL.md\":\"sha256:$SKILL_HASH\"}}"
|
|
|
|
echo "unexpected content" > "$INTEGRITY_DIR/sneaky.sh"
|
|
|
|
ss_capture audit integrity-skill --format json
|
|
assert_finding "TC-28: content-unexpected detected as LOW" "$SS_OUTPUT" "content-unexpected" "LOW"
|
|
|
|
# Clean up phase 3
|
|
rm -rf "$SOURCE_DIR"/integrity-skill
|