@@ -233,7 +233,7 @@ const CommonConfigSchema = z.object({
233233const HTTPConfigSchema = z
234234 .object({
235235 http_url: z.string(),
236- mask: z.string().optional()
236+ mask: z.string().optional() // string array of secrets or boolean
237237})
238238 .merge(CommonConfigSchema);
239239const SQLConfigSchema = z
@@ -254,7 +254,7 @@ function getConfig() {
254254 'postprocess',
255255 ];
256256 keys.forEach(k => {
257- const v = core.getInput(k);
257+ const v = core.getInput(k); // getInput always returns a string
258258 if (v) {
259259 raw[k] = v;
260260 }
@@ -451,19 +451,29 @@ async function run() {
451451 core.startGroup('Fetch data');
452452 let filename = '';
453453 let source;
454- let sourceStripped = '';
454+ let shouldMask = false; // by default we don't mask the source
455+ let sourceMasked = '';
455456 if (config_1.isHTTPConfig(config)) {
456457 filename = await http_1.default(config);
457458 source = config.http_url;
458- // if including a mask config then we strip out secrets from the http_url
459- sourceStripped = source;
459+ // if including a mask config then we can strip out secrets from the http_url
460+ sourceMasked = source; // if no secrets to mask then this is just source
460461 if (config.mask) {
461- core.info('Masking http url');
462- const maskArray = JSON.parse(config.mask);
463- maskArray.forEach((secretToMask) => {
464- const regex = new RegExp(secretToMask, "g");
465- sourceStripped = sourceStripped.replace(regex, "***");
466- });
462+ if (config.mask === 'true' || config.mask === 'false') { // mask param is a string
463+ shouldMask = JSON.parse(config.mask); // convert to boolean
464+ }
465+ else {
466+ try {
467+ const maskArray = JSON.parse(config.mask);
468+ maskArray.forEach((secretToMask) => {
469+ const regex = new RegExp(secretToMask, "g");
470+ sourceMasked = sourceMasked.replace(regex, "***");
471+ });
472+ }
473+ catch (error) {
474+ core.setFailed('Mask param formatted incorrectly. It should be a string array OR a "true" or "false" string.');
475+ }
476+ }
467477 }
468478 }
469479 else if (config_1.isSQLConfig(config)) {
@@ -510,8 +520,8 @@ async function run() {
510520 core.debug(`git adding ${filename}…`);
511521 await exec_1.exec('git', ['add', filename]);
512522 const bytes = await git_1.diff(filename);
513- // core.setOutput('delta_bytes', bytes)
514- editedFiles.push({ name: filename, deltaBytes: bytes, source: sourceStripped });
523+ const source = shouldMask ? {} : { source: sourceMasked };
524+ editedFiles.push({ name: filename, deltaBytes: bytes, ... source });
515525 }
516526 core.endGroup();
517527 core.startGroup('Committing new data');
0 commit comments