c2cciutils 1.7.0.dev334__py3-none-any.whl → 1.7.0.dev338__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.

Potentially problematic release.


This version of c2cciutils might be problematic. Click here for more details.

c2cciutils/schema.json CHANGED
@@ -6,192 +6,6 @@
6
6
  "description": "C2C CI utils configuration file",
7
7
  "additionalProperties": false,
8
8
  "definitions": {
9
- "audit_snyk": {
10
- "title": "Audit with Snyk",
11
- "description": "The audit Snyk configuration",
12
- "oneOf": [
13
- {
14
- "title": "Audit Snyk config",
15
- "description": "The audit Pipfile configuration",
16
- "type": "object",
17
- "properties": {
18
- "test_arguments": {
19
- "description": "The Snyk test arguments",
20
- "title": "audit snyk test arguments",
21
- "default": ["--all-projects", "--fail-on=all", "--severity-threshold=medium"],
22
- "type": "array",
23
- "items": { "type": "string" }
24
- },
25
- "monitor_arguments": {
26
- "description": "The Snyk monitor arguments",
27
- "title": "audit snyk monitor arguments",
28
- "default": ["--all-projects"],
29
- "type": "array",
30
- "items": { "type": "string" }
31
- },
32
- "fix_arguments": {
33
- "description": "The Snyk fix arguments",
34
- "title": "audit snyk fix arguments",
35
- "default": ["--all-projects"],
36
- "type": "array",
37
- "items": { "type": "string" }
38
- },
39
- "fix_github_create_pull_request_arguments": {
40
- "description": "The Snyk fix pull request extra arguments",
41
- "title": "audit snyk fix pull request arguments",
42
- "default": ["--fill", "--label=dependencies"],
43
- "type": "array",
44
- "items": { "type": "string" }
45
- },
46
- "pip_install_arguments": {
47
- "description": "The Snyk pip install arguments",
48
- "title": "audit snyk pip install arguments",
49
- "default": ["--user"],
50
- "type": "array",
51
- "items": { "type": "string" }
52
- },
53
- "pipenv_sync_arguments": {
54
- "description": "The Snyk pipenv sync arguments",
55
- "title": "audit snyk pipenv sync arguments",
56
- "default": [],
57
- "type": "array",
58
- "items": { "type": "string" }
59
- },
60
- "files_no_install": {
61
- "description": "The list of files to not install",
62
- "title": "audit snyk files no install",
63
- "default": [],
64
- "type": "array",
65
- "items": { "type": "string" }
66
- }
67
- }
68
- },
69
- { "type": "boolean" }
70
- ]
71
- },
72
- "codespell": {
73
- "title": "Codespell",
74
- "description": "The codespell check configuration",
75
- "type": "object",
76
- "properties": {
77
- "internal_dictionaries": {
78
- "title": "codespell dictionaries",
79
- "description": "List of argument that will be added to the codespell command",
80
- "default": ["clear", "rare", "informal", "code", "names", "en-GB_to_en-US"],
81
- "type": "array",
82
- "items": { "type": "string" }
83
- },
84
- "arguments": {
85
- "title": "codespell arguments",
86
- "description": "List of argument that will be added to the codespell command",
87
- "default": ["--quiet-level=2", "--check-filenames", "--ignore-words-list=ro"],
88
- "type": "array",
89
- "items": { "type": "string" }
90
- },
91
- "ignore_re": {
92
- "title": "codespell ignore regular expression",
93
- "description": "List of regular expression that should be ignored",
94
- "default": ["(.*/)?poetry\\.lock", "(.*/)?package-lock\\.json"],
95
- "type": "array",
96
- "items": { "type": "string" }
97
- }
98
- }
99
- },
100
- "pr_checks_commits_messages": {
101
- "title": "pull request checks commits messages",
102
- "description": "Check the pull request commits messages",
103
- "oneOf": [
104
- {
105
- "title": "pull request checks commits messages configuration",
106
- "description": "The commit message check configuration",
107
- "type": "object",
108
- "properties": {
109
- "check_fixup": {
110
- "title": "pull request checks commits messages fixup",
111
- "description": "Check that we don't have one fixup commit in the pull request",
112
- "default": true,
113
- "type": "boolean"
114
- },
115
- "check_squash": {
116
- "title": "pull request checks commits messages squash",
117
- "description": "Check that we don't have one squash commit in the pull request",
118
- "default": true,
119
- "type": "boolean"
120
- },
121
- "check_first_capital": {
122
- "title": "pull request checks commits messages first capital",
123
- "description": "Check that the all the commits message starts with a capital letter",
124
- "default": true,
125
- "type": "boolean"
126
- },
127
- "min_head_length": {
128
- "title": "pull request checks commits messages min head length",
129
- "description": "Check that the commits message head is at least this long, use 0 to disable",
130
- "default": 5,
131
- "type": "integer"
132
- },
133
- "check_no_merge_commits": {
134
- "title": "pull request checks commits messages no merge commits",
135
- "description": "Check that we don't have merge commits in the pull request",
136
- "default": true,
137
- "type": "boolean"
138
- },
139
- "check_no_own_revert": {
140
- "title": "pull request checks commits messages no own revert",
141
- "description": "Check that we don't have reverted one of our commits in the pull request",
142
- "default": true,
143
- "type": "boolean"
144
- }
145
- }
146
- },
147
- { "type": "boolean" }
148
- ]
149
- },
150
- "pr_checks_commits_spell": {
151
- "title": "pull request checks commits spelling",
152
- "oneOf": [
153
- {
154
- "title": "pull request checks commits spelling configuration",
155
- "description": "Configuration used to check the spelling of the commits",
156
- "type": "object",
157
- "properties": {
158
- "only_head": {
159
- "title": "pull request checks commits messages only head",
160
- "default": true,
161
- "type": "boolean"
162
- }
163
- }
164
- },
165
- { "type": "boolean" }
166
- ]
167
- },
168
- "pr_checks_pull_request_spell": {
169
- "title": "pull request checks pull request spelling",
170
- "oneOf": [
171
- {
172
- "title": "pull request checks pull request spelling configuration",
173
- "description": "Configuration used to check the spelling of the title and body of the pull request",
174
- "type": "object",
175
- "properties": {
176
- "only_head": {
177
- "title": "pull request checks only head",
178
- "default": true,
179
- "type": "boolean"
180
- }
181
- }
182
- },
183
- { "type": "boolean" }
184
- ]
185
- },
186
- "pr_checks_pull_request_labels": {
187
- "title": "pull request checks request labels",
188
- "description": "According the create changelog configuration",
189
- "type": "boolean"
190
- },
191
- "pr_checks_add_issue_link": {
192
- "title": "pull request checks add issue link",
193
- "type": "boolean"
194
- },
195
9
  "publish_docker": {
196
10
  "title": "Publish Docker",
197
11
  "description": "The configuration used to publish on Docker",
@@ -498,37 +312,6 @@
498
312
  },
499
313
  "properties": {
500
314
  "print_versions": { "$ref": "#/definitions/print_versions" },
501
- "codespell": { "$ref": "#/definitions/codespell" },
502
- "audit": {
503
- "title": "Audit",
504
- "description": "The audit configuration",
505
- "type": "object",
506
- "default": {
507
- "snyk": true
508
- },
509
- "properties": {
510
- "snyk": { "$ref": "#/definitions/audit_snyk" }
511
- }
512
- },
513
- "pr-checks": {
514
- "title": "Pull request checks",
515
- "description": "The PR check configuration",
516
- "type": "object",
517
- "default": {
518
- "commits_messages": true,
519
- "commits_spell": true,
520
- "pull_request_spell": true,
521
- "pull_request_labels": true,
522
- "add_issue_link": true
523
- },
524
- "properties": {
525
- "commits_messages": { "$ref": "#/definitions/pr_checks_commits_messages" },
526
- "commits_spell": { "$ref": "#/definitions/pr_checks_commits_spell" },
527
- "pull_request_spell": { "$ref": "#/definitions/pr_checks_pull_request_spell" },
528
- "pull_request_labels": { "$ref": "#/definitions/pr_checks_pull_request_labels" },
529
- "add_issue_link": { "$ref": "#/definitions/pr_checks_add_issue_link" }
530
- }
531
- },
532
315
  "publish": {
533
316
  "title": "Publish",
534
317
  "description": "The publishing configurations",
@@ -19,7 +19,6 @@ def main() -> None:
19
19
  parser = argparse.ArgumentParser(description="Some utils of c2cciutils.")
20
20
  parser.add_argument("--get-config", action="store_true", help="display the current config")
21
21
  parser.add_argument("--version", action="store_true", help="display the current version")
22
- parser.add_argument("--ls-files-mime", help="List all the files with the specified mime type")
23
22
 
24
23
  args = parser.parse_args()
25
24
 
@@ -30,10 +29,6 @@ def main() -> None:
30
29
  version = pkg_resources.get_distribution("c2cciutils").version
31
30
  print(f"c2cciutils {version}")
32
31
 
33
- if args.ls_files_mime:
34
- for file_name in c2cciutils.get_git_files_mime(args.ls_files_mime):
35
- print(file_name)
36
-
37
32
 
38
33
  if __name__ == "__main__":
39
34
  main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: c2cciutils
3
- Version: 1.7.0.dev334
3
+ Version: 1.7.0.dev338
4
4
  Summary: Common utilities for Camptocamp CI
5
5
  Home-page: https://github.com/camptocamp/c2cciutils
6
6
  License: FreeBSD
@@ -27,23 +27,17 @@ Provides-Extra: pr-checks
27
27
  Provides-Extra: publish
28
28
  Provides-Extra: publish-plugins
29
29
  Provides-Extra: version
30
- Requires-Dist: Markdown (>=3.0,<4.0)
31
30
  Requires-Dist: PyYAML (>=6.0.0,<7.0.0)
32
- Requires-Dist: codespell (==2.3.0) ; extra == "pr-checks"
33
31
  Requires-Dist: debian-inspector (>=31.0.0,<32.0.0)
34
32
  Requires-Dist: defusedxml (>=0.0.0,<1.0.0)
35
33
  Requires-Dist: google-api-python-client (>=2.0.0,<3.0.0) ; extra == "publish"
36
34
  Requires-Dist: google-auth-httplib2 (>=0.0.0,<1.0.0) ; extra == "publish"
37
35
  Requires-Dist: google-auth-oauthlib (>=1.0.0,<2.0.0) ; extra == "publish"
38
36
  Requires-Dist: id (>=1.0.0,<2.0.0) ; extra == "publish"
39
- Requires-Dist: markdown-table (>=2020.0.0,<2021.0.0)
40
37
  Requires-Dist: multi-repo-automation (>=1.0.0,<2.0.0) ; extra == "version"
41
- Requires-Dist: python-magic (>=0.0.0,<1.0.0)
42
38
  Requires-Dist: requests (>=2.0.0,<3.0.0)
43
39
  Requires-Dist: ruamel.yaml (>=0.0.0,<1.0.0)
44
40
  Requires-Dist: security-md (>=0.0.0,<1.0.0)
45
- Requires-Dist: toml (>=0.0.0,<1.0.0)
46
- Requires-Dist: tomlkit (>=0.0.0,<1.0.0) ; extra == "publish"
47
41
  Requires-Dist: twine (>=5.0.0,<6.0.0) ; extra == "publish"
48
42
  Project-URL: Repository, https://github.com/camptocamp/c2cciutils
49
43
  Description-Content-Type: text/markdown
@@ -60,15 +54,6 @@ see the [documentation](https://github.com/camptocamp/c2cciutils/wiki/Publishing
60
54
  When we create a tag by default with the `changelog` workflow a release is created on GitHub, a changelog is
61
55
  generated and added to the release.
62
56
 
63
- ## Security
64
-
65
- The security is managed by the `c2cciutils-audit` command with Snyk, it will audit the dependencies of the project on every
66
- stabilization branches, if possible a pull request is created automatically to update the dependencies.
67
-
68
- When we publish a Docker image the generated image is monitored by Snyk, this means that Snyk will search
69
- for all the dependencies and send the list to the Snyk web site to be monitored.
70
- We also do a test of the image and log the result (This will never cause the build to fail).
71
-
72
57
  ## Checks
73
58
 
74
59
  C2C CI utils will no more provide a tool to do a check of the project, this is replaced by `pre-commit`,
@@ -103,21 +88,16 @@ workflow will delete the workflows older than 500 days.
103
88
 
104
89
  C2cciutils make easier to have those workflows in a project:
105
90
 
106
- - `audit.yaml`: Audit the stabilization branches of the application against vulnerabilities in the python and node dependency
107
91
  - `auto-review.yaml`: Auto review the Renovate pull requests
108
92
  - `backport.yaml`: Trigger the backports (work with labels)
109
93
  - `clean.yaml`: Clean the Docker images related on a deleted feature branch
110
94
  - `main.yaml`: Main workflow especially with the c2cciutils-checks command
111
- - `changelog.yaml`: Generate the changelog and create the release on GitHub
112
- - `delete-old-workflows-run.yaml`: Delete the old workflows
113
- - `pr-checks.yaml`: Run the checks on the pull requests
114
95
 
115
96
  All the provided commands used in the workflow:
116
97
 
117
98
  - `c2cciutils`: some generic tools.
118
99
  - `c2cciutils-version`: Create a new version of the project.
119
- - `c2cciutils-checks`: Run the checks on the code (those checks don't need any project dependencies).
120
- - `c2cciutils-audit`: Do the audit, the main difference with checks is that it can change between runs on the same code.
100
+ - `c2cciutils-env`: Print some environment information.
121
101
  - `c2cciutils-publish`: Publish the project.
122
102
  - `c2cciutils-clean`: Delete Docker images on Docker Hub after corresponding branch have been deleted.
123
103
 
@@ -178,7 +158,6 @@ You can override the configuration with the file `ci/config.yaml`.
178
158
  At the base of the configuration you have:
179
159
 
180
160
  - `version`: Contains some regular expressions to find the versions branches and tags, and to convert them into application versions.
181
- - `audit`: The audit configuration, see `c2cciutils/audit.py` for more information.
182
161
  - `publish`: The publishing configuration, see `c2cciutils/publish.py` for more information.
183
162
 
184
163
  Many actions can be disabled by setting the corresponding configuration part to `False`.
@@ -289,7 +268,7 @@ To make it working in the `Dockerfile` you should have in the `poetry` stage:
289
268
 
290
269
  ```Dockerfile
291
270
  ENV POETRY_DYNAMIC_VERSIONING_BYPASS=dev
292
- RUN poetry export --extras=checks --extras=publish --extras=audit --output=requirements.txt \
271
+ RUN poetry export --extras=checks --extras=publish --output=requirements.txt \
293
272
  && poetry export --with=dev --output=requirements-dev.txt
294
273
  ```
295
274
 
@@ -1,23 +1,20 @@
1
- c2cciutils/__init__.py,sha256=4t1pSEN4U7aByo9XncQxboIIfZoKHTGgzAVnEciEk7o,20984
1
+ c2cciutils/__init__.py,sha256=lZwiKWMrGU1VGERI-2zudOp3H2U_qtKBaVYfJyBo6Ks,13371
2
2
  c2cciutils/applications-versions.yaml,sha256=Toxkfq4-WBUh91fKqmo5ntoE-6fPbceePoXMk1grXik,224
3
3
  c2cciutils/applications.yaml,sha256=yn0XRi08cS29A_jXPofcBPxsGBv7PEBliztjRC3WtfM,504
4
4
  c2cciutils/applications_definition.py,sha256=rOEZ3ISl5fUNDrow6H58Immy3KWJtWwGshicVDpnyNA,1321
5
- c2cciutils/audit.py,sha256=1daWHdzQLJzHOu-79eRzDdwBYWG5MurK42raA37KTV0,5572
6
5
  c2cciutils/branches.graphql,sha256=UZrj1RO-H527M1SKqWm1VnkWtNsuKTnPTf4BCU2YcOU,358
7
6
  c2cciutils/commits.graphql,sha256=3HAuIEig5V7j1L-6mqBaOkiTD3Fb8_gl1ilpZjPJf74,308
8
- c2cciutils/configuration.py,sha256=yGv9L9OVAMb1Rnxt4NKf92pLNl7zHnbXeyUgKnhE2Vs,27857
7
+ c2cciutils/configuration.py,sha256=Xa9nBDhN8oRhBGSrKkGvoGK-uhYL9m0xQIAsvhOXwWk,17063
9
8
  c2cciutils/default_branch.graphql,sha256=CaP3rRsNiyg_7RvqbMk0tOJr0aqWd8cOeSV-ZKgvKY4,131
10
9
  c2cciutils/env.py,sha256=fm_cMLKWM1fVvTWph2ikNyUPAaog0Am59DNzU68qkEI,3418
11
10
  c2cciutils/lib/docker.py,sha256=d_YAUGCw2fXil7IaHFPxO3F_D5AWL4zz4gZj7M3fxj8,5675
12
11
  c2cciutils/lib/oidc.py,sha256=VEQT0j31BuIyyUY5vJeUnCWBvS-6Ja9IeXlVx5synQw,6283
13
12
  c2cciutils/package-lock.json,sha256=aLnN3q1ufs_2pn-Zy6_2v8wL09JT8MZzJidxJi8E9Lc,15611
14
13
  c2cciutils/package.json,sha256=A3gItP1CsTXzsMdigeCu3fNeltY08nYVs_LCU4B5PJs,134
15
- c2cciutils/pr_checks.py,sha256=tBwDHxThcu6648pE2cqpLNsaU711lwwgRc7sB4qR6fU,10109
16
- c2cciutils/publish.py,sha256=k-POvs6oUMhkJPgf2PUbaMjGu3SCAYs4xh34cRqXwXE,17276
14
+ c2cciutils/publish.py,sha256=54bQLYV-xSCzCP5UUQa3uh5y58EmYNGoVP7a2dveJiA,17264
17
15
  c2cciutils/schema-applications.json,sha256=Tus-s9NB7uwKhTrQwhWQM4_oJygF_yHUqShtZhN1IxE,1551
18
- c2cciutils/schema.json,sha256=zKRqIjpNg6H2kvuixP64CK5CAJFhyu-_aUEub0_rAqc,22841
16
+ c2cciutils/schema.json,sha256=G0WbvTVn9zdDjilFr28uZqF7zDVADl7uQus12_TVnSs,14559
19
17
  c2cciutils/scripts/__init__.py,sha256=N4tcdvUifXQrK9vEvFWrGvoyY9oZ0uRcjb-FoYe41cc,36
20
- c2cciutils/scripts/audit.py,sha256=MUQqpA8CNkbSyK5e0HiSC5w-4GPKYEqFgV82lIwKkQk,1104
21
18
  c2cciutils/scripts/clean.py,sha256=7_DWG8GjMiUsiv1RDgR_CR65p-aAXa3jEbrS5lYaqDw,3038
22
19
  c2cciutils/scripts/docker_logs.py,sha256=lcOLJzme0NpFQSqoz0cKL8Hqcr_7a3POh0hp8TKAh6A,1715
23
20
  c2cciutils/scripts/docker_versions_gen.py,sha256=yp1I_UqxyIABKxHek3q3UYWh0YR8tqKWzliC2kqZOa0,1315
@@ -28,14 +25,13 @@ c2cciutils/scripts/k8s/db.py,sha256=GK1tzzyCqrCyIJzcBdIXjyNJUXrBPFNa-9fdtwxyrlU,
28
25
  c2cciutils/scripts/k8s/install.py,sha256=OIQ8KHA3Pst2pjO2E-J5FYNaBHW-i-fqCXlAUcG1tw0,933
29
26
  c2cciutils/scripts/k8s/logs.py,sha256=-xJYu8BBUmSmMrPEwiTBKZjJBRyIlMp1depCB04_NWs,2655
30
27
  c2cciutils/scripts/k8s/wait.py,sha256=mZyQbmSwuC2BZuJlfJDjkLSKWXz4WkIkihOjRzdBa6Y,5689
31
- c2cciutils/scripts/main.py,sha256=ZksoYEDRJD0igEU6i0PnuOFtch4OzsxyHZQxbrjd5AY,1029
28
+ c2cciutils/scripts/main.py,sha256=zz9G7VdAb7RtSlN_10nONij-6c6YV2gCu-WzvqZlRC4,797
32
29
  c2cciutils/scripts/pin_pipenv.py,sha256=jBTwlolcEL0MUyq6VYzO-adkcL1gqN7B3kBb3UjTo2k,2150
33
- c2cciutils/scripts/pr_checks.py,sha256=PA9z9QB81H2JhGSr4T02eoxyeWDjQZ4XoIKFzS5o5A0,2190
34
30
  c2cciutils/scripts/publish.py,sha256=K4oR8DlsZh5mRBUpf7Ruf70376cfUKo9-AJnUw9h4Xs,20428
35
31
  c2cciutils/scripts/trigger_image_update.py,sha256=cDNFVXH_t6CE4b-8l9dn6Ivqf0vhEspKaujrUQdOaIQ,2779
36
32
  c2cciutils/scripts/version.py,sha256=BAhoEBr6pz8WJOf4SGSjP9DINIRhw7LVNr2h0aLJDOo,8911
37
- c2cciutils-1.7.0.dev334.dist-info/LICENSE,sha256=EMCYfDu0AgsMQO6k8Hl_xHzoFxM0db1xu9n_asZW9Vc,1307
38
- c2cciutils-1.7.0.dev334.dist-info/METADATA,sha256=f08LeftPSfDck0GdN-JDADhxAIwR-FgVCNC3oIZ2Th0,19200
39
- c2cciutils-1.7.0.dev334.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
40
- c2cciutils-1.7.0.dev334.dist-info/entry_points.txt,sha256=jPDp7KeB0Fz_TpOwbOODeW2WEcdLNJZACPtKpRqtHs4,1030
41
- c2cciutils-1.7.0.dev334.dist-info/RECORD,,
33
+ c2cciutils-1.7.0.dev338.dist-info/LICENSE,sha256=EMCYfDu0AgsMQO6k8Hl_xHzoFxM0db1xu9n_asZW9Vc,1307
34
+ c2cciutils-1.7.0.dev338.dist-info/METADATA,sha256=5nrvGu0PCKbTmOhUPM5QJUnUoOEoudd4h_yTu3c3Yrk,17802
35
+ c2cciutils-1.7.0.dev338.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
36
+ c2cciutils-1.7.0.dev338.dist-info/entry_points.txt,sha256=54llpn1q67tS78NbLwA8rwSDWnEQ6aE3FaqMN0ctNN8,918
37
+ c2cciutils-1.7.0.dev338.dist-info/RECORD,,
@@ -1,6 +1,5 @@
1
1
  [console_scripts]
2
2
  c2cciutils=c2cciutils.scripts.main:main
3
- c2cciutils-audit=c2cciutils.scripts.audit:main
4
3
  c2cciutils-checks=c2cciutils.scripts.env:main
5
4
  c2cciutils-clean=c2cciutils.scripts.clean:main
6
5
  c2cciutils-docker-logs=c2cciutils.scripts.docker_logs:main
@@ -14,7 +13,6 @@ c2cciutils-k8s-logs=c2cciutils.scripts.k8s.logs:main
14
13
  c2cciutils-k8s-wait=c2cciutils.scripts.k8s.wait:main
15
14
  c2cciutils-pin-pipenv=c2cciutils.scripts.pin_pipenv:main
16
15
  c2cciutils-publish=c2cciutils.scripts.publish:main
17
- c2cciutils-pull-request-checks=c2cciutils.scripts.pr_checks:main
18
16
  c2cciutils-trigger-image-update=c2cciutils.scripts.trigger_image_update:main
19
17
  c2cciutils-version=c2cciutils.scripts.version:main
20
18
 
c2cciutils/audit.py DELETED
@@ -1,175 +0,0 @@
1
- """
2
- The auditing functions.
3
- """
4
-
5
- import os.path
6
- import subprocess # nosec
7
- import sys
8
- from argparse import Namespace
9
-
10
- import c2cciutils
11
- import c2cciutils.configuration
12
-
13
-
14
- def print_versions(
15
- config: c2cciutils.configuration.PrintVersions,
16
- full_config: c2cciutils.configuration.Configuration,
17
- args: Namespace,
18
- ) -> bool:
19
- """
20
- Print the versions.
21
-
22
- Arguments:
23
- config: The audit section config
24
- full_config: All the CI config
25
- args: The parsed command arguments
26
- """
27
- del full_config, args
28
-
29
- print("::group::Versions")
30
- c2cciutils.print_versions(config)
31
- print("::endgroup::")
32
-
33
- return True
34
-
35
-
36
- def snyk(
37
- config: c2cciutils.configuration.AuditSnykConfig,
38
- full_config: c2cciutils.configuration.Configuration,
39
- args: Namespace,
40
- ) -> bool:
41
- """
42
- Audit the code with Snyk.
43
- """
44
- del full_config
45
-
46
- one_done = False
47
- install_success = True
48
- test_success = True
49
-
50
- for file in (
51
- subprocess.run(
52
- ["git", "ls-files", "requirements.txt", "*/requirements.txt"], stdout=subprocess.PIPE, check=True
53
- )
54
- .stdout.decode()
55
- .strip()
56
- .split("\n")
57
- ):
58
- if not file:
59
- continue
60
- if file in config.get(
61
- "files_no_install", c2cciutils.configuration.AUDIT_SNYK_FILES_NO_INSTALL_DEFAULT
62
- ):
63
- continue
64
- print(f"::notice::Install from: {file}")
65
- if not one_done:
66
- print("::group::Install dependencies")
67
- one_done = True
68
- sys.stdout.flush()
69
- sys.stderr.flush()
70
- proc = subprocess.run( # pylint: disable=subprocess-run-check
71
- [
72
- "pip",
73
- "install",
74
- *config.get(
75
- "pip_install_arguments", c2cciutils.configuration.AUDIT_SNYK_PIP_INSTALL_ARGUMENTS_DEFAULT
76
- ),
77
- f"--requirement={file}",
78
- ]
79
- )
80
- if proc.returncode != 0:
81
- print(f"::error::With error from: {file}")
82
- install_success &= proc.returncode == 0
83
-
84
- for file in (
85
- subprocess.run(["git", "ls-files", "Pipfile", "*/Pipfile"], stdout=subprocess.PIPE, check=True)
86
- .stdout.decode()
87
- .strip()
88
- .split("\n")
89
- ):
90
- if not file:
91
- continue
92
- if file in config.get(
93
- "files_no_install", c2cciutils.configuration.AUDIT_SNYK_FILES_NO_INSTALL_DEFAULT
94
- ):
95
- continue
96
- if not one_done:
97
- print("::group::Install dependencies")
98
- one_done = True
99
- print(f"::notice::Install from: {file}")
100
- directory = os.path.dirname(os.path.abspath(file))
101
-
102
- sys.stdout.flush()
103
- sys.stderr.flush()
104
- proc = subprocess.run( # pylint: disable=subprocess-run-check
105
- [
106
- "pipenv",
107
- "sync",
108
- *config.get(
109
- "pipenv_sync_arguments", c2cciutils.configuration.AUDIT_SNYK_PIPENV_SYNC_ARGUMENTS_DEFAULT
110
- ),
111
- ],
112
- cwd=directory,
113
- )
114
- if proc.returncode != 0:
115
- print(f"::error::With error from: {file}")
116
- install_success &= proc.returncode == 0
117
-
118
- if one_done:
119
- print("::endgroup::")
120
- if not install_success:
121
- print("::error::Error while installing the dependencies")
122
-
123
- snyk_exec, env = c2cciutils.snyk_exec()
124
- if not args.fix:
125
- command = [snyk_exec, "monitor", f"--target-reference={args.branch}"] + config.get(
126
- "monitor_arguments", c2cciutils.configuration.AUDIT_SNYK_MONITOR_ARGUMENTS_DEFAULT
127
- )
128
- print(f"::group::Run: {' '.join(command)}")
129
- sys.stdout.flush()
130
- sys.stderr.flush()
131
- subprocess.run(command, env=env) # pylint: disable=subprocess-run-check
132
- print("::endgroup::")
133
-
134
- command = [snyk_exec, "test"] + config.get(
135
- "test_arguments", c2cciutils.configuration.AUDIT_SNYK_TEST_ARGUMENTS_DEFAULT
136
- )
137
- print(f"::group::Run: {' '.join(command)}")
138
- sys.stdout.flush()
139
- sys.stderr.flush()
140
- test_proc = subprocess.run(command, env=env) # pylint: disable=subprocess-run-check
141
- print("::endgroup::")
142
- if test_proc.returncode != 0:
143
- test_success = False
144
- print("::error::With error")
145
-
146
- # Clean all the changes to isolate the fix diff
147
- subprocess.run(["git", "reset", "--hard"], check=True)
148
-
149
- command = [snyk_exec, "fix"] + config.get(
150
- "fix_arguments", c2cciutils.configuration.AUDIT_SNYK_FIX_ARGUMENTS_DEFAULT
151
- )
152
- print(f"::group::Run: {' '.join(command)}")
153
- sys.stdout.flush()
154
- sys.stderr.flush()
155
- snyk_fix_proc = subprocess.run( # pylint: disable=subprocess-run-check
156
- command, env={**env, "FORCE_COLOR": "false"}, stdout=subprocess.PIPE, encoding="utf-8"
157
- )
158
- snyk_fix_message = snyk_fix_proc.stdout.strip()
159
- print("::endgroup::")
160
-
161
- has_diff = False
162
- if not args.fix:
163
- current_branch = c2cciutils.get_branch(args.branch)
164
- fix_github_create_pull_request_arguments = config.get(
165
- "fix_github_create_pull_request_arguments",
166
- c2cciutils.configuration.AUDIT_SNYK_FIX_PULL_REQUEST_ARGUMENTS_DEFAULT,
167
- )
168
- has_diff = c2cciutils.create_pull_request_if_needed(
169
- current_branch,
170
- f"snyk-fix/{current_branch}",
171
- "Snyk auto fix",
172
- [f"--body={snyk_fix_message}", *fix_github_create_pull_request_arguments],
173
- )
174
-
175
- return install_success and test_success and not has_diff