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

fix: added correct verification endpoint & validation logic for alegra #3437

Merged
Merged
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion pkg/detectors/alegra/alegra.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
}

if verify {
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.alegra.com/api/v1/users", nil)
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.alegra.com/api/v1/users/self", nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

I created an account on Alegra and generated a token. Initially, I tested the /users API endpoint using an API client, and it worked as expected, returning the same response as /users/self. However, the Alegra documentation only mentions the /users/self endpoint, and there’s no reference to /users, so I'm unsure why it’s functioning similarly.

Additionally, I noticed an issue with the detector failing to identify my user ID, which I believe is always the email used during signup. The regex used for detecting IDs has a length constraint of 25 to 30 characters. However, I was able to create an account with an email shorter than this limit, and despite using that email (as my username) along with my token to successfully call the API via the API client, the detector did not pick it up.

I suggest testing and adjusting the regex for detecting user IDs to ensure it covers valid email lengths.

As for the API behavior, I’ll leave that to @zricethezav and @abmussani. Both /users and /users/self worked for me, though only the /users/self endpoint is mentioned in the documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the detailed review, @kashifkhan0771 !

I have expanded the email regex to include all case for any possible email.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would feel more confident approving this if you could also test the current email regex to confirm that it isn't working correctly(I tested it but a second round of testing from the PR owner will be good I believe. You can create an account and test this email regex change). A screenshot or any form of documentation from your testing would be sufficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added the testing screenshot, please check

Copy link
Contributor

Choose a reason for hiding this comment

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

New Changes are picking up the key and ID correctly now and verifying. Wait for @zricethezav and @abmussani to respond about the API change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you apply the label for Hacktoberfest @kashifkhan0771?

Copy link
Contributor

Choose a reason for hiding this comment

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

Once the PR is approved. We can add it 😃 - Once again thanks for the all the fixes and contributions!

if err != nil {
continue
}
Expand Down