@ckeditor/ckeditor5-dev-ci 54.5.0 → 54.6.0

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.
package/README.md CHANGED
@@ -129,6 +129,25 @@ These commands accept a mix of environment variables and command line arguments.
129
129
  Can be omitted if it matches `--slug`.
130
130
  - `--release-branch` — *(Optional)* Branch that leads the release process.
131
131
 
132
+ - ⚙️ **`ckeditor5-dev-ci-trigger-snyk-scan`**
133
+
134
+ Publishes Snyk code and dependency snapshots for the current branch.
135
+ It configures the Snyk CLI to use the EU endpoint and the provided organization, then runs `snyk code test --report` and `snyk monitor --all-projects --detection-depth=2`.
136
+
137
+ **Environment variables:**
138
+ - `SNYK_TOKEN` — Snyk token used for authentication.
139
+
140
+ **CircleCI-provided variables:**
141
+ - `CIRCLE_BRANCH` — Git branch used as Snyk's `target-reference`.
142
+
143
+ **Parameters:**
144
+ - `--organization` — Snyk organization ID or slug.
145
+
146
+ **Behavior:**
147
+ - Limits dependency snapshot detection to the repository root and `packages/*`, so test fixtures and deeper nested manifests are ignored.
148
+ - Accepts exit code `1` from `snyk code test --report`, so code snapshots are still published when vulnerabilities are found.
149
+ - Requires exit code `0` from `snyk monitor --all-projects`, because any other code means the dependency snapshot was not created.
150
+
132
151
  ## Changelog
133
152
 
134
153
  See the [`CHANGELOG.md`](https://github.com/ckeditor/ckeditor5-dev/blob/master/packages/ckeditor5-dev-ci/CHANGELOG.md) file.
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
5
+ * For licensing, see LICENSE.md.
6
+ */
7
+
8
+ import { parseArgs } from 'node:util';
9
+ import runSnykCommand from '../lib/run-snyk-command.js';
10
+
11
+ const SNYK_ENDPOINT = 'https://api.eu.snyk.io';
12
+
13
+ try {
14
+ const { CIRCLE_BRANCH, SNYK_TOKEN } = process.env;
15
+
16
+ const { values } = parseArgs( {
17
+ options: {
18
+ organization: {
19
+ type: 'string'
20
+ }
21
+ },
22
+ strict: true
23
+ } );
24
+
25
+ if ( !values.organization ) {
26
+ throw new Error( 'Missing required argument: --organization' );
27
+ }
28
+
29
+ if ( !SNYK_TOKEN ) {
30
+ throw new Error( 'Missing environment variable: SNYK_TOKEN' );
31
+ }
32
+
33
+ if ( !CIRCLE_BRANCH ) {
34
+ throw new Error( 'Missing environment variable: CIRCLE_BRANCH' );
35
+ }
36
+
37
+ await runSnykCommand( [ 'config', 'set', `endpoint=${ SNYK_ENDPOINT }` ] );
38
+ await runSnykCommand( [ 'config', 'set', `org=${ values.organization }` ] );
39
+
40
+ await runSnykCommand(
41
+ [
42
+ 'code',
43
+ 'test',
44
+ '--report',
45
+ '--project-name=Code analysis',
46
+ `--target-reference=${ CIRCLE_BRANCH }`
47
+ ],
48
+
49
+ /**
50
+ * Snyk CLI returns exit code 1 when vulnerabilities are found. Since we want to publish
51
+ * the snapshot even if there are some vulnerabilities, we need to allow exit code 1.
52
+ */
53
+ [ 0, 1 ]
54
+ );
55
+
56
+ await runSnykCommand(
57
+ [
58
+ 'monitor',
59
+ '--all-projects',
60
+ '--detection-depth=2',
61
+ `--target-reference=${ CIRCLE_BRANCH }`
62
+ ],
63
+
64
+ /**
65
+ * Unlike `snyk code test --report`, `snyk monitor` reports a successful snapshot upload
66
+ * only with exit code 0. Any other exit code means the dependency snapshot was not created.
67
+ */
68
+ [ 0 ]
69
+ );
70
+ } catch ( error ) {
71
+ console.error( error );
72
+ process.exitCode = 1;
73
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md.
4
+ */
5
+
6
+ import { spawn } from 'node:child_process';
7
+
8
+ /**
9
+ * Runs the Snyk CLI through `pnpm exec` and resolves only for explicitly allowed exit codes.
10
+ * This lets callers tolerate Snyk's non-zero "findings present" codes when a snapshot should still be published.
11
+ *
12
+ * @param {Array<string>} snykArguments CLI arguments passed to `snyk`.
13
+ * @param {Array<number>} [allowedExitCodes=[ 0 ]] Exit codes treated as successful.
14
+ * @returns {Promise<void>}
15
+ */
16
+ export default function runSnykCommand( snykArguments, allowedExitCodes = [ 0 ] ) {
17
+ return new Promise( ( resolve, reject ) => {
18
+ const childProcess = spawn( 'pnpm', [ '--silent', 'exec', 'snyk', ...snykArguments ], {
19
+ cwd: process.cwd(),
20
+ stdio: 'inherit'
21
+ } );
22
+
23
+ childProcess.on( 'error', reject );
24
+ childProcess.on( 'close', exitCode => {
25
+ if ( allowedExitCodes.includes( exitCode ) ) {
26
+ resolve();
27
+
28
+ return;
29
+ }
30
+
31
+ reject( new Error( `Snyk command failed with exit code ${ exitCode }.` ) );
32
+ } );
33
+ } );
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-dev-ci",
3
- "version": "54.5.0",
3
+ "version": "54.6.0",
4
4
  "description": "Utils used on various Continuous Integration services.",
5
5
  "keywords": [],
6
6
  "author": "CKSource (http://cksource.com/)",
@@ -23,16 +23,18 @@
23
23
  "lib"
24
24
  ],
25
25
  "bin": {
26
- "ckeditor5-dev-ci-notify-circle-status": "bin/notify-circle-status.js",
26
+ "ckeditor5-dev-ci-circle-enable-auto-cancel-builds": "bin/circle-enable-auto-cancel-builds.js",
27
+ "ckeditor5-dev-ci-circle-disable-auto-cancel-builds": "bin/circle-disable-auto-cancel-builds.js",
27
28
  "ckeditor5-dev-ci-circle-workflow-notifier": "bin/circle-workflow-notifier.js",
28
29
  "ckeditor5-dev-ci-is-job-triggered-by-member": "bin/is-job-triggered-by-member.js",
29
30
  "ckeditor5-dev-ci-is-workflow-restarted": "bin/is-workflow-restarted.js",
31
+ "ckeditor5-dev-ci-notify-circle-status": "bin/notify-circle-status.js",
30
32
  "ckeditor5-dev-ci-trigger-circle-build": "bin/trigger-circle-build.js",
31
- "ckeditor5-dev-ci-circle-disable-auto-cancel-builds": "bin/circle-disable-auto-cancel-builds.js",
32
- "ckeditor5-dev-ci-circle-enable-auto-cancel-builds": "bin/circle-enable-auto-cancel-builds.js"
33
+ "ckeditor5-dev-ci-trigger-snyk-scan": "bin/trigger-snyk-scan.js"
33
34
  },
34
35
  "dependencies": {
35
36
  "@octokit/rest": "^22.0.0",
36
- "slack-notify": "^2.0.6"
37
+ "slack-notify": "^2.0.6",
38
+ "snyk": "^1.1303.1"
37
39
  }
38
40
  }