@node-core/utils 6.3.3 → 6.4.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/cli.js CHANGED
@@ -94,6 +94,14 @@ export default class CLI {
94
94
  return answer;
95
95
  }
96
96
 
97
+ async promptCheckbox(message, choices) {
98
+ if (this.assumeYes) {
99
+ return choices.filter((c) => c.checked).map((c) => c.value);
100
+ }
101
+
102
+ return inquirer.checkbox({ message, choices });
103
+ }
104
+
97
105
  setAssumeYes() {
98
106
  this.assumeYes = true;
99
107
  }
@@ -10,11 +10,19 @@ import {
10
10
  validateDate,
11
11
  promptDependencies,
12
12
  getSupportedVersions,
13
+ getReportSeverity,
13
14
  pickReport,
14
15
  SecurityRelease
15
16
  } from './security-release/security-release.js';
16
17
  import _ from 'lodash';
17
18
 
19
+ function relativeDate(date) {
20
+ const days = Math.floor((Date.now() - date) / (1000 * 60 * 60 * 24));
21
+ if (days < 30) return days === 1 ? '1 day ago' : `${days} days ago`;
22
+ const months = Math.floor(days / 30);
23
+ return months === 1 ? '1 month ago' : `${months} months ago`;
24
+ }
25
+
18
26
  export default class PrepareSecurityRelease extends SecurityRelease {
19
27
  title = 'Next Security Release';
20
28
 
@@ -25,6 +33,13 @@ export default class PrepareSecurityRelease extends SecurityRelease {
25
33
  });
26
34
 
27
35
  this.req = new Request(credentials);
36
+
37
+ let excludedReports = [];
38
+ const showTriaged = await this.promptShowTriagedWithoutPR();
39
+ if (showTriaged) {
40
+ excludedReports = await this.showTriagedReportsWithoutPR();
41
+ }
42
+
28
43
  const releaseDate = await this.promptReleaseDate();
29
44
  if (releaseDate !== 'TBD') {
30
45
  validateDate(releaseDate);
@@ -34,7 +49,8 @@ export default class PrepareSecurityRelease extends SecurityRelease {
34
49
  let securityReleasePRUrl;
35
50
  const content = await this.buildDescription(releaseDate, securityReleasePRUrl);
36
51
  if (createVulnerabilitiesJSON) {
37
- securityReleasePRUrl = await this.startVulnerabilitiesJSONCreation(releaseDate, content);
52
+ securityReleasePRUrl = await this.startVulnerabilitiesJSONCreation(
53
+ releaseDate, content, excludedReports);
38
54
  }
39
55
 
40
56
  this.cli.ok('Done!');
@@ -93,12 +109,12 @@ export default class PrepareSecurityRelease extends SecurityRelease {
93
109
  this.cli.ok('Done!');
94
110
  }
95
111
 
96
- async startVulnerabilitiesJSONCreation(releaseDate, content) {
112
+ async startVulnerabilitiesJSONCreation(releaseDate, content, excludedReports = []) {
97
113
  // checkout on the next-security-release branch
98
114
  checkoutOnSecurityReleaseBranch(this.cli, this.repository);
99
115
 
100
116
  // choose the reports to include in the security release
101
- const reports = await this.chooseReports();
117
+ const reports = await this.chooseReports(excludedReports);
102
118
  const depUpdates = await this.getDependencyUpdates();
103
119
  const deps = _.groupBy(depUpdates, 'name');
104
120
 
@@ -184,17 +200,61 @@ export default class PrepareSecurityRelease extends SecurityRelease {
184
200
  { defaultAnswer: true });
185
201
  }
186
202
 
203
+ async promptShowTriagedWithoutPR() {
204
+ return this.cli.prompt(
205
+ 'Do you want to see which reports are triaged but have no PR URL?',
206
+ { defaultAnswer: true });
207
+ }
208
+
209
+ async showTriagedReportsWithoutPR() {
210
+ this.cli.info('Fetching triaged reports without PR URL...');
211
+ const reports = await this.req.getTriagedReports();
212
+ const reportsWithoutPR = reports.data.filter(
213
+ (report) => !report.relationships.custom_field_values.data.length
214
+ );
215
+ if (!reportsWithoutPR.length) {
216
+ this.cli.ok('All triaged reports have a PR URL.');
217
+ return [];
218
+ }
219
+ const severityRank = { critical: 0, high: 1, medium: 2, low: 3 };
220
+ const choices = reportsWithoutPR
221
+ .sort((a, b) => {
222
+ const dateA = new Date(a.attributes.created_at);
223
+ const dateB = new Date(b.attributes.created_at);
224
+ if (dateB - dateA !== 0) return dateB - dateA;
225
+ const rankA = severityRank[getReportSeverity(a).rating] ?? 4;
226
+ const rankB = severityRank[getReportSeverity(b).rating] ?? 4;
227
+ return rankA - rankB;
228
+ })
229
+ .map((report) => {
230
+ const { id, attributes: { title, created_at } } = report;
231
+ const { rating } = getReportSeverity(report);
232
+ const openedDate = relativeDate(new Date(created_at));
233
+ const link = `https://hackerone.com/reports/${id}`;
234
+ return {
235
+ name: `[${openedDate}] (${rating}) ${title} - ${link}`,
236
+ value: id,
237
+ checked: true
238
+ };
239
+ });
240
+ return this.cli.promptCheckbox(
241
+ 'Select reports to exclude from the upcoming security release:',
242
+ choices
243
+ );
244
+ }
245
+
187
246
  async buildDescription() {
188
247
  const template = await this.getSecurityIssueTemplate();
189
248
  return template;
190
249
  }
191
250
 
192
- async chooseReports() {
251
+ async chooseReports(excludedReports = []) {
193
252
  this.cli.info('Getting triaged H1 reports...');
194
253
  const reports = await this.req.getTriagedReports();
195
254
  const selectedReports = [];
196
255
 
197
256
  for (const report of reports.data) {
257
+ if (excludedReports.includes(report.id)) continue;
198
258
  const rep = await pickReport(report, { cli: this.cli, req: this.req });
199
259
  if (!rep) continue;
200
260
  selectedReports.push(rep);
@@ -47,6 +47,14 @@ const highwayIgnore = `/third_party/highway/src/*
47
47
  const dragonboxIgnore = `/third_party/dragonbox/src/*
48
48
  !/third_party/dragonbox/src/include`;
49
49
 
50
+ const llvmLibcIgnore = `/third_party/llvm-libc/src/*
51
+ !/third_party/llvm-libc/src/hdr
52
+ !/third_party/llvm-libc/src/include
53
+ !/third_party/llvm-libc/src/shared
54
+ !/third_party/llvm-libc/src/src
55
+ /third_party/llvm-libc/src/src/*
56
+ !/third_party/llvm-libc/src/src/__support`;
57
+
50
58
  export const v8Deps = [
51
59
  {
52
60
  name: 'trace_event',
@@ -146,4 +154,13 @@ export const v8Deps = [
146
154
  },
147
155
  since: 138
148
156
  },
157
+ {
158
+ name: 'llvm-libc',
159
+ repo: 'third_party/llvm-libc/src',
160
+ gitignore: {
161
+ match: '/third_party/llvm-libc/src',
162
+ replace: llvmLibcIgnore
163
+ },
164
+ since: 150
165
+ },
149
166
  ];
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@node-core/utils",
3
- "version": "6.3.3",
3
+ "version": "6.4.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@node-core/utils",
9
- "version": "6.3.3",
9
+ "version": "6.4.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@inquirer/prompts": "^7.4.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-core/utils",
3
- "version": "6.3.3",
3
+ "version": "6.4.0",
4
4
  "description": "Utilities for Node.js core collaborators",
5
5
  "type": "module",
6
6
  "engines": {