-
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Clean up source code formatting
- Loading branch information
Showing
38 changed files
with
429 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
{ | ||
"extends": "nodesecurity" | ||
"extends": [ | ||
"eslint:recommended", | ||
"prettier" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": "latest" | ||
}, | ||
"env": { | ||
"node": true, | ||
"es2020": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"printWidth": 180 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,29 @@ | ||
1.4.0 / 2017-06-12 | ||
================== | ||
|
||
* Add recommended ruleset to the usage example | ||
* Removes filenames from error output | ||
|
||
1.3.0 / 2017-02-09 | ||
================== | ||
|
||
* README.md - document detect-disable-mustache-escape rule | ||
* README.md - documentation detect-new-buffer rule | ||
* Fixed crash with `detect-no-csrf-before-method-override` rule. | ||
* Style guide applied to all the code involving the tests | ||
* Removing a repeated test and style changes | ||
* ESLint added to the workflow | ||
* Removed not needed variables | ||
* Fix to a problem with a rule detected implementing the tests | ||
* Test engine with tests for all the rules | ||
* Add additional information to README for each rule | ||
|
||
1.2.0 / 2016-01-21 | ||
================== | ||
|
||
* updated to check for new RegExp too | ||
|
||
1.1.0 / 2016-01-06 | ||
================== | ||
|
||
* adding eslint rule to detect new buffer hotspot | ||
|
||
1.0.0 / 2015-11-15 | ||
================== | ||
|
||
* rules disabled by default | ||
# 1.4.0 / 2017-06-12 | ||
|
||
- Add recommended ruleset to the usage example | ||
- Removes filenames from error output | ||
|
||
# 1.3.0 / 2017-02-09 | ||
|
||
- README.md - document detect-disable-mustache-escape rule | ||
- README.md - documentation detect-new-buffer rule | ||
- Fixed crash with `detect-no-csrf-before-method-override` rule. | ||
- Style guide applied to all the code involving the tests | ||
- Removing a repeated test and style changes | ||
- ESLint added to the workflow | ||
- Removed not needed variables | ||
- Fix to a problem with a rule detected implementing the tests | ||
- Test engine with tests for all the rules | ||
- Add additional information to README for each rule | ||
|
||
# 1.2.0 / 2016-01-21 | ||
|
||
- updated to check for new RegExp too | ||
|
||
# 1.1.0 / 2016-01-06 | ||
|
||
- adding eslint rule to detect new buffer hotspot | ||
|
||
# 1.0.0 / 2015-11-15 | ||
|
||
- rules disabled by default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
|
||
Imagine you are trying to buy a ticket to your favorite JavaScript conference, and instead of getting the ticket page, you instead get `500 Internal Server Error`. For some reason the site is down. You can't do the thing that you want to do most and the conference is losing out on your purchase, all because the application is unavailable. | ||
|
||
Availability is not often treated as a security problem, which it is, and it's impacts are immediate, and deeply felt. | ||
Availability is not often treated as a security problem, which it is, and it's impacts are immediate, and deeply felt. | ||
|
||
The attack surface for Node.js in regards to loss of availability is quite large, as we are dealing with a single event loop. If an attacker can control and block that event loop, then nothing else gets done. | ||
|
||
There are many ways to block the event loop, one way an attacker can do that is with [Regular Expression Denial of Service (ReDoS)](https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS). | ||
|
||
If user provided input finds it's way into a regular expression, or a regular expression is designed with certain attributes, such as grouping with repetition, you can find yourself in a vulnerable position, as the regular expression match could take a long time to process. [OWASP](https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS) has a deeper explanation of why this occurs. | ||
If user provided input finds it's way into a regular expression, or a regular expression is designed with certain attributes, such as grouping with repetition, you can find yourself in a vulnerable position, as the regular expression match could take a long time to process. [OWASP](https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS) has a deeper explanation of why this occurs. | ||
|
||
Let's look at an vulnerable example. Below we are attempting the common task of validating an email address on the server. | ||
|
||
|
@@ -24,19 +24,19 @@ With the example above, we can use this test script to show how bad input can im | |
|
||
```js | ||
start = process.hrtime(); | ||
console.log(validateEmailFormat("[email protected]")); | ||
console.log(validateEmailFormat('[email protected]')); | ||
console.log(process.hrtime(start)); | ||
|
||
start = process.hrtime(); | ||
console.log(validateEmailFormat("jjjjjjjjjjjjjjjjjjjjjjjjjjjj@ccccccccccccccccccccccccccccc.5555555555555555555555555555555555555555{")); | ||
console.log(validateEmailFormat('jjjjjjjjjjjjjjjjjjjjjjjjjjjj@ccccccccccccccccccccccccccccc.5555555555555555555555555555555555555555{')); | ||
console.log(process.hrtime(start)); | ||
|
||
start = process.hrtime(); | ||
console.log(validateEmailFormat("jjjjjjjjjjjjjjjjjjjjjjjjjjjj@ccccccccccccccccccccccccccccc.55555555555555555555555555555555555555555{")); | ||
console.log(validateEmailFormat('jjjjjjjjjjjjjjjjjjjjjjjjjjjj@ccccccccccccccccccccccccccccc.55555555555555555555555555555555555555555{')); | ||
console.log(process.hrtime(start)); | ||
|
||
start = process.hrtime(); | ||
console.log(validateEmailFormat("jjjjjjjjjjjjjjjjjjjjjjjjjjjj@ccccccccccccccccccccccccccccc.555555555555555555555555555555555555555555555555555555{")); | ||
console.log(validateEmailFormat('jjjjjjjjjjjjjjjjjjjjjjjjjjjj@ccccccccccccccccccccccccccccc.555555555555555555555555555555555555555555555555555555{')); | ||
console.log(process.hrtime(start)); | ||
``` | ||
|
||
|
@@ -59,21 +59,21 @@ Here is a rule for eslint that you can use to test your JavaScript regular expre | |
|
||
```js | ||
var safe = require('safe-regex'); | ||
module.exports = function(context) { | ||
"use strict"; | ||
module.exports = function (context) { | ||
'use strict'; | ||
|
||
return { | ||
"Literal": function(node) { | ||
Literal: function (node) { | ||
var token = context.getTokens(node)[0], | ||
nodeType = token.type, | ||
nodeValue = token.value; | ||
nodeType = token.type, | ||
nodeValue = token.value; | ||
|
||
if (nodeType === "RegularExpression") { | ||
if (nodeType === 'RegularExpression') { | ||
if (!safe(nodeValue)) { | ||
context.report(node, "Possible Unsafe Regular Expression"); | ||
context.report(node, 'Possible Unsafe Regular Expression'); | ||
} | ||
} | ||
} | ||
}, | ||
}; | ||
}; | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.