c2cciutils 1.7.0.dev285__py3-none-any.whl → 1.7.0.dev289__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 +0 -58
- c2cciutils/configuration.py +1 -18
- c2cciutils/schema.json +1 -8
- c2cciutils/scripts/publish.py +7 -2
- {c2cciutils-1.7.0.dev285.dist-info → c2cciutils-1.7.0.dev289.dist-info}/METADATA +1 -1
- {c2cciutils-1.7.0.dev285.dist-info → c2cciutils-1.7.0.dev289.dist-info}/RECORD +9 -10
- {c2cciutils-1.7.0.dev285.dist-info → c2cciutils-1.7.0.dev289.dist-info}/entry_points.txt +0 -1
- c2cciutils/scripts/docker_versions_update.py +0 -85
- {c2cciutils-1.7.0.dev285.dist-info → c2cciutils-1.7.0.dev289.dist-info}/LICENSE +0 -0
- {c2cciutils-1.7.0.dev285.dist-info → c2cciutils-1.7.0.dev289.dist-info}/WHEEL +0 -0
c2cciutils/audit.py
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
The auditing functions.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
import datetime
|
|
6
|
-
import json
|
|
7
5
|
import os.path
|
|
8
6
|
import subprocess # nosec
|
|
9
7
|
import sys
|
|
@@ -176,59 +174,3 @@ def snyk(
|
|
|
176
174
|
)
|
|
177
175
|
|
|
178
176
|
return install_success and test_success and not has_diff
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
def outdated_versions(
|
|
182
|
-
config: None,
|
|
183
|
-
full_config: c2cciutils.configuration.Configuration,
|
|
184
|
-
args: Namespace,
|
|
185
|
-
) -> bool:
|
|
186
|
-
"""
|
|
187
|
-
Check that the versions from the SECURITY.md are not outdated.
|
|
188
|
-
|
|
189
|
-
Arguments:
|
|
190
|
-
config: The audit section config
|
|
191
|
-
full_config: All the CI config
|
|
192
|
-
args: The parsed command arguments
|
|
193
|
-
"""
|
|
194
|
-
del config, full_config
|
|
195
|
-
|
|
196
|
-
repo = c2cciutils.get_repository().split("/")
|
|
197
|
-
json_response = c2cciutils.graphql(
|
|
198
|
-
"default_branch.graphql",
|
|
199
|
-
{"name": repo[1], "owner": repo[0]},
|
|
200
|
-
)
|
|
201
|
-
|
|
202
|
-
if "errors" in json_response:
|
|
203
|
-
raise RuntimeError(json.dumps(json_response["errors"], indent=2))
|
|
204
|
-
if json_response["repository"]["defaultBranchRef"]["name"] != c2cciutils.get_branch(args.branch):
|
|
205
|
-
return True
|
|
206
|
-
|
|
207
|
-
success = True
|
|
208
|
-
|
|
209
|
-
if not os.path.exists("SECURITY.md"):
|
|
210
|
-
return True
|
|
211
|
-
|
|
212
|
-
with open("SECURITY.md", encoding="utf-8") as security_file:
|
|
213
|
-
security = security_md.Security(security_file.read())
|
|
214
|
-
|
|
215
|
-
version_index = security.version_index
|
|
216
|
-
date_index = security.support_until_index
|
|
217
|
-
|
|
218
|
-
for row in security.data:
|
|
219
|
-
str_date = row[date_index]
|
|
220
|
-
if str_date not in (
|
|
221
|
-
security_md.SUPPORT_TO_BE_DEFINED,
|
|
222
|
-
security_md.SUPPORT_BEST_EFFORT,
|
|
223
|
-
security_md.SUPPORT_UNSUPPORTED,
|
|
224
|
-
):
|
|
225
|
-
date = datetime.datetime.strptime(row[date_index], "%d/%m/%Y")
|
|
226
|
-
if date < datetime.datetime.now():
|
|
227
|
-
c2cciutils.error(
|
|
228
|
-
"versions",
|
|
229
|
-
f"The version '{row[version_index]}' is outdated, it can be set to "
|
|
230
|
-
"'Unsupported', 'Best effort' or 'To be defined'",
|
|
231
|
-
"SECURITY.md",
|
|
232
|
-
)
|
|
233
|
-
success = False
|
|
234
|
-
return success
|
c2cciutils/configuration.py
CHANGED
|
@@ -4,7 +4,7 @@ Automatically generated file from a JSON schema.
|
|
|
4
4
|
|
|
5
5
|
from typing import Any, Literal, TypedDict, Union
|
|
6
6
|
|
|
7
|
-
AUDIT_DEFAULT = {"snyk": True
|
|
7
|
+
AUDIT_DEFAULT = {"snyk": True}
|
|
8
8
|
""" Default value of the field path 'configuration audit' """
|
|
9
9
|
|
|
10
10
|
|
|
@@ -43,17 +43,9 @@ class Audit(TypedDict, total=False):
|
|
|
43
43
|
The audit configuration
|
|
44
44
|
|
|
45
45
|
default:
|
|
46
|
-
outdated_versions: true
|
|
47
46
|
snyk: true
|
|
48
47
|
"""
|
|
49
48
|
|
|
50
|
-
outdated_versions: "AuditOutdatedVersions"
|
|
51
|
-
"""
|
|
52
|
-
Audit outdated versions.
|
|
53
|
-
|
|
54
|
-
Audit of outdated version
|
|
55
|
-
"""
|
|
56
|
-
|
|
57
49
|
snyk: "AuditWithSnyk"
|
|
58
50
|
"""
|
|
59
51
|
Audit with Snyk.
|
|
@@ -65,14 +57,6 @@ class Audit(TypedDict, total=False):
|
|
|
65
57
|
"""
|
|
66
58
|
|
|
67
59
|
|
|
68
|
-
AuditOutdatedVersions = bool
|
|
69
|
-
"""
|
|
70
|
-
Audit outdated versions.
|
|
71
|
-
|
|
72
|
-
Audit of outdated version
|
|
73
|
-
"""
|
|
74
|
-
|
|
75
|
-
|
|
76
60
|
class AuditSnykConfig(TypedDict, total=False):
|
|
77
61
|
"""
|
|
78
62
|
Audit Snyk config.
|
|
@@ -242,7 +226,6 @@ Configuration = TypedDict(
|
|
|
242
226
|
# | The audit configuration
|
|
243
227
|
# |
|
|
244
228
|
# | default:
|
|
245
|
-
# | outdated_versions: true
|
|
246
229
|
# | snyk: true
|
|
247
230
|
"audit": "Audit",
|
|
248
231
|
# | Pull request checks.
|
c2cciutils/schema.json
CHANGED
|
@@ -6,11 +6,6 @@
|
|
|
6
6
|
"description": "C2C CI utils configuration file",
|
|
7
7
|
"additionalProperties": false,
|
|
8
8
|
"definitions": {
|
|
9
|
-
"audit_outdated_versions": {
|
|
10
|
-
"title": "Audit outdated versions",
|
|
11
|
-
"description": "Audit of outdated version",
|
|
12
|
-
"type": "boolean"
|
|
13
|
-
},
|
|
14
9
|
"audit_snyk": {
|
|
15
10
|
"title": "Audit with Snyk",
|
|
16
11
|
"description": "The audit Snyk configuration",
|
|
@@ -509,11 +504,9 @@
|
|
|
509
504
|
"description": "The audit configuration",
|
|
510
505
|
"type": "object",
|
|
511
506
|
"default": {
|
|
512
|
-
"snyk": true
|
|
513
|
-
"outdated_versions": true
|
|
507
|
+
"snyk": true
|
|
514
508
|
},
|
|
515
509
|
"properties": {
|
|
516
|
-
"outdated_versions": { "$ref": "#/definitions/audit_outdated_versions" },
|
|
517
510
|
"snyk": { "$ref": "#/definitions/audit_snyk" }
|
|
518
511
|
}
|
|
519
512
|
},
|
c2cciutils/scripts/publish.py
CHANGED
|
@@ -390,13 +390,18 @@ def main() -> None:
|
|
|
390
390
|
dpkg_success &= c2cciutils.lib.docker.check_versions(versions_config.get(image, {}), image)
|
|
391
391
|
|
|
392
392
|
if not dpkg_success:
|
|
393
|
-
current_versions_in_images = {}
|
|
393
|
+
current_versions_in_images: dict[str, dict[str, str]] = {}
|
|
394
394
|
if dpkg_config_found:
|
|
395
395
|
with open("ci/dpkg-versions.yaml", encoding="utf-8") as dpkg_versions_file:
|
|
396
396
|
current_versions_in_images = yaml.load(dpkg_versions_file, Loader=yaml.SafeLoader)
|
|
397
397
|
for image in images_src:
|
|
398
398
|
_, versions_image = c2cciutils.lib.docker.get_dpkg_packages_versions(image)
|
|
399
|
-
|
|
399
|
+
for dpkg_package, package_version in versions_image.items():
|
|
400
|
+
if dpkg_package not in current_versions_in_images[image]:
|
|
401
|
+
current_versions_in_images[image][dpkg_package] = str(package_version)
|
|
402
|
+
for dpkg_package in current_versions_in_images[image].keys():
|
|
403
|
+
if dpkg_package not in versions_image:
|
|
404
|
+
del current_versions_in_images[image][dpkg_package]
|
|
400
405
|
if dpkg_config_found:
|
|
401
406
|
print(
|
|
402
407
|
"::error::Some packages are have a greater version in the config raster then in the image."
|
|
@@ -2,10 +2,10 @@ 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
|
|
5
|
+
c2cciutils/audit.py,sha256=-WIinz3U6u3-JBQ2ltyuU95UWczLiwUyMuqHYczFKas,5571
|
|
6
6
|
c2cciutils/branches.graphql,sha256=UZrj1RO-H527M1SKqWm1VnkWtNsuKTnPTf4BCU2YcOU,358
|
|
7
7
|
c2cciutils/commits.graphql,sha256=3HAuIEig5V7j1L-6mqBaOkiTD3Fb8_gl1ilpZjPJf74,308
|
|
8
|
-
c2cciutils/configuration.py,sha256
|
|
8
|
+
c2cciutils/configuration.py,sha256=yGv9L9OVAMb1Rnxt4NKf92pLNl7zHnbXeyUgKnhE2Vs,27857
|
|
9
9
|
c2cciutils/default_branch.graphql,sha256=CaP3rRsNiyg_7RvqbMk0tOJr0aqWd8cOeSV-ZKgvKY4,131
|
|
10
10
|
c2cciutils/env.py,sha256=J-lC7GdOkdFVIrWFZEkAxHmIuTYwhDJiE30BICj2UoM,3425
|
|
11
11
|
c2cciutils/lib/docker.py,sha256=lwvCarwSSUWK1Y4O7qcTILPdpkTf2Ujhl_fCwZ6dBUY,5677
|
|
@@ -14,13 +14,12 @@ c2cciutils/package.json,sha256=eVSEaP7N8qu5EyPpkBpefKtnjlKLlfCHTfBXgbOoHDY,134
|
|
|
14
14
|
c2cciutils/pr_checks.py,sha256=tBwDHxThcu6648pE2cqpLNsaU711lwwgRc7sB4qR6fU,10109
|
|
15
15
|
c2cciutils/publish.py,sha256=KOEtPe-y1uw0-DWfKnF5jmYfQb5c0_URKBxakthcrBI,17259
|
|
16
16
|
c2cciutils/schema-applications.json,sha256=Tus-s9NB7uwKhTrQwhWQM4_oJygF_yHUqShtZhN1IxE,1551
|
|
17
|
-
c2cciutils/schema.json,sha256=
|
|
17
|
+
c2cciutils/schema.json,sha256=zKRqIjpNg6H2kvuixP64CK5CAJFhyu-_aUEub0_rAqc,22841
|
|
18
18
|
c2cciutils/scripts/__init__.py,sha256=N4tcdvUifXQrK9vEvFWrGvoyY9oZ0uRcjb-FoYe41cc,36
|
|
19
19
|
c2cciutils/scripts/audit.py,sha256=MUQqpA8CNkbSyK5e0HiSC5w-4GPKYEqFgV82lIwKkQk,1104
|
|
20
20
|
c2cciutils/scripts/clean.py,sha256=tpyipZjqK7om9_dNiLxvz6-l6le7N0L03inkrKe7Y_A,3039
|
|
21
21
|
c2cciutils/scripts/docker_logs.py,sha256=lcOLJzme0NpFQSqoz0cKL8Hqcr_7a3POh0hp8TKAh6A,1715
|
|
22
22
|
c2cciutils/scripts/docker_versions_gen.py,sha256=M_VzKlhqsmUwd9GgPIU9EW6eCmMmytkJQEhOFjYVZl4,1316
|
|
23
|
-
c2cciutils/scripts/docker_versions_update.py,sha256=6AwBXoMqWzocF5yas09VCOWACA3JtIo-_Q3KBFaO3Qs,3511
|
|
24
23
|
c2cciutils/scripts/download_applications.py,sha256=Lxnm2XJSfDtZc47xUtJQx52N2tIARYioTvPEXKOMMJ0,4490
|
|
25
24
|
c2cciutils/scripts/env.py,sha256=4AmCZa2NPF1TaPrzpk5DnrCrMO_cWbFjKK3IM3XSg8s,375
|
|
26
25
|
c2cciutils/scripts/k8s/__init__.py,sha256=ESPfnAzxPBK-TXColaFlz0OxAouX_fHV8MDamhVEsYw,69
|
|
@@ -31,11 +30,11 @@ c2cciutils/scripts/k8s/wait.py,sha256=qzQn6hbB9p1CX4bUxrkukPnbu_p6oRNem29WiMtplN
|
|
|
31
30
|
c2cciutils/scripts/main.py,sha256=ZksoYEDRJD0igEU6i0PnuOFtch4OzsxyHZQxbrjd5AY,1029
|
|
32
31
|
c2cciutils/scripts/pin_pipenv.py,sha256=jBTwlolcEL0MUyq6VYzO-adkcL1gqN7B3kBb3UjTo2k,2150
|
|
33
32
|
c2cciutils/scripts/pr_checks.py,sha256=PA9z9QB81H2JhGSr4T02eoxyeWDjQZ4XoIKFzS5o5A0,2190
|
|
34
|
-
c2cciutils/scripts/publish.py,sha256=
|
|
33
|
+
c2cciutils/scripts/publish.py,sha256=4bFgsaUssKrP_N7lG9FILalQ2oexyxCCcC1ofqcxqTU,20313
|
|
35
34
|
c2cciutils/scripts/trigger_image_update.py,sha256=UPCSgFcllewo1NOC7kUkJ2QMXU0dCA2QAq6LFQHr0Uw,2780
|
|
36
35
|
c2cciutils/scripts/version.py,sha256=BU6I3nG3ofgUXCLrUBNOql45Dz9Loox4gt4ebHRM3iQ,8912
|
|
37
|
-
c2cciutils-1.7.0.
|
|
38
|
-
c2cciutils-1.7.0.
|
|
39
|
-
c2cciutils-1.7.0.
|
|
40
|
-
c2cciutils-1.7.0.
|
|
41
|
-
c2cciutils-1.7.0.
|
|
36
|
+
c2cciutils-1.7.0.dev289.dist-info/LICENSE,sha256=pK1gU5i1jYBv--vi5omcf6-86pYmAWk6ZGbdERjAgcw,1307
|
|
37
|
+
c2cciutils-1.7.0.dev289.dist-info/METADATA,sha256=mQwHNY7jSPbvdDeEIbPEVeXLmMb4aknYd0-8kQGW5F8,18524
|
|
38
|
+
c2cciutils-1.7.0.dev289.dist-info/entry_points.txt,sha256=jPDp7KeB0Fz_TpOwbOODeW2WEcdLNJZACPtKpRqtHs4,1030
|
|
39
|
+
c2cciutils-1.7.0.dev289.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
|
|
40
|
+
c2cciutils-1.7.0.dev289.dist-info/RECORD,,
|
|
@@ -5,7 +5,6 @@ c2cciutils-checks=c2cciutils.scripts.env:main
|
|
|
5
5
|
c2cciutils-clean=c2cciutils.scripts.clean:main
|
|
6
6
|
c2cciutils-docker-logs=c2cciutils.scripts.docker_logs:main
|
|
7
7
|
c2cciutils-docker-versions-gen=c2cciutils.scripts.docker_versions_gen:main
|
|
8
|
-
c2cciutils-docker-versions-update=c2cciutils.scripts.docker_versions_update:main
|
|
9
8
|
c2cciutils-download-applications=c2cciutils.scripts.download_applications:main
|
|
10
9
|
c2cciutils-env=c2cciutils.scripts.env:main
|
|
11
10
|
c2cciutils-google-calendar=c2cciutils.publish:main_calendar
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
import re
|
|
3
|
-
import subprocess # nosec
|
|
4
|
-
import sys
|
|
5
|
-
|
|
6
|
-
import yaml
|
|
7
|
-
|
|
8
|
-
import c2cciutils
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def main() -> None:
|
|
12
|
-
"""Update the version of packages in the file ci/dpkg-versions.yaml."""
|
|
13
|
-
|
|
14
|
-
argparser = argparse.ArgumentParser(
|
|
15
|
-
description="Update the version of packages in the file ci/dpkg-versions.yaml."
|
|
16
|
-
)
|
|
17
|
-
argparser.add_argument("--branch", help="The branch to audit, not defined means autodetect")
|
|
18
|
-
args = argparser.parse_args()
|
|
19
|
-
|
|
20
|
-
cache: dict[str, dict[str, str]] = {}
|
|
21
|
-
with open("ci/dpkg-versions.yaml", encoding="utf-8") as versions_file:
|
|
22
|
-
versions_config = yaml.load(versions_file, Loader=yaml.SafeLoader)
|
|
23
|
-
for versions in versions_config.values():
|
|
24
|
-
for package_full in versions.keys():
|
|
25
|
-
dist, package = package_full.split("/")
|
|
26
|
-
if dist not in cache:
|
|
27
|
-
correspondence = {
|
|
28
|
-
"ubuntu_22_04": ("ubuntu", "22.04"),
|
|
29
|
-
"debian_11": ("debian", "11"),
|
|
30
|
-
"debian_12": ("debian", "12"),
|
|
31
|
-
}
|
|
32
|
-
if dist in correspondence:
|
|
33
|
-
images, tag = correspondence[dist]
|
|
34
|
-
subprocess.run(
|
|
35
|
-
["docker", "rm", "--force", "apt"], stderr=subprocess.DEVNULL, check=False
|
|
36
|
-
)
|
|
37
|
-
subprocess.run(
|
|
38
|
-
[
|
|
39
|
-
"docker",
|
|
40
|
-
"run",
|
|
41
|
-
"--tty",
|
|
42
|
-
"--interactive",
|
|
43
|
-
"--detach",
|
|
44
|
-
"--name=apt",
|
|
45
|
-
"--entrypoint=",
|
|
46
|
-
f"{images}:{tag}",
|
|
47
|
-
"tail",
|
|
48
|
-
"--follow",
|
|
49
|
-
"/dev/null",
|
|
50
|
-
],
|
|
51
|
-
check=True,
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
subprocess.run(["docker", "exec", "apt", "apt-get", "update"], check=True)
|
|
55
|
-
|
|
56
|
-
package_re = re.compile(r"^([^ /]+)/[a-z-,]+ ([^ ]+) (all|amd64)( .*)?$")
|
|
57
|
-
proc = subprocess.run(
|
|
58
|
-
["docker", "exec", "apt", "apt", "list"], check=True, stdout=subprocess.PIPE
|
|
59
|
-
)
|
|
60
|
-
for proc_line in proc.stdout.decode("utf-8").split("\n"):
|
|
61
|
-
package_match = package_re.match(proc_line)
|
|
62
|
-
if package_match is None:
|
|
63
|
-
print(f"not matching: {proc_line}")
|
|
64
|
-
continue
|
|
65
|
-
cache.setdefault(dist, {})[package_match.group(1)] = package_match.group(2)
|
|
66
|
-
|
|
67
|
-
subprocess.run(["docker", "rm", "--force", "apt"], check=True)
|
|
68
|
-
|
|
69
|
-
if package in cache[dist]:
|
|
70
|
-
versions[package_full] = cache[dist][package]
|
|
71
|
-
|
|
72
|
-
with open("ci/dpkg-versions.yaml", "w", encoding="utf-8") as versions_file:
|
|
73
|
-
yaml.dump(versions_config, versions_file, Dumper=yaml.SafeDumper)
|
|
74
|
-
|
|
75
|
-
current_branch = c2cciutils.get_branch(args.branch)
|
|
76
|
-
has_diff = c2cciutils.create_pull_request_if_needed(
|
|
77
|
-
current_branch, f"dpkg-update/{current_branch}", "Update dpkg package versions"
|
|
78
|
-
)
|
|
79
|
-
if has_diff:
|
|
80
|
-
print("There is a diff, please check the pull request")
|
|
81
|
-
sys.exit(1)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if __name__ == "__main__":
|
|
85
|
-
main()
|
|
File without changes
|
|
File without changes
|