Skip to content

Commit afed9c1

Browse files
committed
Make quetz content trust plugin work with mamba
1 parent ce3aeb7 commit afed9c1

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

plugins/quetz_content_trust/quetz_content_trust/main.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,27 @@ def post_index_creation(raw_repodata: dict, channel_name, subdir):
4444
"packages.conda", {}
4545
)
4646
for name, metadata in packages.items():
47+
# Only sign the relevant metadata
48+
signable_metadata_keys = [
49+
"build",
50+
"build_number",
51+
"constrains",
52+
"depends",
53+
"license",
54+
"name",
55+
"version",
56+
"subdir",
57+
"size",
58+
"timestamp",
59+
"md5",
60+
"sha256",
61+
]
62+
metadata_to_sign = {
63+
k: metadata[k] for k in signable_metadata_keys if k in metadata
64+
}
4765
sig = libmamba_api.sign(
48-
json.dumps(metadata, indent=2, sort_keys=True), query[0].private_key
66+
json.dumps(metadata_to_sign, indent=2, sort_keys=True),
67+
query[0].private_key,
4968
)
5069
if name not in signatures:
5170
signatures[name] = {}

quetz/repo_data.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55

66
from quetz import db_models
7+
from quetz.condainfo import MAX_CONDA_TIMESTAMP
78

89

910
def export(dao, channel_name, subdir):
@@ -22,6 +23,9 @@ def export(dao, channel_name, subdir):
2223
):
2324
data = json.loads(info)
2425
data['time_modified'] = int(time_modified.timestamp())
26+
if 'timestamp' in data and data['timestamp'] > MAX_CONDA_TIMESTAMP:
27+
# Convert timestamp from milliseconds to seconds
28+
data['timestamp'] //= 1000
2529
if format == db_models.PackageFormatEnum.conda:
2630
packages_conda[filename] = data
2731
else:

0 commit comments

Comments
 (0)