c2cciutils 1.6.0.dev2__py3-none-any.whl → 1.6.0.dev5__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.
@@ -813,6 +813,14 @@ PUBLISH_DOCKER_REPOSITORY_VERSIONS_DEFAULT = ["version_tag", "version_branch", "
813
813
  """Default value of the field path 'Publish Docker repository versions'"""
814
814
 
815
815
 
816
+ PUBLISH_DOCKER_SNYK_MONITOR_ARGS_DEFAULT = ["--app-vulns"]
817
+ """Default value of the field path 'Publish Docker config snyk monitor_args'"""
818
+
819
+
820
+ PUBLISH_DOCKER_SNYK_TEST_ARGS_DEFAULT = ["--app-vulns", "--severity-threshold=critical"]
821
+ """Default value of the field path 'Publish Docker config snyk test_args'"""
822
+
823
+
816
824
  PUBLISH_GOOGLE_CALENDAR_DEFAULT: Dict[str, Any] = {}
817
825
  """Default value of the field path 'Publish google_calendar'"""
818
826
 
@@ -984,6 +992,12 @@ class PublishDockerConfig(TypedDict, total=False):
984
992
  oneOf
985
993
  """
986
994
 
995
+ snyk: "_PublishDockerConfigSnyk"
996
+ """
997
+ WARNING: The required are not correctly taken in account,
998
+ See: https://github.com/camptocamp/jsonschema-gentypes/issues/6
999
+ """
1000
+
987
1001
 
988
1002
  class PublishDockerImage(TypedDict, total=False):
989
1003
  """Publish Docker image."""
@@ -1338,6 +1352,35 @@ class _PrintVersionsVersionsItem(TypedDict, total=False):
1338
1352
  """Prefix added when we print the version"""
1339
1353
 
1340
1354
 
1355
+ class _PublishDockerConfigSnyk(TypedDict, total=False):
1356
+ """Checks the published images with Snyk"""
1357
+
1358
+ monitor_args: Union[List[str], Literal[False]]
1359
+ """
1360
+ Publish docker snyk monitor args.
1361
+
1362
+ The arguments to pass to the Snyk container monitor command
1363
+
1364
+ default:
1365
+ - --app-vulns
1366
+
1367
+ oneOf
1368
+ """
1369
+
1370
+ test_args: Union[List[str], Literal[False]]
1371
+ """
1372
+ Publish docker snyk test args.
1373
+
1374
+ The arguments to pass to the Snyk container test command
1375
+
1376
+ default:
1377
+ - --app-vulns
1378
+ - --severity-threshold=critical
1379
+
1380
+ oneOf
1381
+ """
1382
+
1383
+
1341
1384
  _VersionTransformItem = TypedDict(
1342
1385
  "_VersionTransformItem",
1343
1386
  {
c2cciutils/schema.json CHANGED
@@ -469,6 +469,40 @@
469
469
  },
470
470
  { "const": false }
471
471
  ]
472
+ },
473
+ "snyk": {
474
+ "description": "Checks the published images with Snyk",
475
+ "type": "object",
476
+ "properties": {
477
+ "monitor_args": {
478
+ "description": "The arguments to pass to the Snyk container monitor command",
479
+ "title": "Publish docker snyk monitor args",
480
+ "default": ["--app-vulns"],
481
+ "oneOf": [
482
+ {
483
+ "type": "array",
484
+ "items": {
485
+ "type": "string"
486
+ }
487
+ },
488
+ { "const": false }
489
+ ]
490
+ },
491
+ "test_args": {
492
+ "description": "The arguments to pass to the Snyk container test command",
493
+ "title": "Publish docker snyk test args",
494
+ "default": ["--app-vulns", "--severity-threshold=critical"],
495
+ "oneOf": [
496
+ {
497
+ "type": "array",
498
+ "items": {
499
+ "type": "string"
500
+ }
501
+ },
502
+ { "const": false }
503
+ ]
504
+ }
505
+ }
472
506
  }
473
507
  }
474
508
  },
@@ -305,28 +305,43 @@ def main() -> None:
305
305
 
306
306
  snyk_exec, env = c2cciutils.snyk_exec()
307
307
  for image in images_snyk:
308
- if version_type in ("version_branch", "version_tag"):
309
- subprocess.run( # pylint: disable=subprocess-run-check
310
- [
311
- snyk_exec,
312
- "container",
313
- "monitor",
314
- "--app-vulns",
315
- # Available only on the business plan
316
- # f"--project-tags=tag={image.split(':')[-1]}",
317
- image,
318
- ],
319
- env=env,
308
+ print(f"::group::Snyk check {image}")
309
+ sys.stdout.flush()
310
+ sys.stderr.flush()
311
+ try:
312
+ if version_type in ("version_branch", "version_tag"):
313
+ monitor_args = docker_config.get("snyk", {}).get(
314
+ "monitor_args",
315
+ c2cciutils.configuration.PUBLISH_DOCKER_SNYK_MONITOR_ARGS_DEFAULT,
316
+ )
317
+ if monitor_args is not False:
318
+ subprocess.run( # pylint: disable=subprocess-run-check
319
+ [
320
+ snyk_exec,
321
+ "container",
322
+ "monitor",
323
+ *monitor_args,
324
+ # Available only on the business plan
325
+ # f"--project-tags=tag={image.split(':')[-1]}",
326
+ image,
327
+ ],
328
+ env=env,
329
+ )
330
+ test_args = docker_config.get("snyk", {}).get(
331
+ "test_args", c2cciutils.configuration.PUBLISH_DOCKER_SNYK_TEST_ARGS_DEFAULT
320
332
  )
321
- # Currently just for information
322
- subprocess.run( # pylint: disable=subprocess-run-check
323
- [snyk_exec, "container", "test", "--app-vulns", "--severity-threshold=high", image], env=env
324
- )
325
- subprocess.run(
326
- [snyk_exec, "container", "test", "--app-vulns", "--severity-threshold=critical", image],
327
- check=not based_on_master and version_type == "version_branch",
328
- env=env,
329
- )
333
+ if test_args is not False:
334
+ subprocess.run(
335
+ [snyk_exec, "container", "test", *test_args, image],
336
+ check=not based_on_master and version_type == "version_branch",
337
+ env=env,
338
+ )
339
+
340
+ print("::endgroup::")
341
+ except subprocess.CalledProcessError as exception:
342
+ print(f"Error: {exception}")
343
+ print("::endgroup::")
344
+ print("::error::With error")
330
345
 
331
346
  versions_config = c2cciutils.lib.docker.get_versions_config()
332
347
  dpkg_success = True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: c2cciutils
3
- Version: 1.6.0.dev2
3
+ Version: 1.6.0.dev5
4
4
  Summary: Common utilities for Camptocamp CI
5
5
  Home-page: https://github.com/camptocamp/c2cciutils
6
6
  License: FreeBSD
@@ -6,7 +6,7 @@ c2cciutils/audit.py,sha256=1tYkhqeMLh8-OD5vnnTyXMWfYyF8hcIKpg48yVna6xU,8625
6
6
  c2cciutils/branches.graphql,sha256=UZrj1RO-H527M1SKqWm1VnkWtNsuKTnPTf4BCU2YcOU,358
7
7
  c2cciutils/checks.py,sha256=11SSP06M4FwaHh4d_QzGQqZ_vxIulOzDSQF4aS6dpOI,15777
8
8
  c2cciutils/commits.graphql,sha256=3HAuIEig5V7j1L-6mqBaOkiTD3Fb8_gl1ilpZjPJf74,308
9
- c2cciutils/configuration.py,sha256=d2ytgVLKeut9pT6FP_ujTT_TEMoAkQmmQRqbqj2uANA,30208
9
+ c2cciutils/configuration.py,sha256=bpkolt3wgMYyJ06hU6YKaZ-xPqoT1ZUZfDKzRZkP4Mo,31268
10
10
  c2cciutils/default_branch.graphql,sha256=CaP3rRsNiyg_7RvqbMk0tOJr0aqWd8cOeSV-ZKgvKY4,131
11
11
  c2cciutils/lib/docker.py,sha256=LcGIUJhY8tvKzpS0NpsCQI68tGuPOt99XwezuV-ZKDc,5415
12
12
  c2cciutils/node_modules/@pkgr/utils/lib/browser.js,sha256=mDk2AdEH8Asv6rUvn3Gco50TCa8FpOx1jUCnreml5YY,3498
@@ -615,7 +615,7 @@ c2cciutils/prettier.js,sha256=PR96NT85pxZx_wPcfKa6B7_z_Gw_Yp4SCRX8cL_GfLU,588
615
615
  c2cciutils/prettier.py,sha256=yxEeaWvbcrgUWtC9jOgo2f_C76pjFpHrWCP1bk0wF1E,5207
616
616
  c2cciutils/publish.py,sha256=2cl1GeyRN6odMLkFnzJsoIud8YmcIsX0v2R6yY7TryY,17707
617
617
  c2cciutils/schema-applications.json,sha256=Uc-U2xER-FrR67ec-67K2C9kvHFO7hBlAEAQhrdUKoA,1548
618
- c2cciutils/schema.json,sha256=khJO25K7ZE7ogo3i_1np3JNJ4TGvmPLIWW_mpvNRmOM,28935
618
+ c2cciutils/schema.json,sha256=Mz3NoKCq_9ShRdn8dv7DA2mhgXCjNjIdZ2nmKCe724Y,30199
619
619
  c2cciutils/scripts/__init__.py,sha256=N4tcdvUifXQrK9vEvFWrGvoyY9oZ0uRcjb-FoYe41cc,36
620
620
  c2cciutils/scripts/audit.py,sha256=yMXtRoOJoAuLwRlON2czpOfl8y9xQYsHEYhzHvalcNE,984
621
621
  c2cciutils/scripts/checks.py,sha256=AYv-qr3UXpN3pnvx5tLkt1Lvc00WTvz8UBDEUpt4hgg,2039
@@ -631,11 +631,11 @@ c2cciutils/scripts/k8s/wait.py,sha256=qzQn6hbB9p1CX4bUxrkukPnbu_p6oRNem29WiMtplN
631
631
  c2cciutils/scripts/main.py,sha256=pj9gPIrmDUctVPEtaQQGZo-7k7mMeIs14sKQ7w6Sw1Y,1162
632
632
  c2cciutils/scripts/pin_pipenv.py,sha256=jBTwlolcEL0MUyq6VYzO-adkcL1gqN7B3kBb3UjTo2k,2150
633
633
  c2cciutils/scripts/pr_checks.py,sha256=SSMisUpKipdf3GsgJ4Jk2ZQL7rO2N61O4N4fJLxr810,2105
634
- c2cciutils/scripts/publish.py,sha256=IRhNNcU3_gxZC9fi9zW17Q_2LRB6e8NFeTtP_rRBDZU,17139
634
+ c2cciutils/scripts/publish.py,sha256=VGxh8Z-jqHgM-5Fb_Queo1i2QzVVXY7UtaafB8EtWhk,17859
635
635
  c2cciutils/scripts/trigger_image_update.py,sha256=yYa0BLn-LGrQ1GXlvI5ok8qbV-yCJ12UObS857SuXcc,2804
636
636
  c2cciutils/security.py,sha256=k5piTZf6HWIPEAf63vbE06vZKJ62CSS7e_6WXHf4o7Q,1517
637
- c2cciutils-1.6.0.dev2.dist-info/entry_points.txt,sha256=HahcOZlCfYF4B95pG1CRD_noaFmhDzEoN5YqxLyucyE,939
638
- c2cciutils-1.6.0.dev2.dist-info/LICENSE,sha256=pK1gU5i1jYBv--vi5omcf6-86pYmAWk6ZGbdERjAgcw,1307
639
- c2cciutils-1.6.0.dev2.dist-info/WHEEL,sha256=gSF7fibx4crkLz_A-IKR6kcuq0jJ64KNCkG8_bcaEao,88
640
- c2cciutils-1.6.0.dev2.dist-info/METADATA,sha256=nyOMys1z5d04B15w_D6Stbbnd4EYsB5VGDHhV3R0lZs,17195
641
- c2cciutils-1.6.0.dev2.dist-info/RECORD,,
637
+ c2cciutils-1.6.0.dev5.dist-info/entry_points.txt,sha256=HahcOZlCfYF4B95pG1CRD_noaFmhDzEoN5YqxLyucyE,939
638
+ c2cciutils-1.6.0.dev5.dist-info/LICENSE,sha256=pK1gU5i1jYBv--vi5omcf6-86pYmAWk6ZGbdERjAgcw,1307
639
+ c2cciutils-1.6.0.dev5.dist-info/WHEEL,sha256=gSF7fibx4crkLz_A-IKR6kcuq0jJ64KNCkG8_bcaEao,88
640
+ c2cciutils-1.6.0.dev5.dist-info/METADATA,sha256=1Y68T_lRWo1PZkqZR1EUQVWCigkKbPQ3_X_ISpFUFd0,17195
641
+ c2cciutils-1.6.0.dev5.dist-info/RECORD,,