Skip to content

Adding CratesApiKey validator#531

Merged
eddynaka merged 2 commits into
mainfrom
users/ednakamu/crates-validator
Aug 11, 2021
Merged

Adding CratesApiKey validator#531
eddynaka merged 2 commits into
mainfrom
users/ednakamu/crates-validator

Conversation

@eddynaka

Copy link
Copy Markdown
Collaborator

Fixes #529

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

@michaelcfanning michaelcfanning Aug 10, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
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,

@michaelcfanning michaelcfanning Aug 10, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed.

$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]|$)

@michaelcfanning michaelcfanning Aug 10, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
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()

@michaelcfanning michaelcfanning Aug 10, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
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