Skip to content

Commit

Permalink
Updating test and removing fix attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
link04 committed Oct 23, 2024
1 parent f6f1fd6 commit 5f1f193
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
12 changes: 5 additions & 7 deletions src/DDTrace/Util/Normalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,11 @@ private static function generateFilteredPostFields($postKey, $postVal, array $wh

// Match it with the regex to redact if needed
$obfuscationRegex = \ini_get('datadog.trace.obfuscation_query_string_regexp');
if ($obfuscationRegex !== "") {
$obfuscationRegex = '(' . $obfuscationRegex . ')';
if (preg_match($obfuscationRegex, $postField)) {
return [$postKey => '<redacted>'];
} else {
return [$postKey => $postVal];
}
$obfuscationRegex = '(' . $obfuscationRegex . ')';
if (preg_match($obfuscationRegex, $postField)) {
return [$postKey => '<redacted>'];
} else {
return [$postKey => $postVal];
}
} else {
// The postkey is not in the whitelist, and no wildcard set, then always use <redacted>
Expand Down
20 changes: 0 additions & 20 deletions tests/Unit/Util/Normalizer/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ protected function ddSetUp()
'DD_TRACE_RESOURCE_URI_MAPPING_INCOMING',
'DD_TRACE_RESOURCE_URI_MAPPING_OUTGOING',
'DD_TRACE_RESOURCE_URI_QUERY_PARAM_ALLOWED',
'DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP',
]);
parent::ddSetUp();
}
Expand All @@ -26,7 +25,6 @@ protected function ddTearDown()
'DD_TRACE_RESOURCE_URI_MAPPING_INCOMING',
'DD_TRACE_RESOURCE_URI_MAPPING_OUTGOING',
'DD_TRACE_RESOURCE_URI_QUERY_PARAM_ALLOWED',
'DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP',
]);
}

Expand Down Expand Up @@ -74,24 +72,6 @@ public function testWrongOutgoingConfigurationResultsInMissedPathNormalizationBu
);
}

public function testMixingFragmentRegexAndPatternMatchingIncoming()
{
$this->putEnvAndReloadConfig(['DD_TRACE_RESOURCE_URI_MAPPING_INCOMING=name/*']);
$this->assertSame(
'/numeric/?/name/?',
\DDTrace\Util\Normalizer::uriNormalizeIncomingPath('/numeric/123/name/some_name')
);
}

public function testMixingFragmentRegexAndPatternMatchingOutgoing()
{
$this->putEnvAndReloadConfig(['DD_TRACE_RESOURCE_URI_MAPPING_OUTGOING=name/*']);
$this->assertSame(
'/numeric/?/name/?',
\DDTrace\Util\Normalizer::uriNormalizeOutgoingPath('/numeric/123/name/some_name')
);
}

/**
* @dataProvider defaultPathNormalizationScenarios
*/
Expand Down
22 changes: 22 additions & 0 deletions tests/ext/root_span_url_with_query_params_obfuscation_empty.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
Root span with http.url and unobfuscated query string with empty regex
--ENV--
DD_TRACE_GENERATE_ROOT_SPAN=0
DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP=''
HTTPS=off
HTTP_HOST=localhost:9999
SCRIPT_NAME=/foo.php
REQUEST_URI=/users?application_key=123
QUERY_STRING=application_key=123
METHOD=GET
--GET--
application_key=123
--FILE--
<?php
DDTrace\start_span();
DDTrace\close_span();
$spans = dd_trace_serialize_closed_spans();
var_dump($spans[0]['meta']["http.url"]);
?>
--EXPECT--
string(48) "https://localhost:9999/users?application_key=123"

0 comments on commit 5f1f193

Please sign in to comment.