Page MenuHomePhabricator

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

Authored by epriestley on Nov 7 2018, 12:34 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 18, 4:45 PM
Unknown Object (File)
Fri, Nov 15, 11:16 PM
Unknown Object (File)
Fri, Nov 8, 5:48 PM
Unknown Object (File)
Fri, Nov 8, 5:02 PM
Unknown Object (File)
Fri, Nov 8, 2:54 PM
Unknown Object (File)
Thu, Oct 24, 12:18 PM
Unknown Object (File)
Thu, Oct 24, 11:39 AM
Unknown Object (File)
Oct 16 2024, 9:46 AM
Subscribers
None

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
Branch
qobject2
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 21097
Build 28672: Run Core Tests
Build 28671: arc lint + arc unit