-
Notifications
You must be signed in to change notification settings - Fork 75
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
api: update cache for vulnerabilities #3318
Conversation
PR ChecklistHow to use this checklistHow to use this checklistPR AuthorFor each section, check a box when it is true. PR ReviewerCheck that the PR checklist action did not fail. Bug ReferencesNone. Confirm
How to properly reference fixed bugs
Test UpdatesUnit Tests
Integration Tests
Documentation
Does this PR require review from someone outside the core ubuntu-pro-client team?
|
): | ||
self.all = all | ||
self.unfixable = unfixable | ||
self.data_file = data_file | ||
self.manifest_file = manifest_file | ||
self.series = series | ||
|
||
if update is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is a boolean you can set it to True
directly on line 80 there and not make it optional, but this as is doesn't hurt either
@@ -50,25 +64,28 @@ def __init__( | |||
cfg: UAConfig, | |||
data_file: Optional[str] = None, | |||
series: Optional[str] = None, | |||
update_data: bool = True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh you did it here
last_published_date: str, | ||
cache_date_file: DataObjectFile, | ||
) -> bool: | ||
) -> Tuple[bool, Optional[datetime.datetime]]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest some comment here explaining what is this datetime's meaning
177d696
to
2dd75d7
Compare
@renanrodrigo updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As part of our process to get ready for v35, I have rebased next-v35
onto main
. As a result, next-v35
is now obsolete. Please rebase this on main
and target the PR to main
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, we should document the architecture of these caching mechanisms, when they are used, and when they are invalidated in some kind of dev-docs explanation.
def _has_apt_state_changed(self): | ||
latest_dpkg_status_time = apt.get_dpkg_status_time() or 0 | ||
|
||
dpkg_status_cache = DataObjectFile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can only be defined once as an instance variable and used here and above
) | ||
|
||
|
||
class VulnerabilityResultCache: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed not using or saving this cache when run against a manifest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also if someone provides a series without a manifest it shouldn't work
We are now caching the vulnerability result as well. That means that if we detect that there is now new vulnerability JSON data to be used and no dpkg related changes on the system, we can simply reuse the old results.
2dd75d7
to
19c9268
Compare
@orndorffgrant updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks also for the diagram (helped understanding everything better) 😄
Why is this needed?
We are now caching the vulnerability result as well. That means that if we detect that there is now new vulnerability JSON data to be used and no dpkg related changes on the system, we can simply reuse the old results.
Test Steps