Skip to content

Commit

Permalink
Update rule metadata (#1028)
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-werner-sonarsource authored Jan 11, 2023
1 parent 7edf35b commit e422306
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
detailed information on both the system running the application and users.</p>
<h2>Ask Yourself Whether</h2>
<ul>
<li> the code or configuration enabling the application debug features is deployed on production servers or distributed to end users. </li>
<li> the application runs by default with debug features activated. </li>
<li> The code or configuration enabling the application debug features is deployed on production servers or distributed to end users. </li>
<li> The application runs by default with debug features activated. </li>
</ul>
<p>There is a risk if you answered yes to any of those questions.</p>
<h2>Recommended Secure Coding Practices</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,21 @@ <h2>Sensitive Code Example</h2>
</pre>
<h2>Compliant Solution</h2>
<pre>
$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))
-&gt;setEncryption('tls') // Compliant
-&gt;setEncryption('tls')
;

$mailer = new PHPMailer(true);
$mailer-&gt;SMTPSecure = 'tls'; // Compliant
$mailer-&gt;SMTPSecure = 'tls';

define( 'FORCE_SSL_ADMIN', true); // Compliant
define( 'FORCE_SSL_LOGIN', true); // Compliant
define( 'FORCE_SSL_ADMIN', true);
define( 'FORCE_SSL_LOGIN', true);
</pre>
<h2>Exceptions</h2>
<p>No issue is reported for the following cases because they are not considered sensitive:</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ <h2>Compliant Solution</h2>
preg_match("/Jack|Peter/", "John"); // returns 0
</pre>
<h2>Exceptions</h2>
<p>One could use an empty alternation to make a regular expression group optional. Rule will not report on such cases.</p>
<p>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.</p>
<pre>
preg_match("/mandatory(-optional|)/", "mandatory"); // returns 1
preg_match("/mandatory(|-optional)/", "mandatory"); // returns 1
preg_match("/mandatory(-optional|)/", "mandatory-optional"); // returns 1
</pre>
<p>However, if there is a quantifier after the group the issue will be reported as using both <code>|</code> and quantifier is redundant.</p>
Expand Down
2 changes: 1 addition & 1 deletion sonarpedia.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"languages": [
"PHP"
],
"latest-update": "2023-01-03T15:30:07.256729179Z",
"latest-update": "2023-01-11T12:33:07.630347077Z",
"options": {
"no-language-in-filenames": true,
"preserve-filenames": true
Expand Down

0 comments on commit e422306

Please sign in to comment.