Skip to main content

Poetry dependencies scanner & gitlab commenter

This project consists of two scripts.

One analyses the poetry.lock and pyproject.toml files it receives and produces an output listing the outdated packages.

The other takes an input and posts it as a comment on a Gitlab merge request.

Here's how we use them:

# .gitlab-ci.yml

scan-deps:
  stage: test
  image: deps-scanner
  allow_failure: true
  script:
    - scan-deps poetry.lock pyproject.toml | comment-gitlab
  only:
    - merge_requests

The deps-scanner image is built from the Dockerfile in this repository.

Here's an example of what the output looks like in a merge request for this repository:

Comment screenshot

Installation

python -m pip install poetry-deps-scanner

Dependencies analysis

The following snippet is an example output the first script may produce:

 Name        │ Type   │ Source        │ Message
─────────────┼────────┼───────────────┼───────────────────────────────────────
 command-log │ direct │ xxxxx.itsf.io │ current=1.0.0 -> latest=2.0.0
 coverage    │ direct │ pypi.org      │ current=6.3.2 -> latest=6.4.1
 asgiref     │ trans. │ pypi.org      │ current=3.5.1 -> latest=3.5.2
 grpclib     │ trans. │ github.com    │ Couldn't compare versions.
 requests    │ error  │               │ ValueError (Hello world)

The Type column indicates whether the package is a direct or transitive dependency, or if there has been an uncaught exception:

  • direct means the package is a direct dependency.
  • trans. means the package is a transitive dependency: the dependency of a direct dependency or of a transitive dependency.
  • error means there has been an uncaught error. The exception class and message are displayed in the Message column

This is computed by using the pyproject.toml if given. If this file is not provided on the command line, the column will be empty.

A dependency is considered direct if it is present in the pyproject.toml.

Gitlab comment

The comment_gitlab.py script requires some environment variables to properly work:

  • BOT_USERNAME: The username for the bot user
  • BOT_TOKEN: A Gitlab access token for the bot user (see https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html)
  • CI_SERVER_URL: The URL of the Gitlab instance where to post
  • CI_PROJECT_ID: The ID of the project containing the MR to post on
  • CI_MERGE_REQUEST_IID: The IID of the merge request to comment on

The last three variables are automatically populated by Gitlab CI when running a job as part of a detached pipeline (for a merge request). Notice the only: [merge_requests] in the .gitlab-ci.yml above.

Of course, you can also provide them manually to integrate with any other build system.

If a comment from the bot user already exists, it will be replaced, in order to reduce the noise. In other words, there will be at most one comment from the bot on a given merge request. It will contain the results of the latest check.

Build the docker image outside ITSF

The Dockerfile inside the repository references images from our internal Docker registry proxy. You can easily build it on your own by removing the nexus.itsf.io:5005/ prefix.

# on Ubuntu
sed -i 's/nexus.itsf.io:5005\///g' Dockerfile
# on macOS
sed -e 's/nexus.itsf.io:5005\///g' -i "" Dockerfile
# then
docker build -t deps-scanner .

Metadata

Release files for poetry-deps-scanner 2.0.0.post2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for poetry-deps-scanner 2.0.0.post2
File Size Uploaded Provenance
poetry-deps-scanner-2.0.0.post2.tar.gz 6.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for poetry-deps-scanner 2.0.0.post2
File Interpreter ABI Platform
poetry_deps_scanner-2.0.0.post2-py3-none-any.whl Python 3 none any Details

Total release size: 13.8 kB

Release files / poetry-deps-scanner-2.0.0.post2.tar.gz

Download URL poetry-deps-scanner-2.0.0.post2.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5f490a83d16b9207bba265c47bd772f2fb19be916c2a634ef390c23ac8012124
BLAKE2b-256 checksum
How to use checksums
57c39a82479232e8eca311dfb8a78f4d86e9d1dcd18de08ebaa864d98e4f32a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.4 Darwin/21.5.0

Release files / poetry_deps_scanner-2.0.0.post2-py3-none-any.whl

Download URL poetry_deps_scanner-2.0.0.post2-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
612739f2b692bbbbf9f7944a3ecfc56bb077066550c6d8d7b4cd48745050f62a
BLAKE2b-256 checksum
How to use checksums
7c14f2e32362d867f91fed6e8a6476e81617c44d26b2e5450b1cc4e4e810287c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.10.4 Darwin/21.5.0

Security for poetry-deps-scanner 2.0.0.post2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page