Skip to content

Commit

Permalink
Merge pull request finos#462 from vaibssingh/412-fix-codeql-issues
Browse files Browse the repository at this point in the history
Address CodeQL issues
  • Loading branch information
JamieSlome authored Mar 21, 2024
2 parents bcceed6 + e88ec4c commit 9b70a1b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
35 changes: 35 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
"email-validator": "^2.0.4",
"express": "^4.18.2",
"express-http-proxy": "^2.0.0",
"express-rate-limit": "^7.1.5",
"express-session": "^1.17.1",
"generate-password": "^1.5.1",
"history": "5.3.0",
"jsonschema": "^1.4.1",
"load-plugin": "^6.0.0",
"lodash": "^4.17.21",
"lusca": "^1.7.0",
"moment": "^2.29.4",
"mongodb": "^5.0.0",
"nodemailer": "^6.6.1",
Expand Down
11 changes: 10 additions & 1 deletion src/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ const session = require('express-session');
const http = require('http');
const cors = require('cors');
const app = express();
const rateLimit = require('express-rate-limit');
const csrf = require('lusca').csrf;

const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // limit each IP to 100 requests per windowMs
});

const { GIT_PROXY_UI_PORT: uiPort } = require('../config/env').Vars;

Expand All @@ -16,18 +23,20 @@ const corsOptions = {
};

const start = async () => {
// confiugraiton of passport is async
// configuration of passport is async
// Before we can bind the routes - we need the passport
const passport = await require('./passport').configure();
const routes = require('./routes');
app.use(cors(corsOptions));
app.use(limiter);
app.use(
session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: false,
}),
);
app.use(csrf());
app.use(passport.initialize());
app.use(passport.session());
app.use(express.json());
Expand Down
7 changes: 6 additions & 1 deletion src/service/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ router.post('/password', async (req, res) => {
throw new Error('current password did not match the given');
}
} catch (e) {
res.status(500).send(e).end();
res
.status(500)
.send({
message: 'An error occurred',
})
.end();
}
} else {
res.status(401).end();
Expand Down

0 comments on commit 9b70a1b

Please sign in to comment.