Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Expose E2E build errors #940
Expose E2E build errors #940
Changes from all commits
afc343c
15a6990
c990d37
e8e3156
f2d04f7
9f0d8b2
c4d7e6b
9c40e93
b70ddb6
b0c32ae
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 74 in node-src/tasks/build.ts
Codacy Production / Codacy Static Code Analysis
node-src/tasks/build.ts#L74
Check warning on line 74 in node-src/tasks/build.ts
Codacy Production / Codacy Static Code Analysis
node-src/tasks/build.ts#L74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RegExp
constructor was called with a non-literal value.The security issue identified by Semgrep is related to the use of the
RegExp
constructor with a non-literal value. This can potentially lead to a Regular Expression Denial of Service (ReDoS) attack if an attacker is able to control the pattern passed toRegExp
, especially if they can provide a complex pattern that can cause the application to hang due to excessive backtracking.In this specific case, the variable
e2eBuildBinName
is interpolated into a regex pattern, which could be a concern ife2eBuildBinName
is user-controlled or can be manipulated. However, without more context, it's unclear ife2eBuildBinName
is a constant, an environment variable, or user input.Assuming
e2eBuildBinName
is a safe, constant value that does not come from user input, you could pre-compile the regexes with the interpolated value to both improve performance and satisfy the linter. Ife2eBuildBinName
is not a constant and can vary at runtime, it's important to sanitize or escape it before using it in a regex pattern to prevent ReDoS attacks.Here's a single line code suggestion that pre-compiles the regexes assuming
e2eBuildBinName
is a safe, constant value:This suggestion replaces the backticks and
${e2eBuildBinName}
interpolation with areplace
call that only happens once, assuminge2eBuildBinName
is not dynamic. Ife2eBuildBinName
is dynamic, you would need to ensure it is properly escaped to prevent it from being used in an attack.This comment was generated by an experimental AI tool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regex
function argument, this might allow an attacker to cause a Regular Expression Denial-of-Service (ReDoS) within your application as RegExP blocks the main thread.The issue identified by Semgrep is related to the potential for a Regular Expression Denial of Service (ReDoS) attack. This can happen when user input or a variable that can be influenced by user input is used to dynamically create a regular expression. If an attacker provides a specially crafted input, it can create a regular expression that takes a very long time to evaluate, effectively blocking the main thread and causing a denial of service.
In the provided code, the variable
e2eBuildBinName
is interpolated into a string that is then used to create a regular expression. Ife2eBuildBinName
is or can be influenced by user input, it could be exploited to cause a ReDoS attack.To mitigate this, we need to sanitize or escape the variable
e2eBuildBinName
before using it in the regular expression. However, since the code suggestion must be a single line change and we don't have the context for wheree2eBuildBinName
is coming from, a general solution could be to use a library likelodash
to escape RegExp special characters.Here's a single line code suggestion that uses the
escapeRegExp
function fromlodash
to escape any special characters ine2eBuildBinName
before using it in the regex:Please note that for this suggestion to work, you must ensure that the
lodash
library is installed and imported in your code as_
. Iflodash
is not already a dependency, you will need to add it to your project and import theescapeRegExp
function:Or, if you prefer to import only the needed function:
This comment was generated by an experimental AI tool.