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

Feat/sonar demo #112

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open

Feat/sonar demo #112

wants to merge 58 commits into from

Conversation

pstember
Copy link
Owner

Creating issue for failing quality gate

erichusband and others added 30 commits November 28, 2019 14:46
This reverts commit a349cd0.
* feat: add prototype pollution exploit in typeorm

* fix: container and db setup
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SnykCode found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
8 Security Hotspots
E Security Rating on New Code (required ≥ A)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

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

console.log(`User logged in: ${username}`)

if (redirectPage) {
return res.redirect(redirectPage)

Check failure

Code scanning / SonarCloud

HTTP request redirections should not be open to forging attacks High

Change this code to not perform redirects based on user-controlled data. See more on SonarCloud
Comment on lines +42 to +46
app.use(session({
secret: 'keyboard cat',
name: 'connect.sid',
cookie: { path: '/' }
}))

Check failure

Code scanning / CodeQL

Missing CSRF middleware High

This cookie middleware is serving a
request handler
without CSRF protection.
cons.dust.helpers = dustHelpers;
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(methodOverride());
app.use(cookieParser());
app.use(session({
secret: 'keyboard cat',

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical

The hard-coded value "keyboard cat" is used as
key
.
// You know password for the user.
{name: 'user', password: 'pwd'},
// You don't know password for the admin.
{name: 'admin', password: Math.random().toString(32), canDelete: true},

Check failure

Code scanning / CodeQL

Insecure randomness High

This uses a cryptographically insecure random number generated at
Math.random()
in a security context.
// You don't know password for the admin.
{name: 'admin', password: Math.random().toString(32), canDelete: true},
{ name: 'admin', password: Math.random().toString(32), canDelete: true },

Check failure

Code scanning / CodeQL

Insecure randomness High

This uses a cryptographically insecure random number generated at
Math.random()
in a security context.
console.log(`User logged in: ${username}`)

if (redirectPage) {
return res.redirect(redirectPage)

Check warning

Code scanning / CodeQL

Server-side URL redirect Medium

Untrusted URL redirection depends on a
user-provided value
.
@@ -14,6 +14,7 @@
<center>password</center>
<input class="input" type="password" name="password" />
<center>
<input type="hidden" name="redirectPage" value="<%- redirectPage %>" />

Check failure

Code scanning / CodeQL

Client-side cross-site scripting High

Cross-site scripting vulnerability due to
user-provided value
.
profile.lastname = validator.rtrim(profile.lastname)

// render the view
return res.render('account.hbs', profile)

Check failure

Code scanning / CodeQL

Template Object Injection Critical

Template object depends on a
user-provided value
.
subhead: 'Vulnerabilities at their best',
todos: todos,
});
});
};

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) {

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources High

This query object depends on a
user-provided value
.
This query object depends on a
user-provided value
.
app.get('/admin', routes.admin);
app.post('/admin', routes.admin);
app.get('/login', routes.login);
app.post('/login', routes.loginHandler);

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
a database access
, but is not rate-limited.
@@ -79,7 +154,7 @@

var item = req.body.content;
var imgRegex = /\!\[alt text\]\((http.*)\s\".*/;
if (typeof(item) == 'string' && item.match(imgRegex)) {
if (typeof (item) == 'string' && item.match(imgRegex)) {

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on
a user-provided value
may run slow on strings starting with '![alt text](http' and with many repetitions of '![alt text](http'.
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.