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

do case-insensitive comparison for lead_security_dependency experiment #10861

Merged
merged 2 commits into from
Oct 31, 2024

Conversation

brettfo
Copy link
Contributor

@brettfo brettfo commented Oct 28, 2024

The lead_security_dependency experiment is downcasing only one half of the dependency name comparison resulting in closed PRs in an ecosystem where the current packages are reported with some upper case characters, e.g., NuGet reporting System.Text.Json and that string not matching system.text.json. The result is that the comparison on line 155 is returning false: dep.name.downcase == lead_dep_name where lead_dep_name comes from security_advisory_dependency. The NuGet example then expands to "system.text.json" == "System.Text.Json" # => false.

The fix is to restore the call to .downcase that is present when the experiment isn't enabled.

@brettfo brettfo requested a review from a team as a code owner October 28, 2024 22:44
Copy link
Member

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

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

This seems like an ideal case for a unit test? If one previously existed it would have caught this regression...

@brettfo
Copy link
Contributor Author

brettfo commented Oct 30, 2024

@jeffwidman I've pushed a commit with a unit test. I first verified that the test failed without the .downcase call and then passed with it.

Copy link
Member

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for double-checking before/after too. 👍

@sachin-sandhu sachin-sandhu merged commit 1175b5a into main Oct 31, 2024
123 checks passed
@sachin-sandhu sachin-sandhu deleted the dev/brettfo/downcase-dep-name branch October 31, 2024 15:57
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.

4 participants