diff --git a/TestSonarQube/CustomerLogic.cs b/TestSonarQube/CustomerLogic.cs index 16adf26..945ae43 100644 --- a/TestSonarQube/CustomerLogic.cs +++ b/TestSonarQube/CustomerLogic.cs @@ -147,7 +147,22 @@ public string Hash(string password) } - public string Hash2(string password) + public string Hash2f(string password) + { + var salt = Encoding.UTF8.GetBytes("Hardcoded salt"); + var fromHardcoded = new Rfc2898DeriveBytes(password, salt); // Noncompliant, salt is hardcoded + + salt = Encoding.UTF8.GetBytes(password); + var fromPassword = new Rfc2898DeriveBytes(password, salt); // Noncompliant, password should not be used as a salt as it makes it predictable + + var shortSalt = new byte[8]; + RandomNumberGenerator.Create().GetBytes(shortSalt); + var fromShort = new Rfc2898DeriveBytes(password, shortSalt); // Noncompliant, salt is too short (should be at least 16 bytes, not 8) + + return fromShort.ToString(); + } + + public string Hash2fff(string password) { var salt = Encoding.UTF8.GetBytes("Hardcoded salt"); var fromHardcoded = new Rfc2898DeriveBytes(password, salt); // Noncompliant, salt is hardcoded diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..e69de29