Skip to content

feat(history): an opt-in setting to hide values in new entries - #604

Merged
EVWorth merged 1 commit into
mainfrom
feat/history-literal-redaction
Sep 10, 2026
Merged

EVWorth merged 1 commit into
mainfrom
feat/history-literal-redaction

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Closes #330. Last of the history area.

History is a file on disk for the life of the install, and SELECT * FROM patients WHERE nhs_number = '...' sits in it. On a shared machine, or anywhere a regulator would look, that's worth being able to turn off.

I went against the issue on the default

The issue asked for default ON. This ships default OFF. A redacted entry can't be rerun and is much harder to read, which is most of what history is for — DBeaver and DataGrip both store literals as typed. Silently making every user's history unrunnable is a bigger change than the risk it addresses, and the people who need it will find the checkbox. Say the word and I'll flip it.

Credential redaction stays unconditional (#587). That one is not a preference and must not become one, so it still applies with this setting off — there's a test.

What it does and doesn't blank

  • Identifiers are left alone. An entry whose table and column names were also blanked would be unreadable rather than merely unrunnable.
  • LIMIT and OFFSET are left alone. They say nothing about anyone, and losing them makes the entry harder to read for nothing.
  • Numbers are blanked otherwise — an account id or a salary identifies a person as readily as an email.
  • Not retroactive, and it can't be. The literals in stored entries exist nowhere else, so blanking them now would destroy history the user chose to keep under the old setting. The checkbox's tooltip says so.

One bug worth flagging

The \b in the LIMIT/OFFSET guard was silently turned into a literal backspace character by my Python heredoc (Python treats \b as an escape; \w and \d it leaves alone, which is why only one broke). The regex compiled fine and simply never matched, so LIMIT values were being redacted. Caught by the test that asserts they aren't.

Verification

8 new redactor tests (36 in the file), 6 store tests, 3 panel tests. Unit 1981, browser 300, 0 lint errors.

History is a file on disk for the life of the install, and
`SELECT * FROM patients WHERE nhs_number = '...'` sits in it. On a shared
machine, or anywhere a regulator would look, that is worth being able to
turn off (#330).

Off by default, and it should be. A redacted entry cannot be rerun and is
much harder to read, which is most of what history is for; DBeaver and
DataGrip both store literals as typed. This is for people who have a reason
to give that up, not a default anyone should be opted into. The issue asked
for default ON — I have gone the other way, because silently making every
user's history unrunnable is a bigger change than the risk it addresses,
and the people who need it will find the checkbox.

Credential redaction stays unconditional. That one is not a preference and
must not become one, so it still applies with this setting off.

Identifiers are left alone: an entry whose table and column names were also
blanked would be unreadable rather than merely unrunnable. LIMIT and OFFSET
are left alone too — they say nothing about anyone, and losing them makes
the entry harder to read for nothing. Numbers are otherwise blanked, since
an account id or a salary identifies a person as readily as an email.

The setting is not retroactive and cannot be: the literals in entries
already stored exist nowhere else, so blanking them now would destroy
history the user chose to keep under the old setting. The checkbox says so.

Closes #330

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth merged commit 7ba2111 into main Sep 10, 2026
12 checks passed
@EVWorth
EVWorth deleted the feat/history-literal-redaction branch September 10, 2026 03:15
@EVWorth EVWorth mentioned this pull request Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1/security] History persists raw SQL with user-supplied values — no scrubbing/redaction

1 participant