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

[tufaceous-lib] Reject duplicate artifact names #3990

Merged
merged 4 commits into from
Aug 31, 2023

Conversation

jgallagher
Copy link
Contributor

Fixes #3988, albeit in a quick-and-dirty way. I have a couple concerns; will leave them as PR comments below.

@@ -276,15 +278,13 @@ impl OmicronRepoEditor {
artifact.target = filename.clone();
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the if part of this branch, we're accepting (and replacing) an artifact if we're called with the same name+version+kind. I'm nervous about that - it certainly seems wrong if we're building from a manifest (since we shouldn't have duplicates like that, and the existence of a such a dup probably means we've made a mistake), but maybe it's necessary in general?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should probably error, yeah. You're right that the existence of a duplicate name-version-kind triple means we've more likely made a mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to an error in 7898a35

target_name.raw() == filename
&& target_name.resolved() == filename
}) {
if !self.existing_target_filenames.insert(filename.clone()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems strange to me that we have to do this check ourselves to avoid clobbering another file, even if the metadata (its kind) and contents (including the hash) are different. Are we (ab)using tuf in some way that makes this necessary?

@iliana
Copy link
Contributor

iliana commented Aug 30, 2023

I think this is fine if we need to fix something quickly, but I don't think guarding against duplicate artifact names that belong to different kinds is correct.

  • TUF requires that target names are different, even if they have different hashes1. This is because the targets.json is more or less a JSON object keyed by the target name.
  • An artifact is unique across the three values (name, version, kind). It is important that the name field be allowed to have the same value within a given repository because we will eventually have two different versions of a gimlet-e SP image in the same repository.

I am also somewhat confused about the underlying issue. I am going to attempt to understand it a bit better.

Footnotes

  1. The presence of a hash in the filename is to allow for repositories to remain consistent while they're in the middle of being modified, as long as you change timestamp.json last.

@jgallagher jgallagher merged commit 01e730a into main Aug 31, 2023
@jgallagher jgallagher deleted the tufaceous-reject-duplicate-names branch August 31, 2023 17:35
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.

TUF repos have incorrect RoT images
2 participants