Commit Graph
13 Commits
Author SHA1 Message Date
Willie 19d88ce905 chore: update schema and red team scripts for centralized metadata
- 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)
2026-04-08 17:43:39 +08:00
Willie 34ecba48ee test: stabilize make test under updated audit rules 2026-03-03 16:08:11 +08:00
Willie bcbbaaf34d refactor(audit): remove noisy rules, recalibrate credential severities
Remove rules that generated excessive false positives:
- source-repository-link (HIGH): legitimate docs links flagged too often;
  external-link (LOW) already covers the same URLs
- env-access (MEDIUM): process.env references are ubiquitous in JS skills
- obfuscation-1 (long base64): caught README badges and binary data

Recalibrate credential-access severity levels to reduce alert fatigue:
- etc-passwd/sudoers: HIGH → MEDIUM (read-only system files, not secrets)
- shell-history, openvpn: MEDIUM → LOW (low-impact reconnaissance)
- auth-log: LOW → INFO (log files, no direct credential exposure)

Update all affected unit tests, integration tests, red team assertions,
skill references, and website docs to match.
2026-03-03 16:08:11 +08:00
Willie dbe759ecfe feat(audit): add CLI rules subcommand, severity override, reset, and redesign Web UI
- Add `audit rules` CLI subcommand with list, enable, disable, severity,
  and reset commands for managing audit rules without editing YAML
- Add SetSeverity/SetPatternSeverity/ResetRules mutations in audit package
- Redesign TUI with severity tabs, two-level pattern→rule navigation,
  inline severity picker (1-5 keys), and reset-all support
- Add compiled rules API endpoints (GET /api/audit/compiled, PATCH toggle)
- Redesign AuditRulesPage with severity-colored stripes, stat cards,
  expand/collapse, toggle switches, and dark-mode-aware CSS variables
- Redesign LogPage with status-colored row stripes, reusable PillButton,
  improved stats cards with left border stripes, default 10 entries/page
- Remove system-writes audit pattern (noisy, low value)
- Fix dark mode contrast across both pages by replacing hardcoded
  design.ts colors with var(--color-*) CSS variable references
2026-03-03 16:08:11 +08:00
Willie 23206306d8 fix(audit): prevent stdout pollution in structured output formats
Two issues caused red team test failures after --format flag introduction:

1. ss_capture helper merged stderr into stdout (2>&1), so the --json
   deprecation warning poisoned JSON parsing by jq. Fix: capture stderr
   to a temp file separately from stdout.

2. Two unguarded fmt.Println() calls in auditInstalled() printed blank
   lines to stdout even in JSON/SARIF/markdown mode. Fix: wrap in
   if !jsonOutput guard.

Also migrate all 39 --json invocations in red team tests to --format json
since --json is deprecated.
2026-03-02 23:01:30 +08:00
Willie 9a7ee1b6f7 fix: address code review findings (3 important + 5 suggestions)
- Fix non-TTY progress bar not incrementing for grouped skills in Phase 2
- Fix Unicode truncation in UpdateTitle using runewidth instead of len()
- Fix IP address regex missing end-of-line bare IPs (add $ anchor)
- Fix gofmt alignment in updateTarget struct comments
- Extract sliceHasName[T] generic helper to deduplicate universal detection
- Add nil meta defensive warning with skipped count in grouped updates
- Replace hand-rolled contains/containsStr with strings.Contains in tests
- Add red team TC-20b for inline code fetch-with-pipe detection
2026-02-28 03:44:02 +08:00
Willie 429e67a88c fix(audit): downgrade data-uri severity to MEDIUM 2026-02-28 03:44:02 +08:00
Willie 1a207e6d2c feat(audit): add fetch-with-pipe, ip-address-url, and data-uri rules
Add 5 new audit rules (31 → 36 total) to close detection gaps:

- fetch-with-pipe (HIGH ×3): curl/wget piped to sh/bash/python/node/etc.
  Previously only double-pipe (||) was caught by shell-chain; single
  pipe (|) to interpreters — the classic RCE vector — was undetected.
- ip-address-url (MEDIUM): URLs with raw IP addresses that bypass DNS
  security controls; excludes RFC 1918 and loopback ranges.
- data-uri (HIGH): data: URIs in markdown links that may embed
  executable content.

fetch-with-pipe is suppressed inside markdown code fences (tutorial
context), matching existing behavior for destructive-commands et al.

Includes unit tests (25 cases), code fence suppression test, red team
TC-18 through TC-21, and audit.md documentation updates.
2026-02-28 03:44:02 +08:00
Willie f8205a27a8 refactor(install): prefer sparse checkout over GitHub API for subdir install
Swap fast path order: sparse checkout is now fast path 1 (works for all
hosts including file://), GitHub Contents API is fast path 2 (fallback
when sparse is unavailable or fails). Also reset subdirPath on sparse
failure to ensure proper fallback chain.

Fix red team helpers to inject -g flag after subcommand, preventing
.skillshare/ auto-detection from hijacking global-mode tests.

Add blocked section assertions to TestUpdate_BatchAll_FailsOnMalicious.
2026-02-25 07:02:54 +08:00
Willie 3ad814d3ba fix: add audit gate to install --track and tracked repo updates
InstallTrackedRepo and updateTrackedRepo had no security audit,
allowing --track to bypass all supply-chain checks. This adds
auditTrackedRepo (removes repo on block for fresh installs) and
auditTrackedRepoUpdate (git reset rollback for updates), plus
input validation, testable removeAll, and hardened error handling
across audit/install/uninstall paths.
2026-02-23 04:18:01 +08:00
Willie 13691861e4 feat: add structural markdown link parsing for audit rules
Replace simple regex-based markdown link extraction with a full
structural parser that handles inline links with titles, autolinks,
reference-style links, HTML anchors, multiline links, and correctly
skips code fences, inline code spans, and image links.

This ensures external-link and source-repository-link audit rules
match all Markdown link syntax variants while avoiding false positives
from code examples and images.
2026-02-23 04:18:01 +08:00
Willie 0af0df57bf test: add red-team phase5 and harden hash path validation 2026-02-23 04:18:01 +08:00
Willie 5c44acd7d1 test: add red team E2E script for supply-chain security validation
Repeatable bash-based test exercising all audit patterns (CRITICAL→INFO),
update gate rollback, content hash integrity, and batch blast radius.

- scripts/red_team_test.sh: main entry (setup + 4 phases + summary)
- scripts/red_team/: split phases + shared helpers
- Makefile/mise.toml: add `test-redteam` target
- docker/sandbox/Dockerfile: add jq for JSON assertions
2026-02-23 04:18:01 +08:00