hardstop 0.0.1 → 1.4.0

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.
@@ -0,0 +1,72 @@
1
+ {
2
+ "$schema": "https://claude.ai/schemas/plugin-manifest-v1.json",
3
+ "name": "hardstop",
4
+ "version": "1.3.6",
5
+ "description": "Pre-execution safety layer that blocks dangerous shell commands and credential file reads using pattern matching + LLM analysis. Fail-closed design.",
6
+ "author": "Francesco Marinoni Moretto",
7
+ "license": "CC-BY-4.0",
8
+ "repository": "https://github.com/frmoretto/hardstop",
9
+ "homepage": "https://github.com/frmoretto/hardstop",
10
+ "keywords": [
11
+ "hardstop",
12
+ "safety",
13
+ "security",
14
+ "pre-execution",
15
+ "shell",
16
+ "bash",
17
+ "powershell",
18
+ "command-blocking",
19
+ "ai-safety",
20
+ "guardrails"
21
+ ],
22
+ "skills": [
23
+ {
24
+ "name": "hs",
25
+ "path": "skills/hs/SKILL.md",
26
+ "triggers": [
27
+ "hardstop",
28
+ "safety check",
29
+ "pre-execution check",
30
+ "is this command safe",
31
+ "check command safety"
32
+ ]
33
+ }
34
+ ],
35
+ "hooks": {
36
+ "PreToolUse": [
37
+ {
38
+ "matcher": "Bash",
39
+ "command": "python hooks/pre_tool_use.py",
40
+ "description": "Pre-execution safety verification for shell commands"
41
+ },
42
+ {
43
+ "matcher": "PowerShell",
44
+ "command": "python hooks/pre_tool_use.py",
45
+ "description": "Pre-execution safety verification for PowerShell commands"
46
+ },
47
+ {
48
+ "matcher": "Read",
49
+ "command": "python hooks/pre_read.py",
50
+ "description": "Pre-read credential file protection"
51
+ }
52
+ ]
53
+ },
54
+ "commands": [
55
+ {
56
+ "name": "hs",
57
+ "aliases": ["hardstop"],
58
+ "description": "Control Hardstop plugin",
59
+ "subcommands": [
60
+ {"name": "on", "description": "Enable protection"},
61
+ {"name": "off", "description": "Disable protection"},
62
+ {"name": "skip", "description": "Skip next N commands (default 1)"},
63
+ {"name": "status", "description": "Show current state"},
64
+ {"name": "log", "description": "View audit log"}
65
+ ]
66
+ }
67
+ ],
68
+ "compatibility": {
69
+ "claude-code": ">=1.0.0",
70
+ "claude-desktop": ">=1.0.0"
71
+ }
72
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "hs",
3
+ "version": "1.4.0",
4
+ "description": "Pre-execution safety layer that blocks dangerous shell commands and credential file reads using pattern matching + LLM analysis. Fail-closed design.",
5
+ "author": {
6
+ "name": "Francesco Marinoni Moretto",
7
+ "email": "contact@clarity-gate.org"
8
+ },
9
+ "homepage": "https://github.com/frmoretto/hardstop",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/frmoretto/hardstop.git"
13
+ },
14
+ "license": "CC-BY-4.0",
15
+ "keywords": [
16
+ "safety",
17
+ "security",
18
+ "shell",
19
+ "commands",
20
+ "protection",
21
+ "guardrails",
22
+ "pre-execution",
23
+ "fail-closed"
24
+ ]
25
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,336 @@
1
+ # Changelog
2
+
3
+ All notable changes to Hardstop will be documented in this file.
4
+
5
+ ## [1.4.0] - 2026-02-11
6
+
7
+ ### Installation & Naming Standardization
8
+
9
+ Major update to streamline installation and standardize naming conventions.
10
+
11
+ ### Changed
12
+ - **BREAKING**: Plugin and skill directories now use `hs` instead of `hardstop`
13
+ - Plugin: `~/.claude/plugins/hs/` (was `~/.claude/plugins/hardstop/`)
14
+ - Skill: `~/.claude/skills/hs/` (was `~/.claude/skills/hardstop/`)
15
+ - Slash command remains `/hs` (unchanged)
16
+ - **bin/install.js**: Now handles complete installation (plugin + skill + hooks)
17
+ - Previously only installed plugin files
18
+ - Now also creates skill at `~/.claude/skills/hs/SKILL.md`
19
+ - Now also configures hooks in `~/.claude/settings.json`
20
+ - **package.json**: Added `skills/` to npm package files
21
+ - All repository skill directories renamed: `.claude/skills/hs/`, `.codex/skills/hs/`, `.github/skills/hs/`, `skills/hs/`
22
+
23
+ ### Migration
24
+ - Users upgrading from 1.3.x should uninstall first: `powershell .\uninstall.ps1` or `bash uninstall.sh`
25
+ - Then reinstall: `npx hardstop install`
26
+ - Or use the installer scripts: `powershell .\install.ps1` or `bash install.sh`
27
+
28
+ ---
29
+
30
+ ## [1.3.6] - 2026-01-31
31
+
32
+ ### macOS Platform Coverage
33
+
34
+ Adds comprehensive macOS-specific dangerous patterns and safe patterns for better platform coverage.
35
+
36
+ ### Added
37
+ - **pre_tool_use.py**: 35 macOS dangerous patterns
38
+ - Disk utility operations (diskutil erase, partition, zeroDisk)
39
+ - Keychain access (security delete-keychain, dump-keychain, find-*-password -w)
40
+ - Time Machine manipulation (tmutil delete, disable, deletelocalsnapshots)
41
+ - Directory services (dscl delete user/group, append admin)
42
+ - System security (spctl --master-disable, csrutil disable, nvram)
43
+ - Privacy database (TCC.db access, tccutil reset)
44
+ - Persistence mechanisms (LaunchDaemons/LaunchAgents)
45
+ - **pre_tool_use.py**: 11 macOS safe patterns (diskutil list/info, sw_vers, defaults read, etc.)
46
+ - **pre_read.py**: 6 macOS credential path patterns (Keychains, TCC.db, Chrome/Firefox passwords, authorization, dslocal)
47
+ - **tests/test_macos_patterns.py**: 46 new tests for macOS patterns
48
+
49
+ ### Technical Details
50
+ - Pattern count: 137 → ~180 patterns
51
+ - Test count: 167 → 213 tests
52
+
53
+ ---
54
+
55
+ ## [1.3.5] - 2026-01-31
56
+
57
+ ### Phase 1 Security Audit Fixes
58
+
59
+ Addresses security audit requirements for "Safe to Install" rating.
60
+
61
+ ### Added
62
+ - **AUDIT.md**: Comprehensive security audit guide for independent reviewers
63
+ - **README.md**: "Verify Before You Trust" section with GitIngest link and audit prompt
64
+ - **README.md**: "Known Limitations" section documenting pattern-based detection limits
65
+ - **README.md**: SKILL.md RAG integration warning
66
+ - **README.md**: Link to AUDIT.md for professional auditors
67
+ - **SECURITY.md**: LLM Analysis Layer documentation (prompt, parsing, fail-closed behavior)
68
+ - **SECURITY.md**: Updated supported versions table
69
+
70
+ ### Changed
71
+ - **`/hs off`**: Now shows "Credential file protection (Read hook) remains active"
72
+ - **`/hs skip`**: Max reduced from 100 → 10 (hardened security)
73
+
74
+ ### Technical Details
75
+ - Test count: 167 tests, all passing
76
+
77
+ ---
78
+
79
+ ## [1.3.4] - 2026-01-31
80
+
81
+ ### Fixed: Chained Command Handling
82
+
83
+ Safe chained commands like `cd /tmp && git push` now fast-path through pattern matching instead of going to LLM analysis (which could incorrectly block them).
84
+
85
+ ### Changed
86
+ - **is_all_safe()**: Now splits chained commands and checks each part individually
87
+ - **cd pattern**: Added to safe patterns with command substitution blocking
88
+ - **LLM prompt**: Improved to explicitly allow git, npm, docker and other dev tools
89
+
90
+ ### Security
91
+ - Defense-in-depth: Added dangerous pattern for `cd` with command substitution
92
+ - `cd $(cmd)` and `cd \`cmd\`` are blocked by both safe pattern exclusion AND dangerous pattern detection
93
+
94
+ ### Technical Details
95
+ - `cd "path" && git push` → fast-path ALLOW (both parts match safe patterns)
96
+ - `cd $(rm -rf /) && git push` → BLOCK (dangerous pattern catches command substitution)
97
+ - Test count: 166 tests, all passing
98
+
99
+ ---
100
+
101
+ ## [1.3.3] - 2026-01-31
102
+
103
+ ### Fixed: Test Suite & Marketplace Sync
104
+
105
+ Synchronized test suite with v1.3.1 JSON output changes and updated marketplace.json.
106
+
107
+ ### Changed
108
+ - **marketplace.json**: Updated version 1.0.0 → 1.3.2, added Read and PowerShell hooks
109
+ - **test_hook.py**: Tests now use JSON parsing instead of exit code 2 assertions
110
+ - **test_read_hook.py**: Tests updated for JSON output and read-only skip checks
111
+
112
+ ### Technical Details
113
+ - Tests now check `permissionDecision: "deny"` in JSON instead of exit code 2
114
+ - `is_skip_enabled()` is now read-only (multi-skip compatibility)
115
+ - Test count: 158 tests, all passing
116
+
117
+ ---
118
+
119
+ ## [1.3.2] - 2026-01-21
120
+
121
+ ### New Feature: Multi-Skip
122
+
123
+ Skip multiple commands at once with `/hs skip <count>`.
124
+
125
+ **Usage:**
126
+ - `/hs skip` — Skip 1 command (unchanged)
127
+ - `/hs skip 3` — Skip next 3 commands
128
+ - `/hs skip 10` — Skip next 10 commands (max: 100)
129
+
130
+ **Status output:**
131
+ ```
132
+ Hardstop v1.3.2
133
+ Status: 🟢 Enabled
134
+ Skip next: 3 commands
135
+ ```
136
+
137
+ ### Changed
138
+ - `hs_cmd.py`: Accept optional count argument for skip command
139
+ - `pre_tool_use.py`: `decrement_skip()` and `get_skip_count()` functions
140
+ - `pre_read.py`: Same skip counter logic for Read tool
141
+ - Status command now shows remaining skip count
142
+ - Backward compatible with old skip file format
143
+
144
+ ---
145
+
146
+ ## [1.3.1] - 2026-01-21
147
+
148
+ ### Fixed: VS Code Extension Chat Restart
149
+
150
+ Changed blocking mechanism from exit code 2 to JSON output with `permissionDecision: "deny"`.
151
+
152
+ **Problem:** Exit code 2 caused VS Code extension to treat blocks as session errors and restart the chat.
153
+
154
+ **Solution:** Use structured JSON output (Claude Code documented API):
155
+ ```json
156
+ {
157
+ "hookSpecificOutput": {
158
+ "hookEventName": "PreToolUse",
159
+ "permissionDecision": "deny",
160
+ "permissionDecisionReason": "🛑 BLOCKED: reason..."
161
+ }
162
+ }
163
+ ```
164
+
165
+ ### Changed
166
+ - `pre_tool_use.py`: `block_command()`, `check_uninstall_script()` now use JSON output
167
+ - `pre_read.py`: `block()`, `block_error()` now use JSON output
168
+ - Both hooks now exit with code 0 (success) and use JSON for allow/deny decisions
169
+
170
+ ---
171
+
172
+ ## [1.3.0] - 2026-01-20
173
+
174
+ ### New Feature: Read Tool Protection
175
+
176
+ Hardstop now monitors the Claude Code `Read` tool to prevent AI from accessing credential files.
177
+
178
+ **DANGEROUS (Blocked):**
179
+ - SSH keys: `~/.ssh/id_rsa`, `~/.ssh/id_ed25519`, etc.
180
+ - Cloud credentials: `~/.aws/credentials`, `~/.config/gcloud/credentials.db`, `~/.azure/credentials`
181
+ - Environment files: `.env`, `.env.local`, `.env.production`
182
+ - Docker/Kubernetes: `~/.docker/config.json`, `~/.kube/config`
183
+ - Database credentials: `~/.pgpass`, `~/.my.cnf`
184
+ - Package managers: `~/.npmrc`, `~/.pypirc`
185
+
186
+ **SENSITIVE (Warned):**
187
+ - Generic configs: `config.json`, `settings.json`
188
+ - Files with "password", "secret", "token", "apikey" in name
189
+
190
+ **SAFE (Allowed):**
191
+ - Source code: `.py`, `.js`, `.ts`, `.go`, etc.
192
+ - Documentation: `README.md`, `CHANGELOG.md`, `LICENSE`
193
+ - Config templates: `.env.example`, `.env.template`
194
+ - Package manifests: `package.json`, `pyproject.toml`
195
+
196
+ ### Added
197
+ - `hooks/pre_read.py` — New hook for Read tool interception
198
+ - Read matcher in `hooks/hooks.json`
199
+ - Read hook configuration in install scripts (`install.sh`, `install.ps1`)
200
+ - Read hook removal in uninstall scripts (`uninstall.sh`, `uninstall.ps1`)
201
+ - Section 9 in SKILL.md documenting Read protection
202
+ - Updated Quick Reference Card with Read tool guidance
203
+ - Comprehensive test suite for Read protection (`tests/test_read_hook.py`)
204
+
205
+ ### Fixed
206
+ - Uninstallers now remove both Bash and Read hooks (backward compatible with v1.0-v1.2)
207
+
208
+ ### Changed
209
+ - Updated skill description to include "FILE READ" trigger
210
+ - Updated SKILL.md version to 1.3
211
+ - Updated plugin.json version to 1.3.0
212
+ - Updated pre_tool_use.py version to 1.3.0
213
+
214
+ ---
215
+
216
+ ## [1.2.0] - 2026-01-20
217
+
218
+ ### New Patterns (~60 added)
219
+ - **Shell wrappers:** `bash -c`, `sh -c`, `sudo bash -c`, `xargs`, `find -exec`
220
+ - **Cloud CLI:** AWS (S3, EC2, RDS, CloudFormation), GCP (gcloud), Firebase, Kubernetes (kubectl, helm)
221
+ - **Infrastructure:** Terraform `destroy`, Pulumi `destroy`, Docker `prune`
222
+ - **Database CLI:** Redis (`FLUSHALL`), MongoDB (`dropDatabase`), PostgreSQL (`dropdb`), MySQL (`mysqladmin drop`)
223
+ - **Platform CLI:** Vercel, Netlify, Heroku, Fly.io, GitHub (`gh repo delete`), npm (`unpublish`)
224
+ - **SQL:** `DROP TABLE`, `DROP DATABASE`, `TRUNCATE`, `DELETE FROM` without WHERE
225
+
226
+ ### Fixed (False Positives)
227
+ - Removed alias patterns (blocked legitimate aliases like `alias ls='ls --color'`)
228
+ - Made `find -delete` path-specific (only blocks on `~`, `/home`, `/`, `/etc`, `/usr`, `/var`)
229
+
230
+ ### Stats
231
+ - Total dangerous patterns: 137
232
+ - Total safe patterns: 66
233
+
234
+ ---
235
+
236
+ ## [1.1.0] - 2026-01-18
237
+
238
+ ### Multi-Platform Skill Distribution
239
+ - Added skill files for Claude.ai Projects, Codex, GitHub Copilot
240
+ - Added `AGENTS.md` universal discovery file (LLM-readable agent capabilities)
241
+ - Added `marketplace.json` for plugin registry integration
242
+ - Added `dist/hardstop.skill` for Claude.ai upload
243
+
244
+ ### Package Manager Safety
245
+ - Added Package Manager Force Operations to INSTANT BLOCK list
246
+ - Added new Section 4: Package Manager Safety with dpkg/rpm flag reference
247
+ - Added error suppression patterns (`2>/dev/null`, `|| true`) as risk escalators
248
+ - Added package info commands (`dpkg -l`, `apt list`) to SAFE list
249
+
250
+ ---
251
+
252
+ ## [1.0.0] - 2025-01-17
253
+
254
+ First public release.
255
+
256
+ ### Core Features
257
+ - **Two-layer defense** — Pattern matching (instant) + LLM analysis (semantic)
258
+ - **Fail-closed design** — If safety check fails, command is blocked (not allowed)
259
+ - **Cross-platform** — Unix (Bash) + Windows (PowerShell) pattern detection
260
+ - **Command chaining** — Analyzes all parts of piped/chained commands (`&&`, `||`, `;`, `|`)
261
+ - **Audit logging** — All decisions logged to `~/.hardstop/audit.log`
262
+ - **Skill command** — `/hs` for status, on/off, skip, and log viewing
263
+
264
+ ### Pattern Coverage
265
+ - Home/root deletion, fork bombs, reverse shells
266
+ - Credential exfiltration (`.ssh`, `.aws`, `.config`)
267
+ - Disk destruction, encoded payloads, pipe-to-shell
268
+ - Windows: Registry manipulation, LOLBins, PowerShell download cradles
269
+
270
+ ### Installation
271
+ - `install.sh` for macOS/Linux
272
+ - `install.ps1` for Windows (uses Python for reliable JSON handling)
273
+ - `uninstall.sh` and `uninstall.ps1` for clean removal
274
+ - Automatic hook configuration in `~/.claude/settings.json`
275
+ - Skill installation to `~/.claude/skills/hs/`
276
+
277
+ ### Reliability
278
+ - Atomic state writes (prevents corruption)
279
+ - Atomic skip flag (prevents race conditions)
280
+ - Windows CLI detection (`claude.cmd` via `cmd /c`)
281
+ - Full-command matching for safe patterns (prevents substring bypass)
282
+ - Path expansion at install time (fixes `~` not working on Windows)
283
+
284
+ ---
285
+
286
+ ## Development History (Pre-release)
287
+
288
+ The following documents the development process leading to v1.0.0.
289
+
290
+ ### 2025-01-17 — Final Polish
291
+
292
+ **Bug Fixes:**
293
+ - Fixed PowerShell JSON handling (ConvertFrom-Json fails on nested objects; now uses Python)
294
+ - Fixed path expansion (`~` and `%USERPROFILE%` don't expand in Windows hook commands)
295
+ - Fixed skill directory name (`hs` not `hs-hardstop-plugin` — directory name = command name)
296
+ - Fixed double naming bug (`hs-hardstop-plugin-hardstop-plugin`)
297
+
298
+ **Improvements:**
299
+ - Added uninstall scripts (`uninstall.ps1`, `uninstall.sh`)
300
+ - Added uninstall detection in hook with friendly confirmation message
301
+ - Added strong restart warnings for VS Code, CLI, and Cowork users
302
+ - Added beta disclaimer and feedback call-to-action
303
+ - Cleaned up `/hardstop` and `/hard` alias references (kept only `/hs`)
304
+
305
+ **Lessons Learned:**
306
+ 1. Directory name = skill command name (not the `name` field in SKILL.md)
307
+ 2. `aliases` field in SKILL.md doesn't create additional slash commands
308
+ 3. `~` doesn't expand in Windows hook commands — must use full paths
309
+ 4. `%USERPROFILE%` also doesn't expand — use Python `os.path.expanduser()`
310
+ 5. PowerShell's `ConvertFrom-Json | ConvertTo-Json` breaks nested objects
311
+ 6. Hooks are snapshotted at startup — restart required after changes
312
+ 7. Hardstop can block its own uninstall — need skip or custom detection
313
+
314
+ ### 2025-01-16 — Structure Refactor
315
+
316
+ - Changed plugin name from "hardstop" to "hs" in plugin.json
317
+ - Improved Windows console encoding handling in hs_cmd.py
318
+ - Added debug logging for hook invocation
319
+ - Created command documentation files (`hs.md`, `on.md`, `off.md`, `skip.md`, `status.md`, `log.md`)
320
+ - Updated installation scripts for new structure
321
+
322
+ ### 2025-01-15 — Initial Development
323
+
324
+ - Implemented two-layer defense (pattern + LLM)
325
+ - Created pattern databases for Unix and Windows
326
+ - Implemented fail-closed error handling
327
+ - Added command chaining analysis
328
+ - Created `/hs` skill interface
329
+ - Added audit logging system
330
+ - Wrote test suite (82 tests)
331
+
332
+ ---
333
+
334
+ ## License
335
+
336
+ CC BY 4.0 — Francesco Marinoni Moretto
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Creative Commons Attribution 4.0 International License (CC BY 4.0)
2
+
3
+ Copyright (c) 2025 Francesco Marinoni Moretto
4
+
5
+ You are free to:
6
+ - Share — copy and redistribute the material in any medium or format
7
+ - Adapt — remix, transform, and build upon the material for any purpose, even commercially
8
+
9
+ Under the following terms:
10
+ - Attribution — You must give appropriate credit, provide a link to the license,
11
+ and indicate if changes were made.
12
+
13
+ Full license text: https://creativecommons.org/licenses/by/4.0/legalcode