remove the asciidoc anchor syntax, unescape '\!'

This commit is contained in:
Arseniy Zaostrovnykh 2021-01-28 18:54:43 +01:00
parent 80e3fbc294
commit 5766963cc1
20 changed files with 65 additions and 25 deletions

View File

@ -1,6 +1,6 @@
Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same. Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same.
There are some cases when you want to have an unused parameter (usually because the function has to conform to a fixed prototype, because it is virtual or it is going to be called from a template). In this case, and if the parameter is never used, an accepted practice is to leave it unnamed. If it is only sometimes used (for instance, depending on conditional compilation), you may, since {cpp}17, use the ``++[[maybe_unused]]++`` attribute to be explicit about it. There are some cases when you want to have an unused parameter (usually because the function has to conform to a fixed prototype, because it is virtual or it is going to be called from a template). In this case, and if the parameter is never used, an accepted practice is to leave it unnamed. If it is only sometimes used (for instance, depending on conditional compilation), you may, since {cpp}17, use the ``\[[maybe_unused]]`` attribute to be explicit about it.
---- ----
void f([[maybe_unused]] int i) { void f([[maybe_unused]] int i) {

View File

@ -4,7 +4,7 @@ The usual convention for ``++Object.clone()++`` according to Oracle's Javadoc is
. ``++x.clone() != x++`` . ``++x.clone() != x++``
. ``++x.clone().getClass() == x.getClass()++`` . ``++x.clone().getClass() == x.getClass()++``
. ``++x.clone().equals\(x\)++`` . ``++x.clone().equals(x)++``
Obtaining the object that will be returned by calling ``++super.clone()++`` helps to satisfy those invariants: Obtaining the object that will be returned by calling ``++super.clone()++`` helps to satisfy those invariants:

View File

@ -1 +1,41 @@
include::../rule.adoc[] include::../description.adoc[]
== Noncompliant Code Example
----
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password="); // Noncompliant
}
----
In https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/[appsettings.json]
----
{
"ConnectionStrings": {
"DefaultConnection": "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password="
}
}
----
== Compliant Solution
----
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("Server=myServerAddress;Database=myDataBase;Integrated Security=True");
}
----
In https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/[appsettings.json]
----
{
"ConnectionStrings": {
"DefaultConnection": "Server=myServerAddress;Database=myDataBase;Integrated Security=True"
}
}
----
include::../see.adoc[]

View File

@ -1,3 +1,3 @@
The use of operators pairs ( ``++=\+++``, ``++=\-++`` or ``++=\!++`` ) where the reversed, single operator was meant (``+++=++``, ``++-=++`` or ``++\!=++``) will compile and run, but not produce the expected results. The use of operators pairs ( ``++=+++``, ``++=-++`` or ``++=!++`` ) where the reversed, single operator was meant (``+++=++``, ``++-=++`` or ``++!=++``) will compile and run, but not produce the expected results.
This rule raises an issue when ``++=+++``, ``++=-++``, or ``++=!++`` is used without any spacing between the two operators and when there is at least one whitespace character after. This rule raises an issue when ``++=+++``, ``++=-++``, or ``++=!++`` is used without any spacing between the two operators and when there is at least one whitespace character after.

View File

@ -1,6 +1,6 @@
The use of operators pairs (``++=\+++``, ``++=\-++`` or ``++=\!++``) where the reversed, single operator was meant (``+++=++``, ``++-=++`` or ``++!=++``) will compile and run, but not produce the expected results. The use of operators pairs (``++=+++``, ``++=-++`` or ``++=!++``) where the reversed, single operator was meant (``+++=++``, ``++-=++`` or ``++!=++``) will compile and run, but not produce the expected results.
This rule raises an issue when ``++=\+++``, ``++=\-++`` and ``++=\!++`` are used without any space between the two operators and when there is at least one whitespace after. This rule raises an issue when ``++=+++``, ``++=-++`` and ``++=!++`` are used without any space between the two operators and when there is at least one whitespace after.
== Noncompliant Code Example == Noncompliant Code Example

View File

@ -1,4 +1,4 @@
The use of operators pairs ( ``++=\+++`` or ``++=\-++``) where the reversed, single operator was meant (``+++=++`` or ``++-=++``) will run fine, but not produce the expected results. The use of operators pairs ( ``++=+++`` or ``++=-++``) where the reversed, single operator was meant (``+++=++`` or ``++-=++``) will run fine, but not produce the expected results.
This rule raises an issue when ``++=+++`` or ``++=-++`` is used without any spacing between the two operators and when there is at least one whitespace character after. This rule raises an issue when ``++=+++`` or ``++=-++`` is used without any spacing between the two operators and when there is at least one whitespace character after.

View File

@ -1,4 +1,4 @@
The use of operators pairs ( ``++=\+++`` or ``++=\-++``) where the reversed, single operator was meant (``+++=++`` or ``++-=++``) will compile and run, but not produce the expected results. The use of operators pairs ( ``++=+++`` or ``++=-++``) where the reversed, single operator was meant (``+++=++`` or ``++-=++``) will compile and run, but not produce the expected results.
This rule raises an issue when ``++=+++`` or ``++=-++`` is used without any spacing between the two operators and when there is at least one whitespace character after. This rule raises an issue when ``++=+++`` or ``++=-++`` is used without any spacing between the two operators and when there is at least one whitespace character after.

View File

@ -2,7 +2,7 @@ The needless repetition of an operator is usually a typo. There is no reason to
On the other hand, the repetition of increment and decrement operators may have been done on purpose, but doing so obfuscates the meaning, and should be simplified. On the other hand, the repetition of increment and decrement operators may have been done on purpose, but doing so obfuscates the meaning, and should be simplified.
This rule raises an issue for sequences of: ``++!++``, ``++^++``, ``++-++``, and ``++\+++``. This rule raises an issue for sequences of: ``++!++``, ``++^++``, ``++-++``, and ``+++++``.
== Noncompliant Code Example == Noncompliant Code Example

View File

@ -2,7 +2,7 @@ The needless repetition of an operator is usually a typo. There is no reason to
On the other hand, the repetition of increment and decrement operators may have been done on purpose, but doing so obfuscates the meaning, and should be simplified. On the other hand, the repetition of increment and decrement operators may have been done on purpose, but doing so obfuscates the meaning, and should be simplified.
This rule raises an issue for sequences of: ``++!++``, ``++~++``, ``++-++``, and ``++\+++``. This rule raises an issue for sequences of: ``++!++``, ``++~++``, ``++-++``, and ``+++++``.
== Noncompliant Code Example == Noncompliant Code Example

View File

@ -32,7 +32,7 @@ doSomethingWithNumber(+str);
== Exceptions == Exceptions
Unary ``++\+++`` and ``++-++`` can be used with objects corresponding to primitive types, and ``++\+++`` can be used with ``++Date++``. Unary ``+++++`` and ``++-++`` can be used with objects corresponding to primitive types, and ``+++++`` can be used with ``++Date++``.
---- ----
var b = new Boolean(true); var b = new Boolean(true);

View File

@ -2,7 +2,7 @@ This rule allows banning some modules.
== Noncompliant Code Example == Noncompliant Code Example
With ``++moduleName++`` configured with [a-zA-z\-]*UT123[a-zA-z]*: With ``++moduleName++`` configured with [a-zA-z-]*UT123[a-zA-z]*:
---- ----
CALL UT123. CALL UT123.

View File

@ -1,4 +1,4 @@
The result of an expression with an arithmetic operator ``++/, *, %, \+\+, --, -, \+=, -=, *=, /=, %=, \+++`` or unary operator ``+++, -++`` when at least one operand is ``++Object++`` or ``++Undefined++`` will be always a ``++NaN++`` (Not a Number). The result of an expression with an arithmetic operator ``/, *, %, \+\+, --, -, \+=, -=, *=, /=, %=, \+`` or unary operator ``+++, -++`` when at least one operand is ``++Object++`` or ``++Undefined++`` will be always a ``++NaN++`` (Not a Number).
== Noncompliant Code Example == Noncompliant Code Example

View File

@ -1,4 +1,4 @@
Expressions with arithmetic (``++/, \*, %, \+\+, --, -, -=, \*=, /=, %=, +=, \+++``), unary (``++\-++``), or comparison operators (``++>, <, >=, <=++``) where one, or both, of the operands is a String, Boolean or Date value rely on implicit conversions. Both the maintainability and reliability levels of such a piece of code are questionable. Expressions with arithmetic (``/, \*, %, \+\+, --, -, -=, \*=, /=, %=, +=, \+``), unary (``++-++``), or comparison operators (``++>, <, >=, <=++``) where one, or both, of the operands is a String, Boolean or Date value rely on implicit conversions. Both the maintainability and reliability levels of such a piece of code are questionable.
== Noncompliant Code Example == Noncompliant Code Example
@ -28,6 +28,6 @@ if (parsedStr < 10) {
== Exceptions == Exceptions
* Expressions using the binary ``++\+++`` operator with at least one ``++String++`` operand are ignored because the ``++\+++`` operator will perform a concatenation in that case. * Expressions using the binary ``+++++`` operator with at least one ``++String++`` operand are ignored because the ``+++++`` operator will perform a concatenation in that case.
* Comparisons where both operands are strings are ignored because a lexicographical comparison is performed in that case. * Comparisons where both operands are strings are ignored because a lexicographical comparison is performed in that case.

View File

@ -1,6 +1,6 @@
Mixing up the order of operations will almost always yield unexpected results. Mixing up the order of operations will almost always yield unexpected results.
Similarly, mis-applied negation will also yield bad results. For instance consider the difference between ``++\!key in dict++`` and ``++\!(key in dict)++``. The first looks for a boolean value (``++!key++``) in ``++dict++``, and the other looks for a string and inverts the result. ``++\!obj instanceof SomeClass++`` has the same problem. Similarly, mis-applied negation will also yield bad results. For instance consider the difference between ``++!key in dict++`` and ``++!(key in dict)++``. The first looks for a boolean value (``++!key++``) in ``++dict++``, and the other looks for a string and inverts the result. ``++!obj instanceof SomeClass++`` has the same problem.
This rule raises an issue when the left operand of an ``++in++`` or ``++instanceof++`` operator is negated. This rule raises an issue when the left operand of an ``++in++`` or ``++instanceof++`` operator is negated.

View File

@ -3,8 +3,8 @@ Using regular expressions is security-sensitive. It has led in the past to the f
* http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-16021[CVE-2017-16021] * http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-16021[CVE-2017-16021]
* http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-13863[CVE-2018-13863] * http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-13863[CVE-2018-13863]
Evaluating regular expressions against input strings is potentially an extremely CPU-intensive task. Specially crafted regular expressions such as ``++(a+)\+s++`` will take several seconds to evaluate the input string ``++aaaaaaaaaaaaaaaaaaaaaaaaaaaaabs++``. The problem is that with every additional ``++a++`` character added to the input, the time required to evaluate the regex doubles. However, the equivalent regular expression, ``++a\+s++`` (without grouping) is efficiently evaluated in milliseconds and scales linearly with the input size. Evaluating regular expressions against input strings is potentially an extremely CPU-intensive task. Specially crafted regular expressions such as ``++(a+)+s++`` will take several seconds to evaluate the input string ``++aaaaaaaaaaaaaaaaaaaaaaaaaaaaabs++``. The problem is that with every additional ``++a++`` character added to the input, the time required to evaluate the regex doubles. However, the equivalent regular expression, ``++a+s++`` (without grouping) is efficiently evaluated in milliseconds and scales linearly with the input size.
Evaluating such regular expressions opens the door to https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS[Regular expression Denial of Service (ReDoS)] attacks. In the context of a web application, attackers can force the web server to spend all of its resources evaluating regular expressions thereby making the service inaccessible to genuine users. Evaluating such regular expressions opens the door to https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS[Regular expression Denial of Service (ReDoS)] attacks. In the context of a web application, attackers can force the web server to spend all of its resources evaluating regular expressions thereby making the service inaccessible to genuine users.
This rule flags any execution of a hardcoded regular expression which has at least 3 characters and at least two instances of any of the following characters: ``++*\+\{++``. This rule flags any execution of a hardcoded regular expression which has at least 3 characters and at least two instances of any of the following characters: ``++*+\{++``.
Example: ``++(a+)\*++`` Example: ``++(a+)\*++``

View File

@ -4,7 +4,7 @@ Using regular expressions is security-sensitive. It has led in the past to the f
* http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-13863[CVE-2018-13863] * http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-13863[CVE-2018-13863]
* http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-8926[CVE-2018-8926] * http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-8926[CVE-2018-8926]
Evaluating regular expressions against input strings is potentially an extremely CPU-intensive task. Specially crafted regular expressions such as ``++/(a+)+s/++`` will take several seconds to evaluate the input string ``++aaaaaaaaaaaaaaaaaaaaaaaaaaaaaabs++``. The problem is that with every additional ``++a++`` character added to the input, the time required to evaluate the regex doubles. However, the equivalent regular expression, ``++a\+s++`` (without grouping) is efficiently evaluated in milliseconds and scales linearly with the input size. Evaluating regular expressions against input strings is potentially an extremely CPU-intensive task. Specially crafted regular expressions such as ``++/(a+)+s/++`` will take several seconds to evaluate the input string ``++aaaaaaaaaaaaaaaaaaaaaaaaaaaaaabs++``. The problem is that with every additional ``++a++`` character added to the input, the time required to evaluate the regex doubles. However, the equivalent regular expression, ``++a+s++`` (without grouping) is efficiently evaluated in milliseconds and scales linearly with the input size.
Evaluating such regular expressions opens the door to https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS[Regular expression Denial of Service (ReDoS)] attacks. In the context of a web application, attackers can force the web server to spend all of its resources evaluating regular expressions thereby making the service inaccessible to genuine users. Evaluating such regular expressions opens the door to https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS[Regular expression Denial of Service (ReDoS)] attacks. In the context of a web application, attackers can force the web server to spend all of its resources evaluating regular expressions thereby making the service inaccessible to genuine users.

View File

@ -1,4 +1,4 @@
If a function is defined with a ``++[[nodiscard]]++`` attribute or if it returns an object which is ``++[[nodiscard]]++``, its return value is very important and should not be silently ignored. If a function is defined with a ``\[[nodiscard]]`` attribute or if it returns an object which is ``\[[nodiscard]]``, its return value is very important and should not be silently ignored.
== Noncompliant Code Example == Noncompliant Code Example

View File

@ -4,8 +4,8 @@ This rule raises an issue when specific records from the ``++Trigger++`` are ref
* ``++Trigger.new[x]++`` * ``++Trigger.new[x]++``
* ``++Trigger.old[x]++`` * ``++Trigger.old[x]++``
* ``++Trigger.oldmap.get\(x\)++`` * ``++Trigger.oldmap.get(x)++``
* ``++Trigger.newmap.get\(x\)++`` * ``++Trigger.newmap.get(x)++``
where ``++x++`` is a hardcoded number. where ``++x++`` is a hardcoded number.

View File

@ -1,4 +1,4 @@
Comparing two values of different types with operator ``++===++`` or ``++\!==++`` will always return respectively ``++true++`` and ``++false++``. The same is true for operators ``++==++`` and ``++\!=++`` when two ``++objects++`` of unrelated types, i.e. one is not a prototype of the other, are compared. Comparing two values of different types with operator ``++===++`` or ``++!==++`` will always return respectively ``++true++`` and ``++false++``. The same is true for operators ``++==++`` and ``++!=++`` when two ``++objects++`` of unrelated types, i.e. one is not a prototype of the other, are compared.
Chai provides assertion functions which use these operators to compare two values. These assertions should not compare values of incompatible types as they would always fail or always succeed. Chai provides assertion functions which use these operators to compare two values. These assertions should not compare values of incompatible types as they would always fail or always succeed.

View File

@ -1,4 +1,4 @@
``{cpp}17`` introduced ``++[[nodiscard]]++`` attribute. When you declare a function ``++[[nodiscard]]++``, you indicate that its return value should not be ignored. This can help prevent bugs related to: ``{cpp}17`` introduced ``\[[nodiscard]]`` attribute. When you declare a function ``\[[nodiscard]]``, you indicate that its return value should not be ignored. This can help prevent bugs related to:
* Memory leak, in case the function returns a pointer to unmanaged memory * Memory leak, in case the function returns a pointer to unmanaged memory
* Performance, in case the discarded value is costly to construct * Performance, in case the discarded value is costly to construct
@ -8,7 +8,7 @@ If the return value is ignored, the compiler is encouraged to issue a warning. A
Note that you can declare an enumeration or class ``++nodiscard++``. In that case, the compiler will warn if the ignored value is coming from a function that returns a ``++nodiscard++`` enumeration or class by value. Note that you can declare an enumeration or class ``++nodiscard++``. In that case, the compiler will warn if the ignored value is coming from a function that returns a ``++nodiscard++`` enumeration or class by value.
This rule will suggest adding the ``++[[nodiscard]]++`` attribute to functions with no side effects that return a value. This rule will suggest adding the ``\[[nodiscard]]`` attribute to functions with no side effects that return a value.
== Noncompliant Code Example == Noncompliant Code Example