-
Notifications
You must be signed in to change notification settings - Fork 239
Improve S2068 performance: Reuse compiled Regex #8185
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
Improve S2068 performance: Reuse compiled Regex #8185
Conversation
|
Kudos, SonarCloud Quality Gate passed! |
|
SonarCloud Quality Gate failed.
|
| private const string MessageUriUserInfo = "Review this hard-coded URI, which may contain a credential."; | ||
| private const string DefaultCredentialWords = "password, passwd, pwd, passphrase"; | ||
| private static readonly ConcurrentDictionary<string, Regex> PasswordValuePattern = new(); | ||
| protected static readonly Regex ValidCredentialPattern = new(@"^(\?|:\w+|\{\d+[^}]*\}|""|')$", RegexOptions.IgnoreCase | RegexOptions.Compiled); |
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.
I've opened #8314 to deal with the timeouts. It should be a small easy change.
analyzers/src/SonarAnalyzer.Common/Rules/Hotspots/DoNotHardcodeCredentialsBase.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.Common/Rules/Hotspots/DoNotHardcodeCredentialsBase.cs
Outdated
Show resolved
Hide resolved
sebastien-marichal
left a comment
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.
LGTM!
pavel-mikula-sonarsource
left a comment
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.
We can remove the concurrent dictionary
pavel-mikula-sonarsource
left a comment
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.
LGTM. I'll let you deal with the hotspots before merging (I'm not sure what the correct resolution for hotspots is in the new CaYC QG)
analyzers/src/SonarAnalyzer.Common/Rules/Hotspots/DoNotHardcodeCredentialsBase.cs
Outdated
Show resolved
Hide resolved
…eCredentialsBase.cs Co-authored-by: Pavel Mikula <57188685+pavel-mikula-sonarsource@users.noreply.github.com>
|
Kudos, SonarCloud Quality Gate passed! |
|
Kudos, SonarCloud Quality Gate passed! |














see also #8181 and #8183
Before:

After:
