# 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" < "$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