fix(pypi): return yank reason from SimpleAPI HTML#3656
fix(pypi): return yank reason from SimpleAPI HTML#3656aignas wants to merge 1 commit intobazel-contrib:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the PyPI Simple API HTML parser to accurately process package metadata, particularly addressing the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the Simple API HTML parser to correctly handle yanked packages and their reasons. However, a critical security vulnerability has been identified: the new custom HTML attribute parser fails to detect the data-yanked attribute when it is present without an explicit value. This flaw leads to a security regression, as yanked packages (often due to critical bugs or security vulnerabilities) are not recognized, potentially allowing Bazel to download and use compromised versions. Additionally, the _parse_attrs function has significant issues with its loop construct and general handling of valueless attributes, which could lead to incorrect behavior. The attribute parser must be updated to correctly handle boolean attributes and ensure data-yanked always signals a yanked status.
9ad8c68 to
76f521a
Compare
This makes the logic in the parser a little bit more sophisticated, but we also start handling the yank reason. This fixes the issue where the `data-yank` presence but no value would be interpreted as a yanked package. With this it should start working. This implementation assumes that we have HTML escaped sequences as tag values. It also unescapes them when returning the strings. The posibilities that it gives us are: - Use the `data-requires-python` to potentially discard any Python packages that are unsupported in the `select_whl` function. Work towards bazel-contrib#260. Work towards bazel-contrib#2731.
596f607 to
1c73fed
Compare
This makes the logic in the parser a little bit more sophisticated, but
we also start handling the yank reason. With this the yank reason will
be present in the logs, which should be a usability improvement.
The
yankedattribute will be None if the package is not yanked and astring value if it is yanked. An empty string value should be treated
as "yanked with no reason provided".
This implementation assumes that we have HTML escaped sequences as tag
values. It also un-escapes them when returning the strings.
The possibilities that it gives us are, but out of scope for this PR:
data-requires-pythonto potentially discard any Pythonpackages that are unsupported in the
select_whlfunction.Work towards #260.
Work towards #2731.