Skip to content

FEATURE: Support for requirements.txt files with hashes #8

Closed

Description

@madpah

Taken from CycloneDX/cyclonedx-python#194.

This library currently supports requirements.txt files according to PEP-508 specification.

PEP-508 does not cater for cryptographic hashes being included in requirements.txt files.

However, since version 8.0 of pip, hashes and checking of hashes during dependency installation has been possible - see here.

Activity

  1. added
    enhancement
    on Sep 16, 2021
  2. added a commit that references this issue on Sep 17, 2021
  3. madpah commented on Sep 17, 2021

    @madpah
    CollaboratorAuthor

    References:

    • PEP-440 has references to hashes for local and remote package definitions

    Support for parsing a requirement with hashes using pkg_resources.parse_requirements() appears to be limited particularly when the requirement spans more than 2 lines (i.e. more than one continuation \).

    Additional tests added ti demonstrate the current limitations with requirements.txt parsing.

    Further investigation required as it's not clear that --hashes is officially part of the Python standard at this time.

  4. sbs2001 commented on Nov 16, 2021

    @sbs2001

    @madpah looks like --hash is supported but it seems to be only a pip feature pypa/packaging#488 . See https://github.com/pypa/pip/blob/main/docs/html/reference/requirements-file-format.md#per-requirement-options and there's multiple references to it in pip to handle it https://github.com/pypa/pip/search?q=%22--hash%22 .

    So I can think of two ways to handle this:

    1. Make a PR to Can not parse --hash=sha256: ... madpah/requirements-parser#51 to fix this. But the lib doesn't seem to be maintained so maybe fork it.
      Or
    2. Borrow code from pip to handle this.
  5. jkowalleck commented on Jan 8, 2022

    @jkowalleck
    Member

    yet another point of view: CycloneDX/cyclonedx-python#194 (comment)

  6. jkowalleck commented on Feb 27, 2022

    @jkowalleck
    Member

    see CycloneDX/cyclonedx-python#319
    for discussion.

  7. mostafa commented on Mar 17, 2022

    @mostafa

    @madpah @jkowalleck I think this can be closed because of CycloneDX/cyclonedx-python#327.

  8. madpah commented on Apr 20, 2022

    @madpah
    CollaboratorAuthor

    Agree @mostafa - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions