Skip to content

Commit

Permalink
Dylan Fixing Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
DefenderK committed Nov 15, 2024
1 parent c95969b commit d465df6
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 14 deletions.
131 changes: 123 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test": "snyk test"
},
"dependencies": {
"adm-zip": "0.4.7",
"adm-zip": "0.5.2",
"body-parser": "1.9.0",
"cfenv": "^1.0.4",
"consolidate": "0.14.5",
Expand Down Expand Up @@ -46,7 +46,8 @@
"stream-buffers": "^3.0.1",
"tap": "^11.1.3",
"typeorm": "^0.2.24",
"validator": "^13.5.2"
"validator": "^13.5.2",
"stimulus_reflex": "3.4.1"
},
"devDependencies": {
"browserify": "^13.1.1",
Expand Down
9 changes: 5 additions & 4 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ exports.index = function (req, res, next) {

// Vulnerable code:


/*
exports.loginHandler = function (req, res, next) {
if (validator.isEmail(req.body.username)) {
User.find({ username: req.body.username, password: req.body.password }, function (err, users) {
User.(find{ username: req.body.username, password: req.body.password }, function (err, users) {
if (users.length > 0) {
const redirectPage = req.body.redirectPage
const session = req.session
Expand Down Expand Up @@ -69,9 +69,10 @@ if (validator.isEmail(req.body.username)) {
} else {
return res.status(401).send()
};
*/

// Fixed code: validator.escape() is used to sanitize the input parameters (username and password) before using them in the database query.
/*

exports.loginHandler = function (req, res, next) {
// Validate if the username is in email format
if (validator.isEmail(req.body.username)) {
Expand Down Expand Up @@ -99,7 +100,7 @@ exports.loginHandler = function (req, res, next) {
return res.status(401).send("Unauthorized");
}
};
*/


function adminLoginSuccess(redirectPage, session, username, res) {
session.loggedIn = 1
Expand Down

0 comments on commit d465df6

Please sign in to comment.