@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,604 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# 실 사용자 ledger 무접촉 — 훅이 남기는 증거 기록은 임시 디렉토리로
|
|
3
|
-
export ROUTINECODE_LEDGER_DIR="$(mktemp -d)"
|
|
4
|
-
# secret-guard 통합 테스트 (v2 — in-flight redaction 모드).
|
|
5
|
-
#
|
|
6
|
-
# 철학 변경:
|
|
7
|
-
# - 로컬 사용은 자유 (PreToolUse 차단 없음)
|
|
8
|
-
# - Anthropic API 전송 직전 PostToolUse에서 tool_response 리다이렉션
|
|
9
|
-
# - UserPromptSubmit 기본 mode는 warn (hardBlock은 policy로 명시)
|
|
10
|
-
#
|
|
11
|
-
# 실행: bash hooks/tests/secret-guard.test.sh
|
|
12
|
-
|
|
13
|
-
set -u
|
|
14
|
-
|
|
15
|
-
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
16
|
-
LIB_DIR="$HOOK_DIR/lib"
|
|
17
|
-
PASS=0
|
|
18
|
-
FAIL=0
|
|
19
|
-
|
|
20
|
-
# 셸 환경과 무관하게 판정 — 개발자 셸의 ROUTINECODE_DEV=1 은 CORE 를 의도적으로 완화한다.
|
|
21
|
-
unset ROUTINECODE_DEV
|
|
22
|
-
# CORE 는 '실물 RoutineCode 패키지'만 보호한다(6cd3898). 이름만 routinecode 인 가상 경로는
|
|
23
|
-
# 사용자 레포로 보고 통과시키므로, package.json 을 가진 픽스처 패키지로 검증한다.
|
|
24
|
-
RC_FIXTURE=$(mktemp -d)
|
|
25
|
-
RC_PKG="$RC_FIXTURE/routinecode"
|
|
26
|
-
mkdir -p "$RC_PKG/hooks/lib" "$RC_PKG/plugin/agents"
|
|
27
|
-
printf '{"name":"@routinecrew/routinecode"}\n' > "$RC_PKG/package.json"
|
|
28
|
-
trap 'rm -rf "${RC_FIXTURE:?}"' EXIT
|
|
29
|
-
|
|
30
|
-
red() { printf '\033[31m%s\033[0m' "$1"; }
|
|
31
|
-
green() { printf '\033[32m%s\033[0m' "$1"; }
|
|
32
|
-
dim() { printf '\033[2m%s\033[0m' "$1"; }
|
|
33
|
-
|
|
34
|
-
# ─── Filter module unit tests ──────────────────────────
|
|
35
|
-
echo ""
|
|
36
|
-
echo "=== secret_filter module unit tests ==="
|
|
37
|
-
|
|
38
|
-
cd "$LIB_DIR"
|
|
39
|
-
|
|
40
|
-
assert_filter() {
|
|
41
|
-
local name="$1"
|
|
42
|
-
local mode="$2"
|
|
43
|
-
local input="$3"
|
|
44
|
-
local expect_key="$4"
|
|
45
|
-
local expect_val="$5"
|
|
46
|
-
|
|
47
|
-
local out
|
|
48
|
-
out=$(printf '%s' "$input" | python3 secret_filter.py "$mode" 2>/dev/null)
|
|
49
|
-
local got
|
|
50
|
-
got=$(printf '%s' "$out" | python3 -c "import sys, json; d=json.loads(sys.stdin.read()); print(d.get('$expect_key'))" 2>/dev/null)
|
|
51
|
-
|
|
52
|
-
if [ "$got" = "$expect_val" ]; then
|
|
53
|
-
printf ' %s %s\n' "$(green ✓)" "$name"
|
|
54
|
-
PASS=$((PASS+1))
|
|
55
|
-
else
|
|
56
|
-
printf ' %s %s (expected %s=%s, got %s)\n' "$(red ✗)" "$name" "$expect_key" "$expect_val" "$got"
|
|
57
|
-
FAIL=$((FAIL+1))
|
|
58
|
-
fi
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
# Pattern detection
|
|
62
|
-
assert_filter "GitHub PAT detected" "scan" "export TOKEN=ghp_abcdefghijklmnopqrstuvwxyz0123456789" "count" "1"
|
|
63
|
-
assert_filter "Anthropic key detected" "scan" "sk-ant-api03-abcdefghijklmnopqrstuvwxyz0123456789012345" "count" "1"
|
|
64
|
-
assert_filter "AWS access key detected" "scan" "AKIAIOSFODNN7EXAMPLE" "count" "1"
|
|
65
|
-
assert_filter "JWT + Bearer detected" "scan" "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" "count" "2"
|
|
66
|
-
assert_filter "SSH private key detected" "scan" "-----BEGIN OPENSSH PRIVATE KEY-----
|
|
67
|
-
AAAA
|
|
68
|
-
-----END OPENSSH PRIVATE KEY-----" "count" "2"
|
|
69
|
-
assert_filter "plain text no false positive" "scan" "hello world this is a normal message" "count" "0"
|
|
70
|
-
assert_filter "password=value detected" "scan" "password=hunter2" "count" "1"
|
|
71
|
-
|
|
72
|
-
# Critical: screenshot/temp paths should NOT false-positive
|
|
73
|
-
assert_filter "macOS screencapture path (no FP)" "scan" "/var/folders/tv/9k9rgwm95q77fjq15l_6y_nh0000gn/T/TemporaryItems/NSIRD_screencaptureui_0IluCL/screencap.png" "count" "0"
|
|
74
|
-
assert_filter "npm package path (no FP)" "scan" "/Users/kangsan/Desktop/work/dev/kangsan/routinecode/hooks/lib/secret-policy.default.json" "count" "0"
|
|
75
|
-
assert_filter "git ref short (no FP)" "scan" "commit abc123d on main" "count" "0"
|
|
76
|
-
|
|
77
|
-
# Redaction preserves structure
|
|
78
|
-
assert_filter "Redact replaces content" "redact" "token=ghp_abcdefghijklmnopqrstuvwxyz0123456789" "count" "1"
|
|
79
|
-
|
|
80
|
-
# Custom pattern from policy file
|
|
81
|
-
assert_filter "Custom ACME pattern detected" "scan" "my company key is ACME-ABCDEF-xxxxxxxxxxxxxxxxxxxxxxxx" "count" "1"
|
|
82
|
-
assert_filter "Custom rcw pattern detected" "scan" "internal rcw-abcdef0123456789abcdef0123456789abcd" "count" "1"
|
|
83
|
-
|
|
84
|
-
# ─── UserPromptSubmit hook ─────────────────────────────
|
|
85
|
-
echo ""
|
|
86
|
-
echo "=== UserPromptSubmit (pre-secret-guard) ==="
|
|
87
|
-
|
|
88
|
-
assert_hook() {
|
|
89
|
-
local name="$1"
|
|
90
|
-
local hook="$2"
|
|
91
|
-
local input="$3"
|
|
92
|
-
local expect="$4"
|
|
93
|
-
|
|
94
|
-
local out
|
|
95
|
-
out=$(printf '%s' "$input" | "$hook" 2>/dev/null)
|
|
96
|
-
local decision
|
|
97
|
-
decision=$(printf '%s' "$out" | python3 -c "import sys, json
|
|
98
|
-
try:
|
|
99
|
-
d=json.loads(sys.stdin.read() or '{}')
|
|
100
|
-
except Exception:
|
|
101
|
-
d={}
|
|
102
|
-
print(d.get('decision','pass'))" 2>/dev/null)
|
|
103
|
-
|
|
104
|
-
if [ "$expect" = "block" ] && [ "$decision" = "block" ]; then
|
|
105
|
-
printf ' %s %s\n' "$(green ✓)" "$name"
|
|
106
|
-
PASS=$((PASS+1))
|
|
107
|
-
elif [ "$expect" = "pass" ] && [ "$decision" != "block" ]; then
|
|
108
|
-
printf ' %s %s\n' "$(green ✓)" "$name"
|
|
109
|
-
PASS=$((PASS+1))
|
|
110
|
-
else
|
|
111
|
-
printf ' %s %s (expected=%s, got=%s, raw=%s)\n' "$(red ✗)" "$name" "$expect" "$decision" "$out"
|
|
112
|
-
FAIL=$((FAIL+1))
|
|
113
|
-
fi
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
# Default mode (warn from policy) — does NOT block user prompts
|
|
117
|
-
unset ROUTINECODE_SECRET_GUARD_MODE
|
|
118
|
-
assert_hook "warn mode: prompt with PAT passes (warning only)" \
|
|
119
|
-
"$HOOK_DIR/pre-secret-guard.sh" \
|
|
120
|
-
'{"prompt":"my token is ghp_abcdefghijklmnopqrstuvwxyz0123456789 please help","session_id":"test"}' \
|
|
121
|
-
"pass"
|
|
122
|
-
|
|
123
|
-
assert_hook "warn mode: plain prompt passes" \
|
|
124
|
-
"$HOOK_DIR/pre-secret-guard.sh" \
|
|
125
|
-
'{"prompt":"please analyze the user module","session_id":"test"}' \
|
|
126
|
-
"pass"
|
|
127
|
-
|
|
128
|
-
assert_hook "warn mode: screenshot path passes (no FP)" \
|
|
129
|
-
"$HOOK_DIR/pre-secret-guard.sh" \
|
|
130
|
-
'{"prompt":"open /var/folders/tv/9k9rgwm95q77fjq15l_6y_nh0000gn/T/TemporaryItems/foo.png","session_id":"test"}' \
|
|
131
|
-
"pass"
|
|
132
|
-
|
|
133
|
-
# hardBlock mode override — strict users
|
|
134
|
-
export ROUTINECODE_SECRET_GUARD_MODE=hardBlock
|
|
135
|
-
assert_hook "hardBlock mode: prompt with PAT blocked" \
|
|
136
|
-
"$HOOK_DIR/pre-secret-guard.sh" \
|
|
137
|
-
'{"prompt":"token is ghp_abcdefghijklmnopqrstuvwxyz0123456789","session_id":"test"}' \
|
|
138
|
-
"block"
|
|
139
|
-
assert_hook "hardBlock mode: plain prompt passes" \
|
|
140
|
-
"$HOOK_DIR/pre-secret-guard.sh" \
|
|
141
|
-
'{"prompt":"analyze the module","session_id":"test"}' \
|
|
142
|
-
"pass"
|
|
143
|
-
unset ROUTINECODE_SECRET_GUARD_MODE
|
|
144
|
-
|
|
145
|
-
# Kill switch
|
|
146
|
-
export ROUTINECODE_SECRET_GUARD_DISABLED=1
|
|
147
|
-
assert_hook "kill switch passes everything" \
|
|
148
|
-
"$HOOK_DIR/pre-secret-guard.sh" \
|
|
149
|
-
'{"prompt":"ghp_abcdefghijklmnopqrstuvwxyz0123456789","session_id":"test"}' \
|
|
150
|
-
"pass"
|
|
151
|
-
unset ROUTINECODE_SECRET_GUARD_DISABLED
|
|
152
|
-
|
|
153
|
-
# ─── PreToolUse WebFetch/WebSearch guard ───────────────
|
|
154
|
-
echo ""
|
|
155
|
-
echo "=== PreToolUse (pre-webfetch-guard) — URL/query에 박힌 토큰 차단 ==="
|
|
156
|
-
|
|
157
|
-
assert_hook "WebFetch with token in URL blocked" \
|
|
158
|
-
"$HOOK_DIR/pre-webfetch-guard.sh" \
|
|
159
|
-
'{"tool_name":"WebFetch","tool_input":{"url":"https://api.example.com/me?token=ghp_abcdefghijklmnopqrstuvwxyz0123456789"},"session_id":"test"}' \
|
|
160
|
-
"block"
|
|
161
|
-
|
|
162
|
-
assert_hook "WebSearch with token in query blocked" \
|
|
163
|
-
"$HOOK_DIR/pre-webfetch-guard.sh" \
|
|
164
|
-
'{"tool_name":"WebSearch","tool_input":{"query":"debug my sk-ant-api03-abcdefghijklmnopqrstuvwxyz0123456789012345 auth"},"session_id":"test"}' \
|
|
165
|
-
"block"
|
|
166
|
-
|
|
167
|
-
assert_hook "WebFetch clean URL passes" \
|
|
168
|
-
"$HOOK_DIR/pre-webfetch-guard.sh" \
|
|
169
|
-
'{"tool_name":"WebFetch","tool_input":{"url":"https://api.github.com/users/anthropics"},"session_id":"test"}' \
|
|
170
|
-
"pass"
|
|
171
|
-
|
|
172
|
-
assert_hook "WebSearch clean query passes" \
|
|
173
|
-
"$HOOK_DIR/pre-webfetch-guard.sh" \
|
|
174
|
-
'{"tool_name":"WebSearch","tool_input":{"query":"react typescript best practices"},"session_id":"test"}' \
|
|
175
|
-
"pass"
|
|
176
|
-
|
|
177
|
-
# ─── PostToolUse redaction ─────────────────────────────
|
|
178
|
-
echo ""
|
|
179
|
-
echo "=== PostToolUse (post-secret-detect) — in-flight redaction ==="
|
|
180
|
-
|
|
181
|
-
# 새 의미론: tool_response에 secret 있으면 decision:block + reason=redacted.
|
|
182
|
-
# 이는 tool을 차단하는 게 아니라 "Claude가 보는 결과를 redacted로 치환"하는 것.
|
|
183
|
-
|
|
184
|
-
assert_post_redacts() {
|
|
185
|
-
local name="$1"
|
|
186
|
-
local input="$2"
|
|
187
|
-
local secret_string="$3" # 이 문자열이 reason에 평문으로 남아있으면 실패
|
|
188
|
-
|
|
189
|
-
local out
|
|
190
|
-
out=$(printf '%s' "$input" | "$HOOK_DIR/post-secret-detect.sh" 2>/dev/null)
|
|
191
|
-
local decision
|
|
192
|
-
decision=$(printf '%s' "$out" | python3 -c "import sys, json; d=json.loads(sys.stdin.read() or '{}'); print(d.get('decision','pass'))" 2>/dev/null)
|
|
193
|
-
local reason
|
|
194
|
-
reason=$(printf '%s' "$out" | python3 -c "import sys, json; d=json.loads(sys.stdin.read() or '{}'); print(d.get('reason',''))" 2>/dev/null)
|
|
195
|
-
|
|
196
|
-
if [ "$decision" != "block" ]; then
|
|
197
|
-
printf ' %s %s (expected decision=block for redaction, got %s)\n' "$(red ✗)" "$name" "$decision"
|
|
198
|
-
FAIL=$((FAIL+1))
|
|
199
|
-
return
|
|
200
|
-
fi
|
|
201
|
-
|
|
202
|
-
if printf '%s' "$reason" | grep -q -- "$secret_string"; then
|
|
203
|
-
printf ' %s %s (secret string LEAKED in reason: %s)\n' "$(red ✗)" "$name" "$secret_string"
|
|
204
|
-
FAIL=$((FAIL+1))
|
|
205
|
-
else
|
|
206
|
-
if printf '%s' "$reason" | grep -q 'REDACTED\|SECRET-GUARD'; then
|
|
207
|
-
printf ' %s %s\n' "$(green ✓)" "$name"
|
|
208
|
-
PASS=$((PASS+1))
|
|
209
|
-
else
|
|
210
|
-
printf ' %s %s (reason does not look redacted: %s)\n' "$(red ✗)" "$name" "$reason"
|
|
211
|
-
FAIL=$((FAIL+1))
|
|
212
|
-
fi
|
|
213
|
-
fi
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
assert_post_redacts "Read .env content → redacted before API" \
|
|
217
|
-
'{"tool_name":"Read","tool_input":{"file_path":"/x/.env"},"tool_response":{"content":"API_KEY=ghp_abcdefghijklmnopqrstuvwxyz0123456789"},"session_id":"test"}' \
|
|
218
|
-
"ghp_abcdefghijklmnopqrstuvwxyz0123456789"
|
|
219
|
-
|
|
220
|
-
assert_post_redacts "Bash env dump → redacted" \
|
|
221
|
-
'{"tool_name":"Bash","tool_input":{"command":"env"},"tool_response":{"stdout":"OPENAI_KEY=sk-abcdefghijklmnopqrstuvwxyz0123456789"},"session_id":"test"}' \
|
|
222
|
-
"sk-abcdefghijklmnopqrstuvwxyz0123456789"
|
|
223
|
-
|
|
224
|
-
assert_post_redacts "Grep result with AWS key → redacted" \
|
|
225
|
-
'{"tool_name":"Grep","tool_input":{"pattern":"KEY"},"tool_response":{"output":"config.ts:AKIAIOSFODNN7EXAMPLE"},"session_id":"test"}' \
|
|
226
|
-
"AKIAIOSFODNN7EXAMPLE"
|
|
227
|
-
|
|
228
|
-
assert_post_redacts "WebFetch response with Bearer token → redacted" \
|
|
229
|
-
'{"tool_name":"WebFetch","tool_input":{"url":"https://api.example.com/me"},"tool_response":{"content":"{\"token\":\"ghp_abcdefghijklmnopqrstuvwxyz0123456789\"}"},"session_id":"test"}' \
|
|
230
|
-
"ghp_abcdefghijklmnopqrstuvwxyz0123456789"
|
|
231
|
-
|
|
232
|
-
assert_post_redacts "WebSearch result with API key → redacted" \
|
|
233
|
-
'{"tool_name":"WebSearch","tool_input":{"query":"example"},"tool_response":{"content":"example blog: my key is sk-ant-api03-abcdefghijklmnopqrstuvwxyz0123456789012345"},"session_id":"test"}' \
|
|
234
|
-
"sk-ant-api03-abcdefghijklmnopqrstuvwxyz0123456789012345"
|
|
235
|
-
|
|
236
|
-
# Pass-through: clean output should NOT get decision:block
|
|
237
|
-
assert_post_passthrough() {
|
|
238
|
-
local name="$1"
|
|
239
|
-
local input="$2"
|
|
240
|
-
|
|
241
|
-
local out
|
|
242
|
-
out=$(printf '%s' "$input" | "$HOOK_DIR/post-secret-detect.sh" 2>/dev/null)
|
|
243
|
-
local decision
|
|
244
|
-
decision=$(printf '%s' "$out" | python3 -c "import sys, json; d=json.loads(sys.stdin.read() or '{}'); print(d.get('decision','pass'))" 2>/dev/null)
|
|
245
|
-
if [ "$decision" = "block" ]; then
|
|
246
|
-
printf ' %s %s (clean output should not be redacted)\n' "$(red ✗)" "$name"
|
|
247
|
-
FAIL=$((FAIL+1))
|
|
248
|
-
else
|
|
249
|
-
printf ' %s %s\n' "$(green ✓)" "$name"
|
|
250
|
-
PASS=$((PASS+1))
|
|
251
|
-
fi
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
assert_post_passthrough "Clean Read passes unchanged" \
|
|
255
|
-
'{"tool_name":"Read","tool_input":{"file_path":"/x.ts"},"tool_response":{"content":"export const foo = 42;"},"session_id":"test"}'
|
|
256
|
-
|
|
257
|
-
assert_post_passthrough "Clean Bash passes unchanged" \
|
|
258
|
-
'{"tool_name":"Bash","tool_input":{"command":"ls"},"tool_response":{"stdout":"file1.txt\nfile2.txt"},"session_id":"test"}'
|
|
259
|
-
|
|
260
|
-
assert_post_passthrough "Screenshot path scan passes (no FP)" \
|
|
261
|
-
'{"tool_name":"Read","tool_input":{"file_path":"/var/folders/tv/9k9rgwm95q77fjq15l_6y_nh0000gn/T/screencap.png"},"tool_response":{"content":"binary data here"},"session_id":"test"}'
|
|
262
|
-
|
|
263
|
-
# POSTTOOL_REDACT_MODE=warn: redaction skipped (debug)
|
|
264
|
-
export ROUTINECODE_POSTTOOL_REDACT_MODE=warn
|
|
265
|
-
out=$(printf '%s' '{"tool_name":"Read","tool_input":{"file_path":"/x"},"tool_response":{"content":"ghp_abcdefghijklmnopqrstuvwxyz0123456789"},"session_id":"t"}' | "$HOOK_DIR/post-secret-detect.sh" 2>/dev/null)
|
|
266
|
-
decision=$(printf '%s' "$out" | python3 -c "import sys, json; d=json.loads(sys.stdin.read() or '{}'); print(d.get('decision','pass'))")
|
|
267
|
-
if [ "$decision" != "block" ]; then
|
|
268
|
-
printf ' %s POSTTOOL_REDACT_MODE=warn skips in-flight redaction\n' "$(green ✓)"
|
|
269
|
-
PASS=$((PASS+1))
|
|
270
|
-
else
|
|
271
|
-
printf ' %s warn mode should not redact (got %s)\n' "$(red ✗)" "$decision"
|
|
272
|
-
FAIL=$((FAIL+1))
|
|
273
|
-
fi
|
|
274
|
-
unset ROUTINECODE_POSTTOOL_REDACT_MODE
|
|
275
|
-
|
|
276
|
-
# ─── Tenant override + CORE self-protection (cross-validated) ──
|
|
277
|
-
echo ""
|
|
278
|
-
echo "=== Tenant override + CORE self-protection ==="
|
|
279
|
-
|
|
280
|
-
TMP_POL=$(mktemp)
|
|
281
|
-
|
|
282
|
-
# helper: run check-path/check-bash with a given policy json + input, assert 'banned'
|
|
283
|
-
assert_guard() {
|
|
284
|
-
local name="$1" fn="$2" policy_json="$3" input="$4" expect="$5"
|
|
285
|
-
printf '%s' "$policy_json" > "$TMP_POL"
|
|
286
|
-
local out banned
|
|
287
|
-
out=$(printf '%s' "$input" | ROUTINECODE_SECRET_POLICY_PATH="$TMP_POL" python3 "$LIB_DIR/secret_filter.py" "$fn" 2>/dev/null)
|
|
288
|
-
banned=$(printf '%s' "$out" | python3 -c "import sys,json;print(json.loads(sys.stdin.read() or '{}').get('banned'))" 2>/dev/null)
|
|
289
|
-
if [ "$banned" = "$expect" ]; then
|
|
290
|
-
printf ' %s %s\n' "$(green ✓)" "$name"; PASS=$((PASS+1))
|
|
291
|
-
else
|
|
292
|
-
printf ' %s %s (expected banned=%s, got %s)\n' "$(red ✗)" "$name" "$expect" "$banned"; FAIL=$((FAIL+1))
|
|
293
|
-
fi
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
# CORE path cannot be exempted even by wildcard allowlist
|
|
297
|
-
assert_guard "CORE hook source not exemptable by allowlist" check-path \
|
|
298
|
-
'{"path_allowlist":["**/*","**/hooks/**"]}' \
|
|
299
|
-
"$RC_PKG/hooks/lib/secret_filter.py" "True"
|
|
300
|
-
|
|
301
|
-
# CORE: all of .routinecode/*.json protected even with wildcard allowlist
|
|
302
|
-
assert_guard "CORE .routinecode json protected" check-path \
|
|
303
|
-
'{"path_allowlist":["**/*"]}' \
|
|
304
|
-
"/home/u/.routinecode/config.json" "True"
|
|
305
|
-
|
|
306
|
-
# replace mode empties generic secret paths (tenant relaxes generic)
|
|
307
|
-
assert_guard "replace mode drops generic .env ban" check-path \
|
|
308
|
-
'{"secret_paths_mode":"replace","banned_paths":[]}' \
|
|
309
|
-
"/proj/.env" "False"
|
|
310
|
-
|
|
311
|
-
# ...but CORE is still enforced under replace
|
|
312
|
-
assert_guard "replace mode keeps CORE hook ban" check-path \
|
|
313
|
-
'{"secret_paths_mode":"replace","banned_paths":[]}' \
|
|
314
|
-
"$RC_PKG/hooks/pre-foo.sh" "True"
|
|
315
|
-
|
|
316
|
-
# backward-compat: default still bans generic .env
|
|
317
|
-
assert_guard "scrub-only: generic .env passes (value-scrub protects)" check-path \
|
|
318
|
-
'{}' "/proj/.env" "False"
|
|
319
|
-
|
|
320
|
-
# command_allowlist exempts a generic command ban
|
|
321
|
-
assert_guard "command_allowlist exempts generic cmd" check-bash \
|
|
322
|
-
'{"command_allowlist":["cat\\s+app-cred"]}' \
|
|
323
|
-
"cat app-cred.txt" "False"
|
|
324
|
-
|
|
325
|
-
# ...but inline secret is ALWAYS blocked, even when command is allowlisted
|
|
326
|
-
GHP_FIXTURE="ghp_$(printf 'a%.0s' $(seq 1 36))"
|
|
327
|
-
assert_guard "scrub-only: inline secret passes (redaction protects)" check-bash \
|
|
328
|
-
'{"command_allowlist":["cat\\s+app-cred"]}' \
|
|
329
|
-
"cat app-cred.txt ; echo $GHP_FIXTURE" "False"
|
|
330
|
-
|
|
331
|
-
# CORE command pattern (routinecode-scoped) cannot be exempted by command_allowlist
|
|
332
|
-
assert_guard "CORE command not exemptable by allowlist" check-bash \
|
|
333
|
-
'{"command_allowlist":["cat .*secret_filter"]}' \
|
|
334
|
-
"cat $RC_PKG/hooks/lib/secret_filter.py" "True"
|
|
335
|
-
|
|
336
|
-
# install-scoped CORE: RoutineCode 자기 파일만 보호, 타 프로젝트는 오탐 없이 통과
|
|
337
|
-
assert_guard "CORE scoped: rc install hook blocked" check-path \
|
|
338
|
-
'{}' "/u/node_modules/@routinecrew/routinecode/hooks/lib/secret_filter.py" "True"
|
|
339
|
-
assert_guard "CORE scoped: rc home config blocked" check-path \
|
|
340
|
-
'{}' "/u/.routinecode/config.json" "True"
|
|
341
|
-
assert_guard "CORE scoped: other-project hook passes (no FP)" check-path \
|
|
342
|
-
'{}' "/myapp/hooks/pre-commit.sh" "False"
|
|
343
|
-
assert_guard "CORE scoped: other-project agents passes (no FP)" check-path \
|
|
344
|
-
'{}' "/myapp/plugin/agents/bot.md" "False"
|
|
345
|
-
assert_guard "CORE scoped: rc plugin read blocked" check-bash \
|
|
346
|
-
'{}' "cat $RC_PKG/plugin/agents/x.md" "True"
|
|
347
|
-
assert_guard "CORE scoped: other-project find plugin passes (no FP)" check-bash \
|
|
348
|
-
'{}' "find plugin/ -name x" "False"
|
|
349
|
-
|
|
350
|
-
rm -f "$TMP_POL"
|
|
351
|
-
|
|
352
|
-
# ─── Plan B (value-based redaction) + Plan C (Grep/NotebookRead/symlink) ──
|
|
353
|
-
echo ""
|
|
354
|
-
echo "=== Plan B/C: value-based redaction + tool-gap closure (fake fixtures) ==="
|
|
355
|
-
|
|
356
|
-
FAKE_DIR=$(mktemp -d)
|
|
357
|
-
printf 'FAKE_PW=NOT_REAL_ABCDEFGH12345\n' > "$FAKE_DIR/.config"
|
|
358
|
-
printf '# rms config\n_pw=NOT_REAL_ABCDEFGH12345\nHOST=example.com\n' > "$FAKE_DIR/.rms_config.md"
|
|
359
|
-
ln -sf .config "$FAKE_DIR/innocent.txt"
|
|
360
|
-
FAKE_VAL="NOT_REAL_ABCDEFGH12345"
|
|
361
|
-
|
|
362
|
-
BC_POL=$(mktemp)
|
|
363
|
-
# realpath 로 /tmp -> /private/tmp 정규화될 수 있으므로 두 형태 모두 ban.
|
|
364
|
-
REAL_DIR=$(python3 -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "$FAKE_DIR")
|
|
365
|
-
printf '{"mode":"warn","secret_paths_mode":"append","banned_paths":["%s/.config","%s/.config","%s/.rms_config.md","%s/.rms_config.md"]}' \
|
|
366
|
-
"$FAKE_DIR" "$REAL_DIR" "$FAKE_DIR" "$REAL_DIR" > "$BC_POL"
|
|
367
|
-
|
|
368
|
-
# helper: post-secret-detect must scrub FAKE_VAL out of the model-visible reason
|
|
369
|
-
assert_value_scrubbed() {
|
|
370
|
-
local name="$1" input="$2"
|
|
371
|
-
local out reason
|
|
372
|
-
out=$(printf '%s' "$input" | ROUTINECODE_SECRET_POLICY_PATH="$BC_POL" "$HOOK_DIR/post-secret-detect.sh" 2>/dev/null)
|
|
373
|
-
reason=$(printf '%s' "$out" | python3 -c "import sys,json;print(json.loads(sys.stdin.read() or '{}').get('reason',''))" 2>/dev/null)
|
|
374
|
-
if printf '%s' "$reason" | grep -q -- "$FAKE_VAL"; then
|
|
375
|
-
printf ' %s %s (VALUE LEAKED)\n' "$(red ✗)" "$name"; FAIL=$((FAIL+1))
|
|
376
|
-
else
|
|
377
|
-
printf ' %s %s\n' "$(green ✓)" "$name"; PASS=$((PASS+1))
|
|
378
|
-
fi
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
# Plan B: protected value scrubbed regardless of vector (no token pattern present)
|
|
382
|
-
assert_value_scrubbed "B: cat stdout value scrubbed" \
|
|
383
|
-
"{\"tool_name\":\"Bash\",\"tool_input\":{\"command\":\"c\"},\"tool_response\":{\"stdout\":\"FAKE_PW=$FAKE_VAL\"},\"session_id\":\"t\"}"
|
|
384
|
-
assert_value_scrubbed "B: python read stdout scrubbed" \
|
|
385
|
-
"{\"tool_name\":\"Bash\",\"tool_input\":{\"command\":\"p\"},\"tool_response\":{\"stdout\":\"$FAKE_VAL\"},\"session_id\":\"t\"}"
|
|
386
|
-
assert_value_scrubbed "B: symlink Read content scrubbed" \
|
|
387
|
-
"{\"tool_name\":\"Read\",\"tool_input\":{\"file_path\":\"$FAKE_DIR/innocent.txt\"},\"tool_response\":{\"content\":\"x $FAKE_VAL\"},\"session_id\":\"t\"}"
|
|
388
|
-
assert_value_scrubbed "B: NotebookRead content scrubbed" \
|
|
389
|
-
"{\"tool_name\":\"NotebookRead\",\"tool_input\":{\"notebook_path\":\"/x.ipynb\"},\"tool_response\":{\"content\":\"$FAKE_VAL\"},\"session_id\":\"t\"}"
|
|
390
|
-
|
|
391
|
-
# Plan B: clean output not touched
|
|
392
|
-
out=$(printf '%s' '{"tool_name":"Bash","tool_input":{"command":"ls"},"tool_response":{"stdout":"a.txt\nb.txt"},"session_id":"t"}' | ROUTINECODE_SECRET_POLICY_PATH="$BC_POL" "$HOOK_DIR/post-secret-detect.sh" 2>/dev/null)
|
|
393
|
-
dec=$(printf '%s' "$out" | python3 -c "import sys,json;print(json.loads(sys.stdin.read() or '{}').get('decision','pass'))")
|
|
394
|
-
if [ "$dec" = "block" ]; then printf ' %s B: clean output not scrubbed (FP)\n' "$(red ✗)"; FAIL=$((FAIL+1)); else printf ' %s B: clean output not scrubbed (no FP)\n' "$(green ✓)"; PASS=$((PASS+1)); fi
|
|
395
|
-
|
|
396
|
-
# helper: pre guard must block a banned target
|
|
397
|
-
assert_pre_block() {
|
|
398
|
-
local name="$1" hook="$2" input="$3" expect="$4"
|
|
399
|
-
local out dec
|
|
400
|
-
out=$(printf '%s' "$input" | ROUTINECODE_SECRET_POLICY_PATH="$BC_POL" "$hook" 2>/dev/null)
|
|
401
|
-
dec=$(printf '%s' "$out" | python3 -c "import sys,json;d=json.loads(sys.stdin.read() or '{}');print(d.get('decision') or d.get('hookSpecificOutput',{}).get('permissionDecision','allow'))")
|
|
402
|
-
if [ "$dec" = "$expect" ]; then printf ' %s %s\n' "$(green ✓)" "$name"; PASS=$((PASS+1)); else printf ' %s %s (expected %s, got %s)\n' "$(red ✗)" "$name" "$expect" "$dec"; FAIL=$((FAIL+1)); fi
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
# Plan C: Grep tool path guard
|
|
406
|
-
assert_pre_block "C: Grep generic path allowed (scrub-only)" "$HOOK_DIR/pre-grep-guard.sh" \
|
|
407
|
-
"{\"tool_name\":\"Grep\",\"tool_input\":{\"pattern\":\"F\",\"path\":\"$FAKE_DIR/.config\",\"output_mode\":\"content\"}}" "allow"
|
|
408
|
-
assert_pre_block "C: Grep symlink generic allowed (scrub-only)" "$HOOK_DIR/pre-grep-guard.sh" \
|
|
409
|
-
"{\"tool_name\":\"Grep\",\"tool_input\":{\"pattern\":\"F\",\"path\":\"$FAKE_DIR/innocent.txt\"}}" "allow"
|
|
410
|
-
assert_pre_block "C: Grep unrelated path allowed" "$HOOK_DIR/pre-grep-guard.sh" \
|
|
411
|
-
"{\"tool_name\":\"Grep\",\"tool_input\":{\"pattern\":\"x\",\"path\":\"$FAKE_DIR/nope.txt\"}}" "allow"
|
|
412
|
-
|
|
413
|
-
# Plan C: NotebookRead guard via pre-read-guard
|
|
414
|
-
assert_pre_block "C: NotebookRead generic allowed (scrub-only)" "$HOOK_DIR/pre-read-guard.sh" \
|
|
415
|
-
"{\"tool_name\":\"NotebookRead\",\"tool_input\":{\"notebook_path\":\"$FAKE_DIR/.config\"}}" "allow"
|
|
416
|
-
|
|
417
|
-
# Plan C: symlink Read blocked (realpath)
|
|
418
|
-
assert_pre_block "C: symlink Read generic allowed (scrub-only)" "$HOOK_DIR/pre-read-guard.sh" \
|
|
419
|
-
"{\"tool_name\":\"Read\",\"tool_input\":{\"file_path\":\"$FAKE_DIR/innocent.txt\"}}" "allow"
|
|
420
|
-
|
|
421
|
-
# ─── TASK 1: encoding-variant value scrub (base64/hex, whole-file/per-line/token) ──
|
|
422
|
-
# 인코딩된 유출(python3 -c 'b64encode(open(f,"rb").read())' 등)도 스크럽되는지.
|
|
423
|
-
# 인코딩형 스크럽셋은 REPLACE 모드(fake fixture만)로 격리 측정한다.
|
|
424
|
-
ENC_POL=$(mktemp)
|
|
425
|
-
ENC_REAL=$(python3 -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "$FAKE_DIR")
|
|
426
|
-
printf '{"mode":"warn","secret_paths_mode":"replace","banned_paths":["%s/.config","%s/.config"]}' \
|
|
427
|
-
"$FAKE_DIR" "$ENC_REAL" > "$ENC_POL"
|
|
428
|
-
|
|
429
|
-
assert_enc_scrubbed() {
|
|
430
|
-
local name="$1" enc="$2"
|
|
431
|
-
local out reason
|
|
432
|
-
local input
|
|
433
|
-
input=$(python3 -c "import json,sys;print(json.dumps({'tool_name':'Bash','tool_input':{'command':'leak'},'tool_response':{'stdout':'X '+sys.argv[1]+' Y'},'session_id':'t'}))" "$enc")
|
|
434
|
-
out=$(printf '%s' "$input" | ROUTINECODE_SECRET_POLICY_PATH="$ENC_POL" "$HOOK_DIR/post-secret-detect.sh" 2>/dev/null)
|
|
435
|
-
reason=$(printf '%s' "$out" | python3 -c "import sys,json;print(json.loads(sys.stdin.read() or '{}').get('reason',''))" 2>/dev/null)
|
|
436
|
-
if printf '%s' "$reason" | grep -qF -- "$enc"; then
|
|
437
|
-
printf ' %s %s (ENCODED VALUE LEAKED)\n' "$(red ✗)" "$name"; FAIL=$((FAIL+1))
|
|
438
|
-
# 2026-10-16: reason 은 본문을 되풀이하지 않는다(PostToolUse 는 원본을 대체 못 함) — 감지 건수로 검증
|
|
439
|
-
elif printf '%s' "$reason" | grep -q 'protected_file_value='; then
|
|
440
|
-
printf ' %s %s\n' "$(green ✓)" "$name"; PASS=$((PASS+1))
|
|
441
|
-
else
|
|
442
|
-
printf ' %s %s (not scrubbed: %s)\n' "$(red ✗)" "$name" "$reason"; FAIL=$((FAIL+1))
|
|
443
|
-
fi
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
# derive the encoded forms of the fixture from the fixture itself
|
|
447
|
-
WF_B64=$(python3 -c "import base64;print(base64.b64encode(open('$FAKE_DIR/.config','rb').read()).decode())")
|
|
448
|
-
WF_HEX=$(python3 -c "import binascii;print(binascii.hexlify(open('$FAKE_DIR/.config','rb').read()).decode())")
|
|
449
|
-
TOK_B64=$(python3 -c "import base64;print(base64.b64encode(b'NOT_REAL_ABCDEFGH12345').decode())")
|
|
450
|
-
TOK_HEX=$(python3 -c "import binascii;print(binascii.hexlify(b'NOT_REAL_ABCDEFGH12345').decode())")
|
|
451
|
-
|
|
452
|
-
assert_enc_scrubbed "T1: whole-file base64 scrubbed" "$WF_B64"
|
|
453
|
-
assert_enc_scrubbed "T1: whole-file hex scrubbed" "$WF_HEX"
|
|
454
|
-
assert_enc_scrubbed "T1: value-token base64 scrubbed" "$TOK_B64"
|
|
455
|
-
assert_enc_scrubbed "T1: value-token hex scrubbed" "$TOK_HEX"
|
|
456
|
-
|
|
457
|
-
# T1 no-FP: a long base64 of UNRELATED bytes is not scrubbed by value-scrub
|
|
458
|
-
# (redact_known_values returns 0 hits; pattern-scan may still flag base64, so we
|
|
459
|
-
# assert specifically that value-scrub itself yields 0 hits via the CLI).
|
|
460
|
-
UNREL=$(python3 -c "import base64;print(base64.b64encode(b'totally unrelated bytes qwerty').decode())")
|
|
461
|
-
VH=$(printf '%s' "unrelated: $UNREL" | ROUTINECODE_SECRET_POLICY_PATH="$ENC_POL" python3 "$LIB_DIR/secret_filter.py" redact-values | python3 -c "import sys,json;print(json.loads(sys.stdin.read() or '{}').get('hits',-1))")
|
|
462
|
-
if [ "$VH" = "0" ]; then
|
|
463
|
-
printf ' %s T1: unrelated base64 not value-scrubbed (no FP)\n' "$(green ✓)"; PASS=$((PASS+1))
|
|
464
|
-
else
|
|
465
|
-
printf ' %s T1: unrelated base64 value-scrubbed (FP! hits=%s)\n' "$(red ✗)" "$VH"; FAIL=$((FAIL+1))
|
|
466
|
-
fi
|
|
467
|
-
|
|
468
|
-
rm -f "$ENC_POL"
|
|
469
|
-
|
|
470
|
-
# ─── TASK 2: Plan A — literal banned path in bash command blocked (deploy-safe) ──
|
|
471
|
-
# check-bash CLI 로 banned 여부 확인. 배포 형태($()/$VAR 간접)는 통과해야 한다.
|
|
472
|
-
A_POL=$(mktemp)
|
|
473
|
-
A_RMS=".rms_config.md"
|
|
474
|
-
printf '{"mode":"warn","secret_paths_mode":"append","banned_paths":["%s/.config","%s/.config","%s/%s","%s/%s"]}' \
|
|
475
|
-
"$FAKE_DIR" "$ENC_REAL" "$FAKE_DIR" "$A_RMS" "$ENC_REAL" "$A_RMS" > "$A_POL"
|
|
476
|
-
|
|
477
|
-
assert_plana() {
|
|
478
|
-
local name="$1" cmd="$2" expect="$3"
|
|
479
|
-
local banned
|
|
480
|
-
banned=$(printf '%s' "$cmd" | ROUTINECODE_SECRET_POLICY_PATH="$A_POL" python3 "$LIB_DIR/secret_filter.py" check-bash | python3 -c "import sys,json;print(json.loads(sys.stdin.read() or '{}').get('banned'))" 2>/dev/null)
|
|
481
|
-
if [ "$banned" = "$expect" ]; then
|
|
482
|
-
printf ' %s %s\n' "$(green ✓)" "$name"; PASS=$((PASS+1))
|
|
483
|
-
else
|
|
484
|
-
printf ' %s %s (expected banned=%s, got %s)\n' "$(red ✗)" "$name" "$expect" "$banned"; FAIL=$((FAIL+1))
|
|
485
|
-
fi
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
# SHOULD BLOCK — literal banned path, any command name
|
|
489
|
-
assert_plana "A: cat literal generic passes (scrub-only)" "cat $FAKE_DIR/.config" "False"
|
|
490
|
-
assert_plana "A: awk literal generic passes (scrub-only)" "awk '{print}' $FAKE_DIR/.config" "False"
|
|
491
|
-
assert_plana "A: symlink literal generic passes (scrub-only)" "cat $FAKE_DIR/innocent.txt" "False"
|
|
492
|
-
# SHOULD NOT BLOCK — deploy indirection (var / command-substitution)
|
|
493
|
-
assert_plana "A: \$VAR indirection allowed" 'cat "$CFG"' "False"
|
|
494
|
-
assert_plana "A: \$() cmdsubst allowed" 'sshpass -p "$(_pw)" ssh host docker ps' "False"
|
|
495
|
-
assert_plana "A: source deploy script allowed" 'source ./scripts/deploy-ulsan.sh' "False"
|
|
496
|
-
assert_plana "A: awk \$RMS_CONFIG | ssh allowed" 'awk "/pw/{print}" "$RMS_CONFIG" | sshpass -p "$(cat -)" ssh h' "False"
|
|
497
|
-
|
|
498
|
-
rm -f "$A_POL"
|
|
499
|
-
|
|
500
|
-
rm -rf "$FAKE_DIR" "$BC_POL"
|
|
501
|
-
|
|
502
|
-
# ─── Summary ──────────────────────────────────────────
|
|
503
|
-
echo ""
|
|
504
|
-
echo "=== Summary ==="
|
|
505
|
-
|
|
506
|
-
# ── scrub-only 회귀 방지: "개발자가 자기 파일을 못 연다" 불편은 다시 접수되지 않는다 ──
|
|
507
|
-
# (2026-09-02 오너 결정: 하드블록은 CORE(RoutineCode 자기자산)만. generic 시크릿은
|
|
508
|
-
# 차단하지 않고 값-스크럽(post-secret-detect)으로 API 유출만 막는다.)
|
|
509
|
-
assert_guard "REG: other dev .env allowed" check-path '{}' "/Users/otherdev/proj/.env" "False"
|
|
510
|
-
assert_guard "REG: dev aws credentials allowed" check-path '{}' "/Users/dev/.aws/credentials" "False"
|
|
511
|
-
assert_guard "REG: dev ssh key path allowed" check-path '{}' "/Users/dev/x/.ssh/id_rsa" "False"
|
|
512
|
-
assert_guard "REG: dev config md allowed" check-path '{}' "/Users/dev/Desktop/x/.myapp_config.md" "False"
|
|
513
|
-
assert_guard "REG: printenv allowed" check-bash '{}' "printenv" "False"
|
|
514
|
-
assert_guard "REG: cat own env allowed" check-bash '{}' "cat /Users/dev/app/.env" "False"
|
|
515
|
-
assert_guard "REG: token-extract + curl Bearer allowed" check-bash '{}' 'export T=$(sed -n 5p /Users/dev/cfg.md); curl -H "Authorization: Bearer $T" https://api.example.com' "False"
|
|
516
|
-
# CORE 쌍대: RoutineCode 자기 것은 계속 차단(개발자로부터도)
|
|
517
|
-
assert_guard "REG: rc runtime config still blocked" check-path '{}' "/u/.routinecode/config.json" "True"
|
|
518
|
-
assert_guard "REG: rc prompt still blocked" check-path '{}' "$RC_PKG/plugin/routinecode-prompt.md" "True"
|
|
519
|
-
assert_guard "REG: rc hooks read still blocked" check-bash '{}' "cat $RC_PKG/hooks/pre-bash-guard.sh" "True"
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
# ── REG2: 미등록 파일도 "읽은 도구 무관" 값-스크럽 (2026-09-02 벡터-완전 보장) ──
|
|
523
|
-
# 개발자는 어떤 도구로든 config 를 읽어 쓰되, 값은 API 전송 전 반드시 마스킹된다.
|
|
524
|
-
assert_unreg_scrubbed() {
|
|
525
|
-
local name="$1" input="$2" val="$3"
|
|
526
|
-
local out reason
|
|
527
|
-
out=$(printf '%s' "$input" | ROUTINECODE_SECRET_POLICY_PATH="$BC_POL" "$HOOK_DIR/post-secret-detect.sh" 2>/dev/null)
|
|
528
|
-
reason=$(printf '%s' "$out" | python3 -c "import sys,json;print(json.loads(sys.stdin.read() or '{}').get('reason',''))" 2>/dev/null)
|
|
529
|
-
if printf '%s' "$reason" | grep -q -- "$val"; then
|
|
530
|
-
printf ' %s %s (VALUE LEAKED)\n' "$(red ✗)" "$name"; FAIL=$((FAIL+1))
|
|
531
|
-
else
|
|
532
|
-
printf ' %s %s\n' "$(green ✓)" "$name"; PASS=$((PASS+1))
|
|
533
|
-
fi
|
|
534
|
-
}
|
|
535
|
-
UNREG_DIR=$(mktemp -d)
|
|
536
|
-
UNREG_FILE="$UNREG_DIR/team.conf.md"
|
|
537
|
-
UNREG_VAL="UnRegVal9Qx7Zt2"
|
|
538
|
-
printf 'serverpw: %s\nhost: 10.0.0.9\n' "$UNREG_VAL" > "$UNREG_FILE"
|
|
539
|
-
assert_unreg_scrubbed "REG2: bash cat unregistered file value scrubbed" \
|
|
540
|
-
"{\"tool_name\":\"Bash\",\"tool_input\":{\"command\":\"cat $UNREG_FILE\"},\"tool_response\":{\"stdout\":\"serverpw: $UNREG_VAL\"},\"session_id\":\"t\"}" "$UNREG_VAL"
|
|
541
|
-
assert_unreg_scrubbed "REG2: grep path unregistered value scrubbed" \
|
|
542
|
-
"{\"tool_name\":\"Grep\",\"tool_input\":{\"pattern\":\"pw\",\"path\":\"$UNREG_FILE\"},\"tool_response\":\"$UNREG_VAL\",\"session_id\":\"t\"}" "$UNREG_VAL"
|
|
543
|
-
assert_unreg_scrubbed "REG2: cd+bare cat unregistered scrubbed" \
|
|
544
|
-
"{\"tool_name\":\"Bash\",\"tool_input\":{\"command\":\"cd $UNREG_DIR && cat team.conf.md\"},\"tool_response\":{\"stdout\":\"$UNREG_VAL\"},\"session_id\":\"t\"}" "$UNREG_VAL"
|
|
545
|
-
rm -rf "$UNREG_DIR"
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
# ── REG3: 변수경로+글롭 rm 선제차단 — Claude Code 하네스 확인창이 고객에게 뜨지 않는다 ──
|
|
549
|
-
# (하네스는 rm+변수글롭을 자체 휴리스틱으로 강제 확인창 처리. 훅이 먼저 block 하면 창 미노출.)
|
|
550
|
-
# (현행 설계: block 대신 ${VAR:?} 가드로 조용히 재작성 후 allow — 확인창·재시도 모두 없음)
|
|
551
|
-
assert_pre_rewrite() {
|
|
552
|
-
local name="$1" input="$2" expect_cmd="$3"
|
|
553
|
-
local got
|
|
554
|
-
got=$(printf '%s' "$input" | ROUTINECODE_SECRET_POLICY_PATH="$BC_POL" "$HOOK_DIR/pre-bash-guard.sh" 2>/dev/null \
|
|
555
|
-
| python3 -c "import sys,json;d=json.loads(sys.stdin.read() or '{}');print(d.get('hookSpecificOutput',{}).get('updatedInput',{}).get('command',''))")
|
|
556
|
-
if [ "$got" = "$expect_cmd" ]; then printf ' %s %s\n' "$(green ✓)" "$name"; PASS=$((PASS+1)); else printf ' %s %s (expected %s, got %s)\n' "$(red ✗)" "$name" "$expect_cmd" "$got"; FAIL=$((FAIL+1)); fi
|
|
557
|
-
}
|
|
558
|
-
assert_pre_rewrite "REG3: var-glob rm guarded (no harness dialog)" \
|
|
559
|
-
'{"tool_name": "Bash", "tool_input": {"command": "rm -f $SD/*.png"}}' 'rm -f ${SD:?}/*.png'
|
|
560
|
-
assert_pre_rewrite "REG3: braced var-glob rm guarded" \
|
|
561
|
-
'{"tool_name": "Bash", "tool_input": {"command": "rm -rf ${DIR}/*.tmp"}}' 'rm -rf ${DIR:?}/*.tmp'
|
|
562
|
-
assert_pre_rewrite "REG3: bare var rm guarded" \
|
|
563
|
-
'{"tool_name": "Bash", "tool_input": {"command": "rm -rf \"$D\""}}' 'rm -rf "${D:?}"'
|
|
564
|
-
assert_pre_rewrite "REG3: bare var guard only inside rm segment" \
|
|
565
|
-
'{"tool_name": "Bash", "tool_input": {"command": "rm -rf $H && echo $H"}}' 'rm -rf ${H:?} && echo $H'
|
|
566
|
-
assert_pre_block "REG3: literal tmp glob rm allowed" "$HOOK_DIR/pre-bash-guard.sh" \
|
|
567
|
-
'{"tool_name": "Bash", "tool_input": {"command": "rm -f /tmp/x/*.png"}}' "allow"
|
|
568
|
-
|
|
569
|
-
# ── REG4: 하네스 '위험 삭제' 확인창 실측 형태(CC 2.1.301) — 훅이 선제 deny/재작성, 확인창 0 ──
|
|
570
|
-
assert_pre_block "REG4: cd+rm+sh -c var rm (screenshot) denied" "$HOOK_DIR/pre-bash-guard.sh" \
|
|
571
|
-
'{"tool_name": "Bash", "tool_input": {"command": "H=/var/tmp/x\ncd /p && rm -f a.tgz\ncolima ssh -- sudo sh -c \"rm -rf $H; mkdir -p ${H:?}/a\""}}' "deny"
|
|
572
|
-
assert_pre_block "REG4: cd + relative glob denied" "$HOOK_DIR/pre-bash-guard.sh" \
|
|
573
|
-
'{"tool_name": "Bash", "tool_input": {"command": "cd build && rm -rf *"}, "cwd": "/tmp/rcws"}' "deny"
|
|
574
|
-
assert_pre_block "REG4: workspace wipe denied" "$HOOK_DIR/pre-bash-guard.sh" \
|
|
575
|
-
'{"tool_name": "Bash", "tool_input": {"command": "rm -rf ./*"}, "cwd": "/tmp/rcws"}' "deny"
|
|
576
|
-
assert_pre_block "REG4: derived var wipe denied" "$HOOK_DIR/pre-bash-guard.sh" \
|
|
577
|
-
'{"tool_name": "Bash", "tool_input": {"command": "R=$(pwd); rm -rf $R"}}' "deny"
|
|
578
|
-
assert_pre_block "REG4: sh -c literal rm allowed" "$HOOK_DIR/pre-bash-guard.sh" \
|
|
579
|
-
'{"tool_name": "Bash", "tool_input": {"command": "sh -c \"rm -rf /tmp/rcws/build\""}}' "allow"
|
|
580
|
-
assert_pre_block "REG4: sh -c docker --rm allowed" "$HOOK_DIR/pre-bash-guard.sh" \
|
|
581
|
-
'{"tool_name": "Bash", "tool_input": {"command": "sh -c '"'"'docker run --rm alpine true'"'"'"}}' "allow"
|
|
582
|
-
assert_pre_block "REG4: top-level literal remote rm allowed" "$HOOK_DIR/pre-bash-guard.sh" \
|
|
583
|
-
'{"tool_name": "Bash", "tool_input": {"command": "colima ssh -- sudo rm -rf /var/tmp/llm-auth-cli-check"}}' "allow"
|
|
584
|
-
assert_pre_rewrite "REG4: var inside sh -c guarded" \
|
|
585
|
-
'{"tool_name": "Bash", "tool_input": {"command": "sh -c '"'"'rm -rf \"$X\"/*.png'"'"'"}}' 'sh -c '"'"'rm -rf "${X:?}"/*.png'"'"''
|
|
586
|
-
assert_pre_rewrite "REG4: heredoc body not rewritten" \
|
|
587
|
-
'{"tool_name": "Bash", "tool_input": {"command": "cat > /tmp/f <<'"'"'E'"'"'\nrm -rf $D/*\nE\nrm -rf $S/x"}}' "$(printf 'cat > /tmp/f <<'"'"'E'"'"'\nrm -rf $D/*\nE\nrm -rf ${S:?}/x')"
|
|
588
|
-
ROUTINECODE_SESSION=1 assert_pre_block "REG4: plan mode denied" "$HOOK_DIR/pre-planmode-guard.sh" \
|
|
589
|
-
'{"tool_name": "ExitPlanMode", "tool_input": {"plan": "x"}}' "deny"
|
|
590
|
-
ROUTINECODE_SESSION= assert_pre_block "REG4: plan mode untouched in plain claude" "$HOOK_DIR/pre-planmode-guard.sh" \
|
|
591
|
-
'{"tool_name": "ExitPlanMode", "tool_input": {"plan": "x"}}' "allow"
|
|
592
|
-
ROUTINECODE_SESSION=1 assert_pre_block "REG4: ask-user denied" "$HOOK_DIR/pre-askuser-guard.sh" \
|
|
593
|
-
'{"tool_name": "AskUserQuestion", "tool_input": {}}' "deny"
|
|
594
|
-
ROUTINECODE_SESSION= assert_pre_block "REG4: ask-user untouched in plain claude" "$HOOK_DIR/pre-askuser-guard.sh" \
|
|
595
|
-
'{"tool_name": "AskUserQuestion", "tool_input": {}}' "allow"
|
|
596
|
-
|
|
597
|
-
TOTAL=$((PASS+FAIL))
|
|
598
|
-
if [ "$FAIL" -eq 0 ]; then
|
|
599
|
-
printf ' %s %d/%d passed\n\n' "$(green "✓")" "$PASS" "$TOTAL"
|
|
600
|
-
exit 0
|
|
601
|
-
else
|
|
602
|
-
printf ' %s %d/%d passed, %d failed\n\n' "$(red "✗")" "$PASS" "$TOTAL" "$FAIL"
|
|
603
|
-
exit 1
|
|
604
|
-
fi
|