Skip to content

Commit

Permalink
Merge pull request #1722 from camptocamp/publish-no-securtiy
Browse files Browse the repository at this point in the history
Publishing: Fix then the Security.md file didn't exists
  • Loading branch information
sbrunner authored Jun 3, 2024
2 parents 05e2e9c + 897495e commit 1766d15
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
10 changes: 7 additions & 3 deletions c2cciutils/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,16 @@ def outdated_versions(
with open("SECURITY.md", encoding="utf-8") as security_file:
security = c2cciutils.security.Security(security_file.read())

version_index = security.headers.index("Version")
date_index = security.headers.index("Supported Until")
version_index = security.version_index
date_index = security.support_until_index

for row in security.data:
str_date = row[date_index]
if str_date not in ("Unsupported", "Best effort", "To be defined"):
if str_date not in (
c2cciutils.security.SUPPORT_TO_BE_DEFINED,
c2cciutils.security.SUPPORT_BEST_EFFORT,
c2cciutils.security.SUPPORT_UNSUPPORTED,
):
date = datetime.datetime.strptime(row[date_index], "%d/%m/%Y")
if date < datetime.datetime.now():
c2cciutils.error(
Expand Down
6 changes: 2 additions & 4 deletions c2cciutils/scripts/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,8 @@ def main() -> None:
sys.exit(1)

security = c2cciutils.security.Security(security_text)
version_index = security.headers.index("Version") if "Version" in security.headers else -1
alternate_tag_index = (
security.headers.index("Alternate Tag") if "Alternate Tag" in security.headers else -1
)
version_index = security.version_index
alternate_tag_index = security.alternate_tag_index

row_index = -1
if version_index >= 0:
Expand Down
5 changes: 2 additions & 3 deletions c2cciutils/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def __init__(self, status: str, check: bool = True):
self._pe(elem.getroot())

self.data = [r for r in self.data if len([c for c in r if c is not None]) > 0]
for row in self.data:
row.append("")

self.version_index = self.headers.index(HEADER_VERSION) if HEADER_VERSION in self.headers else -1
self.alternate_tag_index = (
Expand All @@ -56,7 +54,8 @@ def __init__(self, status: str, check: bool = True):
self.headers.index(HEADER_SUPPORT_UNTIL) if HEADER_SUPPORT_UNTIL in self.headers else -1
)

if check:
# Check the content if the content isn't empty
if check and status:
if not self.check(verbose=0):
raise ValueError("SECURITY.md file is not valid.")

Expand Down

0 comments on commit 1766d15

Please sign in to comment.