Skip to content
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

S2068: Support colon in uri password #6199

Merged
merged 2 commits into from
Oct 12, 2022

Conversation

pavel-mikula-sonarsource
Copy link
Contributor

https://www.rfc-editor.org/rfc/rfc3986#section-3.2.1 defines userInfo as

userinfo    = *( unreserved / pct-encoded / sub-delims / ":" )

therefore : is valid part of the password

var uri = "scheme://user:Pa$$word:With:Colons@domain.com";            // Noncompliant

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. There is a typo and the additionalCharacters parameter should be made optional.

Comment on lines 83 to 91
var loginGroup = CreateUserInfoGroup("Login", null);
var passwordGroup = CreateUserInfoGroup("Password", ":"); // Additional ":" to capture passwords containing it
uriUserInfoPattern = new Regex(@$"\w+:\/\/{loginGroup}:{passwordGroup}@", RegexOptions.Compiled);
this.configuration = configuration;
rule = Language.CreateDescriptor(DiagnosticId, MessageFormat);
CredentialWords = DefaultCredentialWords; // Property will initialize multiple state variables

static string CreateUserInfoGroup(string name, string additionalCharacterss) =>
$@"(?<{name}>[\w\d{Regex.Escape(UriPasswordSpecialCharacters)}{additionalCharacterss}]+)";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo and small improvement

Suggested change
var loginGroup = CreateUserInfoGroup("Login", null);
var passwordGroup = CreateUserInfoGroup("Password", ":"); // Additional ":" to capture passwords containing it
uriUserInfoPattern = new Regex(@$"\w+:\/\/{loginGroup}:{passwordGroup}@", RegexOptions.Compiled);
this.configuration = configuration;
rule = Language.CreateDescriptor(DiagnosticId, MessageFormat);
CredentialWords = DefaultCredentialWords; // Property will initialize multiple state variables
static string CreateUserInfoGroup(string name, string additionalCharacterss) =>
$@"(?<{name}>[\w\d{Regex.Escape(UriPasswordSpecialCharacters)}{additionalCharacterss}]+)";
var loginGroup = CreateUserInfoGroup("Login");
var passwordGroup = CreateUserInfoGroup("Password", ":"); // Additional ":" to capture passwords containing it
uriUserInfoPattern = new Regex(@$"\w+:\/\/{loginGroup}:{passwordGroup}@", RegexOptions.Compiled);
this.configuration = configuration;
rule = Language.CreateDescriptor(DiagnosticId, MessageFormat);
CredentialWords = DefaultCredentialWords; // Property will initialize multiple state variables
static string CreateUserInfoGroup(string name, string additionalCharacters = null) =>
$@"(?<{name}>[\w\d{Regex.Escape(UriPasswordSpecialCharacters)}{additionalCharacters}]+)";

Best Kanban automation moved this from Review in progress to Review approved Oct 12, 2022
@sonarcloud
Copy link

sonarcloud bot commented Oct 12, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Oct 12, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@pavel-mikula-sonarsource pavel-mikula-sonarsource merged commit 0c5c62c into master Oct 12, 2022
Best Kanban automation moved this from Review approved to Validate Peach Oct 12, 2022
@pavel-mikula-sonarsource pavel-mikula-sonarsource deleted the Pavel/S2068-password branch October 12, 2022 11:13
@pavel-mikula-sonarsource pavel-mikula-sonarsource moved this from Validate Peach to Done in Best Kanban Oct 14, 2022
@martin-strecker-sonarsource martin-strecker-sonarsource added this to the 8.47 milestone Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Best Kanban
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants