Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for password leak in logs #100

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions src/util/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
return this._log(message);
}

public debug(message: string): void {
return this._debug(message);
}

public info(message: string): void {
return this._info(message);
}

public warn(message: string): void {
return this._warn(message);
}
Expand All @@ -29,7 +37,30 @@
return;
}

return console.log(`${LIQUIBASE_LABEL} ${message}`);
if(this.logLevel == LiquibaseLogLevels.Debug)

Check failure on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 9

Replace `(this.logLevel·==·LiquibaseLogLevels.Debug)⏎·····` with `·(this.logLevel·==·LiquibaseLogLevels.Debug)`

Check warning on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 9

Expected '===' and instead saw '=='

Check failure on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 9

Replace `(this.logLevel·==·LiquibaseLogLevels.Debug)⏎·····` with `·(this.logLevel·==·LiquibaseLogLevels.Debug)`

Check warning on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 9

Expected '===' and instead saw '=='

Check failure on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 11

Replace `(this.logLevel·==·LiquibaseLogLevels.Debug)⏎·····` with `·(this.logLevel·==·LiquibaseLogLevels.Debug)`

Check warning on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 11

Expected '===' and instead saw '=='

Check failure on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 13

Replace `(this.logLevel·==·LiquibaseLogLevels.Debug)⏎·····` with `·(this.logLevel·==·LiquibaseLogLevels.Debug)`

Check warning on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 13

Expected '===' and instead saw '=='

Check failure on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 15

Replace `(this.logLevel·==·LiquibaseLogLevels.Debug)⏎·····` with `·(this.logLevel·==·LiquibaseLogLevels.Debug)`

Check warning on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 15

Expected '===' and instead saw '=='

Check failure on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 15

Replace `(this.logLevel·==·LiquibaseLogLevels.Debug)⏎·····` with `·(this.logLevel·==·LiquibaseLogLevels.Debug)`

Check warning on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 15

Expected '===' and instead saw '=='

Check failure on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 13

Replace `(this.logLevel·==·LiquibaseLogLevels.Debug)⏎·····` with `·(this.logLevel·==·LiquibaseLogLevels.Debug)`

Check warning on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 13

Expected '===' and instead saw '=='

Check failure on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 13

Replace `(this.logLevel·==·LiquibaseLogLevels.Debug)⏎·····` with `·(this.logLevel·==·LiquibaseLogLevels.Debug)`

Check warning on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 13

Expected '===' and instead saw '=='

Check failure on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 11

Replace `(this.logLevel·==·LiquibaseLogLevels.Debug)⏎·····` with `·(this.logLevel·==·LiquibaseLogLevels.Debug)`

Check warning on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 11

Expected '===' and instead saw '=='

Check failure on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 11

Replace `(this.logLevel·==·LiquibaseLogLevels.Debug)⏎·····` with `·(this.logLevel·==·LiquibaseLogLevels.Debug)`

Check warning on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 11

Expected '===' and instead saw '=='

Check failure on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 15

Replace `(this.logLevel·==·LiquibaseLogLevels.Debug)⏎·····` with `·(this.logLevel·==·LiquibaseLogLevels.Debug)`

Check warning on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 15

Expected '===' and instead saw '=='

Check failure on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 9

Replace `(this.logLevel·==·LiquibaseLogLevels.Debug)⏎·····` with `·(this.logLevel·==·LiquibaseLogLevels.Debug)`

Check warning on line 40 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 9

Expected '===' and instead saw '=='
return this._debug(message);

return console.log(`${LIQUIBASE_LABEL} ${this.sanitizeOutput(message)}`);
}

private _debug(message: string) {
const levels = [LiquibaseLogLevels.Debug, LiquibaseLogLevels.Info, LiquibaseLogLevels.Severe, LiquibaseLogLevels.Warning];

Check failure on line 47 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 9

Replace `LiquibaseLogLevels.Debug,·LiquibaseLogLevels.Info,·LiquibaseLogLevels.Severe,·LiquibaseLogLevels.Warning` with `⏎······LiquibaseLogLevels.Debug,⏎······LiquibaseLogLevels.Info,⏎······LiquibaseLogLevels.Severe,⏎······LiquibaseLogLevels.Warning,⏎····`

Check failure on line 47 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 9

Replace `LiquibaseLogLevels.Debug,·LiquibaseLogLevels.Info,·LiquibaseLogLevels.Severe,·LiquibaseLogLevels.Warning` with `⏎······LiquibaseLogLevels.Debug,⏎······LiquibaseLogLevels.Info,⏎······LiquibaseLogLevels.Severe,⏎······LiquibaseLogLevels.Warning,⏎····`

Check failure on line 47 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 11

Replace `LiquibaseLogLevels.Debug,·LiquibaseLogLevels.Info,·LiquibaseLogLevels.Severe,·LiquibaseLogLevels.Warning` with `⏎······LiquibaseLogLevels.Debug,⏎······LiquibaseLogLevels.Info,⏎······LiquibaseLogLevels.Severe,⏎······LiquibaseLogLevels.Warning,⏎····`

Check failure on line 47 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 13

Replace `LiquibaseLogLevels.Debug,·LiquibaseLogLevels.Info,·LiquibaseLogLevels.Severe,·LiquibaseLogLevels.Warning` with `⏎······LiquibaseLogLevels.Debug,⏎······LiquibaseLogLevels.Info,⏎······LiquibaseLogLevels.Severe,⏎······LiquibaseLogLevels.Warning,⏎····`

Check failure on line 47 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 15

Replace `LiquibaseLogLevels.Debug,·LiquibaseLogLevels.Info,·LiquibaseLogLevels.Severe,·LiquibaseLogLevels.Warning` with `⏎······LiquibaseLogLevels.Debug,⏎······LiquibaseLogLevels.Info,⏎······LiquibaseLogLevels.Severe,⏎······LiquibaseLogLevels.Warning,⏎····`

Check failure on line 47 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 15

Replace `LiquibaseLogLevels.Debug,·LiquibaseLogLevels.Info,·LiquibaseLogLevels.Severe,·LiquibaseLogLevels.Warning` with `⏎······LiquibaseLogLevels.Debug,⏎······LiquibaseLogLevels.Info,⏎······LiquibaseLogLevels.Severe,⏎······LiquibaseLogLevels.Warning,⏎····`

Check failure on line 47 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 13

Replace `LiquibaseLogLevels.Debug,·LiquibaseLogLevels.Info,·LiquibaseLogLevels.Severe,·LiquibaseLogLevels.Warning` with `⏎······LiquibaseLogLevels.Debug,⏎······LiquibaseLogLevels.Info,⏎······LiquibaseLogLevels.Severe,⏎······LiquibaseLogLevels.Warning,⏎····`

Check failure on line 47 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 13

Replace `LiquibaseLogLevels.Debug,·LiquibaseLogLevels.Info,·LiquibaseLogLevels.Severe,·LiquibaseLogLevels.Warning` with `⏎······LiquibaseLogLevels.Debug,⏎······LiquibaseLogLevels.Info,⏎······LiquibaseLogLevels.Severe,⏎······LiquibaseLogLevels.Warning,⏎····`

Check failure on line 47 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 11

Replace `LiquibaseLogLevels.Debug,·LiquibaseLogLevels.Info,·LiquibaseLogLevels.Severe,·LiquibaseLogLevels.Warning` with `⏎······LiquibaseLogLevels.Debug,⏎······LiquibaseLogLevels.Info,⏎······LiquibaseLogLevels.Severe,⏎······LiquibaseLogLevels.Warning,⏎····`

Check failure on line 47 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 11

Replace `LiquibaseLogLevels.Debug,·LiquibaseLogLevels.Info,·LiquibaseLogLevels.Severe,·LiquibaseLogLevels.Warning` with `⏎······LiquibaseLogLevels.Debug,⏎······LiquibaseLogLevels.Info,⏎······LiquibaseLogLevels.Severe,⏎······LiquibaseLogLevels.Warning,⏎····`

Check failure on line 47 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 15

Replace `LiquibaseLogLevels.Debug,·LiquibaseLogLevels.Info,·LiquibaseLogLevels.Severe,·LiquibaseLogLevels.Warning` with `⏎······LiquibaseLogLevels.Debug,⏎······LiquibaseLogLevels.Info,⏎······LiquibaseLogLevels.Severe,⏎······LiquibaseLogLevels.Warning,⏎····`

Check failure on line 47 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 9

Replace `LiquibaseLogLevels.Debug,·LiquibaseLogLevels.Info,·LiquibaseLogLevels.Severe,·LiquibaseLogLevels.Warning` with `⏎······LiquibaseLogLevels.Debug,⏎······LiquibaseLogLevels.Info,⏎······LiquibaseLogLevels.Severe,⏎······LiquibaseLogLevels.Warning,⏎····`

if (!this.shouldOperate(levels)) {
return;
}

return console.debug('\x1b[34m%s\x1b[0m', `${LIQUIBASE_LABEL} ${message}`);
}

private _info(message: string) {
const levels = [LiquibaseLogLevels.Info, LiquibaseLogLevels.Severe, LiquibaseLogLevels.Warning];

if (!this.shouldOperate(levels)) {
return;
}

return console.info('\x1b[32m%s\x1b[0m', `${LIQUIBASE_LABEL} ${this.sanitizeOutput(message)}`);
}

private _warn(message: string) {
Expand All @@ -39,7 +70,7 @@
return;
}

return console.warn('\x1b[33m%s\x1b[0m', `${LIQUIBASE_LABEL} ${message}`);
return console.warn('\x1b[33m%s\x1b[0m', `${LIQUIBASE_LABEL} ${this.sanitizeOutput(message)}`);
}

private _error(message: string) {
Expand All @@ -49,7 +80,7 @@
return;
}

return console.error('\x1b[31m%s\x1b[0m', `${LIQUIBASE_LABEL} ${message}`);
return console.error('\x1b[31m%s\x1b[0m', `${LIQUIBASE_LABEL} ${this.sanitizeOutput(message)}`);
}

private shouldOperate(acceptableLogLevels: Array<LiquibaseLogLevels>) {
Expand All @@ -63,4 +94,9 @@

return this.config?.logLevel || LiquibaseLogLevels.Severe;
}

private sanitizeOutput(output: string): string {
return output.replace(/password=("?\S+"?)/gi, 'password=******');
}

Check failure on line 100 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 9

Delete `⏎`

Check failure on line 100 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 9

Delete `⏎`

Check failure on line 100 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 11

Delete `⏎`

Check failure on line 100 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 13

Delete `⏎`

Check failure on line 100 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 15

Delete `⏎`

Check failure on line 100 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 15

Delete `⏎`

Check failure on line 100 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 13

Delete `⏎`

Check failure on line 100 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 20.x, Postgres 13

Delete `⏎`

Check failure on line 100 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 11

Delete `⏎`

Check failure on line 100 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 11

Delete `⏎`

Check failure on line 100 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 18.x, Postgres 15

Delete `⏎`

Check failure on line 100 in src/util/logger.ts

View workflow job for this annotation

GitHub Actions / Node 16.x, Postgres 9

Delete `⏎`

}
Loading