launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #33089
Re: [Merge] ~ines-almeida/launchpad:uct-export-handler into launchpad:master
Addressed, and added a small update
Diff comments:
> diff --git a/lib/lp/bugs/model/vulnerability.py b/lib/lp/bugs/model/vulnerability.py
> index fd5fba0..1d93b97 100644
> --- a/lib/lp/bugs/model/vulnerability.py
> +++ b/lib/lp/bugs/model/vulnerability.py
> @@ -509,12 +509,19 @@ class VulnerabilitySet:
>
> # Check requester's permissions to handler
> from lp.bugs.scripts.soss.sossexport import SOSSExporter
> + from lp.bugs.scripts.uct.uctexport import UCTExporter
>
> if handler == VulnerabilityHandlerEnum.SOSS:
> distribution = getUtility(IDistributionSet).getByName(
> HANDLER_DISTRIBUTION_MAP[handler]
> )
> exporter = SOSSExporter()
> +
> + elif handler == VulnerabilityHandlerEnum.UCT:
Deal - as long as we are coherent and change it in other relevant places
We could also have a `get_importer(handler)` et al that can be reused easily
> + distribution = getUtility(IDistributionSet).getByName(
> + HANDLER_DISTRIBUTION_MAP[handler]
> + )
> + exporter = UCTExporter()
> else:
> raise NotFoundError(f"{handler} not found")
>
> diff --git a/lib/lp/bugs/scripts/uct/models.py b/lib/lp/bugs/scripts/uct/models.py
> index 42331d0..8473ca2 100644
> --- a/lib/lp/bugs/scripts/uct/models.py
> +++ b/lib/lp/bugs/scripts/uct/models.py
> @@ -272,17 +273,11 @@ class UCTRecord(SVTRecord):
>
> return entry
>
> - def save(self, output_dir: Path) -> Path:
> + def to_str(self) -> str:
> """
> - Save UCTRecord to a file in UCT format.
> + Export UCTRecord to a yaml str format.
Updated
> """
> - if not output_dir.is_dir():
> - raise ValueError(
> - "{} does not exist or is not a directory", output_dir
> - )
> - output_path = output_dir / self.parent_dir / self.candidate
> - output_path.parent.mkdir(exist_ok=True)
> - output = open(str(output_path), "w")
> + output = StringIO()
> if self.public_date_at_USN:
> self._write_field(
> "PublicDateAtUSN",
> diff --git a/lib/lp/bugs/scripts/uct/uctexport.py b/lib/lp/bugs/scripts/uct/uctexport.py
> index dfad576..5b02917 100644
> --- a/lib/lp/bugs/scripts/uct/uctexport.py
> +++ b/lib/lp/bugs/scripts/uct/uctexport.py
> @@ -43,6 +45,32 @@ class UCTExporter(SVTExporter):
> description: str
> references: List[str]
>
> + def to_record(
> + self,
> + bug: BugModel,
> + vulnerability: Vulnerability,
> + ) -> UCTRecord:
> + """
> + Export the bug and vulnerability related to a cve in a distribution
> + and return a `CVE` instance.
Addressed
> +
> + :param bug: `Bug` model
> + :param vulnerability: `Vulnerability` model
> + :return: `CVE` instance
Addressed
> + """
> + if bug is None:
> + raise ValueError("Bug can't be None")
> + if vulnerability is None:
> + raise ValueError("Vulnerability can't be None")
> +
> + cve = self._import_cve(bug, vulnerability)
> + return cve.to_uct_record()
> +
> + def checkUserPermissions(self, user, distribution):
> + return SecurityAdminDistribution(distribution).checkAuthenticated(
> + IPersonRoles(user)
> + )
> +
> def export_bug_to_uct_file(
> self, bug_id: int, output_dir: Path
> ) -> Optional[Path]:
--
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/493617
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:uct-export-handler into launchpad:master.
References