Skip to content

sqlite-inproc: Add allow_attach_file runtime config option#3503

Open
lann wants to merge 1 commit into
mainfrom
allow-attach-file
Open

sqlite-inproc: Add allow_attach_file runtime config option#3503
lann wants to merge 1 commit into
mainfrom
allow-attach-file

Conversation

@lann
Copy link
Copy Markdown
Collaborator

@lann lann commented May 11, 2026

This option defaults to false, blocking the sqlite ATTACH statement from being used with regular files, which could be used to open other sqlite databases.

@lann lann force-pushed the allow-attach-file branch from 1e68736 to f6c284f Compare May 11, 2026 22:53
let line = line!();
return Err(format!(
"{krate}#({file}:{line}) {}", format_args!($fmt, $($arg)*)
"{krate}#({file}:{line}) {}", format_args!($fmt $(, $($arg)*)?)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This drive-by refactor makes the trailing comma optional when no extra args are passed, e.g. https://github.com/spinframework/spin/pull/3503/changes#diff-980855598b2b312f034dcd583093cd525c7d808c00097b4e62424c35a801d89eL56-R56

for forbidden_stmt in ["ATTACH 'any_file' AS attach_file", "VACUUM INTO 'any_file'"] {
match conn.execute(forbidden_stmt, &[]) {
Ok(_) => bail!("{forbidden_stmt:?} should fail"),
Err(Error::Io(s)) if s.contains("authoriz") => {}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Annoyingly the ATTACH and VACUUM errors are sliiiightly different, leading to this awkward check.

Copy link
Copy Markdown
Collaborator

@itowlson itowlson left a comment

Choose a reason for hiding this comment

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

Ouch, nice catch.

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