mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 08:18:04 +00:00
fix(ui): skip TOML comments when scanning sensitive array values
PR-Agent on #1248 flagged that the TOML array walker did not skip `#` line comments while balancing brackets. A sensitive array with a comment containing `]` could terminate the scan early and leave the real tail of the secret unmasked. Skip from `#` to the next newline at the array's top level. Adds a regression test.
This commit is contained in:
1 parent
f404e52439
commit
a633ee0af4
2 files changed
+27
-3
No files matched your search
@@ -131,6 +131,24 @@ describe('CodeEditor', () => {
|
||||
expect(masked).not.toContain('ok');
|
||||
});
|
||||
|
||||
it('does not terminate TOML array masking on a `]` inside a comment', () => {
|
||||
const value = [
|
||||
'AUTH_TOKEN = [',
|
||||
' "first", # closing bracket in comment: ]',
|
||||
' "second",',
|
||||
']',
|
||||
'visible = "ok"',
|
||||
].join('\n');
|
||||
|
||||
const { container } = render(<CodeEditor value={value} onChange={vi.fn()} language="toml" />);
|
||||
const masked = Array.from(container.querySelectorAll('.cm-sensitive-mask'))
|
||||
.map((el) => el.textContent ?? '')
|
||||
.join('');
|
||||
expect(masked).toContain('"first"');
|
||||
expect(masked).toContain('"second"');
|
||||
expect(masked).not.toContain('ok');
|
||||
});
|
||||
|
||||
it('respects escaped quotes inside TOML array values when masking', () => {
|
||||
const value = ['AUTH_TOKEN = ["a \\"quoted\\" value", "x"]', 'visible = "ok"'].join('\n');
|
||||
|
||||
|
||||
Reference in new issue
Block a user