From 65a34a096d1d59086af0aa2d91912f014749d411 Mon Sep 17 00:00:00 2001 From: Salman Chishti Date: Thu, 6 Mar 2025 14:25:32 -0800 Subject: [PATCH] Add secret and signature masking for cache and artifact packages --- src/core.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/core.ts b/src/core.ts index 0a14169..12359d0 100644 --- a/src/core.ts +++ b/src/core.ts @@ -391,3 +391,19 @@ export {toPosixPath, toWin32Path, toPlatformPath} from './path-utils' * Platform utilities exports */ export * as platform from './platform' + +/** + * Masks the `sig` parameter in a URL and sets it as a secret. + * @param url The URL containing the `sig` parameter. + * @param urlType The type of the URL (e.g., 'signed_upload_url', 'signed_download_url'). + * @returns The URL with the `sig` parameter masked. + */ +export function maskSigUrl(url: string, urlType: string): string { + const sigMatch = url.match(/[?&]sig=([^&]+)/) + if (sigMatch) { + setSecret(sigMatch[1]) + debug(`Masked ${urlType}: ${url.replace(sigMatch[1], '***')}`) + return url.replace(sigMatch[1], '***') + } + return url +}