Page MenuHomePhabricator

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

Authored by epriestley on Nov 7 2018, 12:34 AM.
Tags
None
Referenced Files
F20723164: D19782.diff
Mon, Jun 22, 10:10 PM
F20687184: D19782.diff
Mon, Jun 22, 4:23 AM
Unknown Object (File)
Wed, Jun 17, 9:13 PM
Unknown Object (File)
Apr 16 2026, 11:33 AM
Unknown Object (File)
Mar 31 2026, 3:01 AM
Unknown Object (File)
Mar 29 2026, 3:41 PM
Unknown Object (File)
Mar 7 2026, 11:23 PM
Unknown Object (File)
Mar 6 2026, 8:19 PM
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