sqlite: fix crashes on invalid backup and URL args - #65831
Conversation
Signed-off-by: Lazizbek Ergashev <lazerg2@gmail.com>
|
Review requested:
|
|
Caution AgentScan found account activity patterns that may be consistent with automation. This is a heuristic, not proof that this pull request was opened by an agent or violates policy. AI-assisted contributions are permitted, but automated tooling must not open pull requests without advance approval, and contributors must personally understand, test, verify, and take responsibility for every submitted change. See the AgentScan analysis, AI use policy, and automation policy for additional context. |
|
I used agent to resolve the problem. I confirm I revied code myself. |
|
FYI I posted a draft PR around the same time this one went up: #65832 A few things from it may be worth folding in here:
|
Store the DatabaseSync constructor template behind
DatabaseSync::GetConstructorTemplate(), matching StatementSync,
StatementSyncIterator, Session and SQLTagStore, which all already have
one. DatabaseSync was the only class in the file setting its template up
inline in Initialize(), which also meant the Environment slot would be
reassigned if Initialize() ever ran for more than one realm, leaving
instances from the earlier realm failing HasInstance(). This moves
SetSideEffectFreeGetter() to the top of the file so the accessor can use
it; its body is unchanged.
Drop the now-redundant IsObject() check in Backup() so a bad sourceDb
reports one message instead of two, and use the wording
lib/internal/errors.js generates for ERR_INVALID_ARG_TYPE.
Stop discarding an exception thrown by an href getter in
ValidateDatabasePath() and replacing it with ERR_INVALID_ARG_TYPE.
Cover the remaining unwrap cases in tests: an array, a padded plain
object, an object with DatabaseSync.prototype, a StatementSync and a
Session, plus the second ValidateDatabasePath() caller reached through
backup(db, { href: 'zzz' }).
Co-authored-by: Trevor Burnham <trevorburnham@gmail.com>
Signed-off-by: Lazizbek Ergashev <lazerg2@gmail.com>
|
Thanks, this was useful. I went through all four against the source and pushed bf0648c.
One more from your diff that was not in your list: The one place I kept my version is the unparseable On the two PRs: yours was the more complete one, and most of what is now here came from it. If you would rather land yours, say so and I will close this in its favour. Otherwise I believe this one now covers the same ground. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #65831 +/- ##
==========================================
+ Coverage 90.17% 90.18% +0.01%
==========================================
Files 770 770
Lines 264483 264492 +9
Branches 50262 50266 +4
==========================================
+ Hits 238491 238544 +53
+ Misses 16981 16938 -43
+ Partials 9011 9010 -1
🚀 New features to boost your workflow:
|
backup()checked only that its first argument was an object before unwrapping it as aDatabaseSync, sobackup({}, path)crashed with a segfault.ValidateDatabasePath()had a similar problem: it asserted that a duck-typed URL'shrefparses, which aborts the process rather than throwing, sonew DatabaseSync({ href: 'zzz' })took the whole process down too.Both now throw a
TypeErrorinstead.Fixes: #65830