libtea 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {libtea-0.2.0 → libtea-0.3.0}/PKG-INFO +94 -10
- {libtea-0.2.0 → libtea-0.3.0}/README.md +93 -9
- {libtea-0.2.0 → libtea-0.3.0}/docs/cli.md +24 -1
- {libtea-0.2.0 → libtea-0.3.0}/pyproject.toml +1 -1
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/__init__.py +12 -1
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/_cli_fmt.py +13 -9
- libtea-0.3.0/src/libtea/_constants.py +14 -0
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/_hashing.py +2 -0
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/_http.py +76 -31
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/_security.py +20 -5
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/cli.py +253 -155
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/client.py +181 -9
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/discovery.py +129 -13
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/models.py +32 -13
- libtea-0.3.0/src/libtea/protocols.py +145 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/cli/test_cli.py +149 -10
- libtea-0.3.0/tests/client/test_cache.py +204 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/client/test_client.py +61 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/client/test_discovery.py +228 -5
- {libtea-0.2.0 → libtea-0.3.0}/tests/client/test_http.py +24 -1
- libtea-0.3.0/tests/client/test_iterators.py +319 -0
- libtea-0.3.0/tests/conftest.py +45 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/unit/test_models.py +103 -12
- libtea-0.3.0/tests/unit/test_protocols.py +14 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/unit/test_security.py +39 -13
- {libtea-0.2.0 → libtea-0.3.0}/uv.lock +1 -1
- libtea-0.2.0/tests/conftest.py +0 -25
- {libtea-0.2.0 → libtea-0.3.0}/.github/dependabot.yml +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/.github/workflows/ci.yaml +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/.github/workflows/codeql.yaml +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/.github/workflows/pypi.yaml +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/.gitignore +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/.pre-commit-config.yaml +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/CLAUDE.md +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/LICENSE +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/docs/FUTURE.md +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/docs/plans/2025-02-25-tea-client-design.md +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/docs/plans/2026-02-25-v0.2.0-design.md +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/docs/plans/2026-02-26-v0.3.0-design.md +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/_cli_entry.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/_validation.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/exceptions.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/src/libtea/py.typed +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/__init__.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/cli/__init__.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/cli/test_cli_fmt.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/client/__init__.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/client/test_download.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/integration/__init__.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/integration/test_integration.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/unit/__init__.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/unit/test_cli_entry.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/unit/test_exceptions.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/unit/test_hashing.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/unit/test_validation.py +0 -0
- {libtea-0.2.0 → libtea-0.3.0}/tests/unit/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: libtea
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Python client library for the Transparency Exchange API (TEA)
|
|
5
5
|
Project-URL: Homepage, https://github.com/sbomify/py-libtea
|
|
6
6
|
Project-URL: Repository, https://github.com/sbomify/py-libtea
|
|
@@ -48,16 +48,22 @@ TEA is an open standard for discovering and retrieving software transparency art
|
|
|
48
48
|
### Features
|
|
49
49
|
|
|
50
50
|
- Auto-discovery via `.well-known/tea` and TEI URNs
|
|
51
|
+
- Flexible version negotiation — connects to older server versions within the same major series
|
|
51
52
|
- Products, components, releases, and versioned collections
|
|
52
53
|
- Search by PURL, CPE, or TEI identifier
|
|
54
|
+
- Pagination auto-iterators for search results
|
|
55
|
+
- Bulk parallel fetch for products, releases, and artifacts
|
|
53
56
|
- Common Lifecycle Enumeration (CLE) — ECMA-428 lifecycle events
|
|
54
57
|
- Artifact download with on-the-fly checksum verification (MD5 through BLAKE2b)
|
|
58
|
+
- Optional TTL response caching
|
|
55
59
|
- Endpoint failover with SemVer-compatible version selection
|
|
60
|
+
- SSRF protection — blocks private IPs, cloud metadata endpoints, DNS rebinding
|
|
56
61
|
- Bearer token and HTTP basic auth authentication
|
|
57
62
|
- Bearer token isolation — tokens are never sent to artifact download hosts
|
|
63
|
+
- `TeaClientProtocol` for dependency inversion and test doubles
|
|
58
64
|
- Typed Pydantic v2 models with full camelCase/snake_case conversion
|
|
59
65
|
- Structured exception hierarchy with error context
|
|
60
|
-
- CLI with rich-formatted output and
|
|
66
|
+
- CLI with rich-formatted output, JSON mode, and verbose logging
|
|
61
67
|
|
|
62
68
|
## Installation
|
|
63
69
|
|
|
@@ -77,7 +83,7 @@ pip install libtea[cli]
|
|
|
77
83
|
from libtea import TeaClient
|
|
78
84
|
|
|
79
85
|
# Auto-discover the sbomify TEA server from its .well-known/tea
|
|
80
|
-
with TeaClient.from_well_known("trust.sbomify.com"
|
|
86
|
+
with TeaClient.from_well_known("trust.sbomify.com") as client:
|
|
81
87
|
# Discover a product by TEI
|
|
82
88
|
results = client.discover(
|
|
83
89
|
"urn:tei:purl:trust.sbomify.com:pkg:github/sbomify/sbomify"
|
|
@@ -95,7 +101,6 @@ Or connect directly to a known endpoint:
|
|
|
95
101
|
```python
|
|
96
102
|
client = TeaClient(
|
|
97
103
|
base_url="https://trust.sbomify.com/tea/v0.3.0-beta.2",
|
|
98
|
-
token="your-bearer-token",
|
|
99
104
|
timeout=30.0,
|
|
100
105
|
)
|
|
101
106
|
```
|
|
@@ -105,7 +110,6 @@ Using `from_well_known`, you can also override the spec version and timeout:
|
|
|
105
110
|
```python
|
|
106
111
|
client = TeaClient.from_well_known(
|
|
107
112
|
"trust.sbomify.com",
|
|
108
|
-
token="your-bearer-token",
|
|
109
113
|
timeout=15.0,
|
|
110
114
|
version="0.3.0-beta.2", # default
|
|
111
115
|
)
|
|
@@ -162,6 +166,38 @@ with TeaClient.from_well_known("trust.sbomify.com") as client:
|
|
|
162
166
|
print(releases.total_results)
|
|
163
167
|
```
|
|
164
168
|
|
|
169
|
+
### Auto-paginated iterators
|
|
170
|
+
|
|
171
|
+
For iterating over large result sets without manual page management:
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
with TeaClient.from_well_known("trust.sbomify.com") as client:
|
|
175
|
+
# Iterate all matching products (handles pagination automatically)
|
|
176
|
+
for product in client.iter_products("PURL", "pkg:github/sbomify/sbomify"):
|
|
177
|
+
print(product.name)
|
|
178
|
+
|
|
179
|
+
# Iterate all product releases by identifier
|
|
180
|
+
for release in client.iter_product_releases("PURL", "pkg:github/sbomify/sbomify"):
|
|
181
|
+
print(release.version)
|
|
182
|
+
|
|
183
|
+
# Iterate all releases for a specific product UUID
|
|
184
|
+
for release in client.iter_releases_for_product("product-uuid"):
|
|
185
|
+
print(release.version, release.created_date)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Bulk parallel fetch
|
|
189
|
+
|
|
190
|
+
Fetch multiple resources by UUID in parallel:
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
with TeaClient.from_well_known("trust.sbomify.com") as client:
|
|
194
|
+
products = client.get_products(["uuid-1", "uuid-2", "uuid-3"])
|
|
195
|
+
releases = client.get_product_releases_bulk(["uuid-1", "uuid-2"])
|
|
196
|
+
artifacts = client.get_artifacts(["uuid-1", "uuid-2"])
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Results are returned in the same order as the input UUIDs. Use `max_workers=1` for serial execution.
|
|
200
|
+
|
|
165
201
|
### Products and releases
|
|
166
202
|
|
|
167
203
|
```python
|
|
@@ -258,19 +294,67 @@ client = TeaClient.from_well_known("trust.sbomify.com", token="your-token")
|
|
|
258
294
|
client = TeaClient.from_well_known("trust.sbomify.com", basic_auth=("user", "password"))
|
|
259
295
|
```
|
|
260
296
|
|
|
297
|
+
### Response caching
|
|
298
|
+
|
|
299
|
+
Enable optional TTL-based caching to avoid repeated API calls:
|
|
300
|
+
|
|
301
|
+
```python
|
|
302
|
+
# Cache GET responses for 5 minutes
|
|
303
|
+
client = TeaClient("https://trust.sbomify.com/tea/v0.3.0-beta.2", cache_ttl=300)
|
|
304
|
+
product = client.get_product("uuid") # HTTP call
|
|
305
|
+
product = client.get_product("uuid") # served from cache
|
|
306
|
+
|
|
307
|
+
client.clear_cache() # manually invalidate
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
Only JSON API responses are cached — artifact downloads are never cached.
|
|
311
|
+
|
|
312
|
+
### Private network access
|
|
313
|
+
|
|
314
|
+
By default, artifact downloads are blocked from private/internal IPs (SSRF protection). For local development:
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
client = TeaClient.from_well_known(
|
|
318
|
+
"trust.local",
|
|
319
|
+
scheme="http",
|
|
320
|
+
allow_private_ips=True, # allows downloads from 127.0.0.1, 10.x, etc.
|
|
321
|
+
)
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Scheme validation and cloud metadata endpoint blocking are always enforced.
|
|
325
|
+
|
|
326
|
+
### Testing with TeaClientProtocol
|
|
327
|
+
|
|
328
|
+
Use the `TeaClientProtocol` for dependency inversion in consumer code:
|
|
329
|
+
|
|
330
|
+
```python
|
|
331
|
+
from libtea import TeaClientProtocol
|
|
332
|
+
|
|
333
|
+
def fetch_sbom(client: TeaClientProtocol, product_uuid: str):
|
|
334
|
+
"""Accepts any object matching the TeaClient interface."""
|
|
335
|
+
product = client.get_product(product_uuid)
|
|
336
|
+
return product.name
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
This allows using mock objects in tests without depending on the concrete `TeaClient` class.
|
|
340
|
+
|
|
261
341
|
## CLI
|
|
262
342
|
|
|
263
343
|
The `tea-cli` command provides a terminal interface for all TEA operations. Install with `pip install libtea[cli]`. See the [full CLI reference](docs/cli.md) for detailed documentation.
|
|
264
344
|
|
|
265
345
|
### Global options
|
|
266
346
|
|
|
347
|
+
These flags can be placed before or after the subcommand name. They appear under each subcommand's `--help` output.
|
|
348
|
+
|
|
267
349
|
```
|
|
268
|
-
--json
|
|
269
|
-
--
|
|
270
|
-
--
|
|
350
|
+
--json Output raw JSON instead of rich-formatted tables
|
|
351
|
+
--verbose, -v Show verbose output (libtea debug logs)
|
|
352
|
+
--debug, -d Show debug output (full HTTP firehose including urllib3)
|
|
353
|
+
--allow-private-ips Allow artifact downloads from private/internal IPs
|
|
354
|
+
--version Show version
|
|
271
355
|
```
|
|
272
356
|
|
|
273
|
-
All commands accept connection options: `--base-url`, `--domain`, `--token`, `--auth`, `--use-http`, `--port`.
|
|
357
|
+
All commands also accept connection options: `--base-url`, `--domain`, `--token`, `--auth`, `--use-http`, `--port`.
|
|
274
358
|
|
|
275
359
|
### Discover
|
|
276
360
|
|
|
@@ -428,7 +512,7 @@ Optional (for CLI): [click](https://click.palletsprojects.com/) >= 8.0, [rich](h
|
|
|
428
512
|
## Not yet supported
|
|
429
513
|
|
|
430
514
|
- Publisher API (spec is consumer-only in beta.2)
|
|
431
|
-
- Async client (httpx migration)
|
|
515
|
+
- Async client (planned for httpx migration)
|
|
432
516
|
|
|
433
517
|
## Development
|
|
434
518
|
|
|
@@ -16,16 +16,22 @@ TEA is an open standard for discovering and retrieving software transparency art
|
|
|
16
16
|
### Features
|
|
17
17
|
|
|
18
18
|
- Auto-discovery via `.well-known/tea` and TEI URNs
|
|
19
|
+
- Flexible version negotiation — connects to older server versions within the same major series
|
|
19
20
|
- Products, components, releases, and versioned collections
|
|
20
21
|
- Search by PURL, CPE, or TEI identifier
|
|
22
|
+
- Pagination auto-iterators for search results
|
|
23
|
+
- Bulk parallel fetch for products, releases, and artifacts
|
|
21
24
|
- Common Lifecycle Enumeration (CLE) — ECMA-428 lifecycle events
|
|
22
25
|
- Artifact download with on-the-fly checksum verification (MD5 through BLAKE2b)
|
|
26
|
+
- Optional TTL response caching
|
|
23
27
|
- Endpoint failover with SemVer-compatible version selection
|
|
28
|
+
- SSRF protection — blocks private IPs, cloud metadata endpoints, DNS rebinding
|
|
24
29
|
- Bearer token and HTTP basic auth authentication
|
|
25
30
|
- Bearer token isolation — tokens are never sent to artifact download hosts
|
|
31
|
+
- `TeaClientProtocol` for dependency inversion and test doubles
|
|
26
32
|
- Typed Pydantic v2 models with full camelCase/snake_case conversion
|
|
27
33
|
- Structured exception hierarchy with error context
|
|
28
|
-
- CLI with rich-formatted output and
|
|
34
|
+
- CLI with rich-formatted output, JSON mode, and verbose logging
|
|
29
35
|
|
|
30
36
|
## Installation
|
|
31
37
|
|
|
@@ -45,7 +51,7 @@ pip install libtea[cli]
|
|
|
45
51
|
from libtea import TeaClient
|
|
46
52
|
|
|
47
53
|
# Auto-discover the sbomify TEA server from its .well-known/tea
|
|
48
|
-
with TeaClient.from_well_known("trust.sbomify.com"
|
|
54
|
+
with TeaClient.from_well_known("trust.sbomify.com") as client:
|
|
49
55
|
# Discover a product by TEI
|
|
50
56
|
results = client.discover(
|
|
51
57
|
"urn:tei:purl:trust.sbomify.com:pkg:github/sbomify/sbomify"
|
|
@@ -63,7 +69,6 @@ Or connect directly to a known endpoint:
|
|
|
63
69
|
```python
|
|
64
70
|
client = TeaClient(
|
|
65
71
|
base_url="https://trust.sbomify.com/tea/v0.3.0-beta.2",
|
|
66
|
-
token="your-bearer-token",
|
|
67
72
|
timeout=30.0,
|
|
68
73
|
)
|
|
69
74
|
```
|
|
@@ -73,7 +78,6 @@ Using `from_well_known`, you can also override the spec version and timeout:
|
|
|
73
78
|
```python
|
|
74
79
|
client = TeaClient.from_well_known(
|
|
75
80
|
"trust.sbomify.com",
|
|
76
|
-
token="your-bearer-token",
|
|
77
81
|
timeout=15.0,
|
|
78
82
|
version="0.3.0-beta.2", # default
|
|
79
83
|
)
|
|
@@ -130,6 +134,38 @@ with TeaClient.from_well_known("trust.sbomify.com") as client:
|
|
|
130
134
|
print(releases.total_results)
|
|
131
135
|
```
|
|
132
136
|
|
|
137
|
+
### Auto-paginated iterators
|
|
138
|
+
|
|
139
|
+
For iterating over large result sets without manual page management:
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
with TeaClient.from_well_known("trust.sbomify.com") as client:
|
|
143
|
+
# Iterate all matching products (handles pagination automatically)
|
|
144
|
+
for product in client.iter_products("PURL", "pkg:github/sbomify/sbomify"):
|
|
145
|
+
print(product.name)
|
|
146
|
+
|
|
147
|
+
# Iterate all product releases by identifier
|
|
148
|
+
for release in client.iter_product_releases("PURL", "pkg:github/sbomify/sbomify"):
|
|
149
|
+
print(release.version)
|
|
150
|
+
|
|
151
|
+
# Iterate all releases for a specific product UUID
|
|
152
|
+
for release in client.iter_releases_for_product("product-uuid"):
|
|
153
|
+
print(release.version, release.created_date)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Bulk parallel fetch
|
|
157
|
+
|
|
158
|
+
Fetch multiple resources by UUID in parallel:
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
with TeaClient.from_well_known("trust.sbomify.com") as client:
|
|
162
|
+
products = client.get_products(["uuid-1", "uuid-2", "uuid-3"])
|
|
163
|
+
releases = client.get_product_releases_bulk(["uuid-1", "uuid-2"])
|
|
164
|
+
artifacts = client.get_artifacts(["uuid-1", "uuid-2"])
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Results are returned in the same order as the input UUIDs. Use `max_workers=1` for serial execution.
|
|
168
|
+
|
|
133
169
|
### Products and releases
|
|
134
170
|
|
|
135
171
|
```python
|
|
@@ -226,19 +262,67 @@ client = TeaClient.from_well_known("trust.sbomify.com", token="your-token")
|
|
|
226
262
|
client = TeaClient.from_well_known("trust.sbomify.com", basic_auth=("user", "password"))
|
|
227
263
|
```
|
|
228
264
|
|
|
265
|
+
### Response caching
|
|
266
|
+
|
|
267
|
+
Enable optional TTL-based caching to avoid repeated API calls:
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
# Cache GET responses for 5 minutes
|
|
271
|
+
client = TeaClient("https://trust.sbomify.com/tea/v0.3.0-beta.2", cache_ttl=300)
|
|
272
|
+
product = client.get_product("uuid") # HTTP call
|
|
273
|
+
product = client.get_product("uuid") # served from cache
|
|
274
|
+
|
|
275
|
+
client.clear_cache() # manually invalidate
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Only JSON API responses are cached — artifact downloads are never cached.
|
|
279
|
+
|
|
280
|
+
### Private network access
|
|
281
|
+
|
|
282
|
+
By default, artifact downloads are blocked from private/internal IPs (SSRF protection). For local development:
|
|
283
|
+
|
|
284
|
+
```python
|
|
285
|
+
client = TeaClient.from_well_known(
|
|
286
|
+
"trust.local",
|
|
287
|
+
scheme="http",
|
|
288
|
+
allow_private_ips=True, # allows downloads from 127.0.0.1, 10.x, etc.
|
|
289
|
+
)
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Scheme validation and cloud metadata endpoint blocking are always enforced.
|
|
293
|
+
|
|
294
|
+
### Testing with TeaClientProtocol
|
|
295
|
+
|
|
296
|
+
Use the `TeaClientProtocol` for dependency inversion in consumer code:
|
|
297
|
+
|
|
298
|
+
```python
|
|
299
|
+
from libtea import TeaClientProtocol
|
|
300
|
+
|
|
301
|
+
def fetch_sbom(client: TeaClientProtocol, product_uuid: str):
|
|
302
|
+
"""Accepts any object matching the TeaClient interface."""
|
|
303
|
+
product = client.get_product(product_uuid)
|
|
304
|
+
return product.name
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
This allows using mock objects in tests without depending on the concrete `TeaClient` class.
|
|
308
|
+
|
|
229
309
|
## CLI
|
|
230
310
|
|
|
231
311
|
The `tea-cli` command provides a terminal interface for all TEA operations. Install with `pip install libtea[cli]`. See the [full CLI reference](docs/cli.md) for detailed documentation.
|
|
232
312
|
|
|
233
313
|
### Global options
|
|
234
314
|
|
|
315
|
+
These flags can be placed before or after the subcommand name. They appear under each subcommand's `--help` output.
|
|
316
|
+
|
|
235
317
|
```
|
|
236
|
-
--json
|
|
237
|
-
--
|
|
238
|
-
--
|
|
318
|
+
--json Output raw JSON instead of rich-formatted tables
|
|
319
|
+
--verbose, -v Show verbose output (libtea debug logs)
|
|
320
|
+
--debug, -d Show debug output (full HTTP firehose including urllib3)
|
|
321
|
+
--allow-private-ips Allow artifact downloads from private/internal IPs
|
|
322
|
+
--version Show version
|
|
239
323
|
```
|
|
240
324
|
|
|
241
|
-
All commands accept connection options: `--base-url`, `--domain`, `--token`, `--auth`, `--use-http`, `--port`.
|
|
325
|
+
All commands also accept connection options: `--base-url`, `--domain`, `--token`, `--auth`, `--use-http`, `--port`.
|
|
242
326
|
|
|
243
327
|
### Discover
|
|
244
328
|
|
|
@@ -396,7 +480,7 @@ Optional (for CLI): [click](https://click.palletsprojects.com/) >= 8.0, [rich](h
|
|
|
396
480
|
## Not yet supported
|
|
397
481
|
|
|
398
482
|
- Publisher API (spec is consumer-only in beta.2)
|
|
399
|
-
- Async client (httpx migration)
|
|
483
|
+
- Async client (planned for httpx migration)
|
|
400
484
|
|
|
401
485
|
## Development
|
|
402
486
|
|
|
@@ -27,10 +27,14 @@ pip install libtea[cli]
|
|
|
27
27
|
| Option | Description |
|
|
28
28
|
|--------|-------------|
|
|
29
29
|
| `--json` | Output raw JSON instead of rich-formatted tables |
|
|
30
|
-
| `--
|
|
30
|
+
| `--verbose`, `-v` | Show verbose output (libtea debug logs on stderr, suppresses urllib3/requests noise) |
|
|
31
|
+
| `--debug`, `-d` | Show full debug output (all HTTP requests, urllib3, timing) on stderr |
|
|
32
|
+
| `--allow-private-ips` | Allow artifact downloads from private/internal IPs (relaxes SSRF checks for downloads only). Scheme validation and cloud metadata endpoint blocking are always enforced. |
|
|
31
33
|
| `--version` | Show version and exit |
|
|
32
34
|
| `--help` | Show help message and exit |
|
|
33
35
|
|
|
36
|
+
`-v` and `-d` can be combined: `-v -d` is equivalent to `-d` alone (full firehose).
|
|
37
|
+
|
|
34
38
|
## Connection Options
|
|
35
39
|
|
|
36
40
|
Every command accepts the following options for server selection and authentication.
|
|
@@ -44,6 +48,7 @@ Every command accepts the following options for server selection and authenticat
|
|
|
44
48
|
| `--timeout` *SECONDS* | Request timeout in seconds (default: 30). |
|
|
45
49
|
| `--use-http` | Use HTTP instead of HTTPS for `.well-known/tea` discovery. Intended for local development only. |
|
|
46
50
|
| `--port` *PORT* | Port for well-known resolution (overrides the default for the scheme). |
|
|
51
|
+
| `--allow-private-ips` | Allow artifact downloads from private/internal IPs. Useful when the TEA server or its artifacts are hosted on a local network. |
|
|
47
52
|
|
|
48
53
|
## Commands
|
|
49
54
|
|
|
@@ -323,6 +328,24 @@ tea-cli discover -q "urn:tei:purl:trust.sbomify.com:pkg:github/sbomify/sbomify"
|
|
|
323
328
|
xargs -I {} tea-cli --json get-release {} --domain trust.sbomify.com
|
|
324
329
|
```
|
|
325
330
|
|
|
331
|
+
Verbose logging to diagnose issues:
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
# libtea debug logs only (no urllib3 noise)
|
|
335
|
+
tea-cli -v discover "urn:tei:purl:trust.sbomify.com:pkg:github/sbomify/sbomify"
|
|
336
|
+
|
|
337
|
+
# Full HTTP firehose
|
|
338
|
+
tea-cli -d discover "urn:tei:purl:trust.sbomify.com:pkg:github/sbomify/sbomify"
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Local development with private IPs:
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
# Allow downloads from a local TEA server
|
|
345
|
+
tea-cli download "http://192.168.1.100:8080/sbom.json" ./sbom.json \
|
|
346
|
+
--allow-private-ips --base-url "http://192.168.1.100:8080/tea/v0.3.0-beta.2"
|
|
347
|
+
```
|
|
348
|
+
|
|
326
349
|
Using environment variables to avoid repeating credentials:
|
|
327
350
|
|
|
328
351
|
```bash
|
|
@@ -15,7 +15,14 @@ Or auto-discover the server from a domain's ``.well-known/tea``::
|
|
|
15
15
|
from importlib.metadata import version
|
|
16
16
|
|
|
17
17
|
from libtea.client import TEA_SPEC_VERSION, TeaClient
|
|
18
|
-
from libtea.discovery import
|
|
18
|
+
from libtea.discovery import (
|
|
19
|
+
VersionedEndpoint,
|
|
20
|
+
fetch_well_known,
|
|
21
|
+
parse_tei,
|
|
22
|
+
select_best_endpoint,
|
|
23
|
+
select_endpoint,
|
|
24
|
+
select_endpoints,
|
|
25
|
+
)
|
|
19
26
|
from libtea.exceptions import (
|
|
20
27
|
TeaAuthenticationError,
|
|
21
28
|
TeaChecksumError,
|
|
@@ -62,15 +69,19 @@ from libtea.models import (
|
|
|
62
69
|
TeaWellKnown,
|
|
63
70
|
TeiType,
|
|
64
71
|
)
|
|
72
|
+
from libtea.protocols import TeaClientProtocol
|
|
65
73
|
|
|
66
74
|
__version__ = version("libtea")
|
|
67
75
|
__all__ = [
|
|
68
76
|
# Client
|
|
69
77
|
"TEA_SPEC_VERSION",
|
|
70
78
|
"TeaClient",
|
|
79
|
+
"TeaClientProtocol",
|
|
71
80
|
# Discovery
|
|
81
|
+
"VersionedEndpoint",
|
|
72
82
|
"fetch_well_known",
|
|
73
83
|
"parse_tei",
|
|
84
|
+
"select_best_endpoint",
|
|
74
85
|
"select_endpoint",
|
|
75
86
|
"select_endpoints",
|
|
76
87
|
# Exceptions
|
|
@@ -54,7 +54,7 @@ def _fmt_identifiers(identifiers: Sequence[Identifier]) -> str:
|
|
|
54
54
|
"""Format a list of :class:`Identifier` objects as comma-joined ``type:value``."""
|
|
55
55
|
if not identifiers:
|
|
56
56
|
return "-"
|
|
57
|
-
return ", ".join(f"{i.id_type}:{i.id_value}" for i in identifiers)
|
|
57
|
+
return ", ".join(f"{_opt(i.id_type)}:{_opt(i.id_value)}" for i in identifiers)
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
def _kv_panel(title: str, fields: list[tuple[str, str]], *, console: Console) -> None:
|
|
@@ -85,7 +85,9 @@ def _distributions_table(distributions: Sequence[ReleaseDistribution], *, consol
|
|
|
85
85
|
tbl.add_column("Signature URL")
|
|
86
86
|
tbl.add_column("Checksums")
|
|
87
87
|
for d in distributions:
|
|
88
|
-
checksums =
|
|
88
|
+
checksums = (
|
|
89
|
+
", ".join(f"{_opt(cs.algorithm_type)}:{(_opt(cs.algorithm_value))[:12]}..." for cs in d.checksums) or "-"
|
|
90
|
+
)
|
|
89
91
|
tbl.add_row(
|
|
90
92
|
_esc(d.distribution_type), _esc(d.description), _esc(d.url), _esc(d.signature_url), escape(checksums)
|
|
91
93
|
)
|
|
@@ -103,9 +105,9 @@ def _artifacts_table(artifacts: Sequence[Artifact], *, console: Console) -> None
|
|
|
103
105
|
tbl.add_column("Applies To")
|
|
104
106
|
tbl.add_column("Formats")
|
|
105
107
|
for a in artifacts:
|
|
106
|
-
fmt_str = ", ".join(f.media_type for f in a.formats) or "-"
|
|
108
|
+
fmt_str = ", ".join(f.media_type or "?" for f in a.formats) or "-"
|
|
107
109
|
applies = ", ".join(a.distribution_types) if a.distribution_types else "-"
|
|
108
|
-
tbl.add_row(
|
|
110
|
+
tbl.add_row(_esc(a.uuid), _esc(a.name), _esc(a.type), escape(applies), escape(fmt_str))
|
|
109
111
|
console.print(tbl)
|
|
110
112
|
|
|
111
113
|
|
|
@@ -120,8 +122,10 @@ def _formats_table(formats: Sequence[ArtifactFormat], *, console: Console) -> No
|
|
|
120
122
|
tbl.add_column("Signature URL")
|
|
121
123
|
tbl.add_column("Checksums")
|
|
122
124
|
for f in formats:
|
|
123
|
-
checksums =
|
|
124
|
-
|
|
125
|
+
checksums = (
|
|
126
|
+
", ".join(f"{_opt(cs.algorithm_type)}:{(_opt(cs.algorithm_value))[:12]}..." for cs in f.checksums) or "-"
|
|
127
|
+
)
|
|
128
|
+
tbl.add_row(_esc(f.media_type), _esc(f.description), _esc(f.url), _esc(f.signature_url), escape(checksums))
|
|
125
129
|
console.print(tbl)
|
|
126
130
|
|
|
127
131
|
|
|
@@ -237,7 +241,7 @@ def fmt_collection(data: Collection, *, console: Console) -> None:
|
|
|
237
241
|
"""Render a collection as a panel with artifacts table."""
|
|
238
242
|
reason = "-"
|
|
239
243
|
if data.update_reason:
|
|
240
|
-
reason = data.update_reason.type
|
|
244
|
+
reason = _opt(data.update_reason.type)
|
|
241
245
|
if data.update_reason.comment:
|
|
242
246
|
reason += f" ({data.update_reason.comment})"
|
|
243
247
|
_kv_panel(
|
|
@@ -258,7 +262,7 @@ def fmt_artifact(data: Artifact, *, console: Console) -> None:
|
|
|
258
262
|
"""Render artifact metadata as a panel with formats table."""
|
|
259
263
|
_kv_panel(
|
|
260
264
|
"Artifact",
|
|
261
|
-
[("UUID", data.uuid), ("Name", data.name), ("Type", data.type)],
|
|
265
|
+
[("UUID", _opt(data.uuid)), ("Name", _opt(data.name)), ("Type", _opt(data.type))],
|
|
262
266
|
console=console,
|
|
263
267
|
)
|
|
264
268
|
_formats_table(data.formats, console=console)
|
|
@@ -435,7 +439,7 @@ def _inspect_component_details(comp: dict[str, Any], *, console: Console) -> Non
|
|
|
435
439
|
", ".join(f"{cs.get('algType', '?')}:{cs.get('algValue', '')[:12]}..." for cs in checksums_list) or "-"
|
|
436
440
|
)
|
|
437
441
|
tbl.add_row(
|
|
438
|
-
|
|
442
|
+
_esc(d.get("distributionType")),
|
|
439
443
|
_esc(d.get("description")),
|
|
440
444
|
_esc(d.get("url")),
|
|
441
445
|
_esc(d.get("signatureUrl")),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Shared constants used across multiple libtea modules."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def _get_package_version() -> str:
|
|
5
|
+
"""Get the package version for User-Agent header."""
|
|
6
|
+
try:
|
|
7
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
8
|
+
|
|
9
|
+
return version("libtea")
|
|
10
|
+
except (PackageNotFoundError, ValueError):
|
|
11
|
+
return "unknown"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
USER_AGENT = f"py-libtea/{_get_package_version()} (hello@sbomify.com)"
|
|
@@ -10,6 +10,8 @@ from typing import Any
|
|
|
10
10
|
|
|
11
11
|
from libtea.exceptions import TeaChecksumError
|
|
12
12
|
|
|
13
|
+
WEAK_HASH_ALGORITHMS = frozenset({"MD5", "SHA-1"})
|
|
14
|
+
|
|
13
15
|
# Hash algorithm registry: {TEA name: (hashlib name, digest_size)}.
|
|
14
16
|
# When digest_size is None, hashlib.new(name) is used with its default size.
|
|
15
17
|
# When digest_size is set, hashlib.blake2b(digest_size=N) is used instead.
|