Showing 61 of 61 total issues
Function buildGetResponse
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function buildGetResponse(cnData, applicationData, schemaData, jsonData, getSchema){
Function checkForOrgName
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function checkForOrgName(input, processedFieldErrors){
if (input.applicantInfo){
if (input.applicantInfo.orgType && input.applicantInfo.orgType.toUpperCase() !== 'PERSON'){
if (!input.applicantInfo.organizationName || input.applicantInfo.organizationName.length <= 0){
processedFieldErrors.errorArray.push(makeErrorObj('applicantInfo.organizationName', 'missing'));
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function checkForSmallBusiness
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function checkForSmallBusiness(input, processedFieldErrors){
if (input.tempOutfitterFields && input.applicantInfo){
if (input.applicantInfo.orgType && input.applicantInfo.orgType.toUpperCase() !== 'PERSON'){
if ((typeof input.tempOutfitterFields.smallBusiness) !== 'boolean'){
processedFieldErrors.errorArray.push(makeErrorObj('tempOutfitterFields.smallBusiness', 'missing'));
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
return createContact(fieldsObj, person, apiCallsObject);
pg
Remote Code Execution Open
"pg": {
"version": "6.2.3",
"from": "pg@>=6.2.2 <7.0.0",
"resolved": "https://registry.npmjs.org/pg/-/pg-6.2.3.tgz"
},
- Read upRead up
- Exclude checks
Remote Code Execution
Overview:
A remote code execution vulnerability was found within the pg module when the remote database or query specifies a specially crafted column name.
The announcement from node-postgres mentions 2 likely scenarios in which you would likely be vulnerable.
- You are executing unsafe, user-supplied sql which contains a malicious column name like the one in the proof of concept below.
- You are connecting to an untrusted database and executing a query which returns results where any of the column names are malicious.
Proof of concept ``` const { Client } = require('pg') const client = new Client() client.connect()
const sql = SELECT 1 AS "\\'/*", 2 AS "\\'*/\n + console.log(process.env)] = null;\n//"
client.query(sql, (err, res) => { client.end() }) ```
Recommendation:
Upgrade to one of these versions listed below.
fresh
Regular Expression Denial of Service Open
"fresh": {
"version": "0.5.0",
"from": "fresh@0.5.0",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.0.tgz"
},
- Read upRead up
- Exclude checks
Regular Expression Denial of Service
Overview:
Fresh is a module used by the Express.js framework for 'HTTP response freshness testing'. It is vulnerable to a regular expression denial of service when it is passed specially crafted input to parse. This causes the event loop to be blocked causing a denial of service condition.
Recommendation:
If you are using this module via express, upgrade to Express version 4.15.5 or greater.
Upgrade to 0.5.2 or greater
debug
Regular Expression Denial of Service Open
"debug": {
"version": "2.6.8",
"from": "debug@2.6.8",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz"
}
- Read upRead up
- Exclude checks
Regular Expression Denial of Service
Overview:
The debug module is vulnerable to regular expression denial of service when untrusted user input is passed into the o
formatter. It takes around 50k characters to block for 2 seconds making this a low severity issue.
Recommendation:
Upgrade to version 2.6.9 or greater if you are on the 2.6.x series or 3.1.0 or greater.
minimatch
Regular Expression Denial of Service Open
"minimatch": {
"version": "0.2.14",
"from": "minimatch@>=0.2.11 <0.3.0",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz"
}
- Read upRead up
- Exclude checks
Regular Expression Denial of Service
Overview:
Minimatch is a minimal matching utility that works by converting glob expressions into JavaScript RegExp
objects. The primary function, minimatch(path, pattern)
is vulnerable to ReDoS in the pattern
parameter. This is because of the regular expression on line 521 of minimatch.js: /((?:\\{2})*)(\\?)\|/g,
. The problematic portion of the regex is ((?:\\{2})*)
which matches against \\
.
A proof of concept is as follows: ``` var minimatch = require(“minimatch”);
// utility function for generating long strings var genstr = function (len, chr) { var result = “”; for (i=0; i<=len; i++) { result = result + chr; } return result; }
var exploit = “[!” + genstr(1000000, “\”) + “A”;
// minimatch exploit. console.log(“starting minimatch”); minimatch(“foo”, exploit); console.log(“finishing minimatch”); ```
Recommendation:
Updated to version 3.0.2 or greater
mime
Regular Expression Denial of Service Open
"mime": {
"version": "1.2.11",
"from": "mime@>=1.2.11 <1.3.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.2.11.tgz"
},
- Read upRead up
- Exclude checks
Regular Expression Denial of Service
Overview:
The mime module is vulnerable to regular expression denial of service when a mime lookup is performed on untrusted user input.
Recommendation:
Upgrade to version 2.0.3 or greater.
tough-cookie
Regular Expression Denial of Service Open
"tough-cookie": {
"version": "2.3.2",
"from": "tough-cookie@>=2.3.0 <2.4.0",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz",
"dependencies": {
- Read upRead up
- Exclude checks
Regular Expression Denial of Service
Overview:
The tough-cookie module is vulnerable to regular expression denial of service. Input of around 50k characters is required for a slow down of around 2 seconds.
Unless node was compiled using the -DHTTPMAXHEADER_SIZE= option the default header max length is 80kb so the impact of the ReDoS is limited to around 7.3 seconds of blocking.
At the time of writing all version <=2.3.2 are vulnerable
Recommendation:
Please update to version 2.3.3 or greater
minimatch
Regular Expression Denial of Service Open
"minimatch": {
"version": "2.0.10",
"from": "minimatch@>=2.0.1 <3.0.0",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz"
},
- Read upRead up
- Exclude checks
Regular Expression Denial of Service
Overview:
Minimatch is a minimal matching utility that works by converting glob expressions into JavaScript RegExp
objects. The primary function, minimatch(path, pattern)
is vulnerable to ReDoS in the pattern
parameter. This is because of the regular expression on line 521 of minimatch.js: /((?:\\{2})*)(\\?)\|/g,
. The problematic portion of the regex is ((?:\\{2})*)
which matches against \\
.
A proof of concept is as follows: ``` var minimatch = require(“minimatch”);
// utility function for generating long strings var genstr = function (len, chr) { var result = “”; for (i=0; i<=len; i++) { result = result + chr; } return result; }
var exploit = “[!” + genstr(1000000, “\”) + “A”;
// minimatch exploit. console.log(“starting minimatch”); minimatch(“foo”, exploit); console.log(“finishing minimatch”); ```
Recommendation:
Updated to version 3.0.2 or greater
forwarded
Regular Expression Denial of Service Open
"forwarded": {
"version": "0.1.0",
"from": "forwarded@>=0.1.0 <0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz"
},
- Read upRead up
- Exclude checks
Regular Expression Denial of Service
Overview:
The forwarded module is used by the Express.js framework to handle the X-Forwarded-For header. It is vulnerable to a regular expression denial of service when it's passed specially crafted input to parse. This causes the event loop to be blocked causing a denial of service condition.
Recommendation:
If you are using this module via express, upgrade to Express version 4.15.5 or greater.
Upgrade to 0.1.2 or greater
Similar blocks of code found in 2 locations. Consider refactoring. Open
const getFile = function(fp, callback){
models.files.findOne({
where: {filePath: fp}
})
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 100.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
mime
Regular Expression Denial of Service Open
"mime": {
"version": "1.3.4",
"from": "mime@1.3.4",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz"
}
- Read upRead up
- Exclude checks
Regular Expression Denial of Service
Overview:
The mime module is vulnerable to regular expression denial of service when a mime lookup is performed on untrusted user input.
Recommendation:
Upgrade to version 2.0.3 or greater.
debug
Regular Expression Denial of Service Open
"debug": {
"version": "2.6.7",
"from": "debug@2.6.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.7.tgz"
},
- Read upRead up
- Exclude checks
Regular Expression Denial of Service
Overview:
The debug module is vulnerable to regular expression denial of service when untrusted user input is passed into the o
formatter. It takes around 50k characters to block for 2 seconds making this a low severity issue.
Recommendation:
Upgrade to version 2.6.9 or greater if you are on the 2.6.x series or 3.1.0 or greater.
Avoid too many return
statements within this function. Open
return error.sendError(req, res, 404, 'Invalid endpoint.');
Similar blocks of code found in 2 locations. Consider refactoring. Open
const getFiles = function(appId, callback){
models.files.findAll({
where: {applicationId: appId}
})
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 100.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
marked
Regular Expression Denial of Service Open
"marked": {
"version": "0.3.6",
"from": "marked@>=0.3.6 <0.4.0",
"resolved": "https://registry.npmjs.org/marked/-/marked-0.3.6.tgz"
},
- Read upRead up
- Exclude checks
Regular Expression Denial of Service
Overview:
The marked module is vulnerable to a regular expression denial of service. Based on the information published in the public issue, 1k characters can block for around 6 seconds.
Recommendation:
Consider another markdown parser until the issue can be addressed.
First header should be a top level header Open
## CC0 1.0 Universal summary
- Read upRead up
- Exclude checks
MD002 - First header should be a top level header
Tags: headers
Aliases: first-header-h1
Parameters: level (number; default 1)
This rule is triggered when the first header in the document isn't a h1 header:
## This isn't a H1 header
### Another header
The first header in the document should be a h1 header:
# Start with a H1 header
## Then use a H2 for subsections
First header should be a top level header Open
## Welcome!
- Read upRead up
- Exclude checks
MD002 - First header should be a top level header
Tags: headers
Aliases: first-header-h1
Parameters: level (number; default 1)
This rule is triggered when the first header in the document isn't a h1 header:
## This isn't a H1 header
### Another header
The first header in the document should be a h1 header:
# Start with a H1 header
## Then use a H2 for subsections