@capraconsulting/cals-cli 3.1.1 → 3.2.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/lib/cals-cli.js +56 -19
- package/lib/cals-cli.js.map +1 -1
- package/lib/index.es.js +55 -18
- package/lib/index.es.js.map +1 -1
- package/lib/index.js +55 -18
- package/lib/index.js.map +1 -1
- package/lib/snyk/types.d.ts +36 -0
- package/package.json +1 -1
package/lib/cals-cli.js
CHANGED
|
@@ -68,7 +68,7 @@ var read__default = /*#__PURE__*/_interopDefaultLegacy(read);
|
|
|
68
68
|
var findUp__default = /*#__PURE__*/_interopDefaultLegacy(findUp);
|
|
69
69
|
var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
|
|
70
70
|
|
|
71
|
-
var version = "3.
|
|
71
|
+
var version = "3.2.0";
|
|
72
72
|
var engines = {
|
|
73
73
|
node: ">=12.0.0"
|
|
74
74
|
};
|
|
@@ -1124,23 +1124,60 @@ class SnykService {
|
|
|
1124
1124
|
if (token === undefined) {
|
|
1125
1125
|
throw new Error("Missing token for Snyk");
|
|
1126
1126
|
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1127
|
+
let backportedProjects = [];
|
|
1128
|
+
const snykRestApiVersion = "2023-08-04";
|
|
1129
|
+
let nextUrl = `/orgs/${encodeURIComponent(snykAccountId)}/projects?version=${snykRestApiVersion}&meta.latest_dependency_total=true&meta.latest_issue_counts=true&limit=100`;
|
|
1130
|
+
/* The Snyk REST API only allows us to retrieve 100 projects at a time.
|
|
1131
|
+
* The "links.next" value in the response gives us a pointer to the next 100 results.
|
|
1132
|
+
* We continue calling the Snyk API and retrieving more projects until links.next is null
|
|
1133
|
+
* */
|
|
1134
|
+
while (nextUrl) {
|
|
1135
|
+
const response = await fetch__default["default"](`https://api.snyk.io/rest${nextUrl}`, {
|
|
1136
|
+
method: "GET",
|
|
1137
|
+
headers: {
|
|
1138
|
+
Accept: "application/json",
|
|
1139
|
+
Authorization: `token ${token}`,
|
|
1140
|
+
},
|
|
1141
|
+
agent: this.config.agent,
|
|
1142
|
+
});
|
|
1143
|
+
if (response.status === 401) {
|
|
1144
|
+
process.stderr.write("Unauthorized - removing token\n");
|
|
1145
|
+
await this.tokenProvider.markInvalid();
|
|
1146
|
+
}
|
|
1147
|
+
if (!response.ok) {
|
|
1148
|
+
throw new Error(`Response from Snyk not OK (${response.status}): ${JSON.stringify(response)}`);
|
|
1149
|
+
}
|
|
1150
|
+
// Check if the Sunset header is present in the response
|
|
1151
|
+
const sunsetHeader = response.headers.get("Sunset") || response.headers.get("sunset");
|
|
1152
|
+
if (sunsetHeader) {
|
|
1153
|
+
console.warn(`Snyk endpoint with version ${snykRestApiVersion} has been marked as deprecated with deprecation date ${sunsetHeader}`);
|
|
1154
|
+
}
|
|
1155
|
+
const jsonResponse = (await response.json());
|
|
1156
|
+
/* We transform the data to a standard format that we used for data from Snyk API v1 in order for
|
|
1157
|
+
the data to be backover compatible with existing consuments */
|
|
1158
|
+
backportedProjects = [
|
|
1159
|
+
...backportedProjects,
|
|
1160
|
+
...jsonResponse.data.map((project) => {
|
|
1161
|
+
return {
|
|
1162
|
+
id: project.id,
|
|
1163
|
+
name: project.attributes.name,
|
|
1164
|
+
type: project.attributes.type,
|
|
1165
|
+
created: project.attributes.created,
|
|
1166
|
+
origin: project.attributes.origin,
|
|
1167
|
+
testFrequency: project.attributes.settings.recurring_tests.frequency,
|
|
1168
|
+
isMonitored: project.attributes.status === "active",
|
|
1169
|
+
totalDependencies: project.meta.latest_dependency_total.total,
|
|
1170
|
+
issueCountsBySeverity: project.meta.latest_issue_counts,
|
|
1171
|
+
lastTestedDate: project.meta.latest_dependency_total.updated_at,
|
|
1172
|
+
browseUrl: `https://app.snyk.io/org/${snykAccountId}/project/${project.id}`,
|
|
1173
|
+
};
|
|
1174
|
+
}),
|
|
1175
|
+
];
|
|
1176
|
+
/* Update nextUrl with pointer to the next page of results based
|
|
1177
|
+
* on the "links.next" field in the JSON response */
|
|
1178
|
+
nextUrl = jsonResponse.links.next;
|
|
1179
|
+
}
|
|
1180
|
+
return backportedProjects;
|
|
1144
1181
|
}
|
|
1145
1182
|
}
|
|
1146
1183
|
function createSnykService(props) {
|
|
@@ -3365,7 +3402,7 @@ async function main() {
|
|
|
3365
3402
|
/ /___/ ___ |/ /______/ /
|
|
3366
3403
|
\\____/_/ |_/_____/____/
|
|
3367
3404
|
cli ${version}
|
|
3368
|
-
built ${"2023-
|
|
3405
|
+
built ${"2023-08-21T11:00:37+0000"}
|
|
3369
3406
|
|
|
3370
3407
|
https://github.com/capralifecycle/cals-cli/
|
|
3371
3408
|
|
package/lib/cals-cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cals-cli.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cals-cli.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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lib/index.es.js
CHANGED
|
@@ -23,7 +23,7 @@ import { strict } from 'assert';
|
|
|
23
23
|
import execa from 'execa';
|
|
24
24
|
import { Transform } from 'stream';
|
|
25
25
|
|
|
26
|
-
var version = "3.
|
|
26
|
+
var version = "3.2.0";
|
|
27
27
|
|
|
28
28
|
class CacheProvider {
|
|
29
29
|
constructor(config) {
|
|
@@ -1471,23 +1471,60 @@ class SnykService {
|
|
|
1471
1471
|
if (token === undefined) {
|
|
1472
1472
|
throw new Error("Missing token for Snyk");
|
|
1473
1473
|
}
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1474
|
+
let backportedProjects = [];
|
|
1475
|
+
const snykRestApiVersion = "2023-08-04";
|
|
1476
|
+
let nextUrl = `/orgs/${encodeURIComponent(snykAccountId)}/projects?version=${snykRestApiVersion}&meta.latest_dependency_total=true&meta.latest_issue_counts=true&limit=100`;
|
|
1477
|
+
/* The Snyk REST API only allows us to retrieve 100 projects at a time.
|
|
1478
|
+
* The "links.next" value in the response gives us a pointer to the next 100 results.
|
|
1479
|
+
* We continue calling the Snyk API and retrieving more projects until links.next is null
|
|
1480
|
+
* */
|
|
1481
|
+
while (nextUrl) {
|
|
1482
|
+
const response = await fetch(`https://api.snyk.io/rest${nextUrl}`, {
|
|
1483
|
+
method: "GET",
|
|
1484
|
+
headers: {
|
|
1485
|
+
Accept: "application/json",
|
|
1486
|
+
Authorization: `token ${token}`,
|
|
1487
|
+
},
|
|
1488
|
+
agent: this.config.agent,
|
|
1489
|
+
});
|
|
1490
|
+
if (response.status === 401) {
|
|
1491
|
+
process.stderr.write("Unauthorized - removing token\n");
|
|
1492
|
+
await this.tokenProvider.markInvalid();
|
|
1493
|
+
}
|
|
1494
|
+
if (!response.ok) {
|
|
1495
|
+
throw new Error(`Response from Snyk not OK (${response.status}): ${JSON.stringify(response)}`);
|
|
1496
|
+
}
|
|
1497
|
+
// Check if the Sunset header is present in the response
|
|
1498
|
+
const sunsetHeader = response.headers.get("Sunset") || response.headers.get("sunset");
|
|
1499
|
+
if (sunsetHeader) {
|
|
1500
|
+
console.warn(`Snyk endpoint with version ${snykRestApiVersion} has been marked as deprecated with deprecation date ${sunsetHeader}`);
|
|
1501
|
+
}
|
|
1502
|
+
const jsonResponse = (await response.json());
|
|
1503
|
+
/* We transform the data to a standard format that we used for data from Snyk API v1 in order for
|
|
1504
|
+
the data to be backover compatible with existing consuments */
|
|
1505
|
+
backportedProjects = [
|
|
1506
|
+
...backportedProjects,
|
|
1507
|
+
...jsonResponse.data.map((project) => {
|
|
1508
|
+
return {
|
|
1509
|
+
id: project.id,
|
|
1510
|
+
name: project.attributes.name,
|
|
1511
|
+
type: project.attributes.type,
|
|
1512
|
+
created: project.attributes.created,
|
|
1513
|
+
origin: project.attributes.origin,
|
|
1514
|
+
testFrequency: project.attributes.settings.recurring_tests.frequency,
|
|
1515
|
+
isMonitored: project.attributes.status === "active",
|
|
1516
|
+
totalDependencies: project.meta.latest_dependency_total.total,
|
|
1517
|
+
issueCountsBySeverity: project.meta.latest_issue_counts,
|
|
1518
|
+
lastTestedDate: project.meta.latest_dependency_total.updated_at,
|
|
1519
|
+
browseUrl: `https://app.snyk.io/org/${snykAccountId}/project/${project.id}`,
|
|
1520
|
+
};
|
|
1521
|
+
}),
|
|
1522
|
+
];
|
|
1523
|
+
/* Update nextUrl with pointer to the next page of results based
|
|
1524
|
+
* on the "links.next" field in the JSON response */
|
|
1525
|
+
nextUrl = jsonResponse.links.next;
|
|
1526
|
+
}
|
|
1527
|
+
return backportedProjects;
|
|
1491
1528
|
}
|
|
1492
1529
|
}
|
|
1493
1530
|
function createSnykService(props) {
|
package/lib/index.es.js.map
CHANGED
|
@@ -1 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/lib/index.js
CHANGED
|
@@ -64,7 +64,7 @@ var process__namespace = /*#__PURE__*/_interopNamespace(process$1);
|
|
|
64
64
|
var read__default = /*#__PURE__*/_interopDefaultLegacy(read);
|
|
65
65
|
var execa__default = /*#__PURE__*/_interopDefaultLegacy(execa);
|
|
66
66
|
|
|
67
|
-
var version = "3.
|
|
67
|
+
var version = "3.2.0";
|
|
68
68
|
|
|
69
69
|
class CacheProvider {
|
|
70
70
|
constructor(config) {
|
|
@@ -1512,23 +1512,60 @@ class SnykService {
|
|
|
1512
1512
|
if (token === undefined) {
|
|
1513
1513
|
throw new Error("Missing token for Snyk");
|
|
1514
1514
|
}
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1515
|
+
let backportedProjects = [];
|
|
1516
|
+
const snykRestApiVersion = "2023-08-04";
|
|
1517
|
+
let nextUrl = `/orgs/${encodeURIComponent(snykAccountId)}/projects?version=${snykRestApiVersion}&meta.latest_dependency_total=true&meta.latest_issue_counts=true&limit=100`;
|
|
1518
|
+
/* The Snyk REST API only allows us to retrieve 100 projects at a time.
|
|
1519
|
+
* The "links.next" value in the response gives us a pointer to the next 100 results.
|
|
1520
|
+
* We continue calling the Snyk API and retrieving more projects until links.next is null
|
|
1521
|
+
* */
|
|
1522
|
+
while (nextUrl) {
|
|
1523
|
+
const response = await fetch__default["default"](`https://api.snyk.io/rest${nextUrl}`, {
|
|
1524
|
+
method: "GET",
|
|
1525
|
+
headers: {
|
|
1526
|
+
Accept: "application/json",
|
|
1527
|
+
Authorization: `token ${token}`,
|
|
1528
|
+
},
|
|
1529
|
+
agent: this.config.agent,
|
|
1530
|
+
});
|
|
1531
|
+
if (response.status === 401) {
|
|
1532
|
+
process.stderr.write("Unauthorized - removing token\n");
|
|
1533
|
+
await this.tokenProvider.markInvalid();
|
|
1534
|
+
}
|
|
1535
|
+
if (!response.ok) {
|
|
1536
|
+
throw new Error(`Response from Snyk not OK (${response.status}): ${JSON.stringify(response)}`);
|
|
1537
|
+
}
|
|
1538
|
+
// Check if the Sunset header is present in the response
|
|
1539
|
+
const sunsetHeader = response.headers.get("Sunset") || response.headers.get("sunset");
|
|
1540
|
+
if (sunsetHeader) {
|
|
1541
|
+
console.warn(`Snyk endpoint with version ${snykRestApiVersion} has been marked as deprecated with deprecation date ${sunsetHeader}`);
|
|
1542
|
+
}
|
|
1543
|
+
const jsonResponse = (await response.json());
|
|
1544
|
+
/* We transform the data to a standard format that we used for data from Snyk API v1 in order for
|
|
1545
|
+
the data to be backover compatible with existing consuments */
|
|
1546
|
+
backportedProjects = [
|
|
1547
|
+
...backportedProjects,
|
|
1548
|
+
...jsonResponse.data.map((project) => {
|
|
1549
|
+
return {
|
|
1550
|
+
id: project.id,
|
|
1551
|
+
name: project.attributes.name,
|
|
1552
|
+
type: project.attributes.type,
|
|
1553
|
+
created: project.attributes.created,
|
|
1554
|
+
origin: project.attributes.origin,
|
|
1555
|
+
testFrequency: project.attributes.settings.recurring_tests.frequency,
|
|
1556
|
+
isMonitored: project.attributes.status === "active",
|
|
1557
|
+
totalDependencies: project.meta.latest_dependency_total.total,
|
|
1558
|
+
issueCountsBySeverity: project.meta.latest_issue_counts,
|
|
1559
|
+
lastTestedDate: project.meta.latest_dependency_total.updated_at,
|
|
1560
|
+
browseUrl: `https://app.snyk.io/org/${snykAccountId}/project/${project.id}`,
|
|
1561
|
+
};
|
|
1562
|
+
}),
|
|
1563
|
+
];
|
|
1564
|
+
/* Update nextUrl with pointer to the next page of results based
|
|
1565
|
+
* on the "links.next" field in the JSON response */
|
|
1566
|
+
nextUrl = jsonResponse.links.next;
|
|
1567
|
+
}
|
|
1568
|
+
return backportedProjects;
|
|
1532
1569
|
}
|
|
1533
1570
|
}
|
|
1534
1571
|
function createSnykService(props) {
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/lib/snyk/types.d.ts
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
export interface ProjectResponse {
|
|
2
|
+
data: RestAPIProject[];
|
|
3
|
+
links: {
|
|
4
|
+
next?: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export interface RestAPIProject {
|
|
8
|
+
id: string;
|
|
9
|
+
attributes: {
|
|
10
|
+
name: string;
|
|
11
|
+
type: string;
|
|
12
|
+
origin: string;
|
|
13
|
+
created: string;
|
|
14
|
+
status: string;
|
|
15
|
+
settings: {
|
|
16
|
+
recurring_tests: {
|
|
17
|
+
frequency: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
status: boolean;
|
|
22
|
+
meta: {
|
|
23
|
+
latest_dependency_total: {
|
|
24
|
+
updated_at: string;
|
|
25
|
+
total: number;
|
|
26
|
+
};
|
|
27
|
+
latest_issue_counts: {
|
|
28
|
+
critical?: number;
|
|
29
|
+
high: number;
|
|
30
|
+
medium: number;
|
|
31
|
+
low: number;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Type represents format of responses from the deprecated List all projects v1 API
|
|
36
|
+
https://snyk.docs.apiary.io/#reference/projects/all-projects/list-all-projects **/
|
|
1
37
|
export interface SnykProject {
|
|
2
38
|
name: string;
|
|
3
39
|
id: string;
|