@@ -2,6 +2,7 @@ import fs from 'node:fs';
22import path from 'node:path' ;
33import auth from './auth.js' ;
44import Request from './request.js' ;
5+ import { parsePRFromURL } from './links.js' ;
56import {
67 NEXT_SECURITY_RELEASE_BRANCH ,
78 NEXT_SECURITY_RELEASE_FOLDER ,
@@ -196,8 +197,7 @@ export default class PrepareSecurityRelease extends SecurityRelease {
196197 await this . closeAndRequestDisclosure ( vulnerabilityJSON . reports ) ;
197198
198199 this . cli . info ( 'Closing pull requests' ) ;
199- // For now, close the ones with Security Release label
200- await this . closePRWithLabel ( 'Security Release' ) ;
200+ await this . closePullRequests ( vulnerabilityJSON ) ;
201201
202202 if ( vulnerabilityJSON . buildIssue ) {
203203 this . cli . info ( 'Commenting on nodejs/build issue' ) ;
@@ -637,26 +637,25 @@ export default class PrepareSecurityRelease extends SecurityRelease {
637637 this . cli . stopSpinner ( 'Done closing H1 Reports and requesting disclosure' ) ;
638638 }
639639
640- async closePRWithLabel ( labels ) {
641- if ( typeof labels === 'string' ) {
642- labels = [ labels ] ;
643- }
644-
645- const url = 'https://github.com/nodejs-private/node-private/pull' ;
640+ async closePullRequests ( vulnerabilityJSON ) {
646641 this . cli . startSpinner ( 'Closing GitHub Pull Requests...' ) ;
647- // At this point, GitHub does not provide filters through their REST API
648- const prs = await this . req . getPullRequest ( url ) ;
649- for ( const pr of prs ) {
650- if ( pr . labels . some ( ( l ) => labels . includes ( l . name ) ) ) {
651- this . cli . updateSpinner ( `Closing Pull Request: ${ pr . number } ` ) ;
652- await confirmSecurityStep (
653- this . cli ,
654- `close GitHub pull request \`nodejs-private/node-private#${ pr . number } \`` ,
655- 'This closes a pull request labeled for the security release.'
656- ) ;
657- await this . req . closePullRequest ( pr . number ,
658- { owner : 'nodejs-private' , repo : 'node-private' } ) ;
659- }
642+ const entries = [
643+ ...vulnerabilityJSON . reports ,
644+ ...Object . values ( vulnerabilityJSON . dependencies ?? { } )
645+ ] ;
646+ const urls = new Set ( entries . flatMap (
647+ ( { affectedVersions } ) => Object . values ( affectedVersions ) ) ) ;
648+
649+ for ( const url of urls ) {
650+ const { owner, repo, prid } = parsePRFromURL ( url ) ;
651+ const name = `${ owner } /${ repo } #${ prid } ` ;
652+ this . cli . updateSpinner ( `Closing Pull Request: ${ name } ` ) ;
653+ await confirmSecurityStep (
654+ this . cli ,
655+ `close GitHub pull request \`${ name } \`` ,
656+ 'This closes a pull request listed in vulnerabilities.json.'
657+ ) ;
658+ await this . req . closePullRequest ( prid , { owner, repo } ) ;
660659 }
661660 this . cli . stopSpinner ( 'Closed GitHub Pull Requests.' ) ;
662661 }
0 commit comments