Skip to content

Commit aabf1ae

Browse files
committed
feat(ISV-5877): Implement uploading to TPA
Signed-off-by: Jan Koscielniak <jakoscie@redhat.com>
1 parent caee392 commit aabf1ae

14 files changed

Lines changed: 1118 additions & 59 deletions

File tree

docs/sboms/upload.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SBOM for Image Index
2+
3+
The Mobster tool is capable of uploading SBOMs to multiple locations.
4+
5+
## Red Hat Trusted Profile Analyzer (TPA)
6+
7+
To upload an SBOM to TPA, use the `mobster upload tpa` command. In order to authenticate to TPA,
8+
you need to set the following environment variables with OIDC, as in the example below
9+
10+
```
11+
MOBSTER_TPA_SSO_TOKEN_URL="https://example.com/auth/realms/ExampleRealm/protocol/openid-connect/token"
12+
MOBSTER_TPA_SSO_ACCOUNT=example-account
13+
MOBSTER_TPA_SSO_TOKEN=example-account-token
14+
```
15+
16+
After that you can either upload a single SBOM:
17+
```shell
18+
mobster upload tpa --tpa-base-url https://your-tpa-instance.com --file /path/to/your/sbom.json
19+
```
20+
21+
Or multiple SBOM files from a directory with an option to set a number of parallel workers:
22+
```shell
23+
mobster upload tpa --tpa-base-url https://your-tpa-instance.com --from-dir /path/to/sbom_directory --workers 4
24+
```

poetry.lock

Lines changed: 117 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ dependencies = [
3333
"pydantic (>=2.11.4,<3.0.0)",
3434
"python-dateutil (>=2.9.0.post0,<3.0.0)",
3535
"packageurl-python (>=0.16.0,<0.17.0)",
36-
"aiofiles (>=24.1.0,<25.0.0)"
36+
"aiofiles (>=24.1.0,<25.0.0)",
37+
"httpx (>=0.28.1,<0.29.0)"
3738
]
3839

3940
[project.urls]
@@ -85,6 +86,7 @@ pylint = "^3.3.7"
8586
pytest-asyncio = "^1.0.0"
8687
types-python-dateutil = "^2.9.0.20241206"
8788
types-aiofiles = "^24.1.0.20250516"
89+
pytest-httpx = "^0.35.0"
8890

8991
[build-system]
9092
requires = ["poetry-core>=2.0.0,<3.0.0"]

src/mobster/cli.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
from pathlib import Path
55
from typing import Any
66

7-
from mobster.cmd import augment, upload
7+
from mobster.cmd import augment
88
from mobster.cmd.generate import modelcar, oci_artifact, oci_image, oci_index, product
9+
from mobster.cmd.upload import upload
910

1011

1112
def setup_arg_parser() -> argparse.ArgumentParser:
@@ -302,7 +303,10 @@ def upload_tpa_parser(subparsers: Any) -> None:
302303
default=1,
303304
help="Number of workers to execute uploads in parallel",
304305
)
305-
tpa_parser.add_argument("--from-dir", type=Path, help="Directory to upload from")
306-
tpa_parser.add_argument("--file", type=Path, help="File to upload")
306+
307+
# Create a mutually exclusive group and require one of the arguments
308+
source_group = tpa_parser.add_mutually_exclusive_group(required=True)
309+
source_group.add_argument("--from-dir", type=Path, help="Directory to upload from")
310+
source_group.add_argument("--file", type=Path, help="File to upload")
307311

308312
tpa_parser.set_defaults(func=upload.TPAUploadCommand)

src/mobster/cmd/upload.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/mobster/cmd/upload/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Upload module for the Mobster application."""

0 commit comments

Comments
 (0)