@conterra/vuln-scan 0.0.1

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/LICENSE.txt ADDED
@@ -0,0 +1,11 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # ct-vuln-scan
2
+
3
+ ... tbd
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var h=Object.create;var x=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var N=(t,e,n,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of A(e))!I.call(t,s)&&s!==n&&x(t,s,{get:()=>e[s],enumerable:!(l=E(e,s))||l.enumerable});return t};var O=(t,e,n)=>(n=t!=null?h(C(t)):{},N(e||!t||!t.__esModule?x(n,"default",{value:t,enumerable:!0}):n,t));var y=O(require("node:readline/promises")),w=require("node:process");var u=require("path");var c=require("fs/promises");async function g(t){if(await T(t))return JSON.parse(await(0,c.readFile)(t,{encoding:"utf-8"}))}async function T(t){try{return await(0,c.access)(t,c.constants.F_OK),!0}catch{return!1}}async function S(){let t="https://repository.conterra.de/repository/maven-mirror-ct",e="./input/vex",n="./output",l="./.cache",s=["grype","trivy","ossindex"],v=(0,u.resolve)("./vuln-scan-conf.json"),a=await g(v);if(!a)throw new Error(`Missing project configuration file '${v}'`);return{failOnNewVulnerabilities:!1,createSubDirsForProject:a.createSubDirsForProject??!0,mavenRepo:a.mavenRepo??t,vexDir:(0,u.resolve)(a.vexDir??e),outDir:(0,u.resolve)(a.outDir??n),cacheDir:(0,u.resolve)(a.cacheDir??l),scanners:a.scanners??s,projects:(a.projects??[]).map(m=>{let r=m;return r.sbomFile?{...r,sbomFile:(0,u.resolve)(r.sbomFile)}:m})}}var F=require("path");var P=require("fs/promises"),D=require("crypto");(async()=>{let t=await S();console.info("## Add New VEX Statement ##");let e=y.default.createInterface({input:w.stdin,output:w.stdout}),n=await e.question(`CVE name (e.g. CVE-2023-52070):
3
+ > `);n||(console.log("Please provide a CVE name."),process.exit(1));let l=t.projects.map(o=>`${o.name}@${o.version}`),s=await e.question(`Projects to add? Available are:
4
+ - ${l.join(`,
5
+ - `)}
6
+ You can list multiple projects separated by comma:
7
+ > `);s||(console.log("Please provide projects to add."),process.exit(1));let v=s.split(/\s*,\s*/).map(o=>{let i=o.split("@");return{name:i[0],version:i[1]}}),a=new Set(function*(){for(let o of v)for(let i of t.projects)i.name===o.name&&i.version===o.version&&(yield i.purl)}()),m=(0,F.resolve)(t.vexDir,`${n}.json`),r=await g(m),b=["under_investigation","affected","fixed","not_affected"],f=await e.question(`Status? Available are:
8
+ - ${b.join(`,
9
+ - `)}
10
+ > `);b.includes(f)||(f?(console.log("Invalid status."),process.exit(1)):f="under_investigation");let p={};switch(f){case"affected":{let o=await e.question(`Action statement? (required):
11
+ > `);o||(console.log("Please provide an action statement."),process.exit(1)),p.action_statement=o;break}case"not_affected":{let o=["component_not_present","vulnerable_code_not_present","vulnerable_code_not_in_execute_path","vulnerable_code_cannot_be_controlled_by_adversary","inline_mitigations_already_exist"],i=await e.question(`Justification? Available are:
12
+ - ${o.join(`,
13
+ - `)}
14
+ > (optional) `);if(i)if(!o.includes(i))console.log("Invalid justification."),process.exit(1);else{p.justification=i;let d=await e.question(`Impact statement? (optional):
15
+ > `);d&&(p.impact_statement=d)}else{let d=await e.question(`Impact statement? (required):
16
+ > `);d||(console.log("Please provide an impact statement."),process.exit(1)),p.impact_statement=d}break}case"fixed":{let o=await e.question(`Status note? (optional):
17
+ > `);o&&(p.status_notes=o);break}}let _=new Date().toISOString(),j={vulnerability:{name:n},timestamp:_,products:Array.from(a).map(o=>({"@id":o})),status:f,...p};(await e.question(`Following statement will be added to ${m}:
18
+ ${JSON.stringify(j,null,2)}
19
+
20
+ Do you want to proceed? (y/n)?
21
+ > `)).toLowerCase()!=="y"&&(console.log("Aborted."),process.exit(0)),r?(r.last_updated=_,r.version+=1,r.statements.push(j)):r={"@context":"https://openvex.dev/ns/v0.2.0","@id":`https://openvex.dev/docs/public/vex-${(0,D.randomUUID)()}`,author:"conterra",timestamp:_,last_updated:_,version:1,statements:[j]},await(0,P.writeFile)(m,JSON.stringify(r,null,2)),e.close()})();
@@ -0,0 +1,73 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "failOnNewVulnerabilities": {
6
+ "type": "boolean",
7
+ "default": false
8
+ },
9
+ "mavenRepo": {
10
+ "type": "string",
11
+ "format": "uri",
12
+ "default": "https://repository.conterra.de/repository/maven-mirror-ct"
13
+ },
14
+ "scanners": {
15
+ "type": "array",
16
+ "items": {
17
+ "type": "string"
18
+ },
19
+ "default": ["grype", "trivy", "ossindex"]
20
+ },
21
+ "vexDir": {
22
+ "type": "string",
23
+ "default": "./input/vex"
24
+ },
25
+ "outDir": {
26
+ "type": "string",
27
+ "default": "./output"
28
+ },
29
+ "cacheDir": {
30
+ "type": "string",
31
+ "default": "./.cache"
32
+ },
33
+ "createSubDirsForProject": {
34
+ "type": "boolean",
35
+ "default": true
36
+ },
37
+ "projects": {
38
+ "type": "array",
39
+ "items": {
40
+ "type": "object",
41
+ "properties": {
42
+ "name": {
43
+ "type": "string"
44
+ },
45
+ "version": {
46
+ "type": "string"
47
+ },
48
+ "purl": {
49
+ "type": "string"
50
+ },
51
+ "sbomMavenCoordinates": {
52
+ "type": "string"
53
+ },
54
+ "sbomFile": {
55
+ "type": "string"
56
+ }
57
+ },
58
+ "required": ["name", "version", "purl"],
59
+ "oneOf": [
60
+ {
61
+ "required": ["sbomMavenCoordinates"]
62
+ },
63
+ {
64
+ "required": ["sbomFile"]
65
+ }
66
+ ]
67
+ }
68
+ }
69
+ },
70
+ "required": [
71
+ "projects"
72
+ ]
73
+ }
@@ -0,0 +1,320 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/openvex/spec/openvex_json_schema_0.2.0.json",
4
+ "title": "OpenVEX",
5
+ "description": "OpenVEX is an implementation of the Vulnerability Exploitability Exchange (VEX for short) that is designed to be minimal, compliant, interoperable, and embeddable.",
6
+ "type": "object",
7
+ "$defs": {
8
+ "vulnerability": {
9
+ "type": "object",
10
+ "properties": {
11
+ "@id": {
12
+ "type": "string",
13
+ "format": "iri",
14
+ "description": "An Internationalized Resource Identifier (IRI) identifying the struct."
15
+ },
16
+ "name": {
17
+ "type": "string",
18
+ "description": "A string with the main identifier used to name the vulnerability."
19
+ },
20
+ "description": {
21
+ "type": "string",
22
+ "description": "Optional free form text describing the vulnerability."
23
+ },
24
+ "aliases": {
25
+ "type": "array",
26
+ "uniqueItems": true,
27
+ "items": {
28
+ "type": "string"
29
+ },
30
+ "description": "A list of strings enumerating other names under which the vulnerability may be known."
31
+ }
32
+ },
33
+ "required": [
34
+ "name"
35
+ ],
36
+ "additionalProperties": false
37
+ },
38
+ "identifiers": {
39
+ "type": "object",
40
+ "properties": {
41
+ "purl": {
42
+ "type": "string",
43
+ "description": "Package URL"
44
+ },
45
+ "cpe22": {
46
+ "type": "string",
47
+ "description": "Common Platform Enumeration v2.2"
48
+ },
49
+ "cpe23": {
50
+ "type": "string",
51
+ "description": "Common Platform Enumeration v2.3"
52
+ }
53
+ },
54
+ "additionalProperties": false,
55
+ "anyOf": [
56
+ { "required": ["purl"] },
57
+ { "required": ["cpe22"] },
58
+ { "required": ["cpe23"] }
59
+ ]
60
+ },
61
+ "hashes": {
62
+ "type": "object",
63
+ "properties": {
64
+ "md5": {
65
+ "type": "string"
66
+ },
67
+ "sha1": {
68
+ "type": "string"
69
+ },
70
+ "sha-256": {
71
+ "type": "string"
72
+ },
73
+ "sha-384": {
74
+ "type": "string"
75
+ },
76
+ "sha-512": {
77
+ "type": "string"
78
+ },
79
+ "sha3-224": {
80
+ "type": "string"
81
+ },
82
+ "sha3-256": {
83
+ "type": "string"
84
+ },
85
+ "sha3-384": {
86
+ "type": "string"
87
+ },
88
+ "sha3-512": {
89
+ "type": "string"
90
+ },
91
+ "blake2s-256": {
92
+ "type": "string"
93
+ },
94
+ "blake2b-256": {
95
+ "type": "string"
96
+ },
97
+ "blake2b-512": {
98
+ "type": "string"
99
+ }
100
+ },
101
+ "additionalProperties": false
102
+ },
103
+ "subcomponent": {
104
+ "type": "object",
105
+ "properties": {
106
+ "@id": {
107
+ "type": "string",
108
+ "format": "iri",
109
+ "description": "Optional IRI identifying the component to make it externally referenceable."
110
+ },
111
+ "identifiers": {
112
+ "$ref": "#/$defs/identifiers",
113
+ "description": "Optional IRI identifying the component to make it externally referenceable."
114
+ },
115
+ "hashes": {
116
+ "$ref": "#/$defs/hashes",
117
+ "description": "Map of cryptographic hashes of the component."
118
+ }
119
+ },
120
+ "additionalProperties": false,
121
+ "anyOf": [
122
+ { "required": ["@id"] },
123
+ { "required": ["identifiers"] }
124
+ ]
125
+ },
126
+ "component": {
127
+ "type": "object",
128
+ "properties": {
129
+ "@id": {
130
+ "type": "string",
131
+ "format": "iri",
132
+ "description": "Optional IRI identifying the component to make it externally referenceable."
133
+ },
134
+ "identifiers": {
135
+ "$ref": "#/$defs/identifiers",
136
+ "description": "A map of software identifiers where the key is the type and the value the identifier."
137
+ },
138
+ "hashes": {
139
+ "$ref": "#/$defs/hashes",
140
+ "description": "Map of cryptographic hashes of the component."
141
+ },
142
+ "subcomponents": {
143
+ "type": "array",
144
+ "uniqueItems": true,
145
+ "description": "List of subcomponent structs describing the subcomponents subject of the VEX statement.",
146
+ "items": {
147
+ "$ref": "#/$defs/subcomponent"
148
+ }
149
+ }
150
+ },
151
+ "additionalProperties": false,
152
+ "anyOf": [
153
+ { "required": ["@id"] },
154
+ { "required": ["identifiers"] }
155
+ ]
156
+ },
157
+ "statement": {
158
+ "type": "object",
159
+ "properties": {
160
+ "@id": {
161
+ "type": "string",
162
+ "format": "iri",
163
+ "description": "Optional IRI identifying the statement to make it externally referenceable."
164
+ },
165
+ "version": {
166
+ "type": "integer",
167
+ "minimum": 1,
168
+ "description": "Optional integer representing the statement's version number."
169
+ },
170
+ "vulnerability": {
171
+ "$ref": "#/$defs/vulnerability",
172
+ "description": "A struct identifying the vulnerability."
173
+ },
174
+ "timestamp": {
175
+ "type": "string",
176
+ "format": "date-time",
177
+ "description": "Timestamp is the time at which the information expressed in the statement was known to be true."
178
+ },
179
+ "last_updated": {
180
+ "type": "string",
181
+ "format": "date-time",
182
+ "description": "Timestamp when the statement was last updated."
183
+ },
184
+ "products": {
185
+ "type": "array",
186
+ "uniqueItems": true,
187
+ "description": "List of product structs that the statement applies to.",
188
+ "items": {
189
+ "$ref": "#/$defs/component"
190
+ }
191
+ },
192
+ "status": {
193
+ "type": "string",
194
+ "enum": [
195
+ "not_affected",
196
+ "affected",
197
+ "fixed",
198
+ "under_investigation"
199
+ ],
200
+ "description": "A VEX statement MUST provide the status of the vulnerabilities with respect to the products and components listed in the statement."
201
+ },
202
+ "supplier": {
203
+ "type": "string",
204
+ "description": "Supplier of the product or subcomponent."
205
+ },
206
+ "status_notes": {
207
+ "type": "string",
208
+ "description": "A statement MAY convey information about how status was determined and MAY reference other VEX information."
209
+ },
210
+ "justification": {
211
+ "type": "string",
212
+ "enum": [
213
+ "component_not_present",
214
+ "vulnerable_code_not_present",
215
+ "vulnerable_code_not_in_execute_path",
216
+ "vulnerable_code_cannot_be_controlled_by_adversary",
217
+ "inline_mitigations_already_exist"
218
+ ],
219
+ "description": "For statements conveying a not_affected status, a VEX statement MUST include either a status justification or an impact_statement informing why the product is not affected by the vulnerability."
220
+ },
221
+ "impact_statement": {
222
+ "type": "string",
223
+ "description": "For statements conveying a not_affected status, a VEX statement MUST include either a status justification or an impact_statement informing why the product is not affected by the vulnerability."
224
+ },
225
+ "action_statement": {
226
+ "type": "string",
227
+ "description": "For a statement with affected status, a VEX statement MUST include a statement that SHOULD describe actions to remediate or mitigate the vulnerability."
228
+ },
229
+ "action_statement_timestamp": {
230
+ "type": "string",
231
+ "format": "date-time",
232
+ "description": "The timestamp when the action statement was issued."
233
+ }
234
+ },
235
+ "required": [
236
+ "vulnerability",
237
+ "status"
238
+ ],
239
+ "additionalProperties": false,
240
+ "allOf": [
241
+ {
242
+ "if": {
243
+ "properties": { "status": { "const": "not_affected" }}
244
+ },
245
+ "then": {
246
+ "anyOf": [
247
+ { "required": ["justification"]},
248
+ { "required": ["impact_statement"]}
249
+ ]
250
+ }
251
+ },
252
+ {
253
+ "if": {
254
+ "properties": { "status": { "const": "affected" }}
255
+ },
256
+ "then": {
257
+ "required": ["action_statement"]
258
+ }
259
+ }
260
+ ]
261
+ }
262
+ },
263
+ "properties": {
264
+ "@context": {
265
+ "type": "string",
266
+ "format": "uri",
267
+ "description": "The URL linking to the OpenVEX context definition."
268
+ },
269
+ "@id": {
270
+ "type": "string",
271
+ "format": "iri",
272
+ "description": "The IRI identifying the VEX document."
273
+ },
274
+ "author": {
275
+ "type": "string",
276
+ "description": "Author is the identifier for the author of the VEX statement."
277
+ },
278
+ "role": {
279
+ "type": "string",
280
+ "description": "Role describes the role of the document author."
281
+ },
282
+ "timestamp": {
283
+ "type": "string",
284
+ "format": "date-time",
285
+ "description": "Timestamp defines the time at which the document was issued."
286
+ },
287
+ "last_updated": {
288
+ "type": "string",
289
+ "format": "date-time",
290
+ "description": "Date of last modification to the document."
291
+ },
292
+ "version": {
293
+ "type": "integer",
294
+ "minimum": 1,
295
+ "description": "Version is the document version."
296
+ },
297
+ "tooling": {
298
+ "type": "string",
299
+ "description": "Tooling expresses how the VEX document and contained VEX statements were generated."
300
+ },
301
+ "statements": {
302
+ "type": "array",
303
+ "uniqueItems": true,
304
+ "minItems": 1,
305
+ "description": "A statement is an assertion made by the document's author about the impact a vulnerability has on one or more software 'products'.",
306
+ "items": {
307
+ "$ref": "#/$defs/statement"
308
+ }
309
+ }
310
+ },
311
+ "required": [
312
+ "@context",
313
+ "@id",
314
+ "author",
315
+ "timestamp",
316
+ "version",
317
+ "statements"
318
+ ],
319
+ "additionalProperties": false
320
+ }
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+ "use strict";var qi=Object.create;var gt=Object.defineProperty;var Vi=Object.getOwnPropertyDescriptor;var Xi=Object.getOwnPropertyNames;var $i=Object.getPrototypeOf,Bi=Object.prototype.hasOwnProperty;var h=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Gi=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Xi(e))!Bi.call(t,n)&&n!==r&&gt(t,n,{get:()=>e[n],enumerable:!(i=Vi(e,n))||i.enumerable});return t};var vt=(t,e,r)=>(r=t!=null?qi($i(t)):{},Gi(e||!t||!t.__esModule?gt(r,"default",{value:t,enumerable:!0}):r,t));var E=h(Qe=>{"use strict";Qe.fromCallback=function(t){return Object.defineProperty(function(...e){if(typeof e[e.length-1]=="function")t.apply(this,e);else return new Promise((r,i)=>{e.push((n,o)=>n!=null?i(n):r(o)),t.apply(this,e)})},"name",{value:t.name})};Qe.fromPromise=function(t){return Object.defineProperty(function(...e){let r=e[e.length-1];if(typeof r!="function")return t.apply(this,e);e.pop(),t.apply(this,e).then(i=>r(null,i),r)},"name",{value:t.name})}});var Mt=h((Gs,Et)=>{var Q=require("constants"),nn=process.cwd,Le=null,on=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Le||(Le=nn.call(process)),Le};try{process.cwd()}catch{}typeof process.chdir=="function"&&(ze=process.chdir,process.chdir=function(t){Le=null,ze.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,ze));var ze;Et.exports=sn;function sn(t){Q.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(t),t.lutimes||r(t),t.chown=o(t.chown),t.fchown=o(t.fchown),t.lchown=o(t.lchown),t.chmod=i(t.chmod),t.fchmod=i(t.fchmod),t.lchmod=i(t.lchmod),t.chownSync=s(t.chownSync),t.fchownSync=s(t.fchownSync),t.lchownSync=s(t.lchownSync),t.chmodSync=n(t.chmodSync),t.fchmodSync=n(t.fchmodSync),t.lchmodSync=n(t.lchmodSync),t.stat=c(t.stat),t.fstat=c(t.fstat),t.lstat=c(t.lstat),t.statSync=u(t.statSync),t.fstatSync=u(t.fstatSync),t.lstatSync=u(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(a,m,p){p&&process.nextTick(p)},t.lchmodSync=function(){}),t.chown&&!t.lchown&&(t.lchown=function(a,m,p,l){l&&process.nextTick(l)},t.lchownSync=function(){}),on==="win32"&&(t.rename=typeof t.rename!="function"?t.rename:function(a){function m(p,l,d){var S=Date.now(),w=0;a(p,l,function L(V){if(V&&(V.code==="EACCES"||V.code==="EPERM"||V.code==="EBUSY")&&Date.now()-S<6e4){setTimeout(function(){t.stat(l,function(A,ue){A&&A.code==="ENOENT"?a(p,l,L):d(V)})},w),w<100&&(w+=10);return}d&&d(V)})}return Object.setPrototypeOf&&Object.setPrototypeOf(m,a),m}(t.rename)),t.read=typeof t.read!="function"?t.read:function(a){function m(p,l,d,S,w,L){var V;if(L&&typeof L=="function"){var A=0;V=function(ue,ht,St){if(ue&&ue.code==="EAGAIN"&&A<10)return A++,a.call(t,p,l,d,S,w,V);L.apply(this,arguments)}}return a.call(t,p,l,d,S,w,V)}return Object.setPrototypeOf&&Object.setPrototypeOf(m,a),m}(t.read),t.readSync=typeof t.readSync!="function"?t.readSync:function(a){return function(m,p,l,d,S){for(var w=0;;)try{return a.call(t,m,p,l,d,S)}catch(L){if(L.code==="EAGAIN"&&w<10){w++;continue}throw L}}}(t.readSync);function e(a){a.lchmod=function(m,p,l){a.open(m,Q.O_WRONLY|Q.O_SYMLINK,p,function(d,S){if(d){l&&l(d);return}a.fchmod(S,p,function(w){a.close(S,function(L){l&&l(w||L)})})})},a.lchmodSync=function(m,p){var l=a.openSync(m,Q.O_WRONLY|Q.O_SYMLINK,p),d=!0,S;try{S=a.fchmodSync(l,p),d=!1}finally{if(d)try{a.closeSync(l)}catch{}else a.closeSync(l)}return S}}function r(a){Q.hasOwnProperty("O_SYMLINK")&&a.futimes?(a.lutimes=function(m,p,l,d){a.open(m,Q.O_SYMLINK,function(S,w){if(S){d&&d(S);return}a.futimes(w,p,l,function(L){a.close(w,function(V){d&&d(L||V)})})})},a.lutimesSync=function(m,p,l){var d=a.openSync(m,Q.O_SYMLINK),S,w=!0;try{S=a.futimesSync(d,p,l),w=!1}finally{if(w)try{a.closeSync(d)}catch{}else a.closeSync(d)}return S}):a.futimes&&(a.lutimes=function(m,p,l,d){d&&process.nextTick(d)},a.lutimesSync=function(){})}function i(a){return a&&function(m,p,l){return a.call(t,m,p,function(d){f(d)&&(d=null),l&&l.apply(this,arguments)})}}function n(a){return a&&function(m,p){try{return a.call(t,m,p)}catch(l){if(!f(l))throw l}}}function o(a){return a&&function(m,p,l,d){return a.call(t,m,p,l,function(S){f(S)&&(S=null),d&&d.apply(this,arguments)})}}function s(a){return a&&function(m,p,l){try{return a.call(t,m,p,l)}catch(d){if(!f(d))throw d}}}function c(a){return a&&function(m,p,l){typeof p=="function"&&(l=p,p=null);function d(S,w){w&&(w.uid<0&&(w.uid+=4294967296),w.gid<0&&(w.gid+=4294967296)),l&&l.apply(this,arguments)}return p?a.call(t,m,p,d):a.call(t,m,d)}}function u(a){return a&&function(m,p){var l=p?a.call(t,m,p):a.call(t,m);return l&&(l.uid<0&&(l.uid+=4294967296),l.gid<0&&(l.gid+=4294967296)),l}}function f(a){if(!a||a.code==="ENOSYS")return!0;var m=!process.getuid||process.getuid()!==0;return!!(m&&(a.code==="EINVAL"||a.code==="EPERM"))}}});var Tt=h((Js,jt)=>{var Dt=require("stream").Stream;jt.exports=an;function an(t){return{ReadStream:e,WriteStream:r};function e(i,n){if(!(this instanceof e))return new e(i,n);Dt.call(this);var o=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,n=n||{};for(var s=Object.keys(n),c=0,u=s.length;c<u;c++){var f=s[c];this[f]=n[f]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}t.open(this.path,this.flags,this.mode,function(a,m){if(a){o.emit("error",a),o.readable=!1;return}o.fd=m,o.emit("open",m),o._read()})}function r(i,n){if(!(this instanceof r))return new r(i,n);Dt.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,n=n||{};for(var o=Object.keys(n),s=0,c=o.length;s<c;s++){var u=o[s];this[u]=n[u]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var It=h((Ws,Ct)=>{"use strict";Ct.exports=ln;var cn=Object.getPrototypeOf||function(t){return t.__proto__};function ln(t){if(t===null||typeof t!="object")return t;if(t instanceof Object)var e={__proto__:cn(t)};else var e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}});var se=h((Us,Ze)=>{var k=require("fs"),un=Mt(),fn=Tt(),mn=It(),Pe=require("util"),C,Oe;typeof Symbol=="function"&&typeof Symbol.for=="function"?(C=Symbol.for("graceful-fs.queue"),Oe=Symbol.for("graceful-fs.previous")):(C="___graceful-fs.queue",Oe="___graceful-fs.previous");function pn(){}function Rt(t,e){Object.defineProperty(t,C,{get:function(){return e}})}var ee=pn;Pe.debuglog?ee=Pe.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ee=function(){var t=Pe.format.apply(Pe,arguments);t="GFS4: "+t.split(/\n/).join(`
3
+ GFS4: `),console.error(t)});k[C]||(At=global[C]||[],Rt(k,At),k.close=function(t){function e(r,i){return t.call(k,r,function(n){n||Nt(),typeof i=="function"&&i.apply(this,arguments)})}return Object.defineProperty(e,Oe,{value:t}),e}(k.close),k.closeSync=function(t){function e(r){t.apply(k,arguments),Nt()}return Object.defineProperty(e,Oe,{value:t}),e}(k.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ee(k[C]),require("assert").equal(k[C].length,0)}));var At;global[C]||Rt(global,k[C]);Ze.exports=Ke(mn(k));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!k.__patched&&(Ze.exports=Ke(k),k.__patched=!0);function Ke(t){un(t),t.gracefulify=Ke,t.createReadStream=ht,t.createWriteStream=St;var e=t.readFile;t.readFile=r;function r(y,v,g){return typeof v=="function"&&(g=v,v=null),D(y,v,g);function D(j,F,P,O){return e(j,F,function(b){b&&(b.code==="EMFILE"||b.code==="ENFILE")?oe([D,[j,F,P],b,O||Date.now(),Date.now()]):typeof P=="function"&&P.apply(this,arguments)})}}var i=t.writeFile;t.writeFile=n;function n(y,v,g,D){return typeof g=="function"&&(D=g,g=null),j(y,v,g,D);function j(F,P,O,b,T){return i(F,P,O,function(x){x&&(x.code==="EMFILE"||x.code==="ENFILE")?oe([j,[F,P,O,b],x,T||Date.now(),Date.now()]):typeof b=="function"&&b.apply(this,arguments)})}}var o=t.appendFile;o&&(t.appendFile=s);function s(y,v,g,D){return typeof g=="function"&&(D=g,g=null),j(y,v,g,D);function j(F,P,O,b,T){return o(F,P,O,function(x){x&&(x.code==="EMFILE"||x.code==="ENFILE")?oe([j,[F,P,O,b],x,T||Date.now(),Date.now()]):typeof b=="function"&&b.apply(this,arguments)})}}var c=t.copyFile;c&&(t.copyFile=u);function u(y,v,g,D){return typeof g=="function"&&(D=g,g=0),j(y,v,g,D);function j(F,P,O,b,T){return c(F,P,O,function(x){x&&(x.code==="EMFILE"||x.code==="ENFILE")?oe([j,[F,P,O,b],x,T||Date.now(),Date.now()]):typeof b=="function"&&b.apply(this,arguments)})}}var f=t.readdir;t.readdir=m;var a=/^v[0-5]\./;function m(y,v,g){typeof v=="function"&&(g=v,v=null);var D=a.test(process.version)?function(P,O,b,T){return f(P,j(P,O,b,T))}:function(P,O,b,T){return f(P,O,j(P,O,b,T))};return D(y,v,g);function j(F,P,O,b){return function(T,x){T&&(T.code==="EMFILE"||T.code==="ENFILE")?oe([D,[F,P,O],T,b||Date.now(),Date.now()]):(x&&x.sort&&x.sort(),typeof O=="function"&&O.call(this,T,x))}}}if(process.version.substr(0,4)==="v0.8"){var p=fn(t);L=p.ReadStream,A=p.WriteStream}var l=t.ReadStream;l&&(L.prototype=Object.create(l.prototype),L.prototype.open=V);var d=t.WriteStream;d&&(A.prototype=Object.create(d.prototype),A.prototype.open=ue),Object.defineProperty(t,"ReadStream",{get:function(){return L},set:function(y){L=y},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return A},set:function(y){A=y},enumerable:!0,configurable:!0});var S=L;Object.defineProperty(t,"FileReadStream",{get:function(){return S},set:function(y){S=y},enumerable:!0,configurable:!0});var w=A;Object.defineProperty(t,"FileWriteStream",{get:function(){return w},set:function(y){w=y},enumerable:!0,configurable:!0});function L(y,v){return this instanceof L?(l.apply(this,arguments),this):L.apply(Object.create(L.prototype),arguments)}function V(){var y=this;Ge(y.path,y.flags,y.mode,function(v,g){v?(y.autoClose&&y.destroy(),y.emit("error",v)):(y.fd=g,y.emit("open",g),y.read())})}function A(y,v){return this instanceof A?(d.apply(this,arguments),this):A.apply(Object.create(A.prototype),arguments)}function ue(){var y=this;Ge(y.path,y.flags,y.mode,function(v,g){v?(y.destroy(),y.emit("error",v)):(y.fd=g,y.emit("open",g))})}function ht(y,v){return new t.ReadStream(y,v)}function St(y,v){return new t.WriteStream(y,v)}var _i=t.open;t.open=Ge;function Ge(y,v,g,D){return typeof g=="function"&&(D=g,g=null),j(y,v,g,D);function j(F,P,O,b,T){return _i(F,P,O,function(x,Es){x&&(x.code==="EMFILE"||x.code==="ENFILE")?oe([j,[F,P,O,b],x,T||Date.now(),Date.now()]):typeof b=="function"&&b.apply(this,arguments)})}}return t}function oe(t){ee("ENQUEUE",t[0].name,t[1]),k[C].push(t),Ye()}var ke;function Nt(){for(var t=Date.now(),e=0;e<k[C].length;++e)k[C][e].length>2&&(k[C][e][3]=t,k[C][e][4]=t);Ye()}function Ye(){if(clearTimeout(ke),ke=void 0,k[C].length!==0){var t=k[C].shift(),e=t[0],r=t[1],i=t[2],n=t[3],o=t[4];if(n===void 0)ee("RETRY",e.name,r),e.apply(null,r);else if(Date.now()-n>=6e4){ee("TIMEOUT",e.name,r);var s=r.pop();typeof s=="function"&&s.call(null,i)}else{var c=Date.now()-o,u=Math.max(o-n,1),f=Math.min(u*1.2,100);c>=f?(ee("RETRY",e.name,r),e.apply(null,r.concat([n]))):k[C].push(t)}ke===void 0&&(ke=setTimeout(Ye,0))}}});var R=h(U=>{"use strict";var _t=E().fromCallback,N=se(),dn=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchmod","lchown","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(t=>typeof N[t]=="function");Object.assign(U,N);dn.forEach(t=>{U[t]=_t(N[t])});U.exists=function(t,e){return typeof e=="function"?N.exists(t,e):new Promise(r=>N.exists(t,r))};U.read=function(t,e,r,i,n,o){return typeof o=="function"?N.read(t,e,r,i,n,o):new Promise((s,c)=>{N.read(t,e,r,i,n,(u,f,a)=>{if(u)return c(u);s({bytesRead:f,buffer:a})})})};U.write=function(t,e,...r){return typeof r[r.length-1]=="function"?N.write(t,e,...r):new Promise((i,n)=>{N.write(t,e,...r,(o,s,c)=>{if(o)return n(o);i({bytesWritten:s,buffer:c})})})};U.readv=function(t,e,...r){return typeof r[r.length-1]=="function"?N.readv(t,e,...r):new Promise((i,n)=>{N.readv(t,e,...r,(o,s,c)=>{if(o)return n(o);i({bytesRead:s,buffers:c})})})};U.writev=function(t,e,...r){return typeof r[r.length-1]=="function"?N.writev(t,e,...r):new Promise((i,n)=>{N.writev(t,e,...r,(o,s,c)=>{if(o)return n(o);i({bytesWritten:s,buffers:c})})})};typeof N.realpath.native=="function"?U.realpath.native=_t(N.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var Vt=h((Qs,qt)=>{"use strict";var yn=require("path");qt.exports.checkPath=function(e){if(process.platform==="win32"&&/[<>:"|?*]/.test(e.replace(yn.parse(e).root,""))){let i=new Error(`Path contains invalid characters: ${e}`);throw i.code="EINVAL",i}}});var Gt=h((zs,et)=>{"use strict";var Xt=R(),{checkPath:$t}=Vt(),Bt=t=>{let e={mode:511};return typeof t=="number"?t:{...e,...t}.mode};et.exports.makeDir=async(t,e)=>($t(t),Xt.mkdir(t,{mode:Bt(e),recursive:!0}));et.exports.makeDirSync=(t,e)=>($t(t),Xt.mkdirSync(t,{mode:Bt(e),recursive:!0}))});var $=h((Ks,Jt)=>{"use strict";var hn=E().fromPromise,{makeDir:Sn,makeDirSync:tt}=Gt(),rt=hn(Sn);Jt.exports={mkdirs:rt,mkdirsSync:tt,mkdirp:rt,mkdirpSync:tt,ensureDir:rt,ensureDirSync:tt}});var z=h((Ys,Ut)=>{"use strict";var gn=E().fromPromise,Wt=R();function vn(t){return Wt.access(t).then(()=>!0).catch(()=>!1)}Ut.exports={pathExists:gn(vn),pathExistsSync:Wt.existsSync}});var it=h((Zs,Ht)=>{"use strict";var ae=R(),wn=E().fromPromise;async function bn(t,e,r){let i=await ae.open(t,"r+"),n=null;try{await ae.futimes(i,e,r)}finally{try{await ae.close(i)}catch(o){n=o}}if(n)throw n}function xn(t,e,r){let i=ae.openSync(t,"r+");return ae.futimesSync(i,e,r),ae.closeSync(i)}Ht.exports={utimesMillis:wn(bn),utimesMillisSync:xn}});var te=h((ea,Yt)=>{"use strict";var ce=R(),M=require("path"),Qt=E().fromPromise;function Ln(t,e,r){let i=r.dereference?n=>ce.stat(n,{bigint:!0}):n=>ce.lstat(n,{bigint:!0});return Promise.all([i(t),i(e).catch(n=>{if(n.code==="ENOENT")return null;throw n})]).then(([n,o])=>({srcStat:n,destStat:o}))}function Pn(t,e,r){let i,n=r.dereference?s=>ce.statSync(s,{bigint:!0}):s=>ce.lstatSync(s,{bigint:!0}),o=n(t);try{i=n(e)}catch(s){if(s.code==="ENOENT")return{srcStat:o,destStat:null};throw s}return{srcStat:o,destStat:i}}async function kn(t,e,r,i){let{srcStat:n,destStat:o}=await Ln(t,e,i);if(o){if(fe(n,o)){let s=M.basename(t),c=M.basename(e);if(r==="move"&&s!==c&&s.toLowerCase()===c.toLowerCase())return{srcStat:n,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(n.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'.`);if(!n.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${t}'.`)}if(n.isDirectory()&&nt(t,e))throw new Error(Fe(t,e,r));return{srcStat:n,destStat:o}}function On(t,e,r,i){let{srcStat:n,destStat:o}=Pn(t,e,i);if(o){if(fe(n,o)){let s=M.basename(t),c=M.basename(e);if(r==="move"&&s!==c&&s.toLowerCase()===c.toLowerCase())return{srcStat:n,destStat:o,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(n.isDirectory()&&!o.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'.`);if(!n.isDirectory()&&o.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${t}'.`)}if(n.isDirectory()&&nt(t,e))throw new Error(Fe(t,e,r));return{srcStat:n,destStat:o}}async function zt(t,e,r,i){let n=M.resolve(M.dirname(t)),o=M.resolve(M.dirname(r));if(o===n||o===M.parse(o).root)return;let s;try{s=await ce.stat(o,{bigint:!0})}catch(c){if(c.code==="ENOENT")return;throw c}if(fe(e,s))throw new Error(Fe(t,r,i));return zt(t,e,o,i)}function Kt(t,e,r,i){let n=M.resolve(M.dirname(t)),o=M.resolve(M.dirname(r));if(o===n||o===M.parse(o).root)return;let s;try{s=ce.statSync(o,{bigint:!0})}catch(c){if(c.code==="ENOENT")return;throw c}if(fe(e,s))throw new Error(Fe(t,r,i));return Kt(t,e,o,i)}function fe(t,e){return e.ino&&e.dev&&e.ino===t.ino&&e.dev===t.dev}function nt(t,e){let r=M.resolve(t).split(M.sep).filter(n=>n),i=M.resolve(e).split(M.sep).filter(n=>n);return r.every((n,o)=>i[o]===n)}function Fe(t,e,r){return`Cannot ${r} '${t}' to a subdirectory of itself, '${e}'.`}Yt.exports={checkPaths:Qt(kn),checkPathsSync:On,checkParentPaths:Qt(zt),checkParentPathsSync:Kt,isSrcSubdir:nt,areIdentical:fe}});var ir=h((ta,rr)=>{"use strict";var I=R(),me=require("path"),{mkdirs:Fn}=$(),{pathExists:En}=z(),{utimesMillis:Mn}=it(),pe=te();async function Dn(t,e,r={}){typeof r=="function"&&(r={filter:r}),r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
4
+
5
+ see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001");let{srcStat:i,destStat:n}=await pe.checkPaths(t,e,"copy",r);if(await pe.checkParentPaths(t,i,e,"copy"),!await er(t,e,r))return;let s=me.dirname(e);await En(s)||await Fn(s),await tr(n,t,e,r)}async function er(t,e,r){return r.filter?r.filter(t,e):!0}async function tr(t,e,r,i){let o=await(i.dereference?I.stat:I.lstat)(e);if(o.isDirectory())return In(o,t,e,r,i);if(o.isFile()||o.isCharacterDevice()||o.isBlockDevice())return jn(o,t,e,r,i);if(o.isSymbolicLink())return An(t,e,r,i);throw o.isSocket()?new Error(`Cannot copy a socket file: ${e}`):o.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${e}`):new Error(`Unknown file: ${e}`)}async function jn(t,e,r,i,n){if(!e)return Zt(t,r,i,n);if(n.overwrite)return await I.unlink(i),Zt(t,r,i,n);if(n.errorOnExist)throw new Error(`'${i}' already exists`)}async function Zt(t,e,r,i){if(await I.copyFile(e,r),i.preserveTimestamps){Tn(t.mode)&&await Cn(r,t.mode);let n=await I.stat(e);await Mn(r,n.atime,n.mtime)}return I.chmod(r,t.mode)}function Tn(t){return(t&128)===0}function Cn(t,e){return I.chmod(t,e|128)}async function In(t,e,r,i,n){e||await I.mkdir(i);let o=await I.readdir(r);await Promise.all(o.map(async s=>{let c=me.join(r,s),u=me.join(i,s);if(!await er(c,u,n))return;let{destStat:a}=await pe.checkPaths(c,u,"copy",n);return tr(a,c,u,n)})),e||await I.chmod(i,t.mode)}async function An(t,e,r,i){let n=await I.readlink(e);if(i.dereference&&(n=me.resolve(process.cwd(),n)),!t)return I.symlink(n,r);let o=null;try{o=await I.readlink(r)}catch(s){if(s.code==="EINVAL"||s.code==="UNKNOWN")return I.symlink(n,r);throw s}if(i.dereference&&(o=me.resolve(process.cwd(),o)),pe.isSrcSubdir(n,o))throw new Error(`Cannot copy '${n}' to a subdirectory of itself, '${o}'.`);if(pe.isSrcSubdir(o,n))throw new Error(`Cannot overwrite '${o}' with '${n}'.`);return await I.unlink(r),I.symlink(n,r)}rr.exports=Dn});var cr=h((ra,ar)=>{"use strict";var _=se(),de=require("path"),Nn=$().mkdirsSync,Rn=it().utimesMillisSync,ye=te();function _n(t,e,r){typeof r=="function"&&(r={filter:r}),r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
6
+
7
+ see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0002");let{srcStat:i,destStat:n}=ye.checkPathsSync(t,e,"copy",r);if(ye.checkParentPathsSync(t,i,e,"copy"),r.filter&&!r.filter(t,e))return;let o=de.dirname(e);return _.existsSync(o)||Nn(o),nr(n,t,e,r)}function nr(t,e,r,i){let o=(i.dereference?_.statSync:_.lstatSync)(e);if(o.isDirectory())return Jn(o,t,e,r,i);if(o.isFile()||o.isCharacterDevice()||o.isBlockDevice())return qn(o,t,e,r,i);if(o.isSymbolicLink())return Hn(t,e,r,i);throw o.isSocket()?new Error(`Cannot copy a socket file: ${e}`):o.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${e}`):new Error(`Unknown file: ${e}`)}function qn(t,e,r,i,n){return e?Vn(t,r,i,n):or(t,r,i,n)}function Vn(t,e,r,i){if(i.overwrite)return _.unlinkSync(r),or(t,e,r,i);if(i.errorOnExist)throw new Error(`'${r}' already exists`)}function or(t,e,r,i){return _.copyFileSync(e,r),i.preserveTimestamps&&Xn(t.mode,e,r),ot(r,t.mode)}function Xn(t,e,r){return $n(t)&&Bn(r,t),Gn(e,r)}function $n(t){return(t&128)===0}function Bn(t,e){return ot(t,e|128)}function ot(t,e){return _.chmodSync(t,e)}function Gn(t,e){let r=_.statSync(t);return Rn(e,r.atime,r.mtime)}function Jn(t,e,r,i,n){return e?sr(r,i,n):Wn(t.mode,r,i,n)}function Wn(t,e,r,i){return _.mkdirSync(r),sr(e,r,i),ot(r,t)}function sr(t,e,r){_.readdirSync(t).forEach(i=>Un(i,t,e,r))}function Un(t,e,r,i){let n=de.join(e,t),o=de.join(r,t);if(i.filter&&!i.filter(n,o))return;let{destStat:s}=ye.checkPathsSync(n,o,"copy",i);return nr(s,n,o,i)}function Hn(t,e,r,i){let n=_.readlinkSync(e);if(i.dereference&&(n=de.resolve(process.cwd(),n)),t){let o;try{o=_.readlinkSync(r)}catch(s){if(s.code==="EINVAL"||s.code==="UNKNOWN")return _.symlinkSync(n,r);throw s}if(i.dereference&&(o=de.resolve(process.cwd(),o)),ye.isSrcSubdir(n,o))throw new Error(`Cannot copy '${n}' to a subdirectory of itself, '${o}'.`);if(ye.isSrcSubdir(o,n))throw new Error(`Cannot overwrite '${o}' with '${n}'.`);return Qn(n,r)}else return _.symlinkSync(n,r)}function Qn(t,e){return _.unlinkSync(e),_.symlinkSync(t,e)}ar.exports=_n});var Ee=h((ia,lr)=>{"use strict";var zn=E().fromPromise;lr.exports={copy:zn(ir()),copySync:cr()}});var he=h((na,fr)=>{"use strict";var ur=se(),Kn=E().fromCallback;function Yn(t,e){ur.rm(t,{recursive:!0,force:!0},e)}function Zn(t){ur.rmSync(t,{recursive:!0,force:!0})}fr.exports={remove:Kn(Yn),removeSync:Zn}});var vr=h((oa,gr)=>{"use strict";var eo=E().fromPromise,dr=R(),yr=require("path"),hr=$(),Sr=he(),mr=eo(async function(e){let r;try{r=await dr.readdir(e)}catch{return hr.mkdirs(e)}return Promise.all(r.map(i=>Sr.remove(yr.join(e,i))))});function pr(t){let e;try{e=dr.readdirSync(t)}catch{return hr.mkdirsSync(t)}e.forEach(r=>{r=yr.join(t,r),Sr.removeSync(r)})}gr.exports={emptyDirSync:pr,emptydirSync:pr,emptyDir:mr,emptydir:mr}});var Lr=h((sa,xr)=>{"use strict";var to=E().fromPromise,wr=require("path"),H=R(),br=$();async function ro(t){let e;try{e=await H.stat(t)}catch{}if(e&&e.isFile())return;let r=wr.dirname(t),i=null;try{i=await H.stat(r)}catch(n){if(n.code==="ENOENT"){await br.mkdirs(r),await H.writeFile(t,"");return}else throw n}i.isDirectory()?await H.writeFile(t,""):await H.readdir(r)}function io(t){let e;try{e=H.statSync(t)}catch{}if(e&&e.isFile())return;let r=wr.dirname(t);try{H.statSync(r).isDirectory()||H.readdirSync(r)}catch(i){if(i&&i.code==="ENOENT")br.mkdirsSync(r);else throw i}H.writeFileSync(t,"")}xr.exports={createFile:to(ro),createFileSync:io}});var Er=h((aa,Fr)=>{"use strict";var no=E().fromPromise,Pr=require("path"),K=R(),kr=$(),{pathExists:oo}=z(),{areIdentical:Or}=te();async function so(t,e){let r;try{r=await K.lstat(e)}catch{}let i;try{i=await K.lstat(t)}catch(s){throw s.message=s.message.replace("lstat","ensureLink"),s}if(r&&Or(i,r))return;let n=Pr.dirname(e);await oo(n)||await kr.mkdirs(n),await K.link(t,e)}function ao(t,e){let r;try{r=K.lstatSync(e)}catch{}try{let o=K.lstatSync(t);if(r&&Or(o,r))return}catch(o){throw o.message=o.message.replace("lstat","ensureLink"),o}let i=Pr.dirname(e);return K.existsSync(i)||kr.mkdirsSync(i),K.linkSync(t,e)}Fr.exports={createLink:no(so),createLinkSync:ao}});var Dr=h((ca,Mr)=>{"use strict";var Y=require("path"),Se=R(),{pathExists:co}=z(),lo=E().fromPromise;async function uo(t,e){if(Y.isAbsolute(t)){try{await Se.lstat(t)}catch(o){throw o.message=o.message.replace("lstat","ensureSymlink"),o}return{toCwd:t,toDst:t}}let r=Y.dirname(e),i=Y.join(r,t);if(await co(i))return{toCwd:i,toDst:t};try{await Se.lstat(t)}catch(o){throw o.message=o.message.replace("lstat","ensureSymlink"),o}return{toCwd:t,toDst:Y.relative(r,t)}}function fo(t,e){if(Y.isAbsolute(t)){if(!Se.existsSync(t))throw new Error("absolute srcpath does not exist");return{toCwd:t,toDst:t}}let r=Y.dirname(e),i=Y.join(r,t);if(Se.existsSync(i))return{toCwd:i,toDst:t};if(!Se.existsSync(t))throw new Error("relative srcpath does not exist");return{toCwd:t,toDst:Y.relative(r,t)}}Mr.exports={symlinkPaths:lo(uo),symlinkPathsSync:fo}});var Cr=h((la,Tr)=>{"use strict";var jr=R(),mo=E().fromPromise;async function po(t,e){if(e)return e;let r;try{r=await jr.lstat(t)}catch{return"file"}return r&&r.isDirectory()?"dir":"file"}function yo(t,e){if(e)return e;let r;try{r=jr.lstatSync(t)}catch{return"file"}return r&&r.isDirectory()?"dir":"file"}Tr.exports={symlinkType:mo(po),symlinkTypeSync:yo}});var Rr=h((ua,Nr)=>{"use strict";var ho=E().fromPromise,Ir=require("path"),G=R(),{mkdirs:So,mkdirsSync:go}=$(),{symlinkPaths:vo,symlinkPathsSync:wo}=Dr(),{symlinkType:bo,symlinkTypeSync:xo}=Cr(),{pathExists:Lo}=z(),{areIdentical:Ar}=te();async function Po(t,e,r){let i;try{i=await G.lstat(e)}catch{}if(i&&i.isSymbolicLink()){let[c,u]=await Promise.all([G.stat(t),G.stat(e)]);if(Ar(c,u))return}let n=await vo(t,e);t=n.toDst;let o=await bo(n.toCwd,r),s=Ir.dirname(e);return await Lo(s)||await So(s),G.symlink(t,e,o)}function ko(t,e,r){let i;try{i=G.lstatSync(e)}catch{}if(i&&i.isSymbolicLink()){let c=G.statSync(t),u=G.statSync(e);if(Ar(c,u))return}let n=wo(t,e);t=n.toDst,r=xo(n.toCwd,r);let o=Ir.dirname(e);return G.existsSync(o)||go(o),G.symlinkSync(t,e,r)}Nr.exports={createSymlink:ho(Po),createSymlinkSync:ko}});var Jr=h((fa,Gr)=>{"use strict";var{createFile:_r,createFileSync:qr}=Lr(),{createLink:Vr,createLinkSync:Xr}=Er(),{createSymlink:$r,createSymlinkSync:Br}=Rr();Gr.exports={createFile:_r,createFileSync:qr,ensureFile:_r,ensureFileSync:qr,createLink:Vr,createLinkSync:Xr,ensureLink:Vr,ensureLinkSync:Xr,createSymlink:$r,createSymlinkSync:Br,ensureSymlink:$r,ensureSymlinkSync:Br}});var Me=h((ma,Wr)=>{function Oo(t,{EOL:e=`
8
+ `,finalEOL:r=!0,replacer:i=null,spaces:n}={}){let o=r?e:"";return JSON.stringify(t,i,n).replace(/\n/g,e)+o}function Fo(t){return Buffer.isBuffer(t)&&(t=t.toString("utf8")),t.replace(/^\uFEFF/,"")}Wr.exports={stringify:Oo,stripBom:Fo}});var zr=h((pa,Qr)=>{var le;try{le=se()}catch{le=require("fs")}var De=E(),{stringify:Ur,stripBom:Hr}=Me();async function Eo(t,e={}){typeof e=="string"&&(e={encoding:e});let r=e.fs||le,i="throws"in e?e.throws:!0,n=await De.fromCallback(r.readFile)(t,e);n=Hr(n);let o;try{o=JSON.parse(n,e?e.reviver:null)}catch(s){if(i)throw s.message=`${t}: ${s.message}`,s;return null}return o}var Mo=De.fromPromise(Eo);function Do(t,e={}){typeof e=="string"&&(e={encoding:e});let r=e.fs||le,i="throws"in e?e.throws:!0;try{let n=r.readFileSync(t,e);return n=Hr(n),JSON.parse(n,e.reviver)}catch(n){if(i)throw n.message=`${t}: ${n.message}`,n;return null}}async function jo(t,e,r={}){let i=r.fs||le,n=Ur(e,r);await De.fromCallback(i.writeFile)(t,n,r)}var To=De.fromPromise(jo);function Co(t,e,r={}){let i=r.fs||le,n=Ur(e,r);return i.writeFileSync(t,n,r)}var Io={readFile:Mo,readFileSync:Do,writeFile:To,writeFileSync:Co};Qr.exports=Io});var Yr=h((da,Kr)=>{"use strict";var je=zr();Kr.exports={readJson:je.readFile,readJsonSync:je.readFileSync,writeJson:je.writeFile,writeJsonSync:je.writeFileSync}});var Te=h((ya,ti)=>{"use strict";var Ao=E().fromPromise,st=R(),Zr=require("path"),ei=$(),No=z().pathExists;async function Ro(t,e,r="utf-8"){let i=Zr.dirname(t);return await No(i)||await ei.mkdirs(i),st.writeFile(t,e,r)}function _o(t,...e){let r=Zr.dirname(t);st.existsSync(r)||ei.mkdirsSync(r),st.writeFileSync(t,...e)}ti.exports={outputFile:Ao(Ro),outputFileSync:_o}});var ii=h((ha,ri)=>{"use strict";var{stringify:qo}=Me(),{outputFile:Vo}=Te();async function Xo(t,e,r={}){let i=qo(e,r);await Vo(t,i,r)}ri.exports=Xo});var oi=h((Sa,ni)=>{"use strict";var{stringify:$o}=Me(),{outputFileSync:Bo}=Te();function Go(t,e,r){let i=$o(e,r);Bo(t,i,r)}ni.exports=Go});var ai=h((ga,si)=>{"use strict";var Jo=E().fromPromise,q=Yr();q.outputJson=Jo(ii());q.outputJsonSync=oi();q.outputJSON=q.outputJson;q.outputJSONSync=q.outputJsonSync;q.writeJSON=q.writeJson;q.writeJSONSync=q.writeJsonSync;q.readJSON=q.readJson;q.readJSONSync=q.readJsonSync;si.exports=q});var mi=h((va,fi)=>{"use strict";var Wo=R(),ci=require("path"),{copy:Uo}=Ee(),{remove:ui}=he(),{mkdirp:Ho}=$(),{pathExists:Qo}=z(),li=te();async function zo(t,e,r={}){let i=r.overwrite||r.clobber||!1,{srcStat:n,isChangingCase:o=!1}=await li.checkPaths(t,e,"move",r);await li.checkParentPaths(t,n,e,"move");let s=ci.dirname(e);return ci.parse(s).root!==s&&await Ho(s),Ko(t,e,i,o)}async function Ko(t,e,r,i){if(!i){if(r)await ui(e);else if(await Qo(e))throw new Error("dest already exists.")}try{await Wo.rename(t,e)}catch(n){if(n.code!=="EXDEV")throw n;await Yo(t,e,r)}}async function Yo(t,e,r){return await Uo(t,e,{overwrite:r,errorOnExist:!0,preserveTimestamps:!0}),ui(t)}fi.exports=zo});var Si=h((wa,hi)=>{"use strict";var di=se(),ct=require("path"),Zo=Ee().copySync,yi=he().removeSync,es=$().mkdirpSync,pi=te();function ts(t,e,r){r=r||{};let i=r.overwrite||r.clobber||!1,{srcStat:n,isChangingCase:o=!1}=pi.checkPathsSync(t,e,"move",r);return pi.checkParentPathsSync(t,n,e,"move"),rs(e)||es(ct.dirname(e)),is(t,e,i,o)}function rs(t){let e=ct.dirname(t);return ct.parse(e).root===e}function is(t,e,r,i){if(i)return at(t,e,r);if(r)return yi(e),at(t,e,r);if(di.existsSync(e))throw new Error("dest already exists.");return at(t,e,r)}function at(t,e,r){try{di.renameSync(t,e)}catch(i){if(i.code!=="EXDEV")throw i;return ns(t,e,r)}}function ns(t,e,r){return Zo(t,e,{overwrite:r,errorOnExist:!0,preserveTimestamps:!0}),yi(t)}hi.exports=ts});var vi=h((ba,gi)=>{"use strict";var os=E().fromPromise;gi.exports={move:os(mi()),moveSync:Si()}});var bi=h((xa,wi)=>{"use strict";wi.exports={...R(),...Ee(),...vr(),...Jr(),...ai(),...$(),...vi(),...Te(),...z(),...he()}});var xi=h(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.EXTENSIONS_LANGUAGES=void 0;Ce.EXTENSIONS_LANGUAGES={1:"Groff",2:"Groff",3:"Groff",4:"Groff",5:"Groff",6:"Groff",7:"Groff",8:"Groff",9:"Groff",abap:"ABAP",asc:"Public Key",ash:"AGS Script",ampl:"AMPL",mod:"XML",g4:"ANTLR",apib:"API Blueprint",apl:"APL",dyalog:"APL",asp:"ASP",asax:"ASP",ascx:"ASP",ashx:"ASP",asmx:"ASP",aspx:"ASP",axd:"ASP",dats:"ATS",hats:"ATS",sats:"ATS",as:"ActionScript",adb:"Ada",ada:"Ada",ads:"Ada",agda:"Agda",als:"Alloy",apacheconf:"ApacheConf",vhost:"Nginx",cls:"Visual Basic",applescript:"AppleScript",scpt:"AppleScript",arc:"Arc",ino:"Arduino",asciidoc:"AsciiDoc",adoc:"AsciiDoc",aj:"AspectJ",asm:"Assembly",a51:"Assembly",inc:"SourcePawn",nasm:"Assembly",aug:"Augeas",ahk:"AutoHotkey",ahkl:"AutoHotkey",au3:"AutoIt",awk:"Awk",auk:"Awk",gawk:"Awk",mawk:"Awk",nawk:"Awk",bat:"Batchfile",cmd:"Batchfile",befunge:"Befunge",bison:"Bison",bb:"BlitzBasic",decls:"BlitzBasic",bmx:"BlitzMax",bsv:"Bluespec",boo:"Boo",b:"Limbo",bf:"HyPhy",brs:"Brightscript",bro:"Bro",c:"C",cats:"C",h:"Objective-C",idc:"C",w:"C",cs:"Smalltalk",cake:"CoffeeScript",cshtml:"C#",csx:"C#",cpp:"C++","c++":"C++",cc:"C++",cp:"Component Pascal",cxx:"C++","h++":"C++",hh:"Hack",hpp:"C++",hxx:"C++",inl:"C++",ipp:"C++",tcc:"C++",tpp:"C++","c-objdump":"C-ObjDump",chs:"C2hs Haskell",clp:"CLIPS",cmake:"CMake","cmake.in":"CMake",cob:"COBOL",cbl:"COBOL",ccp:"COBOL",cobol:"COBOL",cpy:"COBOL",css:"CSS",csv:"CSV",capnp:"Cap'n Proto",mss:"CartoCSS",ceylon:"Ceylon",chpl:"Chapel",ch:"xBase",ck:"ChucK",cirru:"Cirru",clw:"Clarion",icl:"Clean",dcl:"Clean",click:"Click",clj:"Clojure",boot:"Clojure",cl2:"Clojure",cljc:"Clojure",cljs:"Clojure","cljs.hl":"Clojure",cljscm:"Clojure",cljx:"Clojure",hic:"Clojure",coffee:"CoffeeScript",_coffee:"CoffeeScript",cjsx:"CoffeeScript",cson:"CoffeeScript",iced:"CoffeeScript",cfm:"ColdFusion",cfml:"ColdFusion",cfc:"ColdFusion CFC",lisp:"NewLisp",asd:"Common Lisp",cl:"OpenCL",l:"PicoLisp",lsp:"NewLisp",ny:"Common Lisp",podsl:"Common Lisp",sexp:"Common Lisp",cps:"Component Pascal",coq:"Coq",v:"Verilog",cppobjdump:"Cpp-ObjDump","c++-objdump":"Cpp-ObjDump","c++objdump":"Cpp-ObjDump","cpp-objdump":"Cpp-ObjDump","cxx-objdump":"Cpp-ObjDump",creole:"Creole",cr:"Crystal",feature:"Cucumber",cu:"Cuda",cuh:"Cuda",cy:"Cycript",pyx:"Cython",pxd:"Cython",pxi:"Cython",d:"Makefile",di:"D","d-objdump":"D-ObjDump",com:"DIGITAL Command Language",dm:"DM",zone:"DNS Zone",arpa:"DNS Zone",darcspatch:"Darcs Patch",dpatch:"Darcs Patch",dart:"Dart",diff:"Diff",patch:"Diff",dockerfile:"Dockerfile",djs:"Dogescript",dylan:"Dylan",dyl:"Dylan",intr:"Dylan",lid:"Dylan",E:"E",ecl:"ECLiPSe",eclxml:"ECL",sch:"KiCad",brd:"KiCad",epj:"Ecere Projects",e:"Eiffel",ex:"Elixir",exs:"Elixir",elm:"Elm",el:"Emacs Lisp",emacs:"Emacs Lisp","emacs.desktop":"Emacs Lisp",em:"EmberScript",emberscript:"EmberScript",erl:"Erlang",es:"JavaScript",escript:"Erlang",hrl:"Erlang",xrl:"Erlang",yrl:"Erlang",fs:"GLSL",fsi:"F#",fsx:"F#",fx:"HLSL",flux:"FLUX",f90:"FORTRAN",f:"Forth",f03:"FORTRAN",f08:"FORTRAN",f77:"FORTRAN",f95:"FORTRAN",for:"Forth",fpp:"FORTRAN",factor:"Factor",fy:"Fancy",fancypack:"Fancy",fan:"Fantom","eam.fs":"Formatted",fth:"Forth","4th":"Forth",forth:"Forth",fr:"Text",frt:"Forth",ftl:"FreeMarker",g:"GAP",gco:"G-code",gcode:"G-code",gms:"GAMS",gap:"GAP",gd:"GDScript",gi:"GAP",tst:"Scilab",s:"GAS",ms:"MAXScript",glsl:"GLSL",fp:"GLSL",frag:"JavaScript",frg:"GLSL",fsh:"GLSL",fshader:"GLSL",geo:"GLSL",geom:"GLSL",glslv:"GLSL",gshader:"GLSL",shader:"GLSL",vert:"GLSL",vrx:"GLSL",vsh:"GLSL",vshader:"GLSL",gml:"XML",kid:"Genshi",ebuild:"Gentoo Ebuild",eclass:"Gentoo Eclass",po:"Gettext Catalog",pot:"Gettext Catalog",glf:"Glyph",gp:"Gnuplot",gnu:"Gnuplot",gnuplot:"Gnuplot",plot:"Gnuplot",plt:"Gnuplot",go:"Go",golo:"Golo",gs:"JavaScript",gst:"Gosu",gsx:"Gosu",vark:"Gosu",grace:"Grace",gradle:"Gradle",gf:"Grammatical Framework",graphql:"GraphQL",dot:"Graphviz (DOT)",gv:"Graphviz (DOT)",man:"Groff","1in":"Groff","1m":"Groff","1x":"Groff","3in":"Groff","3m":"Groff","3qt":"Groff","3x":"Groff",me:"Groff",n:"Nemerle",rno:"Groff",roff:"Groff",groovy:"Groovy",grt:"Groovy",gtpl:"Groovy",gvy:"Groovy",gsp:"Groovy Server Pages",hcl:"HCL",tf:"HCL",hlsl:"HLSL",fxh:"HLSL",hlsli:"HLSL",html:"HTML",htm:"HTML","html.hl":"HTML",st:"Smalltalk",xht:"HTML",xhtml:"HTML",mustache:"HTML+Django",jinja:"HTML+Django",eex:"HTML+EEX",erb:"HTML+ERB","erb.deface":"HTML+ERB",phtml:"HTML+PHP",http:"HTTP",php:"PHP",haml:"Haml","haml.deface":"Haml",handlebars:"Handlebars",hbs:"Handlebars",hb:"Harbour",hs:"Haskell",hsc:"Haskell",hx:"Haxe",hxsl:"Haxe",hy:"Hy",pro:"QMake",dlm:"IDL",ipf:"IGOR Pro",ini:"INI",cfg:"INI",prefs:"INI",properties:"INI",irclog:"IRC log",weechatlog:"IRC log",idr:"Idris",lidr:"Idris",ni:"Inform 7",i7x:"Inform 7",iss:"Inno Setup",io:"Io",ik:"Ioke",thy:"Isabelle",ijs:"J",flex:"JFlex",jflex:"JFlex",json:"JSON",geojson:"JSON",lock:"JSON",topojson:"JSON",json5:"JSON5",jsonld:"JSONLD",jq:"JSONiq",jsx:"JSX",jade:"Jade",j:"Objective-J",java:"Java",jsp:"Java Server Pages",js:"JavaScript",_js:"JavaScript",bones:"JavaScript",es6:"JavaScript",jake:"JavaScript",jsb:"JavaScript",jscad:"JavaScript",jsfl:"JavaScript",jsm:"JavaScript",jss:"JavaScript",njs:"JavaScript",pac:"JavaScript",sjs:"JavaScript",ssjs:"JavaScript","sublime-build":"JavaScript","sublime-commands":"JavaScript","sublime-completions":"JavaScript","sublime-keymap":"JavaScript","sublime-macro":"JavaScript","sublime-menu":"JavaScript","sublime-mousemap":"JavaScript","sublime-project":"JavaScript","sublime-settings":"JavaScript","sublime-theme":"JavaScript","sublime-workspace":"JavaScript",sublime_metrics:"JavaScript",sublime_session:"JavaScript",xsjs:"JavaScript",xsjslib:"JavaScript",jl:"Julia",ipynb:"Jupyter Notebook",krl:"KRL",kicad_pcb:"KiCad",kit:"Kit",kt:"Kotlin",ktm:"Kotlin",kts:"Kotlin",lfe:"LFE",ll:"LLVM",lol:"LOLCODE",lsl:"LSL",lslp:"LSL",lvproj:"LabVIEW",lasso:"Lasso",las:"Lasso",lasso8:"Lasso",lasso9:"Lasso",ldml:"Lasso",latte:"Latte",lean:"Lean",hlean:"Lean",less:"Less",lex:"Lex",ly:"LilyPond",ily:"LilyPond",m:"Objective-C",ld:"Linker Script",lds:"Linker Script",liquid:"Liquid",lagda:"Literate Agda",litcoffee:"Literate CoffeeScript",lhs:"Literate Haskell",ls:"LoomScript",_ls:"LiveScript",xm:"Logos",x:"Logos",xi:"Logos",lgt:"Logtalk",logtalk:"Logtalk",lookml:"LookML",lua:"Lua",fcgi:"Shell",nse:"Lua",pd_lua:"Lua",rbxs:"Lua",wlua:"Lua",mumps:"M",m4:"M4Sugar",mcr:"MAXScript",mtml:"MTML",muf:"MUF",mak:"Makefile",mk:"Makefile",mkfile:"Makefile",mako:"Mako",mao:"Mako",md:"Markdown",markdown:"Markdown",mkd:"Markdown",mkdn:"Markdown",mkdown:"Markdown",ron:"Markdown",mask:"Mask",mathematica:"Mathematica",cdf:"Mathematica",ma:"Mathematica",mt:"Mathematica",nb:"Text",nbp:"Mathematica",wl:"Mathematica",wlt:"Mathematica",matlab:"Matlab",maxpat:"Max",maxhelp:"Max",maxproj:"Max",mxt:"Max",pat:"Max",mediawiki:"MediaWiki",wiki:"MediaWiki",moo:"Moocode",metal:"Metal",minid:"MiniD",druby:"Mirah",duby:"Mirah",mir:"Mirah",mirah:"Mirah",mo:"Modelica",mms:"Module Management System",mmk:"Module Management System",monkey:"Monkey",moon:"MoonScript",myt:"Myghty",ncl:"Text",nl:"NewLisp",nsi:"NSIS",nsh:"NSIS",axs:"NetLinx",axi:"NetLinx","axs.erb":"NetLinx+ERB","axi.erb":"NetLinx+ERB",nlogo:"NetLogo",nginxconf:"Nginx",nim:"Nimrod",nimrod:"Nimrod",ninja:"Ninja",nit:"Nit",nix:"Nix",nu:"Nu",numpy:"NumPy",numpyw:"NumPy",numsc:"NumPy",ml:"OCaml",eliom:"OCaml",eliomi:"OCaml",ml4:"OCaml",mli:"OCaml",mll:"OCaml",mly:"OCaml",objdump:"ObjDump",mm:"XML",sj:"Objective-J",omgrofl:"Omgrofl",opa:"Opa",opal:"Opal",opencl:"OpenCL",p:"OpenEdge ABL",scad:"OpenSCAD",org:"Org",ox:"Ox",oxh:"Ox",oxo:"Ox",oxygene:"Oxygene",oz:"Oz",pwn:"PAWN",aw:"PHP",ctp:"PHP",php3:"PHP",php4:"PHP",php5:"PHP",phps:"PHP",phpt:"PHP",pls:"PLSQL",pck:"PLSQL",pkb:"PLSQL",pks:"PLSQL",plb:"PLSQL",plsql:"PLSQL",sql:"SQLPL",pov:"POV-Ray SDL",pan:"Pan",psc:"Papyrus",parrot:"Parrot",pasm:"Parrot Assembly",pir:"Parrot Internal Representation",pas:"Pascal",dfm:"Pascal",dpr:"Pascal",lpr:"Pascal",pp:"Puppet",pl:"Prolog",al:"Perl",cgi:"Shell",perl:"Perl",ph:"Perl",plx:"Perl",pm:"Perl6",pod:"Pod",psgi:"Perl",t:"Turing","6pl":"Perl6","6pm":"Perl6",nqp:"Perl6",p6:"Perl6",p6l:"Perl6",p6m:"Perl6",pl6:"Perl6",pm6:"Perl6",pkl:"Pickle",pig:"PigLatin",pike:"Pike",pmod:"Pike",pogo:"PogoScript",pony:"Pony",ps:"PostScript",eps:"PostScript",ps1:"PowerShell",psd1:"PowerShell",psm1:"PowerShell",pde:"Processing",prolog:"Prolog",yap:"Prolog",spin:"Propeller Spin",proto:"Protocol Buffer",pub:"Public Key",pd:"Pure Data",pb:"PureBasic",pbi:"PureBasic",purs:"PureScript",py:"Python",bzl:"Python",gyp:"Python",lmi:"Python",pyde:"Python",pyp:"Python",pyt:"Python",pyw:"Python",rpy:"Ren'Py",tac:"Python",wsgi:"Python",xpy:"Python",pytb:"Python traceback",qml:"QML",qbs:"QML",pri:"QMake",r:"Rebol",rd:"R",rsx:"R",raml:"RAML",rdoc:"RDoc",rbbas:"REALbasic",rbfrm:"REALbasic",rbmnu:"REALbasic",rbres:"REALbasic",rbtbar:"REALbasic",rbuistate:"REALbasic",rhtml:"RHTML",rmd:"RMarkdown",rkt:"Racket",rktd:"Racket",rktl:"Racket",scrbl:"Racket",rl:"Ragel in Ruby Host",raw:"Raw token data",reb:"Rebol",r2:"Rebol",r3:"Rebol",rebol:"Rebol",red:"Red",reds:"Red",cw:"Redcode",rs:"Rust",rsh:"RenderScript",robot:"RobotFramework",rg:"Rouge",rb:"Ruby",builder:"Ruby",gemspec:"Ruby",god:"Ruby",irbrc:"Ruby",jbuilder:"Ruby",mspec:"Ruby",pluginspec:"XML",podspec:"Ruby",rabl:"Ruby",rake:"Ruby",rbuild:"Ruby",rbw:"Ruby",rbx:"Ruby",ru:"Ruby",ruby:"Ruby",thor:"Ruby",watchr:"Ruby","rs.in":"Rust",sas:"SAS",scss:"SCSS",smt2:"SMT",smt:"SMT",sparql:"SPARQL",rq:"SPARQL",sqf:"SQF",hqf:"SQF",cql:"SQL",ddl:"SQL",prc:"SQL",tab:"SQL",udf:"SQL",viw:"SQL",db2:"SQLPL",ston:"STON",svg:"SVG",sage:"Sage",sagews:"Sage",sls:"Scheme",sass:"Sass",scala:"Scala",sbt:"Scala",sc:"SuperCollider",scaml:"Scaml",scm:"Scheme",sld:"Scheme",sps:"Scheme",ss:"Scheme",sci:"Scilab",sce:"Scilab",self:"Self",sh:"Shell",bash:"Shell",bats:"Shell",command:"Shell",ksh:"Shell","sh.in":"Shell",tmux:"Shell",tool:"Shell",zsh:"Shell","sh-session":"ShellSession",shen:"Shen",sl:"Slash",slim:"Slim",smali:"Smali",tpl:"Smarty",sp:"SourcePawn",sma:"SourcePawn",nut:"Squirrel",stan:"Stan",ML:"Standard ML",fun:"Standard ML",sig:"Standard ML",sml:"Standard ML",do:"Stata",ado:"Stata",doh:"Stata",ihlp:"Stata",mata:"Stata",matah:"Stata",sthlp:"Stata",styl:"Stylus",scd:"SuperCollider",swift:"Swift",sv:"SystemVerilog",svh:"SystemVerilog",vh:"SystemVerilog",toml:"TOML",txl:"TXL",tcl:"Tcl",adp:"Tcl",tm:"Tcl",tcsh:"Tcsh",csh:"Tcsh",tex:"TeX",aux:"TeX",bbx:"TeX",bib:"TeX",cbx:"TeX",dtx:"TeX",ins:"TeX",lbx:"TeX",ltx:"TeX",mkii:"TeX",mkiv:"TeX",mkvi:"TeX",sty:"TeX",toc:"TeX",tea:"Tea",txt:"Text",no:"Text",textile:"Textile",thrift:"Thrift",tu:"Turing",ttl:"Turtle",twig:"Twig",ts:"XML",tsx:"XML",upc:"Unified Parallel C",anim:"Unity3D Asset",asset:"Unity3D Asset",mat:"Unity3D Asset",meta:"Unity3D Asset",prefab:"Unity3D Asset",unity:"Unity3D Asset",uno:"Uno",uc:"UnrealScript",ur:"UrWeb",urs:"UrWeb",vcl:"VCL",vhdl:"VHDL",vhd:"VHDL",vhf:"VHDL",vhi:"VHDL",vho:"VHDL",vhs:"VHDL",vht:"VHDL",vhw:"VHDL",vala:"Vala",vapi:"Vala",veo:"Verilog",vim:"VimL",vb:"Visual Basic",bas:"Visual Basic",frm:"Visual Basic",frx:"Visual Basic",vba:"Visual Basic",vbhtml:"Visual Basic",vbs:"Visual Basic",volt:"Volt",vue:"Vue",owl:"Web Ontology Language",webidl:"WebIDL",x10:"X10",xc:"XC",xml:"XML",ant:"XML",axml:"XML",ccxml:"XML",clixml:"XML",cproject:"XML",csl:"XML",csproj:"XML",ct:"XML",dita:"XML",ditamap:"XML",ditaval:"XML","dll.config":"XML",dotsettings:"XML",filters:"XML",fsproj:"XML",fxml:"XML",glade:"XML",grxml:"XML",iml:"XML",ivy:"XML",jelly:"XML",jsproj:"XML",kml:"XML",launch:"XML",mdpolicy:"XML",mxml:"XML",nproj:"XML",nuspec:"XML",odd:"XML",osm:"XML",plist:"XML",props:"XML",ps1xml:"XML",psc1:"XML",pt:"XML",rdf:"XML",rss:"XML",scxml:"XML",srdf:"XML",storyboard:"XML",stTheme:"XML","sublime-snippet":"XML",targets:"XML",tmCommand:"XML",tml:"XML",tmLanguage:"XML",tmPreferences:"XML",tmSnippet:"XML",tmTheme:"XML",ui:"XML",urdf:"XML",ux:"XML",vbproj:"XML",vcxproj:"XML",vssettings:"XML",vxml:"XML",wsdl:"XML",wsf:"XML",wxi:"XML",wxl:"XML",wxs:"XML",x3d:"XML",xacro:"XML",xaml:"XML",xib:"XML",xlf:"XML",xliff:"XML",xmi:"XML","xml.dist":"XML",xproj:"XML",xsd:"XML",xul:"XML",zcml:"XML","xsp-config":"XPages","xsp.metadata":"XPages",xpl:"XProc",xproc:"XProc",xquery:"XQuery",xq:"XQuery",xql:"XQuery",xqm:"XQuery",xqy:"XQuery",xs:"XS",xslt:"XSLT",xsl:"XSLT",xojo_code:"Xojo",xojo_menu:"Xojo",xojo_report:"Xojo",xojo_script:"Xojo",xojo_toolbar:"Xojo",xojo_window:"Xojo",xtend:"Xtend",yml:"YAML",reek:"YAML",rviz:"YAML","sublime-syntax":"YAML",syntax:"YAML",yaml:"YAML","yaml-tmlanguage":"YAML",yang:"YANG",y:"Yacc",yacc:"Yacc",yy:"Yacc",zep:"Zephir",zimpl:"Zimpl",zmpl:"Zimpl",zpl:"Zimpl",desktop:"desktop","desktop.in":"desktop",ec:"eC",eh:"eC",edn:"edn",fish:"fish",mu:"mupad",nc:"nesC",ooc:"ooc",rst:"reStructuredText",rest:"reStructuredText","rest.txt":"reStructuredText","rst.txt":"reStructuredText",wisp:"wisp",prg:"xBase",prw:"xBase"}});var ge=h(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.setOptionValues=ss;function ss(t,e){for(let r of Object.keys(e))t[r]!==void 0&&(e[r]=t[r]);return e}});var Pi=h(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.SarifBuilder=void 0;var as=require("path"),Li=bi(),cs=xi(),ls=ge(),ut=class{constructor(e={}){this.log={$schema:"http://json.schemastore.org/sarif-2.1.0.json",version:"2.1.0",runs:[]},(0,ls.setOptionValues)(e,this.log)}addRun(e){this.log.runs.push(e.run)}generateSarifFileSync(e){let r=this.buildSarifJsonString();Li.writeFileSync(e,r,"utf8")}async generateSarifFile(e){let r=this.buildSarifJsonString();await Li.writeFile(e,r,"utf8")}buildSarifOutput(){return this.log.runs=this.log.runs.map(e=>this.completeRunFields(e)),this.log}buildSarifJsonString(e={indent:!1}){this.buildSarifOutput();let r=e.indent?JSON.stringify(this.log,null,2):JSON.stringify(this.log);if(r.includes("SARIF_BUILDER_INVALID"))throw new Error("Your SARIF log is invalid, please solve SARIF_BUILDER_INVALID messages");return r}completeRunFields(e){var r,i,n,o;e.artifacts=e.artifacts||[];for(let u of e.results)for(let f of u.locations||[])if(!((i=(r=f?.physicalLocation)===null||r===void 0?void 0:r.artifactLocation)===null||i===void 0)&&i.uri&&e.artifacts.filter(a=>{var m;return((m=a?.location)===null||m===void 0?void 0:m.uri)===f.physicalLocation.artifactLocation.uri}).length===0){let a=as.extname(f.physicalLocation.artifactLocation.uri).replace(".",""),m=cs.EXTENSIONS_LANGUAGES[a]||"unknown";e.artifacts.push({sourceLanguage:m,location:{uri:f.physicalLocation.artifactLocation.uri}})}let s=e.artifacts.map(u=>{var f;return(f=u?.location)===null||f===void 0?void 0:f.uri}),c=(((o=(n=e?.tool)===null||n===void 0?void 0:n.driver)===null||o===void 0?void 0:o.rules)||[]).map(u=>u.id);return e.results=e.results.map(u=>(c.indexOf(u.ruleId)>-1&&(u.ruleIndex=c.indexOf(u.ruleId)),u.locations&&(u.locations=u.locations.map(f=>{var a,m;let p=(m=(a=f?.physicalLocation)===null||a===void 0?void 0:a.artifactLocation)===null||m===void 0?void 0:m.uri;return p&&s.indexOf(p)>-1&&(f.physicalLocation.artifactLocation.index=s.indexOf(p)),f})),u)),e}};Ie.SarifBuilder=ut});var ki=h(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.SarifResultBuilder=void 0;var us=ge(),ft=class{constructor(e={}){this.result={level:"error",message:{},ruleId:"SARIF_BUILDER_INVALID: Please send the rule Id ruleId property, or call setRuleId(ruleId)"},(0,us.setOptionValues)(e,this.result)}initSimple(e){if(this.setLevel(e.level),this.setMessageText(e.messageText),this.setRuleId(e.ruleId),e.fileUri&&this.setLocationArtifactUri({uri:e.fileUri}),e.startLine!==null&&e.startLine!==void 0){let r={startLine:e.startLine,startColumn:e.startColumn||1,endLine:e.endLine||e.startLine,endColumn:e.endColumn||1};if(e.startLine===0||e.startColumn===0||e.endLine===0||e.endColumn===0)throw new Error("Region limit can not be 0 (minimum line 1 or column 1) in "+JSON.stringify(e));this.setLocationRegion(r)}return this}setLevel(e){this.result.level=e}setMessageText(e){this.result.message.text=e}setRuleId(e){this.result.ruleId=e}setLocationRegion(e){this.manageInitPhysicalLocation(),this.result.locations[0].physicalLocation.region=e}setLocationArtifactUri(e){this.manageInitPhysicalLocation(),this.result.locations[0].physicalLocation.artifactLocation=e}manageInitLocation(){var e,r;!((r=(e=this.result)===null||e===void 0?void 0:e.locations)===null||r===void 0)&&r.length||(this.result.locations=[{}])}manageInitPhysicalLocation(){var e;this.manageInitLocation(),!(!((e=this.result)===null||e===void 0)&&e.locations[0].physicalLocation)&&(this.result.locations[0].physicalLocation={})}};Ae.SarifResultBuilder=ft});var Oi=h(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.SarifRuleBuilder=void 0;var fs=ge(),mt=class{constructor(e={}){this.rule={id:"SARIF_BUILDER_INVALID: Please send the rule identifier in id property, or call setRuleId(ruleId)",shortDescription:{text:"SARIF_BUILDER_INVALID: Please send the rule text in shortDescription.text property, or call setShortDescriptionText(text)"}},(0,fs.setOptionValues)(e,this.rule)}initSimple(e){return this.setRuleId(e.ruleId),e.shortDescriptionText&&this.setShortDescriptionText(e.shortDescriptionText),e.fullDescriptionText&&this.setFullDescriptionText(e.fullDescriptionText),e.helpUri&&this.setHelpUri(e.helpUri),this}setRuleId(e){this.rule.id=e}setShortDescriptionText(e){this.rule.shortDescription.text=e}setFullDescriptionText(e){this.rule.fullDescription=this.rule.fullDescription||{text:""},this.rule.fullDescription.text=e}setHelpUri(e){this.rule.helpUri=e}};Ne.SarifRuleBuilder=mt});var Fi=h(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.SarifRunBuilder=void 0;var ms=ge(),pt=class{constructor(e={}){this.run={tool:{driver:{name:process.env.npm_package_name||"SARIF_BUILDER_INVALID: Please send the tool name in tool.driver.name property, or call setToolName(name)",rules:[]}},results:[]},(0,ms.setOptionValues)(e,this.run)}initSimple(e){return this.setToolDriverName(e.toolDriverName),this.setToolDriverVersion(e.toolDriverVersion),e.url&&this.setToolDriverUri(e.url),this}addRule(e){this.run.tool.driver.rules.push(e.rule)}addResult(e){this.run.results.push(e.result)}setToolDriverName(e){this.run.tool.driver.name=e}setToolDriverVersion(e){this.run.tool.driver.version=e}setToolDriverUri(e){this.run.tool.driver.informationUri=e}};Re.SarifRunBuilder=pt});var Ei=h(J=>{"use strict";Object.defineProperty(J,"__esModule",{value:!0});J.SarifResultBuilder=J.SarifRuleBuilder=J.SarifRunBuilder=J.SarifBuilder=void 0;var ps=Pi();Object.defineProperty(J,"SarifBuilder",{enumerable:!0,get:function(){return ps.SarifBuilder}});var ds=ki();Object.defineProperty(J,"SarifResultBuilder",{enumerable:!0,get:function(){return ds.SarifResultBuilder}});var ys=Oi();Object.defineProperty(J,"SarifRuleBuilder",{enumerable:!0,get:function(){return ys.SarifRuleBuilder}});var hs=Fi();Object.defineProperty(J,"SarifRunBuilder",{enumerable:!0,get:function(){return hs.SarifRunBuilder}})});var Di=h((Da,Mi)=>{"use strict";var Ss=/["'&<>]/;Mi.exports=gs;function gs(t){var e=""+t,r=Ss.exec(e);if(!r)return e;var i,n="",o=0,s=0;for(o=r.index;o<e.length;o++){switch(e.charCodeAt(o)){case 34:i="&quot;";break;case 38:i="&amp;";break;case 39:i="&#39;";break;case 60:i="&lt;";break;case 62:i="&gt;";break;default:continue}s!==o&&(n+=e.substring(s,o)),s=o+1,n+=i}return s!==o?n+e.substring(s,o):n}});var Be=require("zx"),re=require("fs/promises");var Je={UNKNOWN:0,LOW:1,MEDIUM:2,HIGH:3,CRITICAL:4};var we=class{allById=new Map;getAllVulnerabilitiesSortedBySeverity(){let e=Array.from(this.allById.values());return e.sort((r,i)=>{let n=wt(r.severity,i.severity);return n===0?r.id.localeCompare(i.id):-n}),e}addVulnerability(e,r){let i=e.id,n=this.allById;if(!n.has(i))n.set(i,e);else{let o=n.get(i);o.title=o.title||e.title,o.severity=Ji(o.severity,e.severity),o.scannerSeverity[r]=e.severity,o.detectedBy=We(o.detectedBy,r),o.components=We(o.components,e.components[0]),o.refs=We(o.refs,e.refs[0])}}enhanceWithVexData(e){let r=[];for(let i of this.allById.values()){let n=e.newestVulnerabilityStatement(i.id);if(!n){r.push(i.id);continue}i.vexStatement=n}return{unmatchedVulnerabilities:r}}};function Ji(t,e){return wt(t,e)>0?t:e}function wt(t,e){return Je[t]-Je[e]}function We(t,e){return e?Array.from(new Set([...t,e]).values()):t}var ne=require("path");var X=require("fs/promises"),Ue=require("path");async function B(t){if(await ie(t))return JSON.parse(await(0,X.readFile)(t,{encoding:"utf-8"}))}function W(t){return t&&t.replace(/\?.*$/,"")}async function ie(t){try{return await(0,X.access)(t,X.constants.F_OK),!0}catch{return!1}}async function He(t){let e=(0,Ue.resolve)(t),r=await(0,X.readdir)(e,{withFileTypes:!0});for(let i of r){let n=(0,Ue.resolve)(i.parentPath,i.name);i.isDirectory()?await He(n):await(0,X.rm)(n)}await(0,X.rmdir)(e)}async function bt(){let t="https://repository.conterra.de/repository/maven-mirror-ct",e="./input/vex",r="./output",i="./.cache",n=["grype","trivy","ossindex"],o=(0,ne.resolve)("./vuln-scan-conf.json"),s=await B(o);if(!s)throw new Error(`Missing project configuration file '${o}'`);return{failOnNewVulnerabilities:!1,createSubDirsForProject:s.createSubDirsForProject??!0,mavenRepo:s.mavenRepo??t,vexDir:(0,ne.resolve)(s.vexDir??e),outDir:(0,ne.resolve)(s.outDir??r),cacheDir:(0,ne.resolve)(s.cacheDir??i),scanners:s.scanners??n,projects:(s.projects??[]).map(c=>{let u=c;return u.sbomFile?{...u,sbomFile:(0,ne.resolve)(u.sbomFile)}:c})}}var xt=require("zx");var be=require("path");async function Lt(t,e,r,i){console.log(" with Grype ...");let n=(0,be.dirname)(e),o=(0,be.basename)(e),s=await xt.$`docker run --rm -v '${t}:/.cache' -v '${n}:/tmp/output' -v '${r.sbomFile}:/tmp/input.json' anchore/grype:latest sbom:/tmp/input.json -o json --file '/tmp/output/${o}' --by-cve --quiet`;s.stdout&&console.log(` Scan log: ${s.stdout}`),s.stderr&&console.log(` Scan error: ${s.stderr}`),console.log(` Grype output file: ${e}`);let c=await B(e);Wi(i,c)}function Wi(t,e){if(e)for(let r of e.matches){let i=Ui(r);t.addVulnerability(i,"grype")}}function Ui(t){let e=t.vulnerability,r=e.id,i=W(t.artifact.purl),n=W(e.dataSource),o=Hi(e.severity);return{id:r,severity:o,scannerSeverity:{grype:o},title:"",description:e.description,components:[i],detectedBy:["grype"],refs:[n]}}function Hi(t){switch(t){case"Negligible":return"LOW";case"Low":return"LOW";case"Medium":return"MEDIUM";case"High":return"HIGH";case"Critical":return"CRITICAL";default:return"UNKNOWN"}}var Pt=require("zx");var xe=require("path");async function kt(t,e,r,i){console.log(" with Trivy ...");let n=(0,xe.dirname)(e),o=(0,xe.basename)(e),s=await Pt.$`docker run --rm -v '${t}:/.cache' -v '${n}:/tmp/output' -v '${r.sbomFile}:/tmp/input.json' aquasec/trivy:latest sbom /tmp/input.json --cache-dir '/.cache' --format json --output /tmp/output/${o} --quiet`;s.stdout&&console.log(` Scan log: ${s.stdout}`),s.stderr&&console.log(` Scan error: ${s.stderr}`),console.log(` Trivy output file: ${e}`);let c=await B(e);Qi(i,c)}function Qi(t,e){if(e){for(let r of e.Results)if(r.Vulnerabilities)for(let i of r.Vulnerabilities){let n=zi(i);t.addVulnerability(n,"trivy")}}}function zi(t){let e=t.VulnerabilityID,r=W(t.PkgIdentifier.PURL),i=W(t.PrimaryURL),n=Ki(t.Severity);return{id:e,severity:n,scannerSeverity:{trivy:n},title:t.Title,description:t.Description,components:[r],detectedBy:["trivy"],refs:[i]}}function Ki(t){switch(t){case"UNKNOWN":case"LOW":case"MEDIUM":case"HIGH":case"CRITICAL":return t;default:return"UNKNOWN"}}var Ot=require("fs/promises");async function Ft(t,e,r,i){console.log(" with Sonatype OSS Index ...");let n={},o="";r.user&&r.token&&(n.Authorization=`Basic ${Buffer.from(`${r.user}:${r.token}`).toString("base64")}`,o="/authorized");let s=`https://ossindex.sonatype.org/api/v3${o}/component-report`,u=(await Yi(e.sbomFile)).map(a=>a.purl.replace(/\?.*$/,"")),f=[];for(let a=0;a<u.length;a+=128){let m=JSON.stringify({coordinates:u.slice(a,a+128)}),l=await(await fetch(s,{method:"POST",headers:{...n,"Content-Type":"application/vnd.ossindex.component-report-request.v1+json"},body:m})).json();Array.isArray(l)?f.push(...l.filter(d=>d.vulnerabilities.length>0)):console.log(` Sonatype OssIndex Error: ${l.code} - ${l.message}`)}await(0,Ot.writeFile)(t,JSON.stringify(f,null,2)),console.log(` Sonatype OssIndex output file: ${t}`),en(i,f)}async function Yi(t){return(await B(t)).components.filter(r=>!Zi(r))}function Zi(t){return t.group?t.group.startsWith("de.conterra")||t.group.startsWith("org.n52.security"):!1}function en(t,e){if(e)for(let r of e)for(let i of r.vulnerabilities){let n=tn(i,r.coordinates);t.addVulnerability(n,"ossindex")}}function tn(t,e){let r=t.cve||t.id,i=W(e),n=W(t.reference),o=rn(t.cvssScore);return{id:r,severity:o,scannerSeverity:{ossindex:o},title:t.title,description:t.description,components:[i],detectedBy:["ossindex"],refs:n?[n]:[]}}function rn(t){return t===0?"UNKNOWN":t<4?"LOW":t<7?"MEDIUM":t<9?"HIGH":"CRITICAL"}var Z=vt(Ei()),ji=vt(Di());function Ti(t,e){let r=new Z.SarifRunBuilder().initSimple({toolDriverName:`${e.name} - ${e.version}`,toolDriverVersion:"0.0.1"}),i=new Date().toISOString().split("T")[0];r.run.tool.driver.fullDescription={text:`Security Scan from ${i}`},r.run.tool.driver.properties={"microsoft/qualityDomain":`Security Scan from ${i}`};for(let o of t){let s=ws(o.severity),c=o.id,u=vs(o.refs),f=new Z.SarifRuleBuilder().initSimple({ruleId:c,shortDescriptionText:o.title,fullDescriptionText:o.description,helpUri:u}),a=o.vexStatement,m,p="new",l="";a&&(s="none",p="updated",l=`--- INVESTIGATED (${a.status}) --- `,a.status==="under_investigation"&&(l="--- UNDER INVESTIGATION --- ")),Object.assign(f.rule,{name:`${l}[${o.severity}] - ${o.title.replace(`[${c}]`,"")}`,messageStrings:{default:{text:o.description,markdown:bs(o,u,l)}},properties:{severity:o.severity,scanners:o.scannerSeverity,links:o.refs,tags:["cve","vulnerability","security",`severity_${o.severity.toLowerCase()}`]}}),r.addRule(f);for(let d of o.components){let S=new Z.SarifResultBuilder().initSimple({ruleId:c,level:s,messageText:`${c} [${o.severity}] - ${d}`});S.result.message.id="default",S.result.locations=[{logicalLocations:[{fullyQualifiedName:d}]}],S.result.baselineState=p,S.result.suppressions=m,r.addResult(S)}}let n=new Z.SarifBuilder;return n.addRun(r),n.buildSarifOutput()}function vs(t){for(let e of t)if(e.startsWith("https://nvd.nist.gov"))return e;return t[0]}function ws(t){switch(t){case"CRITICAL":return"error";case"HIGH":return"error";case"MEDIUM":return"warning";case"LOW":return"note";default:return"note"}}function bs(t,e,r){let i=t.vexStatement,n=i?`
9
+ ${r}
10
+ ${i.justification??""}
11
+ ${i.impact_statement??""}`:"";return`
12
+
13
+ __[${t.id}](${e})__
14
+
15
+ ${n}
16
+
17
+ --- DETAILS ---
18
+
19
+ ${(0,ji.default)(t.description)}
20
+
21
+ ${t.refs.map(o=>`* <${o}>`).join(`
22
+ `)}
23
+ `}var qe=require("fs/promises");async function Ci(t,e,r){if("sbomFile"in t)return await(0,qe.copyFile)(t.sbomFile,e),t.sbomFile=e,t;let i=await r.downloadArtifact(t.sbomMavenCoordinates);return await(0,qe.writeFile)(e,i),{...t,sbomFile:e}}var _e=class{constructor(e,r){this.repo=e;this.authn=r}async downloadArtifact(e){let r=this.toArtifactInfo(e);if(this.isSnapshotVersion(r.version)&&!r.timestamp){let o=await this.fetchLatestSnapshotTimestamp(r);r={...r,timestamp:o}}let i=this.toArtifactUrl(r),n=await this.fetchMavenArtifact(i);return Buffer.from(await n.arrayBuffer())}async fetchLatestSnapshotTimestamp(e){let r=`${this.toArtifactBaseUrl(e)}/maven-metadata.xml`,n=await(await this.fetchMavenArtifact(r)).text(),o=n.match(/<timestamp>([^<]+)<\/timestamp>/),s=n.match(/<buildNumber>([^<]+)<\/buildNumber>/);if(!o||!s)throw new Error(`Failed to get timestamp and build number from ${r}`);return`${o[1]}-${s[1]}`}toArtifactUrl(e){let r=this.toArtifactBaseUrl(e),i=this.isSnapshotVersion(e.version)&&e.timestamp?e.version.replace(/SNAPSHOT$/,e.timestamp):e.version;return`${r}/${e.artifactId}-${i}-${e.classifier}.${e.extension}`}toArtifactBaseUrl(e){return`${this.repo}/${e.groupId.replace(/\./g,"/")}/${e.artifactId}/${e.version}`}isSnapshotVersion(e){return e.endsWith("-SNAPSHOT")}toArtifactInfo(e){let r=e.split(":");return{groupId:r[0],artifactId:r[1],version:r[2],classifier:r[3],extension:"json"}}async fetchMavenArtifact(e){let r=this.authn,i=r.user&&r.pw?{Authorization:`Basic ${Buffer.from(`${r.user}:${r.pw}`).toString("base64")}`}:{},n=await fetch(e,{headers:i});if(!n.ok){let o="";try{o=await n.text()}catch(s){o=`${s}`}throw new Error(`Failed to download sbom: ${e}: ${n.status} - ${n.statusText}: ${o}`)}return n}};var Ii=require("fs/promises"),Ve=require("path");async function yt(t,e=new ve){let r=(0,Ve.resolve)(t);for(let i of await(0,Ii.readdir)(r,{withFileTypes:!0}))if(i.name.endsWith(".json")){let n=await B((0,Ve.resolve)(i.parentPath,i.name));e.add(n)}else i.isDirectory()&&await yt((0,Ve.resolve)(i.parentPath,i.name),e);return e}var ve=class t{statements=[];filteredToProduct;add(e){let r=e.timestamp;for(let i of e.statements){i.timestamp=i.timestamp??r;let n=Date.parse(i.timestamp),o=i.vulnerability.name,s=new Set([o,...i.vulnerability.aliases??[]]),c=new Set(i.products?.map(f=>f["@id"]).filter(f=>!!f)??[]),u=new dt(n,o,s,c,i);this.statements.push(u)}this.sortStatementsByTimestampNewestFirst()}filterByProduct(e){if(this.assertCorrectProductId(e),this.filteredToProduct)return this;let r=new t;return r.filteredToProduct=e,r.statements=this.statements.filter(i=>i.matchesProduct(e)),r}newestVulnerabilityStatement(e,r){let i=this.filterByProduct(r??this.filteredToProduct);for(let n of i.statements)if(n.matchesVulnerability(e))return this.reduceToProductInformation(n.statement,i.filteredToProduct)}toVexFileForProduct(e){let r=this.filterByProduct(e??this.filteredToProduct),i=r.statements[0]?.statement.timestamp??new Date().toISOString(),n=r.statements.map(o=>r.reduceToProductInformation(o.statement)).filter(o=>o.status!=="under_investigation");if(n.length!==0)return{"@context":"https://openvex.dev/ns/v0.2.0","@id":"https://openvex.dev/docs/public/vex-fc763e6eb63bfbcda20b7cbbddd4e9f8feaaa317fe8d8a6f51a5663a1180343e",author:"conterra",timestamp:i,last_updated:i,version:1,statements:n}}assertCorrectProductId(e){if(!e)throw new Error("Product ID must be provided");if(this.filteredToProduct&&this.filteredToProduct!==e)throw new Error("Cannot filter to a different product")}reduceToProductInformation(e,r){return r=r??this.filteredToProduct,{...e,products:e.products?.filter(i=>i["@id"]===r)}}sortStatementsByTimestampNewestFirst(){this.statements.sort((e,r)=>r.timestamp-e.timestamp)}},dt=class{constructor(e,r,i,n,o){this.timestamp=e;this.vulnName=r;this.vulnAliases=i;this.products=n;this.statement=o}matchesProduct(e){return this.products.has(e)}matchesVulnerability(e){return this.vulnAliases.has(e)}};var $e=require("path"),Ai=require("fs/promises");var Xe=class{constructor(e,r,i){this.project=e;this.outputDir=r;this.useSubDirForProject=i}async lookupOutputFileForWriting(e){let r=this.useSubDirForProject?`${this.project.name}-${this.project.version}`:"",i=`${this.project.name}-${this.project.version}-`,n=this.getFileSuffix(e),o=(0,$e.resolve)(this.outputDir,r,`${i}${n}`),s=(0,$e.dirname)(o);return await ie(s)||await(0,Ai.mkdir)(s,{recursive:!0}),o}getFileSuffix(e){switch(e){case"grype-results":return"scan-grype-results.json";case"trivy-results":return"scan-trivy-results.json";case"ossindex-results":return"scan-ossindex-results.json";case"aggregate-results":return"scan-aggregate-results.json";case"aggregated-sarif-results":return"scan-aggregated-results.sarif.json";case"project-cyclonedx-sbom-file":return"sbom.cdx.json";case"project-openvex-file":return"openvex.vex.json";default:throw new Error(`Unknown output file key: ${e}`)}}};Be.os.type().startsWith("Windows")&&(0,Be.usePowerShell)();var Ni=process.argv[2],Ri=process.argv[3],xs=process.env.OSS_INDEX_API_TOKEN,Ls=process.env.OSS_INDEX_API_USER,Ps=process.env.MAVEN_REPO_PW,ks=process.env.MAVEN_REPO_USER;(async()=>{let t=await bt(),e=t.cacheDir;await ie(e)||await(0,re.mkdir)(e);let r=t.outDir;await ie(r)&&await He(r),await(0,re.mkdir)(r);let i=t.vexDir?await yt(t.vexDir):new ve,n=new _e(t.mavenRepo,{user:ks,pw:Ps}),o=t.projects,s=new Map;for(let c of o){if(Ni&&(c.name!==Ni||Ri&&c.version!==Ri))continue;let u=new Xe(c,r,t.createSubDirsForProject),f=await Ci(c,await u.lookupOutputFileForWriting("project-cyclonedx-sbom-file"),n);console.log(`Analyzing project: ${f.name} - ${f.version} - ${f.sbomFile}`);let a=new we;await Promise.all(t.scanners.map(l=>Os(l,f,u,e,a)));let m=i.filterByProduct(f.purl),{unmatchedVulnerabilities:p}=a.enhanceWithVexData(m);p.length>0&&s.set(f.purl,p),await Fs(u,f,a,m)}if(s.size>0){console.log(`
24
+ Detected new vulnerabilities for products:`);for(let[c,u]of s){console.log(` ${c}:`);for(let f of u)console.log(` ${f}`)}console.log("##vso[task.complete result=SucceededWithIssues;]NEW_VULNERABILITIES_DETECTED"),t.failOnNewVulnerabilities&&process.exit(1)}})();async function Os(t,e,r,i,n){switch(t){case"grype":return Lt(i,await r.lookupOutputFileForWriting("grype-results"),e,n);case"trivy":return kt(i,await r.lookupOutputFileForWriting("trivy-results"),e,n);case"ossindex":return Ft(await r.lookupOutputFileForWriting("ossindex-results"),e,{user:Ls,token:xs},n)}}async function Fs(t,e,r,i){let n=r.getAllVulnerabilitiesSortedBySeverity(),o=await t.lookupOutputFileForWriting("aggregate-results");await(0,re.writeFile)(o,JSON.stringify(n,null,2)),console.log(` Vulnerabilities output file: ${o}`);let s=await t.lookupOutputFileForWriting("aggregated-sarif-results"),c=Ti(n,e);await(0,re.writeFile)(s,JSON.stringify(c,null,2)),console.log(` Vuln Sarif output file: ${s}`);let u=i.toVexFileForProduct();if(!u)return;let f=await t.lookupOutputFileForWriting("project-openvex-file");await(0,re.writeFile)(f,JSON.stringify(u,null,2)),console.log(` OpenVex file: ${f}`)}
25
+ /*! Bundled license information:
26
+
27
+ escape-html/index.js:
28
+ (*!
29
+ * escape-html
30
+ * Copyright(c) 2012-2013 TJ Holowaychuk
31
+ * Copyright(c) 2015 Andreas Lubbe
32
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
33
+ * MIT Licensed
34
+ *)
35
+ */
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@conterra/vuln-scan",
3
+ "version": "0.0.1",
4
+ "description": "con terra vulnerability scan process",
5
+ "author": "con terra GmbH",
6
+ "license": "Apache-2.0",
7
+ "type": "commonjs",
8
+ "files": [
9
+ "./dist/**",
10
+ "LICENSE.txt",
11
+ "README.md"
12
+ ],
13
+ "bin": {
14
+ "ct-vuln-scan": "./dist/vuln-scan.js",
15
+ "ct-vuln-add-vex": "./dist/add-statement.js"
16
+ },
17
+ "engines": {
18
+ "node": ">= 20"
19
+ },
20
+ "scripts": {
21
+ "full-build": "npm run clean && npm run type-check && npm run lint && npm run prod",
22
+ "build": "node esbuild.config.mjs build",
23
+ "prod": "node esbuild.config.mjs prod",
24
+ "watch": "node esbuild.config.mjs watch",
25
+ "type-check": "tsc --noEmit",
26
+ "type-watch": "tsc -w --noEmit",
27
+ "update-openvex-types": "json2ts --input ./src/types/openvex-schema.json --output ./src/types/openvex_json.ts --no-style.semi --style.tabWidth 4",
28
+ "lint": "eslint",
29
+ "clean": "rimraf dist"
30
+ },
31
+ "dependencies": {
32
+ "zx": "^8.1.9"
33
+ },
34
+ "devDependencies": {
35
+ "@types/escape-html": "^1.0.4",
36
+ "escape-html": "^1.0.3",
37
+ "node-fetch": "^3.3.2",
38
+ "node-sarif-builder": "^3.2.0",
39
+ "esbuild": "^0.24.0",
40
+ "copyfiles": "^2.4.1",
41
+ "globals": "^15.11.0",
42
+ "typescript-eslint": "^8.11.0",
43
+ "eslint-plugin-headers": "^1.2.0",
44
+ "json-schema-to-typescript": "^15.0.2",
45
+ "mocha": "^10.4.0",
46
+ "chai": "^5.1.1",
47
+ "typescript": "^5.6.3",
48
+ "tiny-glob": "^0.2.9",
49
+ "rimraf": "^6.0.1"
50
+ }
51
+ }