diff --git a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2095_java.html b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2095_java.html
index e47884846a9..5fc41197f66 100644
--- a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2095_java.html
+++ b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2095_java.html
@@ -2,8 +2,8 @@
AutoCloseable
, needs to be closed after use. Further, that close
call must be made in a finally
block otherwise
an exception could keep the call from being made. Preferably, when class implements AutoCloseable
, resource should be created using
"try-with-resources" pattern and will be closed automatically.
Failure to properly close resources will result in a resource leak which could bring first the application and then perhaps the box it's on to -their knees.
+Failure to properly close resources will result in a resource leak which could bring first the application and then perhaps the box the application +is on to their knees.
private void readTheFile() throws IOException { diff --git a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2277_java.json b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2277_java.json index 9b3846af1b7..a0d03f9d0a8 100644 --- a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2277_java.json +++ b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2277_java.json @@ -7,10 +7,23 @@ "constantCost": "20min" }, "tags": [ - + "cwe", + "owasp-a6", + "sans-top25-porous", + "owasp-a3" ], "defaultSeverity": "Critical", "ruleSpecification": "RSPEC-2277", "sqKey": "S2277", - "scope": "Main" + "scope": "Main", + "securityStandards": { + "CWE": [ + 780, + 327 + ], + "OWASP": [ + "A3", + "A6" + ] + } } diff --git a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2278_java.json b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2278_java.json index 95b5a670ae5..e88538b3008 100644 --- a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2278_java.json +++ b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2278_java.json @@ -7,10 +7,22 @@ "constantCost": "20min" }, "tags": [ - + "cwe", + "cert", + "owasp-a6", + "sans-top25-porous" ], "defaultSeverity": "Blocker", "ruleSpecification": "RSPEC-2278", "sqKey": "S2278", - "scope": "Main" + "scope": "Main", + "securityStandards": { + "CWE": [ + 326, + 327 + ], + "OWASP": [ + "A6" + ] + } } diff --git a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2647_java.json b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2647_java.json index e32e482b9f2..f85fe66ea4a 100644 --- a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2647_java.json +++ b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S2647_java.json @@ -8,7 +8,6 @@ }, "tags": [ "cwe", - "owasp-a6", "sans-top25-porous", "owasp-a3" ], @@ -22,7 +21,6 @@ 311 ], "OWASP": [ - "A6", "A3" ] } diff --git a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S3011_java.json b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S3011_java.json index f928270f3f6..e9e8a631ade 100644 --- a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S3011_java.json +++ b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S3011_java.json @@ -7,16 +7,10 @@ "constantCost": "30min" }, "tags": [ - "cert", - "owasp-a3" + "cert" ], "defaultSeverity": "Major", "ruleSpecification": "RSPEC-3011", "sqKey": "S3011", - "scope": "Main", - "securityStandards": { - "OWASP": [ - "A3" - ] - } + "scope": "Main" } diff --git a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S3400_java.html b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S3400_java.html index e3f46b74fc5..70bb176fc4b 100644 --- a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S3400_java.html +++ b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S3400_java.html @@ -9,7 +9,7 @@Noncompliant Code Example
-static int bestNumber = 12; +static final int BEST_NUMBER = 12;
Methods with annotations, such as @Override
and Spring's @RequestMapping
, are ignored.
secp192r1
is a non-compliant curve (n
< 224) but secp224k1
is
compliant (n
>= 224)) Encryption and Decryption:
+Symmetric keys:
This rule will not raise issues for ciphers that are considered weak (no matter the key size) like DES
, Blowfish
.
Strong cipher algorithms are cryptographic systems resistant to cryptanalysis, they are not vulnerable to well-known attacks like brute force attacks for example.
-It is recommended to use only cipher algorithms intensively tested and promoted by the cryptographic community.
+A general recomandation is to only use cipher algorithms intensively tested and promoted by the cryptographic community.
+More specifically for block cipher, it's not recommended to use algorithm with a block size inferior than 128 bits.
import javax.crypto.Cipher; diff --git a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S5841_java.html b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S5841_java.html index d017b1257a1..280dc2801f1 100644 --- a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S5841_java.html +++ b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S5841_java.html @@ -1,8 +1,9 @@AssertJ assertions
-allMatch
anddoesNotContains
on an empty list always returns true whatever the content of the predicate. Despite being correct, you should make explicit if you expect an empty list or not, by adding -isEmpty()
/isNotEmpty()
before calling the assertion. It will justify the useless predicate to improve clarity or increase -the reliability of the test.This rule raises an issue when any of the methods listed are used without asserting that the list is empty or not.
+isEmpty()
/isNotEmpty()
in addition to calling the assertion, or by testing the list's content further. It will justify the +useless predicate to improve clarity or increase the reliability of the test. +This rule raises an issue when any of the methods listed are used without asserting that the list is empty or not and without testing the +content.
Targetted methods:
allMatch
String s = "e\u0300"; Pattern p = Pattern.compile("é|ë|è"); // Noncompliant -System.out.println(p.matcher(s).replaceAll("e")); // print ‘é’ +System.out.println(p.matcher(s).replaceAll("e")); // print 'é'
String s = "e\u0300"; Pattern p = Pattern.compile("é|ë|è", Pattern.CANON_EQ); -System.out.println(p.matcher(s).replaceAll("e")); // print ‘e’ +System.out.println(p.matcher(s).replaceAll("e")); // print 'e'diff --git a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S5869_java.html b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S5869_java.html index 5959803c6b4..199ab6ffc88 100644 --- a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S5869_java.html +++ b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/S5869_java.html @@ -1,15 +1,19 @@
Character classes in regular expressions are a convenient way to match one of several possible characters by listing the allowed characters or ranges of characters. If the same character is listed twice in the same character class or if the character class contains overlapping ranges, this has no effect.
-Thus duplicate characters in a character class are either a simple oversight or a sign that the author misunderstood how character classes work and
-wanted to match more than one character. A common example of the latter mistake is trying to use a range like [0-99]
to match numbers of
-up to two digits, when in fact it is equivalent to [0-9]
.
Thus duplicate characters in a character class are either a simple oversight or a sign that a range in the character class matches more than is
+intended or that the author misunderstood how character classes work and wanted to match more than one character. A common example of the latter
+mistake is trying to use a range like [0-99]
to match numbers of up to two digits, when in fact it is equivalent to [0-9]
.
+Another common cause is forgetting to escape the `-` character, creating an unintended range that overlaps with other characters in the character
+class.
str.matches("[0-99]") // Noncompliant, this won't actually match strings with two digits +str.matches("[0-9.-_]") // Noncompliant, .-_ is a range that already contains 0-9 (as well as various other characters such as capital letters)
str.matches("[0-9]{1,2}") +str.matches("[0-9.\\-_]")diff --git a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/Sonar_way_profile.json b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/Sonar_way_profile.json index 4a981b98ab9..5e189ce3890 100644 --- a/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/Sonar_way_profile.json +++ b/java-checks/src/main/resources/org/sonar/l10n/java/rules/java/Sonar_way_profile.json @@ -352,7 +352,6 @@ "S4684", "S4719", "S4738", - "S4784", "S4790", "S4792", "S4830", diff --git a/sonarpedia.json b/sonarpedia.json index 2fc68a14c3d..c8cbc8f2365 100644 --- a/sonarpedia.json +++ b/sonarpedia.json @@ -3,7 +3,7 @@ "languages": [ "JAVA" ], - "latest-update": "2020-06-18T14:34:25.059019Z", + "latest-update": "2020-07-15T12:00:39.489532200Z", "options": { "no-language-in-filenames": false, "preserve-filenames": false