Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 8931bf6c
authored
Feb 21, 2020
by
Pedro Augusto de Paula Barbosa
Committed by
GitHub
Feb 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(sqlite): properly catch errors (#11877)
1 parent
efd2f406
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
lib/dialects/sqlite/query.js
test/integration/dialects/sqlite/issue-11862.test.js
lib/dialects/sqlite/query.js
View file @
8931bf6
...
...
@@ -251,12 +251,20 @@ class Query extends AbstractQuery {
}
}
function
wrappedAfterExecute
()
{
// See #11862
try
{
return
afterExecute
.
apply
(
this
,
arguments
);
}
catch
(
error
)
{
reject
(
error
);
}
}
if
(
method
===
'exec'
)
{
// exec does not support bind parameter
this
.
database
[
method
](
this
.
sql
,
a
fterExecute
);
this
.
database
[
method
](
this
.
sql
,
wrappedA
fterExecute
);
}
else
{
if
(
!
parameters
)
parameters
=
[];
this
.
database
[
method
](
this
.
sql
,
parameters
,
a
fterExecute
);
this
.
database
[
method
](
this
.
sql
,
parameters
,
wrappedA
fterExecute
);
}
}));
return
null
;
...
...
test/integration/dialects/sqlite/issue-11862.test.js
0 → 100644
View file @
8931bf6
'use strict'
;
const
Support
=
require
(
__dirname
+
'/../../support'
),
dialect
=
Support
.
getTestDialect
(),
DataTypes
=
require
(
__dirname
+
'/../../../../lib/data-types'
);
if
(
dialect
===
'sqlite'
)
{
describe
(
'[SQLITE Specific] Prevents security issue #11862'
,
()
=>
{
it
(
'Prevents security issue #11862'
,
function
()
{
const
Vulnerability
=
this
.
sequelize
.
define
(
'Vulnerability'
,
{
name
:
DataTypes
.
STRING
});
return
Vulnerability
.
sync
({
force
:
true
}).
then
(()
=>
{
// Before #11862 was fixed, the following call would crash the process.
// Here we test that this is no longer the case - the promise should settle properly.
// Ideally it should resolve, of course (not reject!), but from the point of view of the
// security issue, rejecting the promise is by far not as bad as crashing the process.
return
Vulnerability
.
create
({
name
:
'SELECT tbl_name FROM sqlite_master'
}).
reflect
();
// Note that in Sequelize v5+, the above call behaves correctly (resolves).
});
});
});
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment