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

Adding CratesApiKey validator #531

Merged
merged 2 commits into from
Aug 11, 2021
Merged

Conversation

eddynaka
Copy link
Collaborator

Fixes #529

[Fact]
public void CratesApiKeyValidator_Test()
{
string fingerprintText = "";
Copy link
Member

@michaelcfanning michaelcfanning Aug 10, 2021

Choose a reason for hiding this comment

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

""

use string.Empty for this pattern, just a style nit. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i just removed this test

var fingerprint = new Fingerprint(fingerprintText);
var keyValuePairs = new Dictionary<string, string>();

CratesApiKeyValidator.IsValidDynamic(ref fingerprint,
Copy link
Member

@michaelcfanning michaelcfanning Aug 10, 2021

Choose a reason for hiding this comment

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

IsValidDynamic

What is this test validating? Just that we don't raise an exception? Can't we at least validate return value or some other output? #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed.

@@ -129,4 +129,5 @@
$SEC101/044.NpmCredentialsUserPassword=(?is)(?:(?:(?:registry\s*=\s*https:\/\/(?P<host>[^\s]+)(?:$|\s))|(?:username\s*=\s*(?P<id>[^\s]+)(?:$|\s))|(?:_password\s*=\s*(?P<secret>[^\s]+)(?:$|\s)))(?:.{0,200})?){3}
$SEC101/044.NpmCredentialsPassword=(?is)(?:(?:(?:registry\s*=\s*https:\/\/(?P<host>[^\s]+)(?:$|\s))|(?:_password\s*=\s*(?P<secret>[^\s]+)(?:$|\s)))(?:.{0,200})?){2}
$SEC101/045.PostmanApiKey=\b(?P<secret>PMAK-[0-9a-z]{24}-[0-9a-z]{34})(?:[^0-9a-z]|$)
$SEC101/047.CratesApiKey=(?i)(?:[^c]|^)(?P<secret>cio[0-9a-z]{32})(?:[^0-9a-z]|$)
Copy link
Member

@michaelcfanning michaelcfanning Aug 10, 2021

Choose a reason for hiding this comment

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

(?:[^c]|^)

we should push this pattern everywhere. in many other places we use '\b' here instead. Can we scrub for that? #WontFix

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will make a new pr with this change :)

public class CratesApiKeyValidatorTests
{
[Fact]
public void DiscordCredentialsValidator_MockHttpTests()
Copy link
Member

@michaelcfanning michaelcfanning Aug 10, 2021

Choose a reason for hiding this comment

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

DiscordCredentialsValidator_MockHttpTests

Why did you remove that other test? It was a good one. #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It wasn't testing anything.
It was a blank test when I want to test a specific fingerprint.

@eddynaka eddynaka merged commit a8fb06e into main Aug 11, 2021
@eddynaka eddynaka deleted the users/ednakamu/crates-validator branch August 11, 2021 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create rule for https://crates.io/
2 participants