@routinecrew/routinecode 2.31.63 → 2.31.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.sh +7 -0
- package/bin/prompt-vault.js +1 -1
- package/bin/rc-config.js +2 -0
- package/bin/rc-credit-turn.js +1 -218
- package/bin/rc-grant.js +1 -78
- package/bin/rc-team.js +1 -591
- package/bin/seal-open.js +1 -1
- package/hooks/architect-runner.sh +159 -0
- package/hooks/cc-compat-watch.js +1 -70
- package/hooks/hooks-config.json +18 -0
- package/hooks/lib/cc-surface.json +2 -2
- package/hooks/lib/config_bash_track.py +390 -0
- package/hooks/lib/config_guard.py +103 -0
- package/hooks/lib/emit_raw.py +11 -1
- package/hooks/lib/known_solution.py +1 -1
- package/hooks/lib/sync_manager.py +96 -1
- package/hooks/lib/tests/test_config_bash_track.py +189 -0
- package/hooks/lib/tests/test_maintenance_sync.py +190 -0
- package/hooks/maintenance-runner.sh +450 -0
- package/hooks/pending-drainer.sh +12 -7
- package/hooks/post-agent-return.sh +1 -1
- package/hooks/post-bash-knowledge.sh +2 -2
- package/hooks/post-bash-verify.sh +28 -3
- package/hooks/post-build-check.sh +5 -5
- package/hooks/post-delegation-nudge.sh +1 -1
- package/hooks/post-domain-knowledge-record.sh +1 -1
- package/hooks/post-edit-track.sh +26 -1
- package/hooks/post-knowledge-query.sh +2 -2
- package/hooks/pre-agent-briefing.sh +16 -0
- package/hooks/pre-agent-spawn.mjs +1 -1
- package/hooks/pre-bash-guard.sh +19 -0
- package/hooks/pre-edit-config-gate.sh +16 -0
- package/hooks/pre-edit-domain-gate.sh +5 -5
- package/hooks/pre-edit-guard.sh +9 -0
- package/hooks/pre-edit-knowledge-gate.sh +2 -2
- package/hooks/pre-maintenance-guard.sh +48 -0
- package/hooks/pre-read-knowledge-inject.sh +1 -1
- package/hooks/pre-secret-guard.sh +1 -1
- package/hooks/recorder-runner.sh +16 -1
- package/hooks/save-user-message.sh +1 -1
- package/hooks/session-start.sh +69 -7
- package/hooks/stop-claim-check.sh +1 -1
- package/hooks/stop-claim-check.v3.sh +107 -1
- package/hooks/stop-knowledge-remind.sh +2 -2
- package/hooks/user-prompt-submit.sh +23 -7
- package/mcp-db-manager/dist/analyzers/duplicate-detector.js +1 -1
- package/mcp-db-manager/dist/core/model-parser.js +1 -1
- package/mcp-db-manager/dist/core/schema-reader.js +1 -1
- package/mcp-db-manager/dist/executors/migration-executor.js +1 -1
- package/mcp-db-manager/dist/generators/migration-generator.js +1 -1
- package/mcp-db-manager/dist/index.js +1 -1
- package/mcp-db-manager/dist/validators/schema-validator.js +1 -1
- package/mcp-dev-tester/dist/analyzers/auth-diagnoser.js +1 -1
- package/mcp-dev-tester/dist/analyzers/backend-analyzer.js +1 -1
- package/mcp-dev-tester/dist/analyzers/endpoint-diagnoser.js +1 -1
- package/mcp-dev-tester/dist/analyzers/frontend-analyzer.js +1 -1
- package/mcp-dev-tester/dist/analyzers/runtime-diagnoser.js +1 -1
- package/mcp-dev-tester/dist/analyzers/type-comparator.js +1 -1
- package/mcp-dev-tester/dist/analyzers/validation-diagnoser.js +1 -1
- package/mcp-dev-tester/dist/attestation.js +1 -1
- package/mcp-dev-tester/dist/browser/playwright-manager.js +1 -1
- package/mcp-dev-tester/dist/browser/ui-tester.js +1 -1
- package/mcp-dev-tester/dist/config/project-config.js +1 -1
- package/mcp-dev-tester/dist/index.js +1 -1
- package/mcp-dev-tester/dist/testers/api-tester.js +1 -1
- package/mcp-doc-fetcher/dist/index.js +1 -1
- package/mcp-html-renderer/dist/index.js +1 -1
- package/mcp-html-renderer/dist/preview.js +1 -1
- package/mcp-html-renderer/dist/template-engine.js +1 -1
- package/mcp-intelligence/dist/concept-catalog.js +1 -1
- package/mcp-intelligence/dist/concept-server-proxy.js +1 -1
- package/mcp-intelligence/dist/config-auth.js +1 -1
- package/mcp-intelligence/dist/contracts.generated.js +1 -1
- package/mcp-intelligence/dist/domain-templates.js +1 -1
- package/mcp-intelligence/dist/grounding.js +1 -1
- package/mcp-intelligence/dist/handlers.js +1 -1
- package/mcp-intelligence/dist/index.js +1 -1
- package/mcp-intelligence/dist/intelligence-file.js +1 -1
- package/mcp-intelligence/dist/knowledge-critic.js +1 -1
- package/mcp-intelligence/dist/knowledge-handlers.js +1 -1
- package/mcp-intelligence/dist/mention-extractor.js +1 -1
- package/mcp-intelligence/dist/provenance.js +1 -1
- package/mcp-intelligence/dist/semantic-embedder.js +1 -1
- package/mcp-log-watcher/dist/config-auth.js +1 -1
- package/mcp-log-watcher/dist/file-watcher.js +1 -1
- package/mcp-log-watcher/dist/index.js +1 -1
- package/mcp-log-watcher/dist/known-solutions.js +1 -1
- package/mcp-log-watcher/dist/log-store.js +1 -1
- package/mcp-log-watcher/dist/websocket-server.js +1 -1
- package/mcp-plan-manager/dist/__tests__/file-ops-knowledge-dir.test.js +1 -0
- package/mcp-plan-manager/dist/__tests__/plan-parser.test.js +1 -1
- package/mcp-plan-manager/dist/file-ops.js +1 -1
- package/mcp-plan-manager/dist/index.js +1 -1
- package/mcp-plan-manager/dist/plan-parser.js +1 -1
- package/mcp-project-context/dist/git-ops.js +1 -1
- package/mcp-project-context/dist/index.js +1 -1
- package/mcp-project-context/dist/project-analysis.js +1 -1
- package/mcp-routinecode/dist/agent-tracker.js +1 -1
- package/mcp-routinecode/dist/attestation.js +1 -1
- package/mcp-routinecode/dist/blast-radius.js +1 -1
- package/mcp-routinecode/dist/changeset.js +1 -1
- package/mcp-routinecode/dist/config-auth.js +1 -1
- package/mcp-routinecode/dist/config-map/arch-graph.js +1 -0
- package/mcp-routinecode/dist/config-map/architect-store.js +1 -0
- package/mcp-routinecode/dist/config-map/assign.js +1 -0
- package/mcp-routinecode/dist/config-map/audit-cli.js +1 -0
- package/mcp-routinecode/dist/config-map/audit.js +1 -0
- package/mcp-routinecode/dist/config-map/briefing.js +1 -0
- package/mcp-routinecode/dist/config-map/decisions.js +1 -0
- package/mcp-routinecode/dist/config-map/decls.js +1 -0
- package/mcp-routinecode/dist/config-map/extract.js +1 -0
- package/mcp-routinecode/dist/config-map/gate.js +1 -0
- package/mcp-routinecode/dist/config-map/hash.js +1 -0
- package/mcp-routinecode/dist/config-map/ident-norm.js +1 -0
- package/mcp-routinecode/dist/config-map/index-store.js +1 -0
- package/mcp-routinecode/dist/config-map/light-eval.js +1 -0
- package/mcp-routinecode/dist/config-map/link.js +1 -0
- package/mcp-routinecode/dist/config-map/lookup.js +1 -0
- package/mcp-routinecode/dist/config-map/louvain.js +1 -0
- package/mcp-routinecode/dist/config-map/maintenance-cli.js +1 -0
- package/mcp-routinecode/dist/config-map/names.js +1 -0
- package/mcp-routinecode/dist/config-map/proposals.js +1 -0
- package/mcp-routinecode/dist/config-map/recheck.js +1 -0
- package/mcp-routinecode/dist/config-map/repo-id.js +1 -0
- package/mcp-routinecode/dist/config-map/rule-import.js +1 -0
- package/mcp-routinecode/dist/config-map/scc.js +1 -0
- package/mcp-routinecode/dist/config-map/shape-eval.js +1 -0
- package/mcp-routinecode/dist/config-map/shape.js +1 -0
- package/mcp-routinecode/dist/config-map/snapshot.js +1 -0
- package/mcp-routinecode/dist/config-map/stable-id.js +1 -0
- package/mcp-routinecode/dist/config-map/store.js +1 -0
- package/mcp-routinecode/dist/config-map/task-eval.js +1 -0
- package/mcp-routinecode/dist/config-map/templates.js +1 -0
- package/mcp-routinecode/dist/config-map/types.js +1 -0
- package/mcp-routinecode/dist/contracts.generated.js +1 -1
- package/mcp-routinecode/dist/coverage.js +1 -1
- package/mcp-routinecode/dist/explorer-advisor.js +1 -1
- package/mcp-routinecode/dist/failure-tracker.js +1 -1
- package/mcp-routinecode/dist/file-lock-registry.js +1 -1
- package/mcp-routinecode/dist/file-risk-scorer.js +1 -1
- package/mcp-routinecode/dist/index.js +1 -1
- package/mcp-routinecode/dist/known-solutions.js +1 -1
- package/mcp-routinecode/dist/ledger-miner.js +1 -1
- package/mcp-routinecode/dist/observed-draft.js +1 -1
- package/mcp-routinecode/dist/pattern-matcher.js +1 -1
- package/mcp-routinecode/dist/route-match.js +1 -1
- package/mcp-routinecode/dist/routines.js +1 -1
- package/mcp-routinecode/dist/rule-engine.js +1 -1
- package/mcp-routinecode/dist/rule-promoter.js +1 -1
- package/mcp-routinecode/dist/telemetry-analyzer.js +1 -1
- package/mcp-routinecode/dist/test-runner.js +1 -1
- package/mcp-routinecode/dist/verification.js +0 -0
- package/mcp-routinecode/dist/viral-loop.js +1 -1
- package/mcp-routinecode/package.json +3 -1
- package/package.json +3 -2
- package/plugin/agents/analyzer.md.sealed +1 -0
- package/plugin/agents/architect.md.sealed +1 -0
- package/plugin/agents/crawler.md.sealed +1 -0
- package/plugin/agents/explorer.md.sealed +1 -0
- package/plugin/agents/implementor.md.sealed +1 -0
- package/plugin/agents/looker.md.sealed +1 -0
- package/plugin/agents/planner.md.sealed +1 -0
- package/plugin/agents/recorder.md.sealed +1 -0
- package/plugin/agents/reviewer.md.sealed +1 -0
- package/plugin/agents/verifier.md.sealed +1 -0
- package/plugin/commands/analyze.md.sealed +1 -0
- package/plugin/commands/plan.md.sealed +1 -0
- package/plugin/commands/rc.md.sealed +1 -0
- package/plugin/commands/receipt.md.sealed +1 -0
- package/plugin/commands/recharge.md.sealed +1 -0
- package/plugin/commands/routines.md.sealed +1 -0
- package/plugin/commands/share.md.sealed +1 -0
- package/plugin/routinecode-prompt.md.sealed +1 -0
- package/hooks/tests/cd-bypass.test.py +0 -57
- package/hooks/tests/design09-client.test.py +0 -471
- package/hooks/tests/dev-mode.test.py +0 -62
- package/hooks/tests/gate-integration.test.sh +0 -300
- package/hooks/tests/in-project-relax.test.py +0 -106
- package/hooks/tests/knowledge-loop.test.sh +0 -89
- package/hooks/tests/ledger-bench.sh +0 -115
- package/hooks/tests/ledger-chaos.test.sh +0 -185
- package/hooks/tests/ledger-compat.test.sh +0 -138
- package/hooks/tests/ledger-integration.test.sh +0 -200
- package/hooks/tests/ledger-unit.test.sh +0 -300
- package/hooks/tests/mcp-name-wiring.test.sh +0 -64
- package/hooks/tests/rm-guard.test.py +0 -108
- package/hooks/tests/secret-guard-bypass.test.sh +0 -107
- package/hooks/tests/secret-guard.test.sh +0 -604
- package/hooks/tests/secret-premask.test.py +0 -179
- package/hooks/tests/stop-autoproceed.test.sh +0 -60
- package/hooks/tests/stop-claim-check-v3-sim.sh +0 -224
- package/hooks/tests/stop-claim-check-v3.test.sh +0 -373
- package/hooks/tests/stop-claim-check.test.sh +0 -224
- package/mcp-db-manager/dist/analyzers/duplicate-detector.d.ts +0 -48
- package/mcp-db-manager/dist/analyzers/duplicate-detector.d.ts.map +0 -1
- package/mcp-db-manager/dist/core/model-parser.d.ts +0 -71
- package/mcp-db-manager/dist/core/model-parser.d.ts.map +0 -1
- package/mcp-db-manager/dist/core/schema-reader.d.ts +0 -69
- package/mcp-db-manager/dist/core/schema-reader.d.ts.map +0 -1
- package/mcp-db-manager/dist/executors/migration-executor.d.ts +0 -14
- package/mcp-db-manager/dist/executors/migration-executor.d.ts.map +0 -1
- package/mcp-db-manager/dist/generators/migration-generator.d.ts +0 -69
- package/mcp-db-manager/dist/generators/migration-generator.d.ts.map +0 -1
- package/mcp-db-manager/dist/index.d.ts +0 -7
- package/mcp-db-manager/dist/index.d.ts.map +0 -1
- package/mcp-db-manager/dist/types.d.ts +0 -382
- package/mcp-db-manager/dist/types.d.ts.map +0 -1
- package/mcp-db-manager/dist/validators/schema-validator.d.ts +0 -56
- package/mcp-db-manager/dist/validators/schema-validator.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/auth-diagnoser.d.ts +0 -15
- package/mcp-dev-tester/dist/analyzers/auth-diagnoser.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/backend-analyzer.d.ts +0 -18
- package/mcp-dev-tester/dist/analyzers/backend-analyzer.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/endpoint-diagnoser.d.ts +0 -15
- package/mcp-dev-tester/dist/analyzers/endpoint-diagnoser.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/frontend-analyzer.d.ts +0 -15
- package/mcp-dev-tester/dist/analyzers/frontend-analyzer.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/runtime-diagnoser.d.ts +0 -15
- package/mcp-dev-tester/dist/analyzers/runtime-diagnoser.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/type-comparator.d.ts +0 -15
- package/mcp-dev-tester/dist/analyzers/type-comparator.d.ts.map +0 -1
- package/mcp-dev-tester/dist/analyzers/validation-diagnoser.d.ts +0 -15
- package/mcp-dev-tester/dist/analyzers/validation-diagnoser.d.ts.map +0 -1
- package/mcp-dev-tester/dist/attestation.d.ts +0 -36
- package/mcp-dev-tester/dist/attestation.d.ts.map +0 -1
- package/mcp-dev-tester/dist/browser/playwright-manager.d.ts +0 -148
- package/mcp-dev-tester/dist/browser/playwright-manager.d.ts.map +0 -1
- package/mcp-dev-tester/dist/browser/ui-tester.d.ts +0 -28
- package/mcp-dev-tester/dist/browser/ui-tester.d.ts.map +0 -1
- package/mcp-dev-tester/dist/config/project-config.d.ts +0 -94
- package/mcp-dev-tester/dist/config/project-config.d.ts.map +0 -1
- package/mcp-dev-tester/dist/index.d.ts +0 -3
- package/mcp-dev-tester/dist/index.d.ts.map +0 -1
- package/mcp-dev-tester/dist/testers/api-tester.d.ts +0 -77
- package/mcp-dev-tester/dist/testers/api-tester.d.ts.map +0 -1
- package/mcp-dev-tester/dist/types.d.ts +0 -423
- package/mcp-dev-tester/dist/types.d.ts.map +0 -1
- package/mcp-doc-fetcher/dist/index.d.ts +0 -17
- package/mcp-doc-fetcher/dist/index.d.ts.map +0 -1
- package/mcp-html-renderer/dist/index.d.ts +0 -3
- package/mcp-html-renderer/dist/index.d.ts.map +0 -1
- package/mcp-html-renderer/dist/preview.d.ts +0 -15
- package/mcp-html-renderer/dist/preview.d.ts.map +0 -1
- package/mcp-html-renderer/dist/template-engine.d.ts +0 -46
- package/mcp-html-renderer/dist/template-engine.d.ts.map +0 -1
- package/mcp-intelligence/dist/concept-catalog.d.ts +0 -142
- package/mcp-intelligence/dist/concept-catalog.d.ts.map +0 -1
- package/mcp-intelligence/dist/concept-server-proxy.d.ts +0 -38
- package/mcp-intelligence/dist/concept-server-proxy.d.ts.map +0 -1
- package/mcp-intelligence/dist/config-auth.d.ts +0 -18
- package/mcp-intelligence/dist/config-auth.d.ts.map +0 -1
- package/mcp-intelligence/dist/contracts.generated.d.ts +0 -58
- package/mcp-intelligence/dist/contracts.generated.d.ts.map +0 -1
- package/mcp-intelligence/dist/domain-templates.d.ts +0 -25
- package/mcp-intelligence/dist/domain-templates.d.ts.map +0 -1
- package/mcp-intelligence/dist/grounding.d.ts +0 -77
- package/mcp-intelligence/dist/grounding.d.ts.map +0 -1
- package/mcp-intelligence/dist/handlers.d.ts +0 -72
- package/mcp-intelligence/dist/handlers.d.ts.map +0 -1
- package/mcp-intelligence/dist/index.d.ts +0 -3
- package/mcp-intelligence/dist/index.d.ts.map +0 -1
- package/mcp-intelligence/dist/intelligence-file.d.ts +0 -82
- package/mcp-intelligence/dist/intelligence-file.d.ts.map +0 -1
- package/mcp-intelligence/dist/knowledge-critic.d.ts +0 -28
- package/mcp-intelligence/dist/knowledge-critic.d.ts.map +0 -1
- package/mcp-intelligence/dist/knowledge-handlers.d.ts +0 -358
- package/mcp-intelligence/dist/knowledge-handlers.d.ts.map +0 -1
- package/mcp-intelligence/dist/mention-extractor.d.ts +0 -13
- package/mcp-intelligence/dist/mention-extractor.d.ts.map +0 -1
- package/mcp-intelligence/dist/provenance.d.ts +0 -28
- package/mcp-intelligence/dist/provenance.d.ts.map +0 -1
- package/mcp-intelligence/dist/semantic-embedder.d.ts +0 -25
- package/mcp-intelligence/dist/semantic-embedder.d.ts.map +0 -1
- package/mcp-log-watcher/dist/config-auth.d.ts +0 -16
- package/mcp-log-watcher/dist/config-auth.d.ts.map +0 -1
- package/mcp-log-watcher/dist/file-watcher.d.ts +0 -36
- package/mcp-log-watcher/dist/file-watcher.d.ts.map +0 -1
- package/mcp-log-watcher/dist/index.d.ts +0 -3
- package/mcp-log-watcher/dist/index.d.ts.map +0 -1
- package/mcp-log-watcher/dist/known-solutions.d.ts +0 -60
- package/mcp-log-watcher/dist/known-solutions.d.ts.map +0 -1
- package/mcp-log-watcher/dist/log-store.d.ts +0 -72
- package/mcp-log-watcher/dist/log-store.d.ts.map +0 -1
- package/mcp-log-watcher/dist/types.d.ts +0 -52
- package/mcp-log-watcher/dist/types.d.ts.map +0 -1
- package/mcp-log-watcher/dist/websocket-server.d.ts +0 -44
- package/mcp-log-watcher/dist/websocket-server.d.ts.map +0 -1
- package/mcp-plan-manager/dist/__tests__/plan-parser.test.d.ts +0 -7
- package/mcp-plan-manager/dist/__tests__/plan-parser.test.d.ts.map +0 -1
- package/mcp-plan-manager/dist/file-ops.d.ts +0 -39
- package/mcp-plan-manager/dist/file-ops.d.ts.map +0 -1
- package/mcp-plan-manager/dist/index.d.ts +0 -23
- package/mcp-plan-manager/dist/index.d.ts.map +0 -1
- package/mcp-plan-manager/dist/plan-parser.d.ts +0 -76
- package/mcp-plan-manager/dist/plan-parser.d.ts.map +0 -1
- package/mcp-project-context/dist/git-ops.d.ts +0 -40
- package/mcp-project-context/dist/git-ops.d.ts.map +0 -1
- package/mcp-project-context/dist/index.d.ts +0 -20
- package/mcp-project-context/dist/index.d.ts.map +0 -1
- package/mcp-project-context/dist/project-analysis.d.ts +0 -50
- package/mcp-project-context/dist/project-analysis.d.ts.map +0 -1
- package/mcp-routinecode/dist/agent-tracker.d.ts +0 -68
- package/mcp-routinecode/dist/attestation.d.ts +0 -37
- package/mcp-routinecode/dist/blast-radius.d.ts +0 -83
- package/mcp-routinecode/dist/changeset.d.ts +0 -86
- package/mcp-routinecode/dist/config-auth.d.ts +0 -15
- package/mcp-routinecode/dist/contracts.generated.d.ts +0 -57
- package/mcp-routinecode/dist/coverage.d.ts +0 -49
- package/mcp-routinecode/dist/explorer-advisor.d.ts +0 -34
- package/mcp-routinecode/dist/failure-tracker.d.ts +0 -32
- package/mcp-routinecode/dist/file-lock-registry.d.ts +0 -31
- package/mcp-routinecode/dist/file-risk-scorer.d.ts +0 -27
- package/mcp-routinecode/dist/index.d.ts +0 -13
- package/mcp-routinecode/dist/known-solutions.d.ts +0 -57
- package/mcp-routinecode/dist/ledger-miner.d.ts +0 -19
- package/mcp-routinecode/dist/observed-draft.d.ts +0 -42
- package/mcp-routinecode/dist/pattern-matcher.d.ts +0 -14
- package/mcp-routinecode/dist/route-match.d.ts +0 -24
- package/mcp-routinecode/dist/routines.d.ts +0 -59
- package/mcp-routinecode/dist/rule-engine.d.ts +0 -53
- package/mcp-routinecode/dist/rule-promoter.d.ts +0 -22
- package/mcp-routinecode/dist/telemetry-analyzer.d.ts +0 -56
- package/mcp-routinecode/dist/test-runner.d.ts +0 -66
- package/mcp-routinecode/dist/verification.d.ts +0 -173
- package/mcp-routinecode/dist/viral-loop.d.ts +0 -227
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Unit tests for hooks/lib/ledger.py and ledger_reader.py
|
|
3
|
-
# Phase 1 Sprint 1 — Hybrid schema validation
|
|
4
|
-
|
|
5
|
-
set -u
|
|
6
|
-
|
|
7
|
-
HOOKS_DIR=/Users/kangsan/Desktop/work/dev/kangsan/routinecode/hooks
|
|
8
|
-
LIB_DIR="$HOOKS_DIR/lib"
|
|
9
|
-
|
|
10
|
-
# Use temp ledger dir for isolation
|
|
11
|
-
export ROUTINECODE_TEST_LEDGER_DIR="$(mktemp -d)"
|
|
12
|
-
trap 'rm -rf "$ROUTINECODE_TEST_LEDGER_DIR"' EXIT
|
|
13
|
-
|
|
14
|
-
# Override ledger location for testing
|
|
15
|
-
export PYTHONPATH="$LIB_DIR:${PYTHONPATH:-}"
|
|
16
|
-
|
|
17
|
-
pass=0
|
|
18
|
-
fail=0
|
|
19
|
-
|
|
20
|
-
run_python() {
|
|
21
|
-
local name="$1"
|
|
22
|
-
shift
|
|
23
|
-
# Test isolation: per-test ledger dir
|
|
24
|
-
local test_dir
|
|
25
|
-
test_dir=$(mktemp -d)
|
|
26
|
-
local result
|
|
27
|
-
result=$(LEDGER_OVERRIDE="$test_dir" python3 - <<PYEOF 2>&1
|
|
28
|
-
import sys, os
|
|
29
|
-
sys.path.insert(0, "$LIB_DIR")
|
|
30
|
-
# Override ledger paths for test isolation
|
|
31
|
-
import ledger
|
|
32
|
-
import ledger_reader
|
|
33
|
-
from pathlib import Path
|
|
34
|
-
test_dir = Path(os.environ["LEDGER_OVERRIDE"])
|
|
35
|
-
ledger.LEDGER_DIR = test_dir
|
|
36
|
-
ledger.CURRENT_PATH = test_dir / 'current.jsonl'
|
|
37
|
-
ledger.PERSISTENT_PATH = test_dir / 'persistent.jsonl'
|
|
38
|
-
ledger.ARCHIVE_DIR = test_dir / 'archive'
|
|
39
|
-
ledger.CORRUPT_LOG = test_dir / '.corrupt-lines.log'
|
|
40
|
-
ledger.ROTATING_MARKER = test_dir / 'current.jsonl.rotating'
|
|
41
|
-
ledger_reader.LEDGER_DIR = test_dir
|
|
42
|
-
ledger_reader.CURRENT_PATH = test_dir / 'current.jsonl'
|
|
43
|
-
ledger_reader.PERSISTENT_PATH = test_dir / 'persistent.jsonl'
|
|
44
|
-
ledger_reader.CORRUPT_LOG = test_dir / '.corrupt-lines.log'
|
|
45
|
-
|
|
46
|
-
$1
|
|
47
|
-
PYEOF
|
|
48
|
-
)
|
|
49
|
-
rm -rf "$test_dir"
|
|
50
|
-
local exit_code=$?
|
|
51
|
-
if [ $exit_code -eq 0 ] && echo "$result" | grep -q "^OK"; then
|
|
52
|
-
printf ' \033[32mPASS\033[0m %s\n' "$name"
|
|
53
|
-
pass=$((pass + 1))
|
|
54
|
-
else
|
|
55
|
-
printf ' \033[31mFAIL\033[0m %s\n' "$name"
|
|
56
|
-
echo "$result" | sed 's/^/ /'
|
|
57
|
-
fail=$((fail + 1))
|
|
58
|
-
fi
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
echo "=== Ledger Sprint 1 Unit Tests ==="
|
|
62
|
-
|
|
63
|
-
# 1. Evidence ID format & uniqueness
|
|
64
|
-
run_python "1. evidence_id format ev-{ts_ns}-{rand6}" "
|
|
65
|
-
import re
|
|
66
|
-
ids = [ledger._make_evidence_id() for _ in range(100)]
|
|
67
|
-
pattern = re.compile(r'^ev-\d{19}-[a-f0-9]{6}\$')
|
|
68
|
-
assert all(pattern.match(i) for i in ids), 'format mismatch'
|
|
69
|
-
assert len(set(ids)) == 100, 'collision detected'
|
|
70
|
-
print('OK')
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
# 2. Redaction: GitHub PAT
|
|
74
|
-
run_python "2. redact ghp_ token" "
|
|
75
|
-
text = 'git push https://ghp_abcdefghijklmnopqrstuvwxyz0123456789@github.com/x/y'
|
|
76
|
-
result = ledger.redact_for_test(text)
|
|
77
|
-
assert 'ghp_abc' not in result, f'ghp_ leaked: {result}'
|
|
78
|
-
assert '***REDACTED***' in result, f'no redaction marker: {result}'
|
|
79
|
-
print('OK')
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
# 3. Redaction: npm token
|
|
83
|
-
run_python "3. redact npm_ token" "
|
|
84
|
-
text = 'npm config set //registry.npmjs.org/:_authToken=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'
|
|
85
|
-
result = ledger.redact_for_test(text)
|
|
86
|
-
assert 'npm_O5FT' not in result
|
|
87
|
-
print('OK')
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
# 4. Redaction: Anthropic API
|
|
91
|
-
run_python "4. redact sk-ant- token" "
|
|
92
|
-
text = 'curl -H \"Authorization: Bearer sk-ant-api03-AbCdEf1234567890aBcDeF1234567890AbCdEf12345\" url'
|
|
93
|
-
result = ledger.redact_for_test(text)
|
|
94
|
-
assert 'sk-ant-api03-Ab' not in result, f'sk-ant leaked: {result}'
|
|
95
|
-
print('OK')
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
# 5. Redaction: AWS access key
|
|
99
|
-
run_python "5. redact AKIA token" "
|
|
100
|
-
text = 'AWS_ACCESS_KEY_ID=AKIA1234567890ABCDEF'
|
|
101
|
-
result = ledger.redact_for_test(text)
|
|
102
|
-
assert 'AKIA1234567890ABCDEF' not in result
|
|
103
|
-
print('OK')
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
# 6. Redaction: URL embedded credentials
|
|
107
|
-
run_python "6. redact URL credentials" "
|
|
108
|
-
text = 'git clone https://user:secretpass@github.com/x/y'
|
|
109
|
-
result = ledger.redact_for_test(text)
|
|
110
|
-
assert 'secretpass' not in result, f'pass leaked: {result}'
|
|
111
|
-
assert 'https://***@' in result
|
|
112
|
-
print('OK')
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
# 7. Hard guardrail: ghp_ rejection
|
|
116
|
-
run_python "7. HARD_REDACT_CHECK detects ghp_" "
|
|
117
|
-
line = '{\"foo\":\"ghp_abcdefghijklmnopqrstuvwxyz0123456789\"}'
|
|
118
|
-
matched = ledger.check_hard_redact_for_test(line)
|
|
119
|
-
assert matched is not None, 'should detect ghp_'
|
|
120
|
-
print('OK')
|
|
121
|
-
"
|
|
122
|
-
|
|
123
|
-
# 8. Hard guardrail: clean line
|
|
124
|
-
run_python "8. HARD_REDACT_CHECK passes clean line" "
|
|
125
|
-
line = '{\"foo\":\"redacted ***REDACTED***\"}'
|
|
126
|
-
assert ledger.check_hard_redact_for_test(line) is None
|
|
127
|
-
print('OK')
|
|
128
|
-
"
|
|
129
|
-
|
|
130
|
-
# 9. Write basic entry
|
|
131
|
-
run_python "9. write_evidence basic entry" "
|
|
132
|
-
ev_id = ledger.write_evidence(
|
|
133
|
-
session_id='test-sess',
|
|
134
|
-
source_hook='test-hook',
|
|
135
|
-
category='bash_action',
|
|
136
|
-
subcategory='git_push',
|
|
137
|
-
outcome='success',
|
|
138
|
-
payload={'command': 'git push origin main', 'exit_code': 0},
|
|
139
|
-
)
|
|
140
|
-
assert ev_id is not None
|
|
141
|
-
assert ev_id.startswith('ev-')
|
|
142
|
-
# Verify file content
|
|
143
|
-
import json
|
|
144
|
-
lines = open(ledger.CURRENT_PATH).readlines()
|
|
145
|
-
assert len(lines) == 1
|
|
146
|
-
e = json.loads(lines[0])
|
|
147
|
-
assert e['schema_v'] == 1
|
|
148
|
-
assert e['session_id'] == 'test-sess'
|
|
149
|
-
assert e['category'] == 'bash_action'
|
|
150
|
-
assert e['payload']['command_redacted'] == 'git push origin main'
|
|
151
|
-
assert 'command' not in e['payload'] # auto-removed
|
|
152
|
-
print('OK')
|
|
153
|
-
"
|
|
154
|
-
|
|
155
|
-
# 10. Hybrid schema: Layer A 5 fields always present
|
|
156
|
-
run_python "10. Layer A 5 fields always present" "
|
|
157
|
-
ev_id = ledger.write_evidence(session_id='s', source_hook='h')
|
|
158
|
-
import json
|
|
159
|
-
e = json.loads(open(ledger.CURRENT_PATH).readlines()[-1])
|
|
160
|
-
required = {'schema_v', 'evidence_id', 'ts_ns', 'session_id', 'source_hook'}
|
|
161
|
-
assert required.issubset(e.keys()), f'missing: {required - e.keys()}'
|
|
162
|
-
# Optional fields should be absent
|
|
163
|
-
assert 'category' not in e
|
|
164
|
-
assert 'payload' not in e
|
|
165
|
-
print('OK')
|
|
166
|
-
"
|
|
167
|
-
|
|
168
|
-
# 11. Layer C free-form payload
|
|
169
|
-
run_python "11. Layer C free-form payload preserved" "
|
|
170
|
-
ev_id = ledger.write_evidence(
|
|
171
|
-
session_id='s', source_hook='h',
|
|
172
|
-
payload={'any_future_field': 'anything', 'nested': {'x': 1}}
|
|
173
|
-
)
|
|
174
|
-
import json
|
|
175
|
-
e = json.loads(open(ledger.CURRENT_PATH).readlines()[-1])
|
|
176
|
-
assert e['payload']['any_future_field'] == 'anything'
|
|
177
|
-
assert e['payload']['nested']['x'] == 1
|
|
178
|
-
print('OK')
|
|
179
|
-
"
|
|
180
|
-
|
|
181
|
-
# 12. 4KB truncation
|
|
182
|
-
run_python "12. >4KB entry auto-truncated" "
|
|
183
|
-
huge = 'x' * 5000
|
|
184
|
-
ev_id = ledger.write_evidence(
|
|
185
|
-
session_id='s', source_hook='h',
|
|
186
|
-
payload={'big': huge, 'category_hint': 'test'}
|
|
187
|
-
)
|
|
188
|
-
import json
|
|
189
|
-
e = json.loads(open(ledger.CURRENT_PATH).readlines()[-1])
|
|
190
|
-
assert e['payload'].get('_truncated') == True
|
|
191
|
-
print('OK')
|
|
192
|
-
"
|
|
193
|
-
|
|
194
|
-
# 13. Hard redact rejects entry
|
|
195
|
-
run_python "13. entry with ghp_ in payload is rejected" "
|
|
196
|
-
ev_id = ledger.write_evidence(
|
|
197
|
-
session_id='s', source_hook='h',
|
|
198
|
-
payload={'leaked': 'ghp_abcdefghijklmnopqrstuvwxyz0123456789'}
|
|
199
|
-
)
|
|
200
|
-
# raw token in unredacted payload field → HARD_REDACT_CHECK catches it
|
|
201
|
-
assert ev_id is None, 'should reject'
|
|
202
|
-
import os
|
|
203
|
-
size = os.path.getsize(ledger.CURRENT_PATH) if ledger.CURRENT_PATH.exists() else 0
|
|
204
|
-
assert size == 0, f'file should be empty, got {size} bytes'
|
|
205
|
-
print('OK')
|
|
206
|
-
"
|
|
207
|
-
|
|
208
|
-
# 14. Disabled env var
|
|
209
|
-
run_python "14. ROUTINECODE_LEDGER_DISABLED=1 skips write" "
|
|
210
|
-
import os
|
|
211
|
-
os.environ['ROUTINECODE_LEDGER_DISABLED'] = '1'
|
|
212
|
-
ev_id = ledger.write_evidence(session_id='s', source_hook='h')
|
|
213
|
-
del os.environ['ROUTINECODE_LEDGER_DISABLED']
|
|
214
|
-
assert ev_id is None
|
|
215
|
-
import os
|
|
216
|
-
size = os.path.getsize(ledger.CURRENT_PATH) if ledger.CURRENT_PATH.exists() else 0
|
|
217
|
-
assert size == 0
|
|
218
|
-
print('OK')
|
|
219
|
-
"
|
|
220
|
-
|
|
221
|
-
# 15. Reader: query_evidence basic
|
|
222
|
-
run_python "15. query_evidence by session_id" "
|
|
223
|
-
ledger.write_evidence(session_id='s1', source_hook='h', category='bash_action', subcategory='npm_publish', outcome='success')
|
|
224
|
-
ledger.write_evidence(session_id='s2', source_hook='h', category='bash_action', subcategory='npm_publish', outcome='success')
|
|
225
|
-
ledger.write_evidence(session_id='s1', source_hook='h', category='code_change', subcategory='edit_write', outcome='success')
|
|
226
|
-
results = ledger_reader.query_evidence(session_id='s1')
|
|
227
|
-
assert len(results) == 2, f'expected 2 for s1, got {len(results)}'
|
|
228
|
-
results_npm = ledger_reader.query_evidence(session_id='s1', categories=['bash_action'])
|
|
229
|
-
assert len(results_npm) == 1
|
|
230
|
-
print('OK')
|
|
231
|
-
"
|
|
232
|
-
|
|
233
|
-
# 16. Reader: latest_for resolves supersedes
|
|
234
|
-
run_python "16. latest_for + supersedes resolution" "
|
|
235
|
-
e1 = ledger.write_evidence(session_id='s', source_hook='h', category='c', subcategory='sub', outcome='unknown')
|
|
236
|
-
e2 = ledger.write_evidence(session_id='s', source_hook='h', category='c', subcategory='sub', outcome='success',
|
|
237
|
-
payload={'links': {'supersedes': e1}})
|
|
238
|
-
result = ledger_reader.latest_for('s', category='c', subcategory='sub')
|
|
239
|
-
assert result is not None
|
|
240
|
-
assert result['evidence_id'] == e2, f'expected {e2}, got {result.get(\"evidence_id\")}'
|
|
241
|
-
assert result['outcome'] == 'success'
|
|
242
|
-
print('OK')
|
|
243
|
-
"
|
|
244
|
-
|
|
245
|
-
# 17. Reader: get_summary aggregate
|
|
246
|
-
run_python "17. get_summary by_category counts" "
|
|
247
|
-
ledger.write_evidence(session_id='s', source_hook='h', category='bash_action', outcome='success')
|
|
248
|
-
ledger.write_evidence(session_id='s', source_hook='h', category='bash_action', outcome='failure')
|
|
249
|
-
ledger.write_evidence(session_id='s', source_hook='h', category='code_change', outcome='success')
|
|
250
|
-
summary = ledger_reader.get_summary('s')
|
|
251
|
-
assert summary['total_events'] == 3, f'got {summary}'
|
|
252
|
-
assert summary['by_category']['bash_action'] == 2
|
|
253
|
-
assert summary['by_outcome']['success'] == 2
|
|
254
|
-
print('OK')
|
|
255
|
-
"
|
|
256
|
-
|
|
257
|
-
# 18. Reader: corrupt line handling
|
|
258
|
-
run_python "18. corrupt line is skipped, others parsed" "
|
|
259
|
-
ledger.write_evidence(session_id='s', source_hook='h', category='c', outcome='success')
|
|
260
|
-
# Manually inject corrupt line
|
|
261
|
-
with open(ledger.CURRENT_PATH, 'a') as f:
|
|
262
|
-
f.write('this is not json\n')
|
|
263
|
-
f.write('{\"valid\":true}\n') # missing required schema_v but parses as json
|
|
264
|
-
ledger.write_evidence(session_id='s', source_hook='h', category='c', outcome='success')
|
|
265
|
-
results = ledger_reader.query_evidence(session_id='s')
|
|
266
|
-
# should get 2 valid entries (corrupt line skipped, '{valid:true}' lacks session_id so filtered out)
|
|
267
|
-
assert len(results) == 2, f'expected 2, got {len(results)}'
|
|
268
|
-
print('OK')
|
|
269
|
-
"
|
|
270
|
-
|
|
271
|
-
# 19. Persistent retention
|
|
272
|
-
run_python "19. retention=persistent writes to both files" "
|
|
273
|
-
ev_id = ledger.write_evidence(
|
|
274
|
-
session_id='s', source_hook='h',
|
|
275
|
-
category='meta', subcategory='intelligence_record',
|
|
276
|
-
retention='persistent',
|
|
277
|
-
)
|
|
278
|
-
import os
|
|
279
|
-
current_size = os.path.getsize(ledger.CURRENT_PATH)
|
|
280
|
-
persist_size = os.path.getsize(ledger.PERSISTENT_PATH)
|
|
281
|
-
assert current_size > 0, 'current.jsonl empty'
|
|
282
|
-
assert persist_size > 0, 'persistent.jsonl empty'
|
|
283
|
-
print('OK')
|
|
284
|
-
"
|
|
285
|
-
|
|
286
|
-
# 20. Time-range query
|
|
287
|
-
run_python "20. since_ts_ns filter" "
|
|
288
|
-
import time
|
|
289
|
-
ledger.write_evidence(session_id='s', source_hook='h', category='c', outcome='success')
|
|
290
|
-
mid_ts = time.time_ns() if hasattr(time, 'time_ns') else int(time.time() * 1_000_000_000)
|
|
291
|
-
time.sleep(0.001)
|
|
292
|
-
ledger.write_evidence(session_id='s', source_hook='h', category='c', outcome='success')
|
|
293
|
-
results = ledger_reader.query_evidence(session_id='s', since_ts_ns=mid_ts)
|
|
294
|
-
assert len(results) == 1, f'expected 1 after mid_ts, got {len(results)}'
|
|
295
|
-
print('OK')
|
|
296
|
-
"
|
|
297
|
-
|
|
298
|
-
echo ""
|
|
299
|
-
echo "=== Result: ${pass} PASS / ${fail} FAIL ==="
|
|
300
|
-
[ "$fail" -eq 0 ] && exit 0 || exit 1
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# MCP 도구명 배선 회귀 테스트.
|
|
3
|
-
# 대화형 세션 실제 도구명(mcp__mcp-<server>__x, ~/.claude.json 서버키 'mcp-*')과
|
|
4
|
-
# 헤드리스 recorder 도구명(mcp__<server>__x) 양쪽이 모든 MCP matcher·가드에 걸려야 한다.
|
|
5
|
-
# (2.31.43~56: 훅이 구형 이름만 보고 대화형 세션에서 전부 미발화했던 결함의 재발 방지)
|
|
6
|
-
|
|
7
|
-
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
8
|
-
HOOKS="$(dirname "$HERE")"
|
|
9
|
-
ROOT="$(dirname "$HOOKS")"
|
|
10
|
-
FAIL=0
|
|
11
|
-
ok() { echo " ok $1"; }
|
|
12
|
-
bad() { echo " FAIL $1"; FAIL=1; }
|
|
13
|
-
|
|
14
|
-
echo "[1] hooks-config.json MCP matcher × 두 이름 형식"
|
|
15
|
-
python3 - "$HOOKS/hooks-config.json" <<'EOF' || FAIL=1
|
|
16
|
-
import json, re, sys
|
|
17
|
-
d = json.load(open(sys.argv[1]))
|
|
18
|
-
# (이벤트, 훅 스크립트, 서버, 대표 도구) — 각 도구를 구형·실제 두 이름으로 검사
|
|
19
|
-
CASES = [
|
|
20
|
-
('PostToolUse', 'post-build-check.sh', 'routinecode', 'build_check'),
|
|
21
|
-
('PostToolUse', 'post-knowledge-query.sh', 'intelligence', 'get_similar_errors'),
|
|
22
|
-
('PostToolUse', 'post-knowledge-query.sh', 'intelligence', 'get_known_quirks'),
|
|
23
|
-
('PostToolUse', 'post-domain-knowledge-record.sh', 'intelligence', 'record_domain_knowledge'),
|
|
24
|
-
('PreToolUse', 'pre-mark-complete.sh', 'plan_manager', 'mark_task_complete'),
|
|
25
|
-
]
|
|
26
|
-
bad = 0
|
|
27
|
-
for ev, script, srv, tool in CASES:
|
|
28
|
-
ms = [e['matcher'] for e in d['hooks'][ev] if any(h['command'].endswith(script) for h in e['hooks'])]
|
|
29
|
-
for name in (f'mcp__{srv}__{tool}', f'mcp__mcp-{srv.replace("_", "-")}__{tool}'):
|
|
30
|
-
hit = any(re.fullmatch(m, name) for m in ms)
|
|
31
|
-
print((' ok ' if hit else ' FAIL ') + f'{script} <- {name}')
|
|
32
|
-
bad += 0 if hit else 1
|
|
33
|
-
sys.exit(1 if bad else 0)
|
|
34
|
-
EOF
|
|
35
|
-
|
|
36
|
-
echo "[2] pre-credit-guard 세션 MCP 마커 (두 형식)"
|
|
37
|
-
X="$(mktemp -d)"
|
|
38
|
-
for name in mcp__routinecode__build_check mcp__mcp-routinecode__build_check mcp__mcp-project-context__search_code mcp__mcp-intelligence__get_patterns; do
|
|
39
|
-
sid="t-$(echo "$name" | tr -c 'a-z0-9' '-')"
|
|
40
|
-
echo "{\"session_id\":\"$sid\",\"tool_name\":\"$name\"}" | XDG_RUNTIME_DIR="$X" bash "$HOOKS/pre-credit-guard.sh" >/dev/null 2>&1
|
|
41
|
-
[ -f "$X/sess-$sid.mcp" ] && ok "marker ← $name" || bad "marker ← $name"
|
|
42
|
-
done
|
|
43
|
-
rm -rf "$X"
|
|
44
|
-
|
|
45
|
-
echo "[3] evidence.py 정규화"
|
|
46
|
-
python3 -c "
|
|
47
|
-
import sys; sys.path.insert(0, '$HOOKS/lib')
|
|
48
|
-
import evidence as e
|
|
49
|
-
assert e.normalize_mcp_tool_name('mcp__mcp-routinecode__build_check') in e.MCP_TOOL_DOMAIN
|
|
50
|
-
assert e.normalize_mcp_tool_name('mcp__mcp-dev-tester__test_endpoint') in e.MCP_TOOL_DOMAIN
|
|
51
|
-
assert e.normalize_mcp_tool_name('mcp__routinecode__build_check') in e.MCP_TOOL_DOMAIN
|
|
52
|
-
" && ok "evidence normalize" || bad "evidence normalize"
|
|
53
|
-
|
|
54
|
-
echo "[4] 서브에이전트 tools 허용목록에 실제 도구명 포함"
|
|
55
|
-
for a in reviewer planner analyzer; do
|
|
56
|
-
f="$ROOT/plugin/agents/$a.md"
|
|
57
|
-
if grep -q '^tools:.*mcp__intelligence__' "$f"; then
|
|
58
|
-
grep -q '^tools:.*mcp__mcp-intelligence__' "$f" && ok "$a" || bad "$a (mcp__mcp-intelligence__ 누락)"
|
|
59
|
-
else
|
|
60
|
-
ok "$a (MCP 미사용)"
|
|
61
|
-
fi
|
|
62
|
-
done
|
|
63
|
-
|
|
64
|
-
[ "$FAIL" = 0 ] && echo "PASS" || { echo "FAILED"; exit 1; }
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"""rm_guard 회귀 테스트 — Claude Code 2.1.301 헤드리스 실측표 고정.
|
|
2
|
-
|
|
3
|
-
PROMPTED: 순수 하네스(bypass)에서 '위험 삭제' 확인창이 뜬 형태 → 반드시 deny/rewrite/block.
|
|
4
|
-
CLEAN : 확인창이 안 뜬 형태 → 손대지 않음(None). 재작성(rewrite)은 무해하므로 허용 목록 별도.
|
|
5
|
-
실행: python3 hooks/tests/rm-guard.test.py
|
|
6
|
-
"""
|
|
7
|
-
import os
|
|
8
|
-
import sys
|
|
9
|
-
|
|
10
|
-
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'lib'))
|
|
11
|
-
import rm_guard as rg # noqa: E402
|
|
12
|
-
|
|
13
|
-
WS = '/private/tmp/rclab-unit/ws'
|
|
14
|
-
|
|
15
|
-
PROMPTED = [ # (id, command, expected action)
|
|
16
|
-
('L03', 'rm -rf ./*', 'deny'),
|
|
17
|
-
('L04', 'rm -rf *', 'deny'),
|
|
18
|
-
('L06', 'cd build && rm -rf ./*', 'deny'),
|
|
19
|
-
('L08', 'rm -rf .', 'deny'),
|
|
20
|
-
('L10', f'rm -rf {WS}', 'deny'),
|
|
21
|
-
('L12', 'rm -rf ../ws/build/*', 'deny'),
|
|
22
|
-
('L13', 'rm -rf build/*/*', 'deny'),
|
|
23
|
-
('V05', 'rm -rf $RCLABX/lib', 'rewrite'),
|
|
24
|
-
('V07', 'rm -f $RCLABX/*.rclabnx', 'rewrite'),
|
|
25
|
-
('V09', 'rm -rf $RCLABX/$RCLABF/rclab-nx', 'rewrite'),
|
|
26
|
-
('V11', 'R=$(pwd); rm -rf $R', 'deny'),
|
|
27
|
-
('V14', 'for f in a b; do rm -rf $RCLABX/$f; done', 'rewrite'),
|
|
28
|
-
('S06', 'sh -c \'rm -rf "$RCLABX"/*.rclabnx\'', 'rewrite'),
|
|
29
|
-
('S08', "sh -c $'rm -rf rclab-nx\\necho x'", 'deny'),
|
|
30
|
-
('S24', f'S={WS}/build; H=/var/tmp/rclab-check\ncd {WS} && rm -f ${{S:?}}/*.tgz\ncolima ssh -- sudo sh -c "rm -rf $H; mkdir -p ${{H:?}}/a"', 'deny'),
|
|
31
|
-
('N02', 'H=/var/tmp/rclab-check\ncd build && rm -f a.png\ncolima ssh -- sudo sh -c "rm -rf $H"', 'deny'),
|
|
32
|
-
('C18', 'cd build && rm -rf *', 'deny'),
|
|
33
|
-
('C19', 'cd build && rm -rf sub/*', 'deny'),
|
|
34
|
-
('D02', 'R=$(pwd); rm -rf $R/*', 'deny'),
|
|
35
|
-
('D06', f'rm -rf {WS}/*', 'deny'),
|
|
36
|
-
('D07', 'rm -rf ../ws', 'deny'),
|
|
37
|
-
('D08', 'rm -rf build dist .', 'deny'),
|
|
38
|
-
('S09', 'sudo -n sh -c "rm -rf $RCLABX/lib" 2>/dev/null; echo done', 'deny'),
|
|
39
|
-
('S09g', 'sh -c "rm -rf ${RCLABX:?}/tmp"', 'deny'),
|
|
40
|
-
('X01', 'sh -c "rm -rf $RCLABX/$RCLABF/rclab-nx"', 'deny'),
|
|
41
|
-
('X03', 'bash -c "cd build && rm -rf *"', 'deny'),
|
|
42
|
-
('X04', 'sh -c "rm -rf ./*"', 'deny'),
|
|
43
|
-
('X06', '(cd build && rm -rf *)', 'deny'),
|
|
44
|
-
('X07', '{ cd build; rm -rf ./*; }', 'deny'),
|
|
45
|
-
('X08', 'cd build || exit; rm -rf *', 'deny'),
|
|
46
|
-
('X09', 'pushd build && rm -rf * && popd', 'deny'),
|
|
47
|
-
('X10', 'rm -rf -- *', 'deny'),
|
|
48
|
-
('X12', 'rm -rf $(ls -d build)', 'deny'),
|
|
49
|
-
('X23', 'cd build && rm -rf ../dist/*', 'deny'),
|
|
50
|
-
('X24', 'rm -rf ./build/../*', 'deny'),
|
|
51
|
-
('T2', 'rm -rf /x/p\nfor d in 0.1; do\n bash -c "echo x" & pid=$!\n python3 -c "import time;time.sleep($d)"\ndone', 'deny'),
|
|
52
|
-
('Q', 'S=/x/k; rm -rf ${S:?}/p\nFN=$(sed -n p f)\nfor s in TERM; do\n bash -c "$FN"$\'\\n\'"f ${S:?}/p" & pid=$!\n wait $pid\ndone', 'deny'),
|
|
53
|
-
('SHOT', 'S=/x/scratch; H=/var/tmp/llm-auth-cli-check\ncd /x/pkg && rm -f ${S:?}/*.tgz && npm pack --pack-destination $S >/dev/null\n'
|
|
54
|
-
'colima ssh -- sudo sh -c "rm -rf $H; mkdir -p ${H:?}/claude-auth ${H:?}/vendor && chown 1000:1000 ${H:?}/claude-auth"\n'
|
|
55
|
-
'colima ssh -- sudo sh -c "stat -c \'%u:%g %a\' ${H:?}/claude-auth/tokens.json; rm -rf $H"', 'deny'),
|
|
56
|
-
]
|
|
57
|
-
|
|
58
|
-
CLEAN = [ # 확인창 없음 → None
|
|
59
|
-
'rm -rf build', f'rm -rf {WS}/build', 'rm -f *.log', 'cd build && rm -f *.png', 'rm -rf ~/rclab-nx/*',
|
|
60
|
-
'rm -rf */node_modules', 'rm -rf build/*', 'cd build; rm -rf sub', 'rmdir -p a/node_modules',
|
|
61
|
-
'rm -rf ${RCLABX:?}/rclab-nx/*', 'rm -rf "$(pwd)"/build', 'rm -rf $(pwd)/rclab-nx/*',
|
|
62
|
-
f'rm -rf "$(dirname {WS})/ws/dist"', f'sh -c "rm -rf {WS}/build"', 'bash -c \'rm -rf "$0"/x\' /p',
|
|
63
|
-
f'eval "rm -rf {WS}/dist"', "find build -name '*.png' | xargs rm -f", "find build -name '*.png' -delete",
|
|
64
|
-
'colima ssh -- sudo rm -rf /var/tmp/rclab-nx', 'cd .. && rm -rf ws', 'rm -rf ./build ./dist',
|
|
65
|
-
'rm -rf ../rclab-nx-sibling', 'cd build && sh -c "rm -rf sub"', 'cd build && rm -rf /abs/dist/*',
|
|
66
|
-
'H=/v/t; cd build; sh -c "rm -rf ${H:?}"', 'git rm --cached a.txt', "grep -rn 'rm -rf' hooks/",
|
|
67
|
-
'docker run --rm alpine true', "find . -maxdepth 1 -name 'x.log' -exec rm -f {} +", 'ls | xargs rm -rf',
|
|
68
|
-
'rm -rf {build,dist}', 'git clean -fdx -e keep', 'sh -c "rm -rf $RCLABX/rclab-nx/*; echo x"', 'rm -rf ${X:?}/lib', 'sh -c "rm -rf ${X:?}/rclab-nx/*"',
|
|
69
|
-
]
|
|
70
|
-
|
|
71
|
-
BLOCK = ['rm -rf /', 'rm -rf ~', 'rm -rf $HOME', 'rm -rf /usr/local/lib', 'sudo rm -rf /etc/x', 'rm -rf ~/.ssh']
|
|
72
|
-
|
|
73
|
-
HEREDOC = ("cat > /tmp/x.tsv <<'EOF'\nV07\trm -f $RCLABX/*.png\nrm -rf $D/*\nEOF\nrm -rf $SCR/$f",
|
|
74
|
-
"cat > /tmp/x.tsv <<'EOF'\nV07\trm -f $RCLABX/*.png\nrm -rf $D/*\nEOF\nrm -rf ${SCR:?}/$f")
|
|
75
|
-
|
|
76
|
-
ok = fail = 0
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
def check(name, cond, detail=''):
|
|
80
|
-
global ok, fail
|
|
81
|
-
if cond:
|
|
82
|
-
ok += 1
|
|
83
|
-
print(f' \033[32m✓\033[0m {name}')
|
|
84
|
-
else:
|
|
85
|
-
fail += 1
|
|
86
|
-
print(f' \033[31m✗\033[0m {name} {detail}')
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
for cid, cmd, want in PROMPTED:
|
|
90
|
-
r = rg.analyze(cmd, WS)
|
|
91
|
-
got = list(r)[0] if r else 'none'
|
|
92
|
-
check(f'PROMPTED {cid} → {want}', got == want, f'(got {got}: {r})')
|
|
93
|
-
if got == 'rewrite':
|
|
94
|
-
again = rg.analyze(r['rewrite'], WS)
|
|
95
|
-
check(f'PROMPTED {cid} rewrite is stable', again is None, f'(re-analyze → {again})')
|
|
96
|
-
for cmd in CLEAN:
|
|
97
|
-
r = rg.analyze(cmd, WS)
|
|
98
|
-
check(f'CLEAN {cmd[:50]!r}', r is None or 'rewrite' in r, f'(got {r})')
|
|
99
|
-
for cmd in BLOCK:
|
|
100
|
-
r = rg.analyze(cmd, WS)
|
|
101
|
-
check(f'BLOCK {cmd!r}', bool(r) and 'block' in r, f'(got {r})')
|
|
102
|
-
r = rg.analyze(HEREDOC[0], WS)
|
|
103
|
-
check('heredoc body is never rewritten', bool(r) and r.get('rewrite') == HEREDOC[1], f'(got {r})')
|
|
104
|
-
check('deny reasons carry [RoutineCode] + example', all(
|
|
105
|
-
rg.deny_reason(k).startswith('[RoutineCode]') for k in rg.REASONS))
|
|
106
|
-
|
|
107
|
-
print(f'\n{ok}/{ok + fail} passed')
|
|
108
|
-
sys.exit(1 if fail else 0)
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# secret-guard 우회 접근 방어 테스트 (2026-10-16)
|
|
3
|
-
#
|
|
4
|
-
# 보호 파일 값이 "경로를 숨긴 접근"으로도 모델 출력에 실리지 않는지 검증한다.
|
|
5
|
-
# - Bash: 따옴표 조각 경로 · 변수 경로 · 글롭 · 디렉토리 · 인라인 인터프리터 · base64 인코딩
|
|
6
|
-
# - Read/Grep: Bash 로 만든 사본 파일
|
|
7
|
-
# - 회귀: 무관한 명령은 감싸지 않고, 차단(block)은 새로 생기지 않는다(scrub-only 경계)
|
|
8
|
-
#
|
|
9
|
-
# 실행: bash hooks/tests/secret-guard-bypass.test.sh
|
|
10
|
-
|
|
11
|
-
set -u
|
|
12
|
-
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
13
|
-
LIB_DIR="$HOOK_DIR/lib"
|
|
14
|
-
PASS=0; FAIL=0
|
|
15
|
-
ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS+1)); }
|
|
16
|
-
ng() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL+1)); }
|
|
17
|
-
|
|
18
|
-
W=$(mktemp -d "${TMPDIR:-/tmp}/rc-bypass.XXXXXX")
|
|
19
|
-
trap 'rm -rf "${W:?}"' EXIT
|
|
20
|
-
mkdir -p "$W/vault"
|
|
21
|
-
SECRET="sk-ant-oat01-$(LC_ALL=C tr -dc 'A-Za-z0-9' </dev/urandom | head -c 90)AA"
|
|
22
|
-
OTHER="npm_$(LC_ALL=C tr -dc 'A-Za-z0-9' </dev/urandom | head -c 36)"
|
|
23
|
-
CFG="$W/vault/my.cfg"
|
|
24
|
-
printf 'notes\nclaude setup-token = %s\nNPM = %s\n' "$SECRET" "$OTHER" > "$CFG"
|
|
25
|
-
chmod 600 "$CFG"
|
|
26
|
-
POL="$W/policy.json"
|
|
27
|
-
printf '{"mode":"warn","redact_only_paths":["%s"]}' "$CFG" > "$POL"
|
|
28
|
-
export ROUTINECODE_SECRET_POLICY_PATH="$POL"
|
|
29
|
-
|
|
30
|
-
targets() { # stdout: "<탐지 파일 수> <강제 래핑 여부>"
|
|
31
|
-
printf '%s' "$1" | python3 -c "
|
|
32
|
-
import sys; sys.path.insert(0, '$LIB_DIR')
|
|
33
|
-
import secret_filter as sf
|
|
34
|
-
f, force = sf.bash_secret_targets(sys.stdin.read())
|
|
35
|
-
print(len(f), force)"
|
|
36
|
-
}
|
|
37
|
-
expect_targets() { local got; got=$(targets "$2"); [ "$got" = "$3" ] && ok "$1 → $got" || ng "$1 — 기대 [$3] 실제 [$got]"; }
|
|
38
|
-
|
|
39
|
-
echo ""
|
|
40
|
-
echo "=== bash_secret_targets: 우회 경로 해석 ==="
|
|
41
|
-
expect_targets "리터럴 경로" "cat $CFG" "1 False"
|
|
42
|
-
expect_targets "따옴표 조각 경로" "cat \"$W/vault/my.\"\"cfg\"" "1 True"
|
|
43
|
-
expect_targets "변수 대입 경로" "C=$W/vault/my.cfg; awk '{print}' \"\$C\"" "1 False"
|
|
44
|
-
expect_targets "변수 조립 경로" "D=$W/vault; F=my.cfg; tail -1 \"\$D/\$F\"" "1 False"
|
|
45
|
-
expect_targets "글롭" "head -2 $W/vault/my.c*" "1 False"
|
|
46
|
-
expect_targets "디렉토리 재귀 grep" "grep -r token $W" "1 False"
|
|
47
|
-
expect_targets "python -c 인라인" "python3 -c \"print(open('x'+'y').read())\"" "0 True"
|
|
48
|
-
expect_targets "node -e 인라인" "node -e \"console.log(1)\"" "0 True"
|
|
49
|
-
expect_targets "python heredoc" "python3 - <<'EOF'
|
|
50
|
-
print(1)
|
|
51
|
-
EOF" "0 True"
|
|
52
|
-
expect_targets "eval" "eval \"cat x\"" "0 True"
|
|
53
|
-
expect_targets "base64 디코딩" "echo eA== | base64 -d" "0 True"
|
|
54
|
-
expect_targets "find -exec" "find /tmp -name x -exec cat {} \\;" "0 True"
|
|
55
|
-
expect_targets "회귀: 무관 명령" "ls -la /tmp && echo \"a\" \"b\"" "0 False"
|
|
56
|
-
expect_targets "회귀: git" "git status --short" "0 False"
|
|
57
|
-
expect_targets "알려진 한계: 백그라운드 &" "python3 -c \"print(1)\" &" "0 False"
|
|
58
|
-
|
|
59
|
-
echo ""
|
|
60
|
-
echo "=== pre-bash-guard 실행: 출력에서 값이 가려지는가 ==="
|
|
61
|
-
run_guarded() { # 훅이 재작성한 명령(없으면 원본)을 실행해 출력
|
|
62
|
-
local cmd="$1" input out newcmd
|
|
63
|
-
input=$(python3 -c "import json,sys; print(json.dumps({'tool_name':'Bash','tool_input':{'command':sys.argv[1]},'session_id':'t'}))" "$cmd")
|
|
64
|
-
out=$(printf '%s' "$input" | "$HOOK_DIR/pre-bash-guard.sh" 2>/dev/null)
|
|
65
|
-
if printf '%s' "$out" | grep -q '"decision": *"block"'; then echo "__BLOCKED__"; return; fi
|
|
66
|
-
newcmd=$(printf '%s' "$out" | python3 -c "
|
|
67
|
-
import sys,json
|
|
68
|
-
try:
|
|
69
|
-
d=json.loads(sys.stdin.read() or '{}'); print(d.get('hookSpecificOutput',{}).get('updatedInput',{}).get('command',''))
|
|
70
|
-
except Exception: print('')")
|
|
71
|
-
[ -n "$newcmd" ] || newcmd="$cmd"
|
|
72
|
-
bash -c "$newcmd" 2>&1
|
|
73
|
-
}
|
|
74
|
-
expect_masked() {
|
|
75
|
-
local name="$1" cmd="$2" out
|
|
76
|
-
out=$(run_guarded "$cmd")
|
|
77
|
-
if [ "$out" = "__BLOCKED__" ]; then ng "$name — 차단됨(scrub-only 경계 위반)"; return; fi
|
|
78
|
-
if printf '%s' "$out" | grep -qF -e "$SECRET" -e "$OTHER"; then ng "$name — 값 노출"; return; fi
|
|
79
|
-
printf '%s' "$out" | grep -q 'MASKED\|PROTECTED\|REDACTED' && ok "$name — 가려짐" || ng "$name — 마스크 흔적 없음: $(printf '%s' "$out" | head -c 80)"
|
|
80
|
-
}
|
|
81
|
-
expect_masked "따옴표 조각 cat" "cat \"$W/vault/my.\"\"cfg\""
|
|
82
|
-
expect_masked "변수 경로 awk" "C=$W/vault/my.cfg; awk -F' = ' '/setup-token/{print \$2}' \"\$C\""
|
|
83
|
-
expect_masked "python 문자열 조립" "python3 -c \"print(open('$W/vault/my.'+'cfg').read())\""
|
|
84
|
-
expect_masked "node 인라인" "node -e \"console.log(require('fs').readFileSync('$W/vault/my'+'.cfg','utf8'))\""
|
|
85
|
-
expect_masked "base64 인코딩 덤프" "python3 -c \"import base64;print(base64.b64encode(open('$W/vault/my.'+'cfg','rb').read()).decode())\""
|
|
86
|
-
expect_masked "디렉토리 grep" "grep -rh token $W"
|
|
87
|
-
|
|
88
|
-
echo ""
|
|
89
|
-
echo "=== Read / Grep: Bash 로 만든 사본 ==="
|
|
90
|
-
COPY="$W/copy.txt"; cp "$CFG" "$COPY"; chmod 644 "$COPY"
|
|
91
|
-
read_redirect() {
|
|
92
|
-
local tool="$1" key="$2" input out
|
|
93
|
-
input=$(python3 -c "import json,sys; print(json.dumps({'tool_name':sys.argv[1],'tool_input':{sys.argv[2]:sys.argv[3],'pattern':'token'},'session_id':'t'}))" "$tool" "$key" "$COPY")
|
|
94
|
-
out=$(printf '%s' "$input" | "$HOOK_DIR/$3" 2>/dev/null)
|
|
95
|
-
printf '%s' "$out" | python3 -c "import sys,json; print(json.loads(sys.stdin.read() or '{}').get('hookSpecificOutput',{}).get('updatedInput',{}).get(sys.argv[1],''))" "$key"
|
|
96
|
-
}
|
|
97
|
-
R=$(read_redirect Read file_path pre-read-guard.sh)
|
|
98
|
-
if [ -n "$R" ] && [ "$R" != "$COPY" ] && ! grep -qF "$SECRET" "$R" && grep -q "setup-token" "$R"; then ok "Read 사본 → 값만 가린 사본으로 대체(키 이름 유지)"; else ng "Read 사본 대체 실패 [$R]"; fi
|
|
99
|
-
G=$(read_redirect Grep path pre-grep-guard.sh)
|
|
100
|
-
if [ -n "$G" ] && [ "$G" != "$COPY" ] && ! grep -qF "$SECRET" "$G"; then ok "Grep 사본 → 값만 가린 사본 검색"; else ng "Grep 사본 대체 실패 [$G]"; fi
|
|
101
|
-
PLAIN="$W/plain.txt"; echo "hello" > "$PLAIN"
|
|
102
|
-
P=$(COPY="$PLAIN"; input=$(python3 -c "import json,sys; print(json.dumps({'tool_name':'Read','tool_input':{'file_path':sys.argv[1]},'session_id':'t'}))" "$PLAIN"); printf '%s' "$input" | "$HOOK_DIR/pre-read-guard.sh" 2>/dev/null | grep -c updatedInput)
|
|
103
|
-
[ "$P" = "0" ] && ok "회귀: 보호 값 없는 파일 Read 는 그대로" || ng "회귀: 일반 파일이 재작성됨"
|
|
104
|
-
|
|
105
|
-
echo ""
|
|
106
|
-
echo "결과: PASS $PASS / FAIL $FAIL"
|
|
107
|
-
[ "$FAIL" -eq 0 ]
|