Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[quetz-content-trust] Apply some changes to make it work with mamba-content-trust #688

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion plugins/quetz_content_trust/quetz_content_trust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,27 @@ def post_index_creation(raw_repodata: dict, channel_name, subdir):
"packages.conda", {}
)
for name, metadata in packages.items():
# Only sign the relevant metadata
signable_metadata_keys = [
"build",
"build_number",
"constrains",
"depends",
"license",
"name",
"version",
"subdir",
"size",
"timestamp",
"md5",
"sha256",
]
metadata_to_sign = {
k: metadata[k] for k in signable_metadata_keys if k in metadata
}
sig = libmamba_api.sign(
json.dumps(metadata, indent=2, sort_keys=True), query[0].private_key
json.dumps(metadata_to_sign, indent=2, sort_keys=True),
query[0].private_key,
)
if name not in signatures:
signatures[name] = {}
Expand Down
4 changes: 4 additions & 0 deletions quetz/repo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json

from quetz import db_models
from quetz.condainfo import MAX_CONDA_TIMESTAMP


def export(dao, channel_name, subdir):
Expand All @@ -22,6 +23,9 @@ def export(dao, channel_name, subdir):
):
data = json.loads(info)
data['time_modified'] = int(time_modified.timestamp())
if 'timestamp' in data and data['timestamp'] > MAX_CONDA_TIMESTAMP:
# Convert timestamp from milliseconds to seconds
data['timestamp'] //= 1000
if format == db_models.PackageFormatEnum.conda:
packages_conda[filename] = data
else:
Expand Down
Loading