File tree Expand file tree Collapse file tree 2 files changed +60
-2
lines changed
Expand file tree Collapse file tree 2 files changed +60
-2
lines changed Original file line number Diff line number Diff line change @@ -93475,10 +93475,33 @@ function extractGoArchive(archivePath) {
9347593475 });
9347693476}
9347793477exports.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+ }
9347893489function getManifest(auth) {
9347993490 return __awaiter(this, void 0, void 0, function* () {
9348093491 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);
9348293505 }
9348393506 catch (err) {
9348493507 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> {
275275 return extPath ;
276276}
277277
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+
278295export async function getManifest (
279296 auth : string | undefined
280297) : Promise < tc . IToolRelease [ ] > {
281298 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 ) ;
283318 } catch ( err ) {
284319 core . debug ( 'Fetching the manifest via the API failed.' ) ;
285320 if ( err instanceof Error ) {
You can’t perform that action at this time.
0 commit comments