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

Check if metadata files at revision match those downloaded by TUF updater #389

Merged
merged 6 commits into from
Feb 21, 2024

Conversation

renatav
Copy link
Collaborator

@renatav renatav commented Feb 15, 2024

Description (e.g. "Related to ...", etc.)

TUF updater does not always check the validity of all metadata files
if timestamp is not updated, the updater will determine that a new version
of the snapshot file does not need to be downloaded and it will not be validated
during the update process, the metadata files that TUF updater downloads is stored
in a separate folder within the temp directory
For each commit, check if the metadata files inside that directory are the same
as the ones in the auth repository's metadata folder at that revision

Closes #385

Code review checklist (for code reviewer to complete)

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Commit messages are meaningful (see this for details)
  • Tests have been included and/or updated, as appropriate
  • Docstrings have been included and/or updated, as appropriate
  • Changelog has been updated, as needed (see CHANGELOG.md)

…F updater

+
+        TUF updater does not always check the validity of all metadata files
+        if timestamp is not updated, the updater will determine that a new version
+        of the snapshot file does not need to be downloaded and it will not be validated
+        during the update process, the metadata files that TUF updater downloads is stored
+        in a separate folder within the temp directory
+        For each commit, check if the metadata files inside that directory are the same
+        as the ones in the auth repository's metadata folder at that revision
@renatav renatav requested a review from n-dusan February 15, 2024 02:41
@renatav renatav self-assigned this Feb 15, 2024
Comment on lines 1210 to 1217

# TUF updater does not always check the validity of all metadata files
# if timestamp is not updated, the updater will determine that a new version
# of the snapshot file does not need to be downloaded and it will not be validated
# during the update process, the metadata files that TUF updater downloads is stored
# in a separate folder within the temp directory
# For each commit, check if the metadata files inside that directory are the same
# as the ones in the auth repository's metadata folder at that revision
Copy link
Contributor

Choose a reason for hiding this comment

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

This explanation looks like a good candidate to be a docstring. Could we move the code to a function?

# in a separate folder within the temp directory
# For each commit, check if the metadata files inside that directory are the same
# as the ones in the auth repository's metadata folder at that revision
pattern = r"\d+\.[^\.\s]+\.\w+"
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to add explanation as to what this pattern is searching for

Comment on lines 1230 to 1238
# this validation causes an issue with one of the first
# commits of our production repositories and it should
# not be enabled until we specify a later commit of those
# repositories as the initial valid ones
# this error happens when a metadata file is added, but
# snapshot is not updated
# raise UpdateFailedError(
# f"Invalid metadata file {metadata_file_name}"
# )
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we turn this into an issue?

# For each commit, check if the metadata files inside that directory are the same
# as the ones in the auth repository's metadata folder at that revision
pattern = r"\d+\.[^\.\s]+\.\w+"
for metadata_file_name in git_updater.get_current_metadata():
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're reading all metadata files from disk for each commit, it's worth timing the updater to see how long this new validation takes, compared to the implementation we have on master.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ran SMC clone a couoek of times. The first was was slightly slower than on master, the second faster than on master, so I don't think that this impacts the performance. Other operations are much slower

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome

@renatav renatav requested a review from n-dusan February 20, 2024 12:01
@renatav renatav merged commit 9b2f4f5 into master Feb 21, 2024
25 checks passed
@renatav renatav deleted the renatav/metadata-validation branch February 21, 2024 13:00
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.

Update does not fail when snapshot is not valid
2 participants