What happens
Main echoes the raw argument vector before anything else:
Console.WriteLine("Tool: pg2b3dm " + version);
Console.WriteLine("Options: " + string.Join(" ", args));
Since --connection is the supported way to pass credentials, any non-interactive run puts the
database password in stdout verbatim:
Options: -t citydb.my_surface --connection Host=db.example.org;Port=5432;Username=tiler;Password=hunter2 -o out
Why it matters
The interactive path is already careful - PasswordAsker prompts and never echoes. But an automated
run (CI job, cron, nohup ... > bake.log) has no interactive path, so it must use --connection, and
that is exactly the case whose output gets captured and kept. The consequence is that ordinary build
logs become secrets: they need the same handling as a credentials file, and anyone who has ever pasted
a pg2b3dm log into an issue has published a password.
We hit this baking 3D Tiles from 3DCityDB v5 in a scripted pipeline. Our wrapper masks the string in
its own logging, but it cannot stop pg2b3dm writing it to stdout - the only workaround left is
filtering the tool's output, or deleting the logs afterwards, which is what we ended up doing.
Suggested fix
Redact the password before the echo rather than dropping the line - the Options: echo is genuinely
useful for reproducing a run. Something like:
Console.WriteLine("Options: " + string.Join(" ", args.Select(Redact)));
// Password=... (and the Npgsql alias pwd=...) inside a connection string argument
private static string Redact(string arg)
=> Regex.Replace(arg, @"(?<=\b(password|pwd)\s*=)[^;]*", "***", RegexOptions.IgnoreCase);
That keeps host, database, user and every other option visible, which is what makes the line worth
printing.
Happy to open a PR with the redaction plus a unit test on the helper if you would take it.
What happens
Mainechoes the raw argument vector before anything else:Since
--connectionis the supported way to pass credentials, any non-interactive run puts thedatabase password in stdout verbatim:
Why it matters
The interactive path is already careful -
PasswordAskerprompts and never echoes. But an automatedrun (CI job, cron,
nohup ... > bake.log) has no interactive path, so it must use--connection, andthat is exactly the case whose output gets captured and kept. The consequence is that ordinary build
logs become secrets: they need the same handling as a credentials file, and anyone who has ever pasted
a pg2b3dm log into an issue has published a password.
We hit this baking 3D Tiles from 3DCityDB v5 in a scripted pipeline. Our wrapper masks the string in
its own logging, but it cannot stop pg2b3dm writing it to stdout - the only workaround left is
filtering the tool's output, or deleting the logs afterwards, which is what we ended up doing.
Suggested fix
Redact the password before the echo rather than dropping the line - the
Options:echo is genuinelyuseful for reproducing a run. Something like:
That keeps host, database, user and every other option visible, which is what makes the line worth
printing.
Happy to open a PR with the redaction plus a unit test on the helper if you would take it.