-
Notifications
You must be signed in to change notification settings - Fork 9
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
Issue/72 new api allow for full fledged processing of protection profiles #466
base: main
Are you sure you want to change the base?
Issue/72 new api allow for full fledged processing of protection profiles #466
Conversation
@J08nY first batch of commits that refactored Some of my early design notes:
|
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 OK. But still has conflicts with main. Is the merge commit a real merge commit?
@property | ||
def pp_dataset_path(self) -> Path: | ||
""" | ||
Returns a path to the dataset of Protection Profiles | ||
""" | ||
return self.auxiliary_datasets_dir / "pp_dataset.json" | ||
|
||
@property | ||
def mu_dataset_dir(self) -> Path: | ||
""" | ||
Returns directory that holds dataset of maintenance updates | ||
""" | ||
return self.auxiliary_datasets_dir / "maintenances" | ||
|
||
@property | ||
def mu_dataset_path(self) -> Path: | ||
""" | ||
Returns a path to the dataset of maintenance updates | ||
""" | ||
return self.mu_dataset_dir / "maintenance_updates.json" | ||
|
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 need a way to get to these somehow, when handling the updates on the site. Can I do it with the new API? Iterate over aux_handlers and get their paths and detect based on type?
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.
They form a dictionary and each child of AuxiliaryDatasetHandler
must implement:
root_dir
attribute, where the dataset files are stored.dset_path
attribute, where the final json is stored.
Example, in the case of CPEDataset
you can:
cpe_dset = cc_dset.aux_handlers[CPEDatasetHandler].dset
cpe_dset_json_path = cc_dset.aux_handlers[CPEDatasetHandler].dset_path
if self.auxiliary_datasets.pp_dset: | ||
self.auxiliary_datasets.pp_dset.json_path = self.pp_dataset_path | ||
|
||
if self.auxiliary_datasets.mu_dset: | ||
self.auxiliary_datasets.mu_dset.root_dir = self.mu_dataset_dir | ||
|
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.
Is this set properly in the new API?
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.
Yes, see
sec-certs/src/sec_certs/dataset/dataset.py
Lines 238 to 240 in e6cab19
def _set_local_paths(self) -> None: | |
for handler in self.aux_handlers.values(): | |
handler.set_local_paths(self.auxiliary_datasets_dir) |
self.aux_handlers[CCMaintenanceUpdateDatasetHandler].certs_with_updates = [ # type: ignore | ||
x for x in self if x.maintenance_updates | ||
] | ||
self.aux_handlers[CCSchemeDatasetHandler].only_schemes = {x.scheme for x in self} # type: ignore |
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.
It seems a bit weird that these two handlers have special stuff here.
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.
Not sure how to take care of this differently. The Handlers cannot access the Dataset
instance they're bound to. And if they must be provided with some specific configuration (e.g., to avoid downloading data for all schemes, when only some are in the dataset), this information must be injected into the handlers.
Meh, something was left out, should be fixed by now. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #466 +/- ##
==========================================
- Coverage 68.55% 68.23% -0.32%
==========================================
Files 62 67 +5
Lines 7934 7961 +27
==========================================
- Hits 5438 5431 -7
- Misses 2496 2530 +34 ☔ View full report in Codecov by Sentry. |
Closes #72