From e422306c83041539a64816b14374a1480b0d77bd Mon Sep 17 00:00:00 2001 From: Nils Werner <64034005+nils-werner-sonarsource@users.noreply.github.com> Date: Wed, 11 Jan 2023 13:46:12 +0100 Subject: [PATCH] Update rule metadata (#1028) --- .../org/sonar/l10n/php/rules/php/S4507.html | 4 ++-- .../org/sonar/l10n/php/rules/php/S5332.html | 16 ++++++++-------- .../org/sonar/l10n/php/rules/php/S6323.html | 5 +++-- sonarpedia.json | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/php-checks/src/main/resources/org/sonar/l10n/php/rules/php/S4507.html b/php-checks/src/main/resources/org/sonar/l10n/php/rules/php/S4507.html index 9e5bc9ce0b..504f602d7f 100644 --- a/php-checks/src/main/resources/org/sonar/l10n/php/rules/php/S4507.html +++ b/php-checks/src/main/resources/org/sonar/l10n/php/rules/php/S4507.html @@ -8,8 +8,8 @@ detailed information on both the system running the application and users.
There is a risk if you answered yes to any of those questions.
-$url = "https://example.com"; // Compliant -$url = "sftp://anonymous@example.com"; // Compliant -$url = "ssh://anonymous@example.com"; // Compliant +$url = "https://example.com"; +$url = "sftp://anonymous@example.com"; +$url = "ssh://anonymous@example.com"; -$con = ftp_ssl_connect('example.com'); // Compliant +$con = ftp_ssl_connect('example.com'); $trans = (new Swift_SmtpTransport('smtp.example.org', 1234)) - ->setEncryption('tls') // Compliant + ->setEncryption('tls') ; $mailer = new PHPMailer(true); -$mailer->SMTPSecure = 'tls'; // Compliant +$mailer->SMTPSecure = 'tls'; -define( 'FORCE_SSL_ADMIN', true); // Compliant -define( 'FORCE_SSL_LOGIN', true); // Compliant +define( 'FORCE_SSL_ADMIN', true); +define( 'FORCE_SSL_LOGIN', true);
No issue is reported for the following cases because they are not considered sensitive:
diff --git a/php-checks/src/main/resources/org/sonar/l10n/php/rules/php/S6323.html b/php-checks/src/main/resources/org/sonar/l10n/php/rules/php/S6323.html index 5a2a6b393f..2179b1ee32 100644 --- a/php-checks/src/main/resources/org/sonar/l10n/php/rules/php/S6323.html +++ b/php-checks/src/main/resources/org/sonar/l10n/php/rules/php/S6323.html @@ -10,9 +10,10 @@One could use an empty alternation to make a regular expression group optional. Rule will not report on such cases.
+One could use an empty alternation to make a regular expression group optional. Note that the empty alternation should be the first or the last +within the group, or else the rule will still report.
-preg_match("/mandatory(-optional|)/", "mandatory"); // returns 1 +preg_match("/mandatory(|-optional)/", "mandatory"); // returns 1 preg_match("/mandatory(-optional|)/", "mandatory-optional"); // returns 1
However, if there is a quantifier after the group the issue will be reported as using both |
and quantifier is redundant.