Repository navigation
fix(mask): read env files, with two columns and no guesses (#13) - #14
Merged
Merged
Conversation
Closes #13. The masking page was built on a CSV reader, which is the wrong model for a .env file. With no header and no delimiter to find, the guesswork turned a banner comment into a column title, invented Column 2…N from the padding and listed comments as rows — and for a file without comments it consumed the first variable as the header, printing its value as a column name, unmasked, and dropping it from the export. A masking tool that publishes a value is not a formatting bug. The page now reads the format it is named for: - one row per KEY=value assignment, in file order, first line included; - comment, blank and unreadable lines are not rows, and are counted and reported ("4 comment lines, 1 blank line skipped"); - duplicate keys resolve the way dotenv resolves them, last one wins, and the repeated keys are named; - a multi-column CSV is refused with a message instead of parsed into a table. src/core/csv and its 15 tests are deleted with the feature that used them: a second input format is a product decision, and the issue asked for one shape. Output is .env-shaped — KEY=masked-value per line, no comments, no values, <name>.masked.env — and reuses the compare engine's grammar, so the two pages cannot disagree about export, quoting or trailing comments. formatValue single-quotes anything containing #, " or a backslash because single quotes are the only form dotenv returns verbatim, and only newlines force double quotes; a test round-trips its own output through the reader. Defaults keep the masked file useful: obvious configuration (info, 3000, production, a credential-free URL) stays visible, credential-shaped values hide, and a key whose name says secret outranks a harmless-looking value. Warnings now name keys — "DATABASE_URL, OPENAI_API_KEY are still visible" — rather than a column index. Renamed throughout: nav entry, page title, buttons, file picker, README, PRD §8.6 / US-24 and the tests. The route stays /mask, which describes the action and needs no redirect. Tests: 459 (25 files). Two new suites replace the CSV one, tests/unit/env-source.test.ts (12) and a rewritten tests/unit/mask.test.ts (18); the 19 component tests assert the two-column shape and the actual regressions (no value in a heading or summary, no comment as a row, first line as a row), and e2e/mask.spec.ts checks the same shape with the no-request and no-storage promises unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #13.
The masking page was built on a CSV reader, which is the wrong model for a
.envfile. With no header and no delimiter to find, the guesswork turned a banner comment into a column title, inventedColumn 2…Nfrom the padding, and listed comments as rows — and for a file without comments it consumed the first variable as the header, printing its value as a column name, unmasked, and dropping it from the export. A masking tool that publishes a value is not a formatting bug.What the page reads now
KEY=valueassignment, in file order — the first line included.dotenvresolves them (last one wins), and the repeated keys are named.keyandvalue. No delimiter detection, no headers, no generated column names.The reported file now yields what the issue asked for:
with
{"comments": 5, "blank": 1, "unreadable": 0}in the summary — no value in a label anywhere.Deleted, not parked
src/core/csvand its 15 tests are gone with the feature that used them. A second input format is a product decision, and the issue asked for one shape.Output
.env-shaped: oneKEY=masked-valueper line, no comments, no originals, downloaded as<name>.masked.env. It reuses the compare engine's grammar, so the two pages cannot disagree aboutexport, quoting or trailing comments.formatValuesingle-quotes anything containing#,"or a backslash — the only formdotenvreturns verbatim — and only newlines force double quotes; a test round-trips its own output back through the parser.Defaults keep the masked file useful: obvious configuration (
info,3000,production, a credential-free URL) stays visible, credential-shaped values hide, and a key whose name says secret outranks a harmless-looking value. Warnings now name keys — "DATABASE_URL, OPENAI_API_KEY are still visible" — rather than a column index.Rename
Nav entry, page title, buttons, file picker label,
README,PRD§8.6 / US-24 and the tests all say env. The route stays/mask, which describes the action and needs no redirect.Verification
npm run check— 459 tests / 25 files, tsc clean, build ✓, privacy guard ✓tests/unit/env-source.test.ts(12) and a rewrittentests/unit/mask.test.ts(18): banner, first line, comments, blanks, duplicates, quoting round-trips, wide-CSV refusale2e/mask.spec.tschecks the same shape against real layout, with the no-request and no-storage promises unchanged