-
Notifications
You must be signed in to change notification settings - Fork 231
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
Improve S2068 performance: Reuse compiled Regex #8185
Conversation
Kudos, SonarCloud Quality Gate passed! |
SonarCloud Quality Gate failed.
|
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
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!
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
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:
![image](https://private-user-images.githubusercontent.com/103252490/274387115-28cd0253-1303-4d9c-b614-a130b4ab3a3d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5Mjc4MzIsIm5iZiI6MTczODkyNzUzMiwicGF0aCI6Ii8xMDMyNTI0OTAvMjc0Mzg3MTE1LTI4Y2QwMjUzLTEzMDMtNGQ5Yy1iNjE0LWExMzBiNGFiM2EzZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QxMTI1MzJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kM2RiODY0NTg1ZTVjOGNhZWQ4YmNkN2M2YWRkMjQxN2RhMGZjMGYxNTUxYjVjMTk5MmYzNmZiOGQxYjJkNjkwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.Lw4YbWHpLGJxwFPehS67GAW001redL6jYv4nGp8zKiA)
After:
![image](https://private-user-images.githubusercontent.com/103252490/274387410-8254d8fc-e0ec-4d15-95a6-89fbe50c3259.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5Mjc4MzIsIm5iZiI6MTczODkyNzUzMiwicGF0aCI6Ii8xMDMyNTI0OTAvMjc0Mzg3NDEwLTgyNTRkOGZjLWUwZWMtNGQxNS05NWE2LTg5ZmJlNTBjMzI1OS5wbmc_WC1B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