Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #13

Closed
wants to merge 32 commits into from
Closed

Develop #13

wants to merge 32 commits into from

Conversation

smyllet
Copy link
Member

@smyllet smyllet commented Nov 17, 2023

Required :

src/app.ts Outdated

app.use(express.json({limit: '50mb'}));
app.use(express.urlencoded({limit: '50mb' ,extended: false}));
app.use(cookieParser());

Check failure

Code scanning / CodeQL

Missing CSRF middleware

This cookie middleware is serving a [request handler](1) without CSRF protection.
src/app.ts Outdated
Comment on lines 51 to 119
app.all('*', function (req, res, next) {
if (req.path === '/users/login' || req.path === '/users') {
next();
} else {
const { application_token} = req.headers;
if(application_token && typeof application_token === "string") {
jwt.verify(application_token, env.APPLICATION_TOKEN_SECRET)
.then((decoded) => {
ApplicationModel.findOne({
where: {
token: req.headers.application_token,
},
})
.then((application) => {
// decoded cannot be a string since the
// token is generated from an object
if (application && typeof decoded !== "string") {
req.user = new UserDto(decoded.user);
next();
} else {
res.status(401).send({
message: "Invalid application token",
});
}
})
.catch((err) => {
res.status(500).send({
message: "Internal server error",
});
});
})
.catch((err) => {
console.log(err);
res.status(401).send({
message: "Invalid application token",
});
});
} else {
jwt.verify(req.cookies.access_token, env.ACCESS_TOKEN_SECRET)
.then(decoded => {
req.user = new UserDto(decoded);
next();
})
.catch((err) => {
jwt.verify(req.cookies.refresh_token, env.REFRESH_TOKEN_SECRET)
.then((user) => {
UserModel.findByPk(user.id)
.then(async function (user) {
if (user) {
res.cookie('access_token', await UserTokenUtil.generateAccessToken(new UserDto(user)), {maxAge: 1000 * 60 * 30});
res.cookie('refresh_token', req.cookies.refresh_token, {maxAge: 1000 * 60 * 60 * 24 * 30});
req.user = new UserDto(user);
next();
} else {
res.status(401).send();
}
})
.catch(function (err) {
res.status(401).send();
});
})
.catch((err) => {
res.status(401).send();
});

})
}
}
});

Check failure

Code scanning / CodeQL

Missing rate limiting

This route handler performs [authorization](1), but is not rate-limited. This route handler performs [authorization](2), but is not rate-limited.
src/app.ts Fixed Show fixed Hide fixed
src/app.ts Fixed Show fixed Hide fixed
src/routes/users.ts Fixed Show fixed Hide fixed
src/app.ts Fixed Show fixed Hide fixed
src/app.ts Fixed Show fixed Hide fixed
@aquatracking aquatracking deleted a comment from sonarcloud bot Feb 9, 2024
Copy link

sonarcloud bot commented Feb 9, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots
3.9% Duplication on New Code (required ≤ 3%)
D Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

idea Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

@smyllet smyllet closed this Feb 9, 2024
@smyllet smyllet deleted the develop branch February 9, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants