Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.8k
fix(security): pentest remediation — condition escaping, SSRF hardening, ReDoS protection#3820
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
026bc76f1fc068ccaa49d34be2a78d03be3f63d1c6301f9beFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| import safe from 'safe-regex2' | ||
| /** | ||
| * Validate if input matches regex pattern | ||
| */ | ||
| @@ -7,15 +9,23 @@ export interface ValidationResult { | ||
| } | ||
| export function validateRegex(inputStr: string, pattern: string): ValidationResult { | ||
| let regex: RegExp | ||
| try { | ||
| const regex = new RegExp(pattern) | ||
| const match = regex.test(inputStr) | ||
| if (match) { | ||
| return { passed: true } | ||
| } | ||
| return { passed: false, error: 'Input does not match regex pattern' } | ||
| regex = new RegExp(pattern) | ||
| } catch (error: any) { | ||
| return { passed: false, error: `Invalid regex pattern: ${error.message}` } | ||
| } | ||
| if (!safe(pattern)) { | ||
| return { | ||
| passed: false, | ||
| error: 'Regex pattern rejected: potentially unsafe (catastrophic backtracking)', | ||
| } | ||
| } | ||
| const match = regex.test(inputStr) | ||
| if (match) { | ||
| return { passed: true } | ||
| } | ||
| return { passed: false, error: 'Input does not match regex pattern' } | ||
waleedlatif1 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.