Skip to content

Commit

Permalink
Add docs for late escaping check
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Nov 11, 2024
1 parent 74abb6a commit b90a6b9
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions includes/Checker/Checks/Security/Late_Escaping_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,41 @@ public function get_description(): string {
public function get_documentation_url(): string {
return __( 'https://developer.wordpress.org/apis/security/escaping/', 'plugin-check' );
}

/**
* Amends the given result with a message for the specified file, including error information.
*
* @since 1.3.0
*
* @param Check_Result $result The check result to amend, including the plugin context to check.
* @param bool $error Whether it is an error or notice.
* @param string $message Error message.
* @param string $code Error code.
* @param string $file Absolute path to the file where the issue was found.
* @param int $line The line on which the message occurred. Default is 0 (unknown line).
* @param int $column The column on which the message occurred. Default is 0 (unknown column).
* @param string $docs URL for further information about the message.
* @param int $severity Severity level. Default is 5.
*/
protected function add_result_message_for_file( Check_Result $result, $error, $message, $code, $file, $line = 0, $column = 0, string $docs = '', $severity = 5 ) {
switch ( $code ) {
case 'WordPress.Security.EscapeOutput.OutputNotEscaped':
$docs = __( 'https://developer.wordpress.org/apis/security/escaping/#escaping-functions', 'plugin-check' );
break;

case 'WordPress.Security.EscapeOutput.UnsafePrintingFunction':
$docs = __( 'https://developer.wordpress.org/apis/security/escaping/#escaping-with-localization', 'plugin-check' );
break;

Check warning on line 105 in includes/Checker/Checks/Security/Late_Escaping_Check.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Checks/Security/Late_Escaping_Check.php#L103-L105

Added lines #L103 - L105 were not covered by tests

case 'WordPress.Security.EscapeOutput.UnsafeSearchQuery':
$docs = __( 'https://developer.wordpress.org/reference/functions/get_search_query/', 'plugin-check' );
break;

Check warning on line 109 in includes/Checker/Checks/Security/Late_Escaping_Check.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Checks/Security/Late_Escaping_Check.php#L107-L109

Added lines #L107 - L109 were not covered by tests

default:
$docs = __( 'https://developer.wordpress.org/apis/security/escaping/', 'plugin-check' );
break;

Check warning on line 113 in includes/Checker/Checks/Security/Late_Escaping_Check.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Checks/Security/Late_Escaping_Check.php#L112-L113

Added lines #L112 - L113 were not covered by tests
}

parent::add_result_message_for_file( $result, $error, $message, $code, $file, $line, $column, $docs, $severity );
}
}

0 comments on commit b90a6b9

Please sign in to comment.