Skip to content

fix(cli): read the semicolon from raw SQL in the remote confirm check - #869

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
0froq:fix/remote-confirm-sql-literals
Nov 18, 2026
Merged

cpojer merged 1 commit into
voidzero-dev:mainfrom
0froq:fix/remote-confirm-sql-literals

Conversation

@0froq

@0froq 0froq commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Description

The remote void db execute confirmation prompt is meant to fail closed. Only a single read-only statement skips it, and the semicolon test ran on text with comments stripped, so a literal could hide a second statement. void db execute --remote "SELECT '--' ; DROP TABLE t" was cut at the --, read as one SELECT, and sent without the prompt.

The semicolon is now read from the raw SQL, minus a trailing one, so a literal cannot hide it. Comment stripping stays for the read-only prefix test, which keeps -- header\nSELECT 1 prompt-free and EXPLAIN ANALYZE prompting. A semicolon inside a comment or a literal now costs one extra prompt, which is the safe side of that trade.

Test

db-execute-remote.test.ts runs the prompt in a TTY. The new cases assert that SELECT '--' ; DROP TABLE users, SELECT '/*' ; DROP TABLE users and -- a; comment\nSELECT 1 prompt, while SELECT 1; and SELECT '--' do not.

`SELECT '--' ; DROP TABLE users` was stripped as a comment, so the check saw
one SELECT and sent the DROP without the confirmation prompt. Read the
semicolon from the raw text, where a literal cannot hide it, and keep comment
stripping for the read-only prefix test.

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@cpojer
cpojer merged commit 0d75c97 into voidzero-dev:main Nov 18, 2026
18 checks passed
@0froq
0froq deleted the fix/remote-confirm-sql-literals branch November 18, 2026 01:51
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.

2 participants