Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion TestSonarQube/CustomerLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file added test.txt
Empty file.