Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion server/src/telemetry/scrub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const RULES: [RegExp, (match: string, ...groups: string[]) => string][] = [
// `-psecret` for mysql and friends. Nothing separates them: a space means the password is asked for
// at the prompt and the word after `-p` is the database, so only the attached form is redacted.
[
/(\bmysql(?:dump)?\b(?:[^|;&\\\r\n]|\\[\s\S])*?(?:[ \t]|\\\r?\n)-p)("[^"]*"|'[^']*'|[^\s'"-]\S*)/gi,
/(\bmysql(?:dump)?\b(?:[^|;&\\\r\n]|\\[\s\S])*?(?:[ \t]|\\\r?\n)-p)("[^"]*"|'[^']*'|[^\s'"-]\S*)/g,
(_m, lead) => `${lead}${REDACTED}`,
],
// `docker login -p secret`, where `-p` is the password rather than a port.
Expand Down
5 changes: 5 additions & 0 deletions server/tests/enterprise-controls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ describe("scrubbing commands", () => {
"psql postgres://app:[REDACTED]@db:5432/app",
],
["mysql -uroot -phunter2 app", "mysql -uroot -p[REDACTED] app"],
// `-P` is mysql's port, not its password: the attached port must survive and the real
// password later in the same command must still be redacted (gh-815).
["mysql -h db -P3306 -phunter2 app", "mysql -h db -P3306 -p[REDACTED] app"],
["mysql -uroot -p3306 app", "mysql -uroot -p[REDACTED] app"],
["mysqldump -phunter2 db", "mysqldump -p[REDACTED] db"],
[
"tool --password hunter2 --verbose",
"tool --password [REDACTED] --verbose",
Expand Down
Loading