Page MenuHomePhabricator

D19709.id47096.diff
No OneTemporary

D19709.id47096.diff

Index: src/error/__tests__/PhutilOpaqueEnvelopeTestCase.php
===================================================================
--- src/error/__tests__/PhutilOpaqueEnvelopeTestCase.php
+++ src/error/__tests__/PhutilOpaqueEnvelopeTestCase.php
@@ -8,9 +8,13 @@
// the diff itself, and thus this source code. Since we look for the secret
// in traces later on, split it apart here so that invocation via
// "arc diff" doesn't create a false test failure.
-
$secret = 'hunter'.'2';
+ // Also split apart this "signpost" value which we are not going to put in
+ // an envelope. We expect to be able to find it in the argument lists in
+ // stack traces, and don't want a false positive.
+ $signpost = 'shaman'.'3';
+
$envelope = new PhutilOpaqueEnvelope($secret);
$this->assertFalse(strpos(var_export($envelope, true), $secret));
@@ -24,23 +28,34 @@
$this->assertFalse(strpos($dump, $secret));
try {
- $this->throwTrace($envelope);
+ $this->throwTrace($envelope, $signpost);
} catch (Exception $ex) {
$trace = $ex->getTrace();
- $this->assertFalse(strpos(print_r($trace, true), $secret));
+
+ // NOTE: The entire trace may be very large and contain complex
+ // recursive datastructures. Look at only the last few frames: we expect
+ // to see the signpost value but not the secret.
+ $trace = array_slice($trace, 0, 2);
+ $trace = print_r($trace, true);
+
+ $this->assertTrue(strpos($trace, $signpost) !== false);
+ $this->assertFalse(strpos($trace, $secret));
}
- $backtrace = $this->getBacktrace($envelope);
+ $backtrace = $this->getBacktrace($envelope, $signpost);
+ $backtrace = array_slice($backtrace, 0, 2);
+
+ $this->assertTrue(strpos($trace, $signpost) !== false);
$this->assertFalse(strpos(print_r($backtrace, true), $secret));
$this->assertEqual($secret, $envelope->openEnvelope());
}
- private function throwTrace($v) {
+ private function throwTrace($v, $w) {
throw new Exception('!');
}
- private function getBacktrace($v) {
+ private function getBacktrace($v, $w) {
return debug_backtrace();
}
Index: src/parser/__tests__/PhutilTypeSpecTestCase.php
===================================================================
--- src/parser/__tests__/PhutilTypeSpecTestCase.php
+++ src/parser/__tests__/PhutilTypeSpecTestCase.php
@@ -150,8 +150,7 @@
foreach ($map as $expect => $input) {
$this->assertEqual(
$expect,
- PhutilTypeSpec::getTypeOf($input),
- print_r($input, true));
+ PhutilTypeSpec::getTypeOf($input));
PhutilTypeSpec::newFromString($expect)->check($input);
}

File Metadata

Mime Type
text/plain
Expires
Mar 15 2025, 3:01 PM (5 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7385156
Default Alt Text
D19709.id47096.diff (2 KB)

Event Timeline