-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ext/kv): don't request permissions for ":memory:" #18346
Conversation
if path.is_empty() { | ||
return Err(type_error("Filename cannot be empty")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.sqlite.org/c3ref/open.html
If the filename is an empty string, then a private, temporary on-disk database will be created. This private database will be automatically deleted as soon as the database connection is closed.
if path.starts_with(':') { | ||
return Err(type_error( | ||
"Filename cannot start with ':' unless prefixed with './'", | ||
)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.sqlite.org/c3ref/open.html
Future versions of SQLite might make use of additional special filenames that begin with the ":" character. It is recommended that when a database filename actually does begin with a ":" character you should prefix the filename with a pathname such as "./" to avoid ambiguity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filename cannot start with ':' unless prefixed with './'
may not be applicable to Windows though. Except for drive letters, :
is completely out of league.
let path = Path::new(path); | ||
{ | ||
let mut state = state.borrow_mut(); | ||
let permissions = state.borrow_mut::<P>(); | ||
permissions.check_read(path, "Deno.openKv")?; | ||
permissions.check_write(path, "Deno.openKv")?; | ||
} | ||
rusqlite::Connection::open(path)? | ||
let flags = OpenFlags::default().difference(OpenFlags::SQLITE_OPEN_URI); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabled URI paths
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Currently
Deno.openKv(":memory:")
requests read+write permissions for./:memory:
even though no file is read or written. Also added some guards for special sqlite paths that were unintentionally opted into.