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

cyclonedx-py fails with poetry v1.3 due to new v2 lock format #467

Closed
tewfik-ghariani opened this issue Dec 12, 2022 · 3 comments · Fixed by #469
Closed

cyclonedx-py fails with poetry v1.3 due to new v2 lock format #467

tewfik-ghariani opened this issue Dec 12, 2022 · 3 comments · Fixed by #469
Labels
enhancement New feature or request source: poetry

Comments

@tewfik-ghariani
Copy link
Contributor

Starting poetry v1.3, the lock file format has changed essentially in the part of specifying the files/hashes per package instead of a dedicated metadata.files

lock v1

Screenshot 2022-12-12 at 19 06 00

lock v2

Screenshot 2022-12-12 at 19 09 15

Refs: python-poetry/poetry#6393

As a result, the cyclonedx-py tool is no longer able to generate the bom file because it cannot parse the new format

$ cyclonedx-py --poetry -o target/bom.xml
Traceback (most recent call last):
  File "/usr/local/bin/cyclonedx-py", line 8, in <module>
    sys.exit(main())
  File "/usr/local/libexec/cyclonedx-bom/lib/python3.9/site-packages/cyclonedx_py/client.py", line 307, in main
    CycloneDxCmd(args).execute()
  File "/usr/local/libexec/cyclonedx-bom/lib/python3.9/site-packages/cyclonedx_py/client.py", line 147, in execute
    output = self.get_output()
  File "/usr/local/libexec/cyclonedx-bom/lib/python3.9/site-packages/cyclonedx_py/client.py", line 84, in get_output
    parser = self._get_input_parser()
  File "/usr/local/libexec/cyclonedx-bom/lib/python3.9/site-packages/cyclonedx_py/client.py", line [295](https://git.mam.dev/acdc/gocd/pipeline-templates/-/jobs/9232334#L295), in _get_input_parser
    return PoetryParser(poetry_lock_contents=input_data,
  File "/usr/local/libexec/cyclonedx-bom/lib/python3.9/site-packages/cyclonedx_py/parser/poetry.py", line 44, in __init__
    for file_metadata in poetry_lock['metadata']['files'][package['name']]:
KeyError: 'files'
@jkowalleck
Copy link
Member

thanks for the report and the RP #468.
I will look into it ASAP.

@jkowalleck
Copy link
Member

should be fixed via 3.10.0.

could you test and confirm, @tewfik-ghariani ?

@tewfik-ghariani
Copy link
Contributor Author

@jkowalleck Works like a charm, thanks a lot! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request source: poetry
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants