c2cciutils 1.7.0.dev277__py3-none-any.whl → 1.7.0.dev279__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
c2cciutils/audit.py CHANGED
@@ -9,9 +9,10 @@ import subprocess # nosec
9
9
  import sys
10
10
  from argparse import Namespace
11
11
 
12
+ import security_md
13
+
12
14
  import c2cciutils
13
15
  import c2cciutils.configuration
14
- import c2cciutils.security
15
16
 
16
17
 
17
18
  def print_versions(
@@ -209,7 +210,7 @@ def outdated_versions(
209
210
  return True
210
211
 
211
212
  with open("SECURITY.md", encoding="utf-8") as security_file:
212
- security = c2cciutils.security.Security(security_file.read())
213
+ security = security_md.Security(security_file.read())
213
214
 
214
215
  version_index = security.version_index
215
216
  date_index = security.support_until_index
@@ -217,9 +218,9 @@ def outdated_versions(
217
218
  for row in security.data:
218
219
  str_date = row[date_index]
219
220
  if str_date not in (
220
- c2cciutils.security.SUPPORT_TO_BE_DEFINED,
221
- c2cciutils.security.SUPPORT_BEST_EFFORT,
222
- c2cciutils.security.SUPPORT_UNSUPPORTED,
221
+ security_md.SUPPORT_TO_BE_DEFINED,
222
+ security_md.SUPPORT_BEST_EFFORT,
223
+ security_md.SUPPORT_UNSUPPORTED,
223
224
  ):
224
225
  date = datetime.datetime.strptime(row[date_index], "%d/%m/%Y")
225
226
  if date < datetime.datetime.now():
@@ -13,6 +13,7 @@ from re import Match
13
13
  from typing import Optional, cast
14
14
 
15
15
  import requests
16
+ import security_md
16
17
  import yaml
17
18
 
18
19
  import c2cciutils
@@ -21,7 +22,6 @@ import c2cciutils.env
21
22
  import c2cciutils.lib.docker
22
23
  import c2cciutils.publish
23
24
  import c2cciutils.scripts.download_applications
24
- import c2cciutils.security
25
25
  from c2cciutils.publish import GoogleCalendar
26
26
  from c2cciutils.scripts.trigger_image_update import dispatch
27
27
 
@@ -213,7 +213,7 @@ def main() -> None:
213
213
  print(f"::error:: {security_response.status_code} {security_response.text}")
214
214
  sys.exit(1)
215
215
 
216
- security = c2cciutils.security.Security(security_text)
216
+ security = security_md.Security(security_text)
217
217
  version_index = security.version_index
218
218
  alternate_tag_index = security.alternate_tag_index
219
219
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: c2cciutils
3
- Version: 1.7.0.dev277
3
+ Version: 1.7.0.dev279
4
4
  Summary: Common utilities for Camptocamp CI
5
5
  Home-page: https://github.com/camptocamp/c2cciutils
6
6
  License: FreeBSD
@@ -39,6 +39,7 @@ Requires-Dist: multi-repo-automation (>=1.0.0,<2.0.0) ; extra == "version"
39
39
  Requires-Dist: python-magic (>=0.0.0,<1.0.0)
40
40
  Requires-Dist: requests (>=2.0.0,<3.0.0)
41
41
  Requires-Dist: ruamel.yaml (>=0.0.0,<1.0.0)
42
+ Requires-Dist: security-md (>=0.0.0,<1.0.0)
42
43
  Requires-Dist: toml (>=0.0.0,<1.0.0)
43
44
  Requires-Dist: tomlkit (>=0.0.0,<1.0.0) ; extra == "publish"
44
45
  Requires-Dist: twine (>=5.0.0,<6.0.0) ; extra == "publish"
@@ -2,7 +2,7 @@ c2cciutils/__init__.py,sha256=M6hqae9Eai2yB2dD4igKHktBJ5ZRqh6Cpv18fLP9Kzo,20992
2
2
  c2cciutils/applications-versions.yaml,sha256=6zZVsRCsCVvHGXPS-PgnRGGOoUBTksnhlleWDzPCj98,225
3
3
  c2cciutils/applications.yaml,sha256=yn0XRi08cS29A_jXPofcBPxsGBv7PEBliztjRC3WtfM,504
4
4
  c2cciutils/applications_definition.py,sha256=rOEZ3ISl5fUNDrow6H58Immy3KWJtWwGshicVDpnyNA,1321
5
- c2cciutils/audit.py,sha256=V7PEn1EchANFpGoNy_91wWpxJBQ13IhrFZnGUEKqnUg,7423
5
+ c2cciutils/audit.py,sha256=T2pNVumr-N5qZOsDvAP48SarNUvQP7OdAnbeZuEYwwQ,7384
6
6
  c2cciutils/branches.graphql,sha256=UZrj1RO-H527M1SKqWm1VnkWtNsuKTnPTf4BCU2YcOU,358
7
7
  c2cciutils/commits.graphql,sha256=3HAuIEig5V7j1L-6mqBaOkiTD3Fb8_gl1ilpZjPJf74,308
8
8
  c2cciutils/configuration.py,sha256=fktdX1tcAxt8UxpRzscNeKRvpT5K-Hc-ykDJg0jIVmk,28558
@@ -31,12 +31,11 @@ c2cciutils/scripts/k8s/wait.py,sha256=qzQn6hbB9p1CX4bUxrkukPnbu_p6oRNem29WiMtplN
31
31
  c2cciutils/scripts/main.py,sha256=pj9gPIrmDUctVPEtaQQGZo-7k7mMeIs14sKQ7w6Sw1Y,1162
32
32
  c2cciutils/scripts/pin_pipenv.py,sha256=jBTwlolcEL0MUyq6VYzO-adkcL1gqN7B3kBb3UjTo2k,2150
33
33
  c2cciutils/scripts/pr_checks.py,sha256=PA9z9QB81H2JhGSr4T02eoxyeWDjQZ4XoIKFzS5o5A0,2190
34
- c2cciutils/scripts/publish.py,sha256=i38MT9pfHs4Nf8h_5OekCEpe7jjVe01vnYmHyv5TFww,19938
34
+ c2cciutils/scripts/publish.py,sha256=D-J-GwkJ5sxVCANSGBolcoZ7cVyU5aqwixD1T1sqaZw,19922
35
35
  c2cciutils/scripts/trigger_image_update.py,sha256=UPCSgFcllewo1NOC7kUkJ2QMXU0dCA2QAq6LFQHr0Uw,2780
36
36
  c2cciutils/scripts/version.py,sha256=BU6I3nG3ofgUXCLrUBNOql45Dz9Loox4gt4ebHRM3iQ,8912
37
- c2cciutils/security.py,sha256=lsZzejJuuHwWTyyaLRlelI39JBJtBzNMaRtHdES7GG8,3463
38
- c2cciutils-1.7.0.dev277.dist-info/LICENSE,sha256=pK1gU5i1jYBv--vi5omcf6-86pYmAWk6ZGbdERjAgcw,1307
39
- c2cciutils-1.7.0.dev277.dist-info/METADATA,sha256=NSiWxf9wQ8lKMh1PgMSp6LklLyptodfwsWnk6rOPa9g,18480
40
- c2cciutils-1.7.0.dev277.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
41
- c2cciutils-1.7.0.dev277.dist-info/entry_points.txt,sha256=Sr-v-X7Ri-vY7zX4yqZ9gOMFo8kZQyaiixiGYaIqOZQ,1170
42
- c2cciutils-1.7.0.dev277.dist-info/RECORD,,
37
+ c2cciutils-1.7.0.dev279.dist-info/LICENSE,sha256=pK1gU5i1jYBv--vi5omcf6-86pYmAWk6ZGbdERjAgcw,1307
38
+ c2cciutils-1.7.0.dev279.dist-info/METADATA,sha256=TV1SHcN-fcX-WPF4IS1ZYHFY07HQYb4Qs83J2KK1RKg,18524
39
+ c2cciutils-1.7.0.dev279.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
40
+ c2cciutils-1.7.0.dev279.dist-info/entry_points.txt,sha256=qB_mezKHsYy5j11RAhsEB_gPVZC2BebEvfT5Giu_D7s,1111
41
+ c2cciutils-1.7.0.dev279.dist-info/RECORD,,
@@ -16,7 +16,6 @@ c2cciutils-k8s-wait=c2cciutils.scripts.k8s.wait:main
16
16
  c2cciutils-pin-pipenv=c2cciutils.scripts.pin_pipenv:main
17
17
  c2cciutils-publish=c2cciutils.scripts.publish:main
18
18
  c2cciutils-pull-request-checks=c2cciutils.scripts.pr_checks:main
19
- c2cciutils-security-md=c2cciutils.scripts.security_md:main
20
19
  c2cciutils-trigger-image-update=c2cciutils.scripts.trigger_image_update:main
21
20
  c2cciutils-version=c2cciutils.scripts.version:main
22
21
 
c2cciutils/security.py DELETED
@@ -1,112 +0,0 @@
1
- """
2
- Read the table of versions from SECURITY.md.
3
- """
4
-
5
- import xml.etree.ElementTree # nosec
6
- from typing import Optional
7
-
8
- import markdown
9
- from markdown.extensions.tables import TableExtension
10
-
11
- HEADER_VERSION = "Version"
12
- HEADER_ALTERNATE_TAG = "Alternate Tag"
13
- HEADER_SUPPORTED_UNTIL = "Supported Until"
14
- SUPPORT_TO_BE_DEFINED = "To be defined"
15
- SUPPORT_BEST_EFFORT = "Best effort"
16
- SUPPORT_UNSUPPORTED = "Unsupported"
17
-
18
-
19
- class Security:
20
- """
21
- Read the table of versions from SECURITY.md.
22
- """
23
-
24
- headers: list[str]
25
- data: list[list[str]]
26
- _row: Optional[list[str]] = None
27
-
28
- def __init__(self, status: str, check: bool = True):
29
- """
30
- Initialize.
31
-
32
- Arguments:
33
- status: the content of the SECURITY.md file.
34
- check: Set to `False` to skip the check.
35
- """
36
-
37
- self.headers = []
38
- self.data = []
39
-
40
- markdown_instance = markdown.Markdown(extensions=[TableExtension()])
41
-
42
- elem = markdown_instance.parser.parseDocument(
43
- [s for s in status.split("\n") if s != "" and s[0] == "|"]
44
- )
45
- self._pe(elem.getroot())
46
-
47
- self.data = [r for r in self.data if len([c for c in r if c is not None]) > 0]
48
-
49
- self.version_index = self.headers.index(HEADER_VERSION) if HEADER_VERSION in self.headers else -1
50
- self.alternate_tag_index = (
51
- self.headers.index(HEADER_ALTERNATE_TAG) if HEADER_ALTERNATE_TAG in self.headers else -1
52
- )
53
- self.support_until_index = (
54
- self.headers.index(HEADER_SUPPORTED_UNTIL) if HEADER_SUPPORTED_UNTIL in self.headers else -1
55
- )
56
-
57
- # Check the content if the content isn't empty
58
- if check and status:
59
- if not self.check(verbose=0):
60
- raise ValueError("SECURITY.md file is not valid.")
61
-
62
- def check(self, verbose: int = -1) -> bool:
63
- """
64
- Check the content.
65
-
66
- Arguments:
67
- verbose: the verbosity level, `-1` for no output, `0` for errors only, `1` for all.
68
-
69
- Return:
70
- `True` if the content is valid, `False` otherwise.
71
- """
72
-
73
- success = True
74
- if self.version_index == -1:
75
- if verbose >= 0:
76
- print("`Version` column not found.")
77
- success = False
78
- elif verbose >= 1:
79
- print(f"`Version` column found at index {self.version_index}.")
80
-
81
- if self.alternate_tag_index == -1:
82
- if verbose >= 1:
83
- print("Optional `Alternate Tag` column not found.")
84
- elif verbose >= 1:
85
- print(f"`Alternate Tag` column found at index {self.alternate_tag_index}.")
86
-
87
- if self.support_until_index == -1:
88
- if verbose >= 0:
89
- print("`Supported Until` column not found.")
90
- success = False
91
- elif verbose >= 1:
92
- print(f"`Supported Until` column found at index {self.support_until_index}.")
93
-
94
- return success
95
-
96
- def _pe(self, elem: xml.etree.ElementTree.Element) -> None:
97
- """
98
- Parse the HTML table.
99
-
100
- Arguments:
101
- elem: The XML element
102
- """
103
- if elem.tag == "th":
104
- assert elem.text is not None
105
- self.headers.append(elem.text)
106
- if elem.tag == "tr":
107
- self._row = []
108
- self.data.append(self._row)
109
- if elem.tag == "td":
110
- self._row.append(elem.text) # type: ignore
111
- for element in list(elem):
112
- self._pe(element)