@eui/tools 6.3.17 → 6.3.19

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.
@@ -1 +1 @@
1
- 6.3.17
1
+ 6.3.19
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 6.3.19 (2023-02-06)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * add dependencies gates for v15.x - updated resolutions and yarn.lock for 14.x - EUI-6844 [EUI-6844](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-6844) ([cb2762ec](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/cb2762ec53a6abe437fc845879c4bf9490e2db60))
7
+
8
+ * * *
9
+ * * *
10
+ ## 6.3.18 (2023-02-06)
11
+
12
+ ##### Bug Fixes
13
+
14
+ * **other:**
15
+ * wrong function call - MWP-9204 [MWP-9204](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-9204) ([79ee451a](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/79ee451adedd0ed360757061ea79dee90fb6ade4))
16
+
17
+ * * *
18
+ * * *
1
19
  ## 6.3.17 (2023-02-06)
2
20
 
3
21
  ##### Chores
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "6.3.17",
3
+ "version": "6.3.19",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
package/sandbox.js CHANGED
@@ -1057,8 +1057,8 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
1057
1057
  // return injectionUtils.routesReplacement.buildRoutes(project, 'TST', true);
1058
1058
  // })
1059
1059
 
1060
- Promise.resolve()
1061
- .then(() => {
1060
+ // Promise.resolve()
1061
+ // .then(() => {
1062
1062
  // const prjName = 'my-workplace-host';
1063
1063
  // const prj = configUtils.projects.getCsdrProject(prjName);
1064
1064
 
@@ -1071,45 +1071,65 @@ Promise.resolve()
1071
1071
  // }
1072
1072
  // console.log(pkg);
1073
1073
 
1074
- const f = {
1075
- name: 'sedia-ecs-eui10-remote-el-ui',
1076
- version: '1.1.0',
1077
- date: '20230111-11:43',
1078
- npmPkg: '@sedia/ecs-eui10-remote-el',
1079
- duration: 463832,
1080
- envTarget: 'TST',
1081
- dependencies: {
1082
- '@eui/deps-base': '10.6.14',
1083
- '@csdr/core': '2.3.13',
1084
- '@csdr/integration': '2.0.46',
1085
- '@ecs/global': '4.0.3',
1086
- '@ecs/person-data': '4.0.3'
1087
- }
1088
- };
1089
- const t = {
1090
- name: 'sedia-ecs-eui10-remote-el-ui',
1091
- version: '1.5.0',
1092
- date: '20230202-09:41',
1093
- npmPkg: '@sedia/ecs-eui10-remote-el',
1094
- duration: 356556,
1095
- envTarget: 'TST',
1096
- dependencies: {
1097
- '@eui/deps-base': '10.6.16',
1098
- '@csdr/core': '2.3.13',
1099
- '@csdr/integration': '2.0.46',
1100
- '@ecs/global': '4.0.4',
1101
- '@ecs/person-data': '4.0.4'
1102
- }
1103
- };
1104
- return metadataUtils.packageHistory.getDiffBetweenBuildVersions(null, f, t);
1105
- })
1074
+ // const f = {
1075
+ // name: 'sedia-ecs-eui10-remote-el-ui',
1076
+ // version: '1.1.0',
1077
+ // date: '20230111-11:43',
1078
+ // npmPkg: '@sedia/ecs-eui10-remote-el',
1079
+ // duration: 463832,
1080
+ // envTarget: 'TST',
1081
+ // dependencies: {
1082
+ // '@eui/deps-base': '10.6.14',
1083
+ // '@csdr/core': '2.3.13',
1084
+ // '@csdr/integration': '2.0.46',
1085
+ // '@ecs/global': '4.0.3',
1086
+ // '@ecs/person-data': '4.0.3'
1087
+ // }
1088
+ // };
1089
+ // const t = {
1090
+ // name: 'sedia-ecs-eui10-remote-el-ui',
1091
+ // version: '1.5.0',
1092
+ // date: '20230202-09:41',
1093
+ // npmPkg: '@sedia/ecs-eui10-remote-el',
1094
+ // duration: 356556,
1095
+ // envTarget: 'TST',
1096
+ // dependencies: {
1097
+ // '@eui/deps-base': '10.6.16',
1098
+ // '@csdr/core': '2.3.13',
1099
+ // '@csdr/integration': '2.0.46',
1100
+ // '@ecs/global': '4.0.4',
1101
+ // '@ecs/person-data': '4.0.4'
1102
+ // }
1103
+ // };
1104
+ // return metadataUtils.packageHistory.getDiffBetweenBuildVersions(null, f, t);
1105
+ // })
1106
1106
 
1107
- .then((diffMetadata) => {
1108
- console.log(diffMetadata);
1107
+ // .then((diffMetadata) => {
1108
+ // console.log(diffMetadata);
1109
+
1110
+ // return metadataUtils.packageHistory.flattenDiffMetadata(diffMetadata);
1111
+ // })
1112
+
1113
+ // .then((flatDiffMetadata) => {
1114
+ // console.log(flatDiffMetadata);
1115
+ // })
1109
1116
 
1110
- return metadataUtils.packageHistory.flattenDiffMetadata(diffMetadata);
1111
- })
1112
1117
 
1113
- .then((flatDiffMetadata) => {
1114
- console.log(flatDiffMetadata);
1118
+ Promise.resolve()
1119
+ .then(() => {
1120
+ return auditUtils.yarn.audit(null);
1121
+ })
1122
+ .catch((e) => {
1123
+ console.log(e);
1115
1124
  })
1125
+
1126
+ // Promise.resolve()
1127
+ // .then(() => {
1128
+ // const prjName = 'my-workplace-host';
1129
+ // const project = configUtils.projects.getCsdrProject(prjName);
1130
+ // // console.log(project);
1131
+ // return preBuildUtils.projects.processCustomEnvScriptInjection(project, "dev");
1132
+ // })
1133
+ // .catch((e) => {
1134
+ // console.log(e);
1135
+ // })
@@ -7,6 +7,8 @@ const execa = require('execa');
7
7
  // LOCAL
8
8
  const tools = require('../../utils/tools');
9
9
  const notificationUtils = require('../../utils/notification/notification-utils');
10
+ const configUtils = require('../config/config-utils');
11
+ const initUtils = require('../init/init-utils');
10
12
 
11
13
  // GET ARGS
12
14
  const { dryRun } = tools.getArgs();
@@ -25,7 +27,10 @@ const getVulnerabilitiesList = () => {
25
27
  }
26
28
 
27
29
  let auditContentArray = [];
28
- let vulnerabilitiesFound = {};
30
+ let parsedOutput = {
31
+ "auditSummary": {},
32
+ "vulnerabilities": {}
33
+ };
29
34
 
30
35
  // yarn audit output uses a specific json-lines format, we need to split it first
31
36
  auditContentArray = auditContent.split('\n');
@@ -34,13 +39,30 @@ const getVulnerabilitiesList = () => {
34
39
  auditContentArray.forEach((c) => {
35
40
  try {
36
41
  const parsedContent = JSON.parse(c);
37
- if (parsedContent && parsedContent.type === 'auditSummary') {
38
- vulnerabilitiesFound = parsedContent.data.vulnerabilities;
42
+ if (parsedContent) {
43
+ if (parsedContent.type === 'auditSummary') {
44
+ parsedOutput['auditSummary'] = parsedContent.data.vulnerabilities;
45
+ } else {
46
+ // console.log(parsedContent);
47
+ const auditData = parsedContent.data;
48
+
49
+ parsedOutput.vulnerabilities[`${auditData.resolution.id} ${auditData.advisory.module_name} ${auditData.resolution.path}`] = {
50
+ "module_name": auditData.advisory.module_name,
51
+ "severity": auditData.advisory.severity,
52
+ "path": auditData.resolution.path,
53
+ "title": auditData.advisory.title,
54
+ "recommendation": auditData.advisory.recommendation,
55
+ "patched_versions":auditData.advisory.patched_versions,
56
+ "vulnerable_versions": auditData.advisory.vulnerable_versions
57
+ }
58
+ }
39
59
  }
40
- } catch(e) {} // it can fail
60
+ } catch(e) {
61
+ // console.log(e);
62
+ } // it can fail
41
63
  })
42
64
 
43
- return vulnerabilitiesFound;
65
+ return parsedOutput;
44
66
  }
45
67
 
46
68
 
@@ -49,18 +71,10 @@ module.exports.audit = (pkg) => {
49
71
 
50
72
  tools.logTitle('Yarn auditing package');
51
73
 
52
- return Promise.resolve()
53
-
54
- // first pass to display the visual report into the CI logs
55
- .then(() => {
56
- return Promise.resolve()
57
- .then(() => {
58
- return execa.shellSync('yarn audit --level high', { cwd: process.cwd(), stdio: 'inherit' });
59
- })
60
- .catch((e) => {}) // it can fail
61
- })
74
+ let outReport;
62
75
 
63
- // second pass to extract the audit summary lines
76
+ return Promise.resolve()
77
+ // extract the audit summary lines
64
78
  .then(() => {
65
79
  return Promise.resolve()
66
80
  .then(() => {
@@ -80,26 +94,88 @@ module.exports.audit = (pkg) => {
80
94
 
81
95
  // sending output to slack channel
82
96
  .then((vulnerabilityReport) => {
97
+
98
+ outReport = vulnerabilityReport;
99
+
83
100
  if (!vulnerabilityReport) {
84
101
  tools.logSuccess('OK, no vulnerabilities detected');
85
102
 
86
- return notificationUtils.package.sendPackageMessage({
87
- package: pkg,
88
- text: 'Dependencies audit : NO vulnerabilities detected'
89
- });
103
+ if (pkg) {
104
+ return notificationUtils.package.sendPackageMessage({
105
+ package: pkg,
106
+ text: 'Dependencies audit : NO vulnerabilities detected'
107
+ });
108
+ }
90
109
 
91
110
  } else {
92
111
  tools.logWarning(JSON.stringify(vulnerabilityReport));
93
112
 
94
113
  let message = '';
95
- Object.entries(vulnerabilityReport).forEach((v) => {
114
+ Object.entries(vulnerabilityReport.auditSummary).forEach((v) => {
96
115
  message += `${v[0]}:*${v[1]}* `;
97
116
  });
98
117
 
99
- return notificationUtils.package.sendPackageMessage({
100
- package: pkg,
101
- text: `Dependencies audit detected vulnerabilities : ${message}`
102
- });
118
+ if (pkg) {
119
+ return notificationUtils.package.sendPackageMessage({
120
+ package: pkg,
121
+ text: `Dependencies audit detected vulnerabilities : ${message}`
122
+ });
123
+ }
124
+ }
125
+ })
126
+
127
+ .then(() => {
128
+ // getting config options for gates defined
129
+ const configOptions = configUtils.global.getConfigOptions();
130
+
131
+ // getting local csdr euiVersion
132
+ const euiVersion = initUtils.global.getLocalEuiVersion();
133
+
134
+ // if eUI version not found, no action
135
+ if (!euiVersion) {
136
+ return;
103
137
  }
138
+
139
+ // getting gates for euiVersion found
140
+ const gates = configOptions.AUDIT_DEPENDENCIES_GATES[euiVersion];
141
+
142
+ tools.logTitle(`Checking audit dependencies gates for local euiVersion : ${euiVersion}`);
143
+
144
+ // if no gates found for corresponding version, no action
145
+ if (!gates) {
146
+ tools.logInfo('No gates found for local eUI version...skipping');
147
+ return;
148
+ }
149
+
150
+ tools.logInfo(`Based on summary : ${JSON.stringify(outReport.auditSummary)}`);
151
+ tools.logInfo(`Gates found : ${JSON.stringify(gates)}`);
152
+
153
+ // checking gates level if any
154
+ let gatesPassed = true;
155
+
156
+ Object.keys(outReport.auditSummary).forEach((level) => {
157
+ tools.logInfo(`Checking audit level : ${level} - item found ${outReport.auditSummary[level]}`);
158
+
159
+ if (gates[level] === undefined) {
160
+ tools.logInfo(`No gates found for level`);
161
+ tools.logInfo(`===> PASSED`);
162
+ } else {
163
+ tools.logInfo(`Gates found for level maxium allowed : ${gates[level]}`);
164
+ if (outReport.auditSummary[level] > gates[level]) {
165
+ tools.logError(`===> FAILED`);
166
+ gatesPassed = false;
167
+ } else {
168
+ tools.logInfo(`===> PASSED`);
169
+ }
170
+ }
171
+ })
172
+
173
+ if (!gatesPassed) {
174
+ throw new Error('AUDIT_DEPENDENCIES_GATES_FAILED');
175
+ }
176
+ })
177
+
178
+ .catch((e) => {
179
+ throw e;
104
180
  })
105
181
  }
@@ -200,6 +200,7 @@ module.exports.getConfigOptions = () => {
200
200
  SLACK_CHANNEL_BACKEND: null,
201
201
  SLACK_CHANNEL_PROJECT: null,
202
202
  API_HOST: null,
203
+ AUDIT_DEPENDENCIES_GATES: null,
203
204
  }
204
205
 
205
206
  // getting devops metadata options
@@ -336,6 +337,26 @@ module.exports.getConfigOptions = () => {
336
337
  }
337
338
  }
338
339
 
340
+ // audit options
341
+ const audit = config && config.audit;
342
+ if (audit) {
343
+ if (audit.dependencies) {
344
+ if (audit.dependencies.gates) {
345
+ configOptions.AUDIT_DEPENDENCIES_GATES = [];
346
+ Object.keys(audit.dependencies.gates).forEach((v) => {
347
+ const gatesForVersion = audit.dependencies.gates[v];
348
+ configOptions.AUDIT_DEPENDENCIES_GATES[v] = {
349
+ "critical": gatesForVersion.critical,
350
+ "high": gatesForVersion.high,
351
+ "moderate": gatesForVersion.moderate
352
+ };
353
+ })
354
+ }
355
+ console.log(configOptions.AUDIT_DEPENDENCIES_GATES);
356
+ }
357
+ }
358
+
359
+
339
360
  return configOptions;
340
361
  }
341
362
 
@@ -9,28 +9,39 @@ const configUtils = require('../config/config-utils');
9
9
 
10
10
 
11
11
 
12
+ const getLocalEuiVersion = module.exports.getLocalEuiVersion = () => {
13
+ let euiVersionsLocal = [
14
+ ...configUtils.packages.getLocalPackagesEuiVersion(),
15
+ ...configUtils.projects.getLocalProjectsEuiVersion(),
16
+ ];
17
+ euiVersionsLocal = tools.removeArrayDuplicates(euiVersionsLocal);
18
+
19
+ if (euiVersionsLocal.length > 1) {
20
+ tools.logError('Multiple versions of eUI found in local CSDR...aborting');
21
+ tools.logError(`Ensure tha you've not installed packages that differs in versions, check the log above to identify which one is problematic`);
22
+ console.log(euiVersionsLocal);
23
+ throw new Error('MULTIPLE_LOCAL_EUI_VERSIONS_FOUND');
24
+
25
+ } else {
26
+ tools.logSuccess('eUI version checked OK');
27
+ }
28
+
29
+ if (euiVersionsLocal) {
30
+ return euiVersionsLocal[0];
31
+
32
+ } else {
33
+ return null;
34
+ }
35
+ }
36
+
37
+
38
+
12
39
  module.exports.processLocalEuiVersions = () => {
13
40
  tools.logTitle('Processing injections for local installed eUI versions if needed');
14
41
 
15
42
  return Promise.resolve()
16
43
  .then(() => {
17
- let euiVersionsLocal = [
18
- ...configUtils.packages.getLocalPackagesEuiVersion(),
19
- ...configUtils.projects.getLocalProjectsEuiVersion(),
20
- ];
21
- euiVersionsLocal = tools.removeArrayDuplicates(euiVersionsLocal);
22
-
23
- if (euiVersionsLocal.length > 1) {
24
- tools.logError('Multiple versions of eUI found in local CSDR...aborting');
25
- tools.logError(`Ensure tha you've not installed packages that differs in versions, check the log above to identify which one is problematic`);
26
- console.log(euiVersionsLocal);
27
- throw new Error('MULTIPLE_LOCAL_EUI_VERSIONS_FOUND');
28
-
29
- } else {
30
- tools.logSuccess('eUI version checked OK');
31
- }
32
-
33
- const euiVersion = euiVersionsLocal[0];
44
+ const euiVersion = getLocalEuiVersion();
34
45
 
35
46
  if (!euiVersion || euiVersion === 'DEFAULT') {
36
47
  tools.logInfo('Default eUI version found or empty...skipping');
@@ -95,9 +106,7 @@ module.exports.processResolutionsForNodeVersion = () => {
95
106
 
96
107
  const rootPackageJsonFile = path.join(process.cwd(), 'package.json');
97
108
  const rootPackageJson = require(rootPackageJsonFile);
98
-
99
109
  const nodeVersionResource = `nodejs-${nodeVersion}`;
100
-
101
110
  const resolutionsJsonFile = path.join(__dirname, 'resources', nodeVersionResource, 'resolutions.json');
102
111
 
103
112
  tools.logInfo(`Checking nodejsResolution resource for path: ${resolutionsJsonFile}`);
@@ -2,5 +2,6 @@
2
2
  "@types/node": ">=14.14.10",
3
3
  "https-proxy-agent": ">=2.2.3",
4
4
  "mem": ">=4.3.0 <=8.1.1",
5
- "zone.js": ">=0.11.5"
5
+ "zone.js": ">=0.11.5",
6
+ "nth-check": ">=2.0.1"
6
7
  }