Skip to content

Add checksum field to location in database and GraphQL#747

Merged
rhigman merged 8 commits intodevelopfrom
feature/archive_checksum
Apr 30, 2026
Merged

Add checksum field to location in database and GraphQL#747
rhigman merged 8 commits intodevelopfrom
feature/archive_checksum

Conversation

@rhigman
Copy link
Copy Markdown
Member

@rhigman rhigman commented Apr 29, 2026

No description provided.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c16cee0fb3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 742 to 746
publication_id,
work.landing_page.clone(),
cdn_url,
Some(cdn_checksum.to_string()),
)?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Route checksum writes through LocationPolicy checks

This upload path now forwards cdn_checksum into upsert_thoth_location, which persists location.checksum via Location::create/update without calling LocationPolicy::can_create or can_update. In practice, complete_file_upload is authorized by file/CDN permissions (not superuser-only), so a non-superuser who can complete a publication upload can still add or change a checksum, bypassing the superuser restriction introduced in LocationPolicy.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behaviour is desired: checksums should not be manually entered/changed by non-superuser, but automated file uploads should be able to set them for Thoth locations

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f383df401

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread thoth-api/src/model/location/policy.rs Outdated
}

// Only superusers can update or delete an existing checksum.
if current.checksum.is_some() && current.checksum != patch.checksum && !user.is_superuser()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate checksum algorithm changes in location updates

The new checksum permission gate only compares patch.checksum to current.checksum, so a non-superuser can still change patch.checksum_algorithm (for example MD5SHA256) while keeping the checksum string unchanged, and can_update will allow it. This bypasses the intended restriction that checksum metadata is superuser-controlled and can leave checksum data semantically incorrect for downstream consumers that trust the algorithm field.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, I had been thinking that would be covered by the database constraints, but I forgot about that case.

ja573
ja573 previously approved these changes Apr 30, 2026
@@ -0,0 +1,9 @@
CREATE TYPE public.checksum_algorithm AS ENUM (
'MD5',
'SHA256'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add SHA1 too just to be safe

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5b003a6a1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +88 to +90
if ((current.checksum.is_some() && current.checksum != patch.checksum)
|| (current.checksum_algorithm.is_some()
&& current.checksum_algorithm != patch.checksum_algorithm))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Treat absent checksum fields as no-op in update checks

PatchLocation uses nullable fields with treat_none_as_null, so clients that do not send the newly added checksum/checksum_algorithm fields produce None in patch even when they are not trying to edit checksum metadata. This condition then interprets omitted fields as a checksum change and rejects non-superuser updates (or clears checksum for superusers), which breaks ordinary update_location calls that only edit unrelated fields on records that already have a checksum.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behaviour is desired: the patch will overwrite whatever is in the existing record, so we don't want to let any client submit None for these fields if they have already been set.

@rhigman rhigman merged commit 67c851b into develop Apr 30, 2026
12 checks passed
@rhigman rhigman deleted the feature/archive_checksum branch April 30, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants