Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hexang 息壤平台
persona
Commits
aa65d9cb
Commit
aa65d9cb
authored
12 years ago
by
Lloyd Hilaiel
Browse files
Options
Downloads
Patches
Plain Diff
fix defects found in code review for improved api argument validation, issue #1526
parent
b0721b75
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/wsapi.js
+0
-3
0 additions, 3 deletions
lib/wsapi.js
lib/wsapi/cert_key.js
+9
-1
9 additions, 1 deletion
lib/wsapi/cert_key.js
lib/wsapi/complete_reverify.js
+0
-66
0 additions, 66 deletions
lib/wsapi/complete_reverify.js
with
9 additions
and
70 deletions
lib/wsapi.js
+
0
−
3
View file @
aa65d9cb
...
...
@@ -265,9 +265,6 @@ exports.setup = function(options, app) {
// set up the argument validator
if
(
api
.
args
)
{
if
(
Array
.
isArray
(
api
.
args
))
{
console
.
log
(
"
WARNING: you should update
"
,
operation
,
"
it uses unvalidated arguments
"
);
}
wsapis
[
operation
].
validate
=
validate
(
api
.
args
);
}
else
{
wsapis
[
operation
].
validate
=
function
(
req
,
res
,
next
)
{
next
();
};
...
...
This diff is collapsed.
Click to expand it.
lib/wsapi/cert_key.js
+
9
−
1
View file @
aa65d9cb
...
...
@@ -37,8 +37,16 @@ exports.process = function(req, res) {
// forward to the keysigner!
var
keysigner
=
urlparse
(
config
.
get
(
'
keysigner_url
'
));
keysigner
.
path
=
'
/wsapi/cert_key
'
;
// parameter validation moves arguments from req.body to req.params,
// and removes them from req.body. This feature makes it impossible
// to use unvalidated params in your wsapi "process" function.
//
// http_forward, however, will only forward params in req.body
// or req.query. so we explicitly copy req.params to req.body
// to cause them to be forwarded.
req
.
body
=
req
.
params
;
console
.
log
(
'
bid params
'
,
req
.
params
);
forward
(
keysigner
,
req
,
res
,
function
(
err
)
{
if
(
err
)
{
logger
.
error
(
"
error forwarding request to keysigner:
"
+
err
);
...
...
This diff is collapsed.
Click to expand it.
lib/wsapi/complete_reverify.js
deleted
100644 → 0
+
0
−
66
View file @
b0721b75
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const
db
=
require
(
'
../db.js
'
),
logger
=
require
(
'
../logging.js
'
).
logger
,
wsapi
=
require
(
'
../wsapi.js
'
),
bcrypt
=
require
(
'
../bcrypt.js
'
),
httputils
=
require
(
'
../httputils.js
'
);
exports
.
method
=
'
post
'
;
exports
.
writes_db
=
true
;
exports
.
authed
=
false
;
exports
.
args
=
{
'
token
'
:
'
token
'
,
// NOTE: 'pass' is required when a user is not authenticated
'
pass
'
:
{
type
:
'
password
'
,
optional
:
true
}
};
exports
.
i18n
=
false
;
exports
.
process
=
function
(
req
,
res
)
{
// in order to complete an email re-verification, one of the following must be true:
//
// 1. you must already be authenticated as the user who initiated the verification
// 2. you must provide the password of the initiator.
db
.
authForVerificationSecret
(
req
.
params
.
token
,
function
(
err
,
initiator_hash
,
initiator_uid
)
{
if
(
err
)
{
logger
.
info
(
"
unknown verification secret:
"
+
err
);
return
wsapi
.
databaseDown
(
res
,
err
);
}
if
(
req
.
session
.
userid
===
initiator_uid
)
{
postAuthentication
();
}
else
if
(
typeof
req
.
params
.
pass
===
'
string
'
)
{
bcrypt
.
compare
(
req
.
params
.
pass
,
initiator_hash
,
function
(
err
,
success
)
{
if
(
err
)
{
logger
.
warn
(
"
max load hit, failing on auth request with 503:
"
+
err
);
return
httputils
.
serviceUnavailable
(
res
,
"
server is too busy
"
);
}
else
if
(
!
success
)
{
return
httputils
.
authRequired
(
res
,
"
password mismatch
"
);
}
else
{
postAuthentication
();
}
});
}
else
{
return
httputils
.
authRequired
(
res
,
"
password required
"
);
}
function
postAuthentication
()
{
db
.
completeReverify
(
req
.
params
.
token
,
function
(
e
,
email
,
uid
)
{
if
(
e
)
{
logger
.
warn
(
"
couldn't complete email verification:
"
+
e
);
wsapi
.
databaseDown
(
res
,
e
);
}
else
{
wsapi
.
authenticateSession
(
req
.
session
,
uid
,
'
password
'
);
res
.
json
({
success
:
true
});
}
});
};
});
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment