Skip to content

Commit

Permalink
Revert "Fix regression that discloses file path in some errors"
Browse files Browse the repository at this point in the history
This reverts commit d5d85f1.
  • Loading branch information
vboctor committed Feb 6, 2018
1 parent 404a75e commit 15c7af5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
19 changes: 6 additions & 13 deletions api/soap/mc_api.php
Expand Up @@ -162,10 +162,6 @@ static function faultServerError( $p_fault_string ) {
*/
static function faultFromException( Exception $p_exception ) {
$t_code = $p_exception->getCode();
$t_message = $p_exception->getMessage();

# Make sure the file path is not disclosed via exception details
$t_message = str_replace( config_get_global( 'absolute_path' ), '.../', $t_message );

switch( $t_code ) {
case ERROR_NO_FILE_SPECIFIED:
Expand Down Expand Up @@ -231,7 +227,7 @@ static function faultFromException( Exception $p_exception ) {
case ERROR_COLUMNS_INVALID:
case ERROR_API_TOKEN_NAME_NOT_UNIQUE:
case ERROR_INVALID_FIELD_VALUE:
return ApiObjectFactory::faultBadRequest( $t_message );
return ApiObjectFactory::faultBadRequest( $p_exception->getMessage() );

case ERROR_BUG_NOT_FOUND:
case ERROR_FILE_NOT_FOUND:
Expand All @@ -253,7 +249,7 @@ static function faultFromException( Exception $p_exception ) {
case ERROR_FILTER_NOT_FOUND:
case ERROR_TAG_NOT_FOUND:
case ERROR_TOKEN_NOT_FOUND:
return ApiObjectFactory::faultNotFound( $t_message );
return ApiObjectFactory::faultNotFound( $p_exception->getMessage() );

case ERROR_ACCESS_DENIED:
case ERROR_PROTECTED_ACCOUNT:
Expand All @@ -271,18 +267,18 @@ static function faultFromException( Exception $p_exception ) {
case ERROR_LOST_PASSWORD_NOT_ENABLED:
case ERROR_LOST_PASSWORD_MAX_IN_PROGRESS_ATTEMPTS_REACHED:
case ERROR_FORM_TOKEN_INVALID:
return ApiObjectFactory::faultForbidden( $t_message );
return ApiObjectFactory::faultForbidden( $p_exception->getMessage() );

case ERROR_SPAM_SUSPECTED:
return ApiObjectFactory::faultTooManyRequests( $t_message );
return ApiObjectFactory::faultTooManyRequests( $p_exception->getMessage() );

case ERROR_CONFIG_OPT_INVALID:
case ERROR_FILE_INVALID_UPLOAD_PATH:
# TODO: These are configuration or db state errors.
return ApiObjectFactory::faultServerError( $t_message );
return ApiObjectFactory::faultServerError( $p_exception->getMessage() );

default:
return ApiObjectFactory::faultServerError( $t_message );
return ApiObjectFactory::faultServerError( $p_exception->getMessage() );
}
}

Expand Down Expand Up @@ -1138,9 +1134,6 @@ function mc_error_handler( $p_type, $p_error, $p_file, $p_line, array $p_context

$t_error_stack = error_get_stack_trace();

# Make sure the file path is not disclosed via exception details
$t_error_description = str_replace( config_get_global( 'absolute_path' ), '.../', $t_error_description );

error_log( '[mantisconnect.php] Error Type: ' . $t_error_type . ',' . "\n" . 'Error Description: ' . $t_error_description . "\n" . 'Stack Trace:' . "\n" . $t_error_stack );

throw new SoapFault( 'Server', 'Error Type: ' . $t_error_type . ',' . "\n" . 'Error Description: ' . $t_error_description );
Expand Down
9 changes: 2 additions & 7 deletions core/error_api.php
Expand Up @@ -247,16 +247,11 @@ function error_handler( $p_type, $p_error, $p_file, $p_line, array $p_context )

$t_error_description = nl2br( $t_error_description );

# Make sure the file path is not disclosed via exception details
$t_error_description = str_replace( config_get_global( 'absolute_path' ), '.../', $t_error_description );

$t_show_detailed_errors = config_get_global( 'show_detailed_errors' ) == ON;

if( php_sapi_name() == 'cli' ) {
if( DISPLAY_ERROR_NONE != $t_method ) {
echo $t_error_type . ': ' . $t_error_description . "\n";

if( $t_show_detailed_errors ) {
if( ON == config_get_global( 'show_detailed_errors' ) ) {
echo "\n";
error_print_stack_trace();
}
Expand Down Expand Up @@ -339,7 +334,7 @@ function error_handler( $p_type, $p_error, $p_file, $p_line, array $p_context )
}
echo '</div>';

if( $t_show_detailed_errors ) {
if( ON == config_get_global( 'show_detailed_errors' ) ) {
echo '<p>';
error_print_details( $p_file, $p_line, $p_context );
echo '</p>';
Expand Down

0 comments on commit 15c7af5

Please sign in to comment.