File tree 2 files changed +60
-2
lines changed
2 files changed +60
-2
lines changed Original file line number Diff line number Diff line change @@ -93475,10 +93475,33 @@ function extractGoArchive(archivePath) {
93475
93475
});
93476
93476
}
93477
93477
exports.extractGoArchive = extractGoArchive;
93478
+ function isIToolRelease(obj) {
93479
+ return (typeof obj === 'object' &&
93480
+ obj !== null &&
93481
+ typeof obj.version === 'string' &&
93482
+ typeof obj.stable === 'boolean' &&
93483
+ Array.isArray(obj.files) &&
93484
+ obj.files.every((file) => typeof file.filename === 'string' &&
93485
+ typeof file.platform === 'string' &&
93486
+ typeof file.arch === 'string' &&
93487
+ typeof file.download_url === 'string'));
93488
+ }
93478
93489
function getManifest(auth) {
93479
93490
return __awaiter(this, void 0, void 0, function* () {
93480
93491
try {
93481
- return yield getManifestFromRepo(auth);
93492
+ const manifest = yield getManifestFromRepo(auth);
93493
+ if (Array.isArray(manifest) &&
93494
+ manifest.length &&
93495
+ manifest.every(isIToolRelease)) {
93496
+ return manifest;
93497
+ }
93498
+ let errorMessage = 'An unexpected error occurred while fetching the manifest.';
93499
+ if (typeof manifest === 'object' &&
93500
+ manifest !== null &&
93501
+ 'message' in manifest) {
93502
+ errorMessage = manifest.message;
93503
+ }
93504
+ throw new Error(errorMessage);
93482
93505
}
93483
93506
catch (err) {
93484
93507
core.debug('Fetching the manifest via the API failed.');
Original file line number Diff line number Diff line change @@ -275,11 +275,46 @@ export async function extractGoArchive(archivePath: string): Promise<string> {
275
275
return extPath ;
276
276
}
277
277
278
+ function isIToolRelease ( obj : any ) : obj is tc . IToolRelease {
279
+ return (
280
+ typeof obj === 'object' &&
281
+ obj !== null &&
282
+ typeof obj . version === 'string' &&
283
+ typeof obj . stable === 'boolean' &&
284
+ Array . isArray ( obj . files ) &&
285
+ obj . files . every (
286
+ ( file : any ) =>
287
+ typeof file . filename === 'string' &&
288
+ typeof file . platform === 'string' &&
289
+ typeof file . arch === 'string' &&
290
+ typeof file . download_url === 'string'
291
+ )
292
+ ) ;
293
+ }
294
+
278
295
export async function getManifest (
279
296
auth : string | undefined
280
297
) : Promise < tc . IToolRelease [ ] > {
281
298
try {
282
- return await getManifestFromRepo ( auth ) ;
299
+ const manifest = await getManifestFromRepo ( auth ) ;
300
+ if (
301
+ Array . isArray ( manifest ) &&
302
+ manifest . length &&
303
+ manifest . every ( isIToolRelease )
304
+ ) {
305
+ return manifest ;
306
+ }
307
+
308
+ let errorMessage =
309
+ 'An unexpected error occurred while fetching the manifest.' ;
310
+ if (
311
+ typeof manifest === 'object' &&
312
+ manifest !== null &&
313
+ 'message' in manifest
314
+ ) {
315
+ errorMessage = ( manifest as { message : string } ) . message ;
316
+ }
317
+ throw new Error ( errorMessage ) ;
283
318
} catch ( err ) {
284
319
core . debug ( 'Fetching the manifest via the API failed.' ) ;
285
320
if ( err instanceof Error ) {
You can’t perform that action at this time.
0 commit comments