Repository navigation
Commit d638250
Prevent redact commands from being saved to history (#322)
* Prevent redact commands from being saved to history
The hishtory redact command is used to find and remove sensitive
information from command history. However, the redact command itself
was being saved to history, which defeats its purpose since the search
term used with redact is often sensitive.
This change adds detection to skip saving any "hishtory redact" or
"hishtory delete" commands to history. The detection:
- Works in both presaveHistoryEntry and buildHistoryEntry
- Handles environment variable prefixes (e.g., HISHTORY_REDACT_FORCE=1)
- Supports both "redact" and "delete" (which is an alias)
- Includes comprehensive unit tests
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Update test golden files for TestTui-Exit and TestTui-Resize
Fix GitHub Action test failures by updating the golden files to match
the new expected output. These changes reflect minor formatting
differences in the TUI output.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Fix TestTui-Exit-linux golden file formatting
Remove extra blank line from TestTui-Exit-linux golden file.
The test expects only one blank line, not two.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Update redaction tests for new behavior
Update test expectations to reflect that redact commands are no longer
saved to history. This means:
- Redact commands delete one fewer entry (don't delete themselves)
- Redact commands no longer appear in history exports
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Fix redaction count expectation for 's' redaction test
Update the expected deletion count from 10-11 to 9-10 entries to account
for redact commands no longer being saved to history.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Fix empty history check in redaction tests
When history is empty, use `hishtory export` instead of
`hishtory export | grep -v pipefail` because grep returns exit code 1
when there are no matches, which fails the test.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Fix offline redaction tests - use -pipefail flag
Change `hishtory export` to `hishtory export -pipefail` in empty history
checks to prevent bash/zsh from echoing commands in offline mode.
This fixes all failing offline redaction tests on both ubuntu-latest and
macos-14 test shards.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Fix fuzz test to not expect redact commands in history
The PR prevents redact commands from being saved to history, so the
fuzz test should not add redact commands to the expected output.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Fix isRedactCommand to handle piped redact commands
The previous implementation only checked if the command started with
"hishtory redact", but didn't handle cases where redact commands are
piped from other commands like "yes | hishtory redact foo".
Now we check if "hishtory redact" or "hishtory delete" appears
anywhere in the command, not just at the beginning.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Fix isRedactCommand to avoid false positives
The previous fix was too broad and caught commands like
"echo hishtory redact" which should not be filtered. Now we only
check for "hishtory redact" at the beginning of the command (after
env vars) or after a pipe character.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Simplify isRedactCommand to use regex pattern
Use a simple regex pattern to check for "hishtory\s+redact" substring
instead of complex logic with environment variable stripping and pipe
handling.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Fix regex to also match 'hishtory delete'
The regex pattern now matches both 'hishtory redact' and 'hishtory delete'
using an alternation pattern.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Fix regex to avoid false positives for echo commands
The regex now checks that hishtory redact/delete appears at the
start of the command or after a pipe, with optional environment
variables. This prevents matching "echo hishtory redact" which
should not be filtered.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Revert "Fix regex to avoid false positives for echo commands"
This reverts commit c6b3790.
* Use simple regex hishtory\s+redact and update tests
- Changed isRedactCommand to just check for hishtory\s+redact substring
- Updated tests to reflect that this will match any command containing
that pattern, including "echo hishtory redact"
- Removed hishtory delete from test expectations since it's not covered
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Update regex to match hishtory\s+(redact|delete)
- Changed regex to match both "hishtory redact" and "hishtory delete"
- Updated tests to expect both patterns to be caught
- Note: This will match any substring occurrence, including
"echo hishtory redact" and "echo hishtory delete"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 72101dc commit d638250
5 files changed
Lines changed: 130 additions & 35 deletions
File tree
- client
- cmd
- testdata
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
168 | 174 | | |
169 | 175 | | |
170 | 176 | | |
| |||
373 | 379 | | |
374 | 380 | | |
375 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
376 | 388 | | |
377 | 389 | | |
378 | 390 | | |
| |||
409 | 421 | | |
410 | 422 | | |
411 | 423 | | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
412 | 429 | | |
413 | 430 | | |
414 | 431 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | 115 | | |
117 | 116 | | |
118 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1451 | 1451 | | |
1452 | 1452 | | |
1453 | 1453 | | |
1454 | | - | |
| 1454 | + | |
1455 | 1455 | | |
1456 | 1456 | | |
1457 | 1457 | | |
1458 | 1458 | | |
1459 | 1459 | | |
1460 | | - | |
| 1460 | + | |
1461 | 1461 | | |
1462 | 1462 | | |
1463 | 1463 | | |
1464 | 1464 | | |
1465 | 1465 | | |
1466 | 1466 | | |
1467 | | - | |
| 1467 | + | |
1468 | 1468 | | |
1469 | 1469 | | |
1470 | 1470 | | |
1471 | 1471 | | |
1472 | | - | |
1473 | | - | |
| 1472 | + | |
| 1473 | + | |
1474 | 1474 | | |
1475 | 1475 | | |
1476 | 1476 | | |
1477 | 1477 | | |
1478 | 1478 | | |
1479 | 1479 | | |
1480 | 1480 | | |
1481 | | - | |
| 1481 | + | |
1482 | 1482 | | |
1483 | 1483 | | |
1484 | 1484 | | |
| |||
1489 | 1489 | | |
1490 | 1490 | | |
1491 | 1491 | | |
1492 | | - | |
1493 | | - | |
| 1492 | + | |
| 1493 | + | |
1494 | 1494 | | |
1495 | 1495 | | |
1496 | 1496 | | |
| |||
1532 | 1532 | | |
1533 | 1533 | | |
1534 | 1534 | | |
1535 | | - | |
| 1535 | + | |
1536 | 1536 | | |
1537 | 1537 | | |
1538 | 1538 | | |
1539 | 1539 | | |
1540 | 1540 | | |
1541 | | - | |
| 1541 | + | |
1542 | 1542 | | |
1543 | 1543 | | |
1544 | 1544 | | |
| |||
0 commit comments