From 0adce49912c76890cada7d737aa9e0129f4752eb Mon Sep 17 00:00:00 2001 From: IS DevOps Bot <135168451+is-devops-bot@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:19:22 +0300 Subject: [PATCH] Update charm libraries (#10) * chore: update charm libraries * update trivyignore --------- Co-authored-by: Arturo Seijas --- .trivyignore | 2 ++ lib/charms/smtp_integrator/v0/smtp.py | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.trivyignore b/.trivyignore index a3574f5..6805b7b 100644 --- a/.trivyignore +++ b/.trivyignore @@ -13,3 +13,5 @@ CVE-2022-1471 CVE-2024-21634 # nodejs CVE-2024-37890 +# clojure +CVE-2024-22871 diff --git a/lib/charms/smtp_integrator/v0/smtp.py b/lib/charms/smtp_integrator/v0/smtp.py index 6238a10..2816965 100644 --- a/lib/charms/smtp_integrator/v0/smtp.py +++ b/lib/charms/smtp_integrator/v0/smtp.py @@ -68,7 +68,7 @@ def _on_config_changed(self, _) -> None: # Increment this PATCH version before using `charmcraft publish-lib` or reset # to 0 if you are raising the major API version -LIBPATCH = 9 +LIBPATCH = 11 PYDEPS = ["pydantic>=2"] @@ -76,6 +76,7 @@ def _on_config_changed(self, _) -> None: import itertools import logging import typing +from ast import literal_eval from enum import Enum from typing import Dict, Optional @@ -127,7 +128,8 @@ class SmtpRelationData(BaseModel): password_id: The secret ID where the SMTP AUTH password for the SMTP relay is stored. auth_type: The type used to authenticate with the SMTP relay. transport_security: The security protocol to use for the outgoing SMTP relay. - domain: The domain used by the sent emails from SMTP relay. + domain: The domain used by the emails sent from SMTP relay. + skip_ssl_verify: Specifies if certificate trust verification is skipped in the SMTP relay. """ host: str = Field(..., min_length=1) @@ -138,6 +140,7 @@ class SmtpRelationData(BaseModel): auth_type: AuthType transport_security: TransportSecurity domain: Optional[str] = None + skip_ssl_verify: Optional[bool] = False def to_relation_data(self) -> Dict[str, str]: """Convert an instance of SmtpRelationData to the relation representation. @@ -150,6 +153,7 @@ def to_relation_data(self) -> Dict[str, str]: "port": str(self.port), "auth_type": self.auth_type.value, "transport_security": self.transport_security.value, + "skip_ssl_verify": str(self.skip_ssl_verify), } if self.domain: result["domain"] = self.domain @@ -173,7 +177,8 @@ class SmtpDataAvailableEvent(ops.RelationEvent): password_id: The secret ID where the SMTP AUTH password for the SMTP relay is stored. auth_type: The type used to authenticate with the SMTP relay. transport_security: The security protocol to use for the outgoing SMTP relay. - domain: The domain used by the sent emails from SMTP relay. + domain: The domain used by the emails sent from SMTP relay. + skip_ssl_verify: Specifies if certificate trust verification is skipped in the SMTP relay. """ @property @@ -224,6 +229,14 @@ def domain(self) -> str: assert self.relation.app return typing.cast(str, self.relation.data[self.relation.app].get("domain")) + @property + def skip_ssl_verify(self) -> bool: + """Fetch the skip_ssl_verify flag from the relation.""" + assert self.relation.app + return literal_eval( + typing.cast(str, self.relation.data[self.relation.app].get("skip_ssl_verify")) + ) + class SmtpRequiresEvents(ops.CharmEvents): """SMTP events. @@ -287,6 +300,7 @@ def _get_relation_data_from_relation(self, relation: ops.Relation) -> SmtpRelati auth_type=AuthType(relation_data.get("auth_type")), transport_security=TransportSecurity(relation_data.get("transport_security")), domain=relation_data.get("domain"), + skip_ssl_verify=typing.cast(bool, relation_data.get("skip_ssl_verify")), ) def _is_relation_data_valid(self, relation: ops.Relation) -> bool: