Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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: 2 additions & 0 deletions src/python_inspector/package_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def get_pypi_data_from_purl(
)
)

valid_distribution_urls = [url for url in valid_distribution_urls if url]

# if prefer_source is True then only source distribution is used
# in case of no source distribution available then wheel is used
if not valid_distribution_urls or not prefer_source:
Expand Down
3 changes: 3 additions & 0 deletions src/python_inspector/utils_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ def get_python_dot_version(version):
"manylinux1_x86_64",
"manylinux2010_x86_64",
"manylinux2014_x86_64",
"manylinux2014_aarch6",
"musllinux_1_2_x86_64",
"manylinux_2_33_aarch64",
],
"macos": [
"macosx_10_6_intel",
Expand Down
10 changes: 5 additions & 5 deletions tests/data/azure-devops.req-310-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@
"subpath": null,
"primary_language": "Python",
"description": "cryptography is a package which provides cryptographic recipes and primitives to Python developers.\npyca/cryptography\n=================\n\n.. image:: https://img.shields.io/pypi/v/cryptography.svg\n :target: https://pypi.org/project/cryptography/\n :alt: Latest Version\n\n.. image:: https://readthedocs.org/projects/cryptography/badge/?version=latest\n :target: https://cryptography.io\n :alt: Latest Docs\n\n.. image:: https://github.com/pyca/cryptography/workflows/CI/badge.svg?branch=main\n :target: https://github.com/pyca/cryptography/actions?query=workflow%3ACI+branch%3Amain\n\n\n``cryptography`` is a package which provides cryptographic recipes and\nprimitives to Python developers. Our goal is for it to be your \"cryptographic\nstandard library\". It supports Python 3.7+ and PyPy3 7.3.11+.\n\n``cryptography`` includes both high level recipes and low level interfaces to\ncommon cryptographic algorithms such as symmetric ciphers, message digests, and\nkey derivation functions. For example, to encrypt something with\n``cryptography``'s high level symmetric encryption recipe:\n\n.. code-block:: pycon\n\n >>> from cryptography.fernet import Fernet\n >>> # Put this somewhere safe!\n >>> key = Fernet.generate_key()\n >>> f = Fernet(key)\n >>> token = f.encrypt(b\"A really secret message. Not for prying eyes.\")\n >>> token\n b'...'\n >>> f.decrypt(token)\n b'A really secret message. Not for prying eyes.'\n\nYou can find more information in the `documentation`_.\n\nYou can install ``cryptography`` with:\n\n.. code-block:: console\n\n $ pip install cryptography\n\nFor full details see `the installation documentation`_.\n\nDiscussion\n~~~~~~~~~~\n\nIf you run into bugs, you can file them in our `issue tracker`_.\n\nWe maintain a `cryptography-dev`_ mailing list for development discussion.\n\nYou can also join ``#pyca`` on ``irc.libera.chat`` to ask questions or get\ninvolved.\n\nSecurity\n~~~~~~~~\n\nNeed to report a security issue? Please consult our `security reporting`_\ndocumentation.\n\n\n.. _`documentation`: https://cryptography.io/\n.. _`the installation documentation`: https://cryptography.io/en/latest/installation/\n.. _`issue tracker`: https://github.com/pyca/cryptography/issues\n.. _`cryptography-dev`: https://mail.python.org/mailman/listinfo/cryptography-dev\n.. _`security reporting`: https://cryptography.io/en/latest/security/",
"release_date": "2025-03-02T00:00:42",
"release_date": "2025-03-02T00:00:28",
"parties": [
{
"type": "person",
Expand Down Expand Up @@ -1067,11 +1067,11 @@
"Topic :: Security :: Cryptography"
],
"homepage_url": null,
"download_url": "https://files.pythonhosted.org/packages/d7/fc/99fe639bcdf58561dfad1faa8a7369d1dc13f20acd78371bb97a01613585/cryptography-44.0.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"size": 4167812,
"download_url": "https://files.pythonhosted.org/packages/f3/cd/2558cc08f7b1bb40683f99ff4327f8dcfc7de3affc669e9065e14824511b/cryptography-44.0.2-cp37-abi3-musllinux_1_2_x86_64.whl",
"size": 4298367,
"sha1": null,
"md5": "c4d1bb9c2ff2e88d4c4bbfe67d92a008",
"sha256": "9a1e657c0f4ea2a23304ee3f964db058c9e9e635cc7019c4aa21c330755ef6fd",
"md5": "3d99f96dacf683212ee78a468b3ab242",
"sha256": "3b721b8b4d948b218c88cb8c45a01793483821e709afe5f622861fc6182b20a7",
"sha512": null,
"bug_tracking_url": null,
"code_view_url": null,
Expand Down
10 changes: 5 additions & 5 deletions tests/data/azure-devops.req-312-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@
"subpath": null,
"primary_language": "Python",
"description": "cryptography is a package which provides cryptographic recipes and primitives to Python developers.\npyca/cryptography\n=================\n\n.. image:: https://img.shields.io/pypi/v/cryptography.svg\n :target: https://pypi.org/project/cryptography/\n :alt: Latest Version\n\n.. image:: https://readthedocs.org/projects/cryptography/badge/?version=latest\n :target: https://cryptography.io\n :alt: Latest Docs\n\n.. image:: https://github.com/pyca/cryptography/workflows/CI/badge.svg?branch=main\n :target: https://github.com/pyca/cryptography/actions?query=workflow%3ACI+branch%3Amain\n\n\n``cryptography`` is a package which provides cryptographic recipes and\nprimitives to Python developers. Our goal is for it to be your \"cryptographic\nstandard library\". It supports Python 3.7+ and PyPy3 7.3.11+.\n\n``cryptography`` includes both high level recipes and low level interfaces to\ncommon cryptographic algorithms such as symmetric ciphers, message digests, and\nkey derivation functions. For example, to encrypt something with\n``cryptography``'s high level symmetric encryption recipe:\n\n.. code-block:: pycon\n\n >>> from cryptography.fernet import Fernet\n >>> # Put this somewhere safe!\n >>> key = Fernet.generate_key()\n >>> f = Fernet(key)\n >>> token = f.encrypt(b\"A really secret message. Not for prying eyes.\")\n >>> token\n b'...'\n >>> f.decrypt(token)\n b'A really secret message. Not for prying eyes.'\n\nYou can find more information in the `documentation`_.\n\nYou can install ``cryptography`` with:\n\n.. code-block:: console\n\n $ pip install cryptography\n\nFor full details see `the installation documentation`_.\n\nDiscussion\n~~~~~~~~~~\n\nIf you run into bugs, you can file them in our `issue tracker`_.\n\nWe maintain a `cryptography-dev`_ mailing list for development discussion.\n\nYou can also join ``#pyca`` on ``irc.libera.chat`` to ask questions or get\ninvolved.\n\nSecurity\n~~~~~~~~\n\nNeed to report a security issue? Please consult our `security reporting`_\ndocumentation.\n\n\n.. _`documentation`: https://cryptography.io/\n.. _`the installation documentation`: https://cryptography.io/en/latest/installation/\n.. _`issue tracker`: https://github.com/pyca/cryptography/issues\n.. _`cryptography-dev`: https://mail.python.org/mailman/listinfo/cryptography-dev\n.. _`security reporting`: https://cryptography.io/en/latest/security/",
"release_date": "2025-03-02T00:00:42",
"release_date": "2025-03-02T00:00:28",
"parties": [
{
"type": "person",
Expand Down Expand Up @@ -1067,11 +1067,11 @@
"Topic :: Security :: Cryptography"
],
"homepage_url": null,
"download_url": "https://files.pythonhosted.org/packages/d7/fc/99fe639bcdf58561dfad1faa8a7369d1dc13f20acd78371bb97a01613585/cryptography-44.0.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"size": 4167812,
"download_url": "https://files.pythonhosted.org/packages/f3/cd/2558cc08f7b1bb40683f99ff4327f8dcfc7de3affc669e9065e14824511b/cryptography-44.0.2-cp37-abi3-musllinux_1_2_x86_64.whl",
"size": 4298367,
"sha1": null,
"md5": "c4d1bb9c2ff2e88d4c4bbfe67d92a008",
"sha256": "9a1e657c0f4ea2a23304ee3f964db058c9e9e635cc7019c4aa21c330755ef6fd",
"md5": "3d99f96dacf683212ee78a468b3ab242",
"sha256": "3b721b8b4d948b218c88cb8c45a01793483821e709afe5f622861fc6182b20a7",
"sha512": null,
"bug_tracking_url": null,
"code_view_url": null,
Expand Down
20 changes: 10 additions & 10 deletions tests/data/azure-devops.req-313-expected.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions tests/data/azure-devops.req-38-expected.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tests/data/test-api-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
"subpath": null,
"primary_language": "Python",
"description": "Safely add untrusted strings to HTML/XML markup.\n# MarkupSafe\n\nMarkupSafe implements a text object that escapes characters so it is\nsafe to use in HTML and XML. Characters that have special meanings are\nreplaced so that they display as the actual characters. This mitigates\ninjection attacks, meaning untrusted user input can safely be displayed\non a page.\n\n\n## Examples\n\n```pycon\n>>> from markupsafe import Markup, escape\n\n>>> # escape replaces special characters and wraps in Markup\n>>> escape(\"<script>alert(document.cookie);</script>\")\nMarkup('&lt;script&gt;alert(document.cookie);&lt;/script&gt;')\n\n>>> # wrap in Markup to mark text \"safe\" and prevent escaping\n>>> Markup(\"<strong>Hello</strong>\")\nMarkup('<strong>hello</strong>')\n\n>>> escape(Markup(\"<strong>Hello</strong>\"))\nMarkup('<strong>hello</strong>')\n\n>>> # Markup is a str subclass\n>>> # methods and operators escape their arguments\n>>> template = Markup(\"Hello <em>{name}</em>\")\n>>> template.format(name='\"World\"')\nMarkup('Hello <em>&#34;World&#34;</em>')\n```\n\n## Donate\n\nThe Pallets organization develops and supports MarkupSafe and other\npopular packages. In order to grow the community of contributors and\nusers, and allow the maintainers to devote more time to the projects,\n[please donate today][].\n\n[please donate today]: https://palletsprojects.com/donate",
"release_date": "2024-10-18T15:20:55",
"release_date": "2024-10-18T15:20:59",
"parties": [
{
"type": "person",
Expand All @@ -495,11 +495,11 @@
"Typing :: Typed"
],
"homepage_url": null,
"download_url": "https://files.pythonhosted.org/packages/22/35/137da042dfb4720b638d2937c38a9c2df83fe32d20e8c8f3185dbfef05f7/MarkupSafe-3.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"size": 20866,
"download_url": "https://files.pythonhosted.org/packages/bd/6e/61ebf08d8940553afff20d1fb1ba7294b6f8d279df9fd0c0db911b4bbcfd/MarkupSafe-3.0.2-cp310-cp310-musllinux_1_2_x86_64.whl",
"size": 21091,
"sha1": null,
"md5": "6fb2985db3f3b1aec8d8615221fb91ea",
"sha256": "bbcb445fa71794da8f178f0f6d66789a28d7319071af7a496d4d507ed566270d",
"md5": "ef4de80fb119dfe436aa346068b6cbc8",
"sha256": "b424c77b206d63d500bcb69fa55ed8d0e6a3774056bdc4839fc9298a7edca171",
"sha512": null,
"bug_tracking_url": null,
"code_view_url": "https://github.com/pallets/markupsafe/",
Expand Down
10 changes: 5 additions & 5 deletions tests/data/test-api-pdt-expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
"subpath": null,
"primary_language": "Python",
"description": "Safely add untrusted strings to HTML/XML markup.\n# MarkupSafe\n\nMarkupSafe implements a text object that escapes characters so it is\nsafe to use in HTML and XML. Characters that have special meanings are\nreplaced so that they display as the actual characters. This mitigates\ninjection attacks, meaning untrusted user input can safely be displayed\non a page.\n\n\n## Examples\n\n```pycon\n>>> from markupsafe import Markup, escape\n\n>>> # escape replaces special characters and wraps in Markup\n>>> escape(\"<script>alert(document.cookie);</script>\")\nMarkup('&lt;script&gt;alert(document.cookie);&lt;/script&gt;')\n\n>>> # wrap in Markup to mark text \"safe\" and prevent escaping\n>>> Markup(\"<strong>Hello</strong>\")\nMarkup('<strong>hello</strong>')\n\n>>> escape(Markup(\"<strong>Hello</strong>\"))\nMarkup('<strong>hello</strong>')\n\n>>> # Markup is a str subclass\n>>> # methods and operators escape their arguments\n>>> template = Markup(\"Hello <em>{name}</em>\")\n>>> template.format(name='\"World\"')\nMarkup('Hello <em>&#34;World&#34;</em>')\n```\n\n## Donate\n\nThe Pallets organization develops and supports MarkupSafe and other\npopular packages. In order to grow the community of contributors and\nusers, and allow the maintainers to devote more time to the projects,\n[please donate today][].\n\n[please donate today]: https://palletsprojects.com/donate",
"release_date": "2024-10-18T15:20:55",
"release_date": "2024-10-18T15:20:59",
"parties": [
{
"type": "person",
Expand All @@ -495,11 +495,11 @@
"Typing :: Typed"
],
"homepage_url": null,
"download_url": "https://files.pythonhosted.org/packages/22/35/137da042dfb4720b638d2937c38a9c2df83fe32d20e8c8f3185dbfef05f7/MarkupSafe-3.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"size": 20866,
"download_url": "https://files.pythonhosted.org/packages/bd/6e/61ebf08d8940553afff20d1fb1ba7294b6f8d279df9fd0c0db911b4bbcfd/MarkupSafe-3.0.2-cp310-cp310-musllinux_1_2_x86_64.whl",
"size": 21091,
"sha1": null,
"md5": "6fb2985db3f3b1aec8d8615221fb91ea",
"sha256": "bbcb445fa71794da8f178f0f6d66789a28d7319071af7a496d4d507ed566270d",
"md5": "ef4de80fb119dfe436aa346068b6cbc8",
"sha256": "b424c77b206d63d500bcb69fa55ed8d0e6a3774056bdc4839fc9298a7edca171",
"sha512": null,
"bug_tracking_url": null,
"code_view_url": "https://github.com/pallets/markupsafe/",
Expand Down
67 changes: 67 additions & 0 deletions tests/data/test-api-with-lief-python-312.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"files": [],
"packages": [
{
"type": "pypi",
"namespace": null,
"name": "lief",
"version": "0.15.1",
"qualifiers": {},
"subpath": null,
"primary_language": "Python",
"description": "Library to instrument executable formats\nAbout\n=====\n\nThe purpose of this project is to provide a cross platform library that can parse, modify and\nabstract ELF, PE and MachO formats.\n\nMain features:\n\n * **Parsing**: LIEF can parse ELF, PE, MachO, OAT, DEX, VDEX, ART and provides an user-friendly API to access to format internals.\n * **Modify**: LIEF enables to modify some parts of these formats\n * **Abstract**: Three formats have common features like sections, symbols, entry point... LIEF factors them.\n * **API**: LIEF can be used in C, C++ and Python\n\n\nDownloads / Install\n===================\n\nFirst, make sure to have an updated version of setuptools:\n\n.. code-block:: console\n\n $ pip install setuptools --upgrade\n\nTo install the latest **version** (release):\n\n.. code-block:: console\n\n $ pip install lief\n\nTo install nightly build:\n\n.. code-block:: console\n\n $ pip install [--user] --index-url https://lief.s3-website.fr-par.scw.cloud/latest lief\n\n\nGetting started\n===============\n\nPython\n------\n\n.. code-block:: python\n\n import lief\n\n # ELF\n binary = lief.parse(\"/usr/bin/ls\")\n print(binary)\n\n # PE\n binary = lief.parse(\"C:\\\\Windows\\\\explorer.exe\")\n print(binary)\n\n # Mach-O\n binary = lief.parse(\"/usr/bin/ls\")\n print(binary)\n\nC++\n---\n\n.. code-block:: cpp\n\n #include <LIEF/LIEF.hpp>\n\n int main(int argc, char** argv) {\n // ELF\n try {\n std::unique_ptr<LIEF::ELF::Binary> elf = LIEF::ELF::Parser::parse(\"/bin/ls\");\n std::cout << *elf << '\\n';\n } catch (const LIEF::exception& err) {\n std::cerr << err.what() << '\\n';\n }\n\n // PE\n try {\n std::unique_ptr<LIEF::PE::Binary> pe = LIEF::PE::Parser::parse(\"C:\\\\Windows\\\\explorer.exe\");\n std::cout << *pe << '\\n';\n } catch (const LIEF::exception& err) {\n std::cerr << err.what() << '\\n';\n }\n\n // Mach-O\n try {\n std::unique_ptr<LIEF::MachO::FatBinary> macho = LIEF::MachO::Parser::parse(\"/bin/ls\");\n std::cout << *macho << '\\n';\n } catch (const LIEF::exception& err) {\n std::cerr << err.what() << '\\n';\n }\n\n return 0;\n }\n\nC (Limited API)\n----------------\n\n.. code-block:: cpp\n\n #include <LIEF/LIEF.h>\n\n int main(int argc, char** argv) {\n Elf_Binary_t* elf = elf_parse(\"/usr/bin/ls\");\n\n Elf_Section_t** sections = elf->sections;\n\n for (size_t i = 0; sections[i] != NULL; ++i) {\n printf(\"%s\\n\", sections[i]->name);\n }\n\n elf_binary_destroy(elf);\n return 0;\n }\n\nDocumentation\n=============\n\n* `Main documentation <https://lief-project.github.io/doc/latest/index.html>`_\n* `Tutorial <https://lief-project.github.io/doc/latest/tutorials/index.html>`_\n* `API <https://lief-project.github.io/doc/latest/api/index.html>`_\n* `Doxygen <https://lief-project.github.io/doc/latest/doxygen/index.html>`_\n\nContact\n=======\n\n* **Mail**: contact at lief.re\n* **Gitter**: `lief-project <https://gitter.im/lief-project>`_\n\n\nAuthors\n=======\n\nRomain Thomas `@rh0main <https://twitter.com/rh0main>`_ - `Quarkslab <https://www.quarkslab.com>`_\n\n----\n\nLIEF is provided under the `Apache 2.0 license <https://github.com/lief-project/LIEF/blob/0.12.3/LICENSE>`_",
"release_date": "2024-07-23T14:52:11",
"parties": [
{
"type": "person",
"role": "author",
"name": null,
"email": "Romain Thomas <[email protected]>",
"url": null
}
],
"keywords": [
"parser",
"elf",
"pe",
"macho",
"reverse-engineering",
"Development Status :: 4 - Beta",
"Programming Language :: C++",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries"
],
"homepage_url": "https://lief-project.github.io/",
"download_url": "https://files.pythonhosted.org/packages/bd/e8/398583add15a3a74207624be6a853a30a986252440f19b4052022cea911a/lief-0.15.1-cp312-cp312-musllinux_1_2_x86_64.whl",
"size": 2476427,
"sha1": null,
"md5": "0a223b5258a2a5a112b92af3f38cf9f2",
"sha256": "c2ec738bcafee8a569741f4a749f0596823b12f10713306c7d0cbbf85759f51c",
"sha512": null,
"bug_tracking_url": "https://github.com/lief-project/LIEF/issues",
"code_view_url": null,
"vcs_url": null,
"copyright": null,
"license_expression": null,
"declared_license": {
"license": "Apache License 2.0"
},
"notice_text": null,
"source_packages": [],
"file_references": [],
"extra_data": {},
"dependencies": [],
"repository_homepage_url": null,
"repository_download_url": null,
"api_data_url": "https://pypi.org/pypi/lief/0.15.1/json",
"datasource_id": null,
"purl": "pkg:pypi/[email protected]"
}
],
"resolution": [
{
"package": "pkg:pypi/[email protected]",
"dependencies": []
}
]
}
11 changes: 11 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ def test_api_with_python_311():
check_data_results(results=results.to_dict(generic_paths=True), expected_file=expected_file)


def test_api_with_lief_python_312():
expected_file = test_env.get_test_loc("test-api-with-lief-python-312.json", must_exist=False)
results = resolver_api(
specifiers=["lief==0.15.1"],
python_version="3.12",
operating_system="linux",
prefer_source=True,
)
check_data_results(results=results.to_dict(generic_paths=True), expected_file=expected_file)


def test_api_with_partial_setup_py():
expected_file = test_env.get_test_loc("test-api-with-partial-setup-py.json", must_exist=False)
results = resolver_api(
Expand Down
Loading