Skip to main content

code-provenance

Resolve Docker images in a docker-compose file to their exact source code commits on GitHub.

Installation

pip install code-provenance

Requires Python 3.10+.

CLI Usage

code-provenance [machine-url] [--workload FILE] [--image IMAGE] [--json] [--verbose]
  • machine-url -- SecretVM machine URL or hostname (e.g. secretai-jedi.scrtlabs.com); the docker-compose is fetched from it over port 29343, falling back to 21434 for GPU machines
  • --workload FILE -- resolve a local docker-compose file instead of a machine URL
  • --image IMAGE -- resolve a single image reference
  • --secretvm URL -- SecretVM machine URL (same as passing it positionally; kept for backward compatibility)
  • --json -- output results as JSON
  • --verbose, -v -- show resolution steps for each image

Examples

Resolve all images running on a SecretVM machine (default mode):

code-provenance secretai-jedi.scrtlabs.com

Resolve all images in a local docker-compose file:

code-provenance --workload docker-compose.yml
web: traefik:v3.6.0
  repo:       github.com/traefik/traefik
  commit:     06db5168c0d9
  status:     resolved
  confidence: exact
  url:        https://github.com/traefik/traefik/commit/06db5168c0d9...

Resolve a single image:

code-provenance --image ollama/ollama:0.12.3
image: ollama/ollama:0.12.3
  repo:       github.com/ollama/ollama
  commit:     b04e46da3ebc
  status:     resolved
  confidence: exact
  url:        https://github.com/ollama/ollama/commit/b04e46da3ebc...

Library Usage

from code_provenance.compose_parser import parse_compose, parse_image_ref
from code_provenance.resolver import resolve_image

yaml_content = open("docker-compose.yml").read()
for service, image in parse_compose(yaml_content):
    ref = parse_image_ref(image)
    result = resolve_image(service, ref)
    print(f"{result.service}: {result.commit} ({result.confidence})")

API Reference

Functions

  • parse_compose(yaml_content: str) -> list[tuple[str, str]] -- parse a docker-compose YAML string and return (service_name, image_string) pairs
  • parse_image_ref(image: str) -> ImageRef -- parse a Docker image string into its components
  • resolve_image(service: str, ref: ImageRef) -> ImageResult -- resolve an image reference to its source code commit

ImageRef

Field Type Description
registry str e.g. "ghcr.io", "docker.io"
namespace str e.g. "myorg", "library"
name str e.g. "traefik", "postgres"
tag str e.g. "v3.6.0", "latest"
raw str original image string from docker-compose

ImageResult

Field Type Description
service str service name from docker-compose
image str original image string
registry str image registry
repo str | None GitHub repository URL
tag str image tag
commit str | None resolved commit SHA
commit_url str | None URL to the commit on GitHub
status str "resolved", "repo_not_found", "repo_found_tag_not_matched", or "no_tag"
resolution_method str | None how the commit was resolved (e.g. "oci_labels", "tag_match")
confidence str | None "exact" or "approximate"
steps list[str] resolution steps taken (useful with --verbose)

Authentication

Set GITHUB_TOKEN for full functionality (digest resolution, :latest on GHCR, higher rate limits):

export GITHUB_TOKEN=ghp_your_token_here

Create a classic token at https://github.com/settings/tokens with read:packages scope. If using the gh CLI, run gh auth refresh -h github.com -s read:packages first.

The run.sh wrapper auto-detects the token from gh CLI if available.

License

MIT

Metadata

Release files for code-provenance 0.1.14

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

Source distribution (sdist)

Source distribution for code-provenance 0.1.14
File Size Uploaded
code_provenance-0.1.14.tar.gz 20.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for code-provenance 0.1.14
File Interpreter ABI Platform
code_provenance-0.1.14-py3-none-any.whl Python 3 none any Details

Total release size: 35.9 kB

Release files / code_provenance-0.1.14.tar.gz

Download URL code_provenance-0.1.14.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
90b27da085c82d9170ee3d83da1d9cd786af688b6cdbbfbe9879bc10c42f41c0
BLAKE2b-256 checksum
How to use checksums
18abd16a37619daddb381d8bc3f12fb0daec0fc29923b22937e546388f888db3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / code_provenance-0.1.14-py3-none-any.whl

Download URL code_provenance-0.1.14-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9fdcefc47ea19239a52f75312c8cc33dafb9ddc88a0834444f1d1c67b95475e
BLAKE2b-256 checksum
How to use checksums
278c38ee85b69f395d9e011898028e16f494b2ebf03b2a5e951c062342ed7bfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.1.14 This release

2 release files

0.1.13

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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