FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/javascript/ql/src/Performance/ReDoS.qhelp at codeql-cli-2.19.2 · github/codeql · GitHub
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10.1k
Code
Issues
1k
Pull requests
470
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
javascript
/
ql
/
src
/
Performance
/
ReDoS.qhelp
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (27 loc) · 1020 Bytes
Breadcrumbs
codeql
/
javascript
/
ql
/
src
/
Performance
/
ReDoS.qhelp
Copy path
File metadata and controls
32 lines (27 loc) · 1020 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!
DOCTYPE
qhelp
PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<
qhelp
>
<
include
src
=
"
ReDoSIntroduction.inc.qhelp
"
/>
<
example
>
<
p
>
Consider this regular expression:
</
p
>
<
sample
language
=
"
javascript
"
>
/^_(__|.)+_$/</
sample
>
<
p
>
Its sub-expression <
code
>"(__|.)+?"</
code
> can match the string <
code
>"__"</
code
> either by the
first alternative <
code
>"__"</
code
> to the left of the <
code
>"|"</
code
> operator, or by two
repetitions of the second alternative <
code
>"."</
code
> to the right. Thus, a string consisting
of an odd number of underscores followed by some other character will cause the regular
expression engine to run for an exponential amount of time before rejecting the input.
</
p
>
<
p
>
This problem can be avoided by rewriting the regular expression to remove the ambiguity between
the two branches of the alternative inside the repetition:
</
p
>
<
sample
language
=
"
javascript
"
>
/^_(__|[^_])+_$/</
sample
>
</
example
>
<
include
src
=
"
ReDoSReferences.inc.qhelp
"
/>
</
qhelp
>
Back
|
FazBrowse Home
|
New Git URL