Page MenuHomePhabricator

Support %P (Password or Secret) in qsprintf()
ClosedPublic

Authored by epriestley on Nov 7 2018, 12:34 AM.

Details

Summary

Depends on D19781. Fixes T6960. Ref T13217. Ref T13216. Occasionally, we issue queries which contain passwords or secrets. Supporting "%P" (similar to the csprintf() "%P") allows us to mask these in logs and output while still generating the correct values when we actually execute a query.

Test Plan
$ cat test.php 
<?php

require_once 'scripts/init/init-script.php';

$conn = id(new PhabricatorUser())->establishConnection('r');

$query = qsprintf(
  $conn,
  'SELECT %P',
  new PhutilOpaqueEnvelope('hunter2'));

echo $query."\n";
var_dump(queryfx_one($conn, '%Q', $query));
$ php -f test.php 
SELECT ********
array(1) {
  ["hunter2"]=>
  string(7) "hunter2"
}

Diff Detail

Repository
rPHU libphutil
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

epriestley created this revision.Nov 7 2018, 12:34 AM
epriestley requested review of this revision.Nov 7 2018, 12:35 AM
amckinley accepted this revision.Nov 7 2018, 8:54 PM
This revision is now accepted and ready to land.Nov 7 2018, 8:54 PM
This revision was automatically updated to reflect the committed changes.