Skip to content

Commit b1f4dc6

Browse files
committed
loadConfig: fix copy/paste typo in redacted replacement, create redacted content only if hideConfigSecrets is true
1 parent 9dd964e commit b1f4dc6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

js/utils.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,21 @@ const loadConfig = () => {
129129
// Load config.js and catch errors if not accessible
130130
try {
131131
let configContent = fs.readFileSync(configFilename, "utf-8");
132+
const hideConfigSecrets = configContent.match(/^\s*hideConfigSecrets: true.*$/m);
132133
let configContentFull = configContent;
133-
let configContentRedacted = configContent;
134+
let configContentRedacted = hideConfigSecrets ? configContent : undefined;
134135
Object.keys(process.env).forEach((env) => {
135136
configContentFull = configContentFull.replaceAll(`\${${env}}`, process.env[env]);
136-
if (env.startsWith("SECRET_")) {
137-
configContentRedacted = configContentRedacted.replaceAll(`"\${${env}}"`, `"**${env}**"`);
138-
configContentRedacted = configContentRedacted.replaceAll(`\${${env}}`, `"**${env}**"`);
139-
} else {
140-
configContentRedacted = configContentRedacted.replaceAll(`\${${env}}`, process.env[env]);
137+
if (hideConfigSecrets) {
138+
if (env.startsWith("SECRET_")) {
139+
configContentRedacted = configContentRedacted.replaceAll(`"\${${env}}"`, `"**${env}**"`);
140+
configContentRedacted = configContentRedacted.replaceAll(`\${${env}}`, `**${env}**`);
141+
} else {
142+
configContentRedacted = configContentRedacted.replaceAll(`\${${env}}`, process.env[env]);
143+
}
141144
}
142145
});
146+
configContentRedacted = configContentRedacted ? configContentRedacted : configContentFull;
143147
const configObj = {
144148
configFilename: configFilename,
145149
configContentFull: configContentFull,

0 commit comments

Comments
 (0)