@@ -20,6 +20,7 @@ const MAX_SAFE_SEMVER_VERSION = semverParse(
20
20
) ;
21
21
const validVersionNumberRegex = / ^ v \d + \. \d + \. \d + $ / ;
22
22
const prUrlRegex = new RegExp ( "^https://github.com/nodejs/node/pull/\\d+$" ) ;
23
+ const privatePRUrl = "https://github.com/nodejs-private/node-private/pull/" ;
23
24
24
25
const kContainsIllegalKey = Symbol ( "illegal key" ) ;
25
26
const kWrongKeyOrder = Symbol ( "Wrong key order" ) ;
@@ -71,6 +72,30 @@ function invalidChangesKeys(change) {
71
72
if ( keys [ index ] !== changesExpectedKeys [ index ] ) return true ;
72
73
}
73
74
}
75
+ function validateSecurityChange ( file , node , change , index ) {
76
+ if ( "commit" in change ) {
77
+ if ( typeof change . commit !== "string" || isNaN ( `0x${ change . commit } ` ) ) {
78
+ file . message (
79
+ `changes[${ index } ]: Ill-formed security change commit ID` ,
80
+ node
81
+ ) ;
82
+ }
83
+
84
+ if ( Object . keys ( change ) [ 1 ] === "commit" ) {
85
+ change = { ...change } ;
86
+ delete change . commit ;
87
+ }
88
+ }
89
+ if ( invalidChangesKeys ( change ) ) {
90
+ const securityChangeExpectedKeys = [ ...changesExpectedKeys ] ;
91
+ securityChangeExpectedKeys [ 0 ] += "[, commit]" ;
92
+ file . message (
93
+ `changes[${ index } ]: Invalid keys. Expected keys are: ` +
94
+ securityChangeExpectedKeys . join ( ", " ) ,
95
+ node
96
+ ) ;
97
+ }
98
+ }
74
99
function validateChanges ( file , node , changes ) {
75
100
if ( ! Array . isArray ( changes ) )
76
101
return file . message ( "`changes` must be a YAML list" , node ) ;
@@ -81,8 +106,14 @@ function validateChanges(file, node, changes) {
81
106
82
107
const isAncient =
83
108
typeof change . version === "string" && change . version . startsWith ( "v0." ) ;
84
-
85
- if ( ! isAncient && invalidChangesKeys ( change ) ) {
109
+ const isSecurityChange =
110
+ ! isAncient &&
111
+ typeof change [ "pr-url" ] === "string" &&
112
+ change [ "pr-url" ] . startsWith ( privatePRUrl ) ;
113
+
114
+ if ( isSecurityChange ) {
115
+ validateSecurityChange ( file , node , change , index ) ;
116
+ } else if ( ! isAncient && invalidChangesKeys ( change ) ) {
86
117
file . message (
87
118
`changes[${ index } ]: Invalid keys. Expected keys are: ` +
88
119
changesExpectedKeys . join ( ", " ) ,
@@ -100,7 +131,7 @@ function validateChanges(file, node, changes) {
100
131
file . message ( `changes[${ index } ]: list of versions is not in order` , node ) ;
101
132
}
102
133
103
- if ( ! isAncient && ! prUrlRegex . test ( change [ "pr-url" ] ) ) {
134
+ if ( ! isAncient && ! isSecurityChange && ! prUrlRegex . test ( change [ "pr-url" ] ) ) {
104
135
file . message (
105
136
`changes[${ index } ]: PR-URL does not match the expected pattern` ,
106
137
node
0 commit comments