Skip to content

Commit a591f47

Browse files
committed
ACOMMONS-27 OWASP Mobile Top 10 2024
1 parent 053b799 commit a591f47

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

commons/src/main/java/org/sonarsource/analyzer/commons/RuleMetadataLoader.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.sonar.api.server.rule.RulesDefinition.NewRule;
4141
import org.sonar.api.server.rule.RulesDefinition.OwaspAsvsVersion;
4242
import org.sonar.api.server.rule.RulesDefinition.OwaspTop10Version;
43+
import org.sonar.api.server.rule.RulesDefinition.OwaspMobileTop10Version;
4344
import org.sonar.api.server.rule.RulesDefinition.PciDssVersion;
4445
import org.sonar.api.server.rule.RulesDefinition.StigVersion;
4546
import org.sonar.api.server.rule.RulesDefinitionAnnotationLoader;
@@ -66,6 +67,7 @@ public class RuleMetadataLoader {
6667
private final SonarRuntime sonarRuntime;
6768
private final EducationRuleLoader educationRuleLoader;
6869

70+
private static final String OWASP_MOBILE_2024 = "OWASP Mobile Top 10 2024";
6971
private static final String OWASP_2021 = "OWASP Top 10 2021";
7072
private static final String OWASP_2017 = "OWASP";
7173
private static final String PCI_DSS_PREFIX = "PCI DSS ";
@@ -258,6 +260,7 @@ private void setSecurityStandardsFromJson(NewRule rule, Map<String, Object> secu
258260
}
259261

260262
addOwasp(rule, securityStandards);
263+
addOwaspMobile(rule, securityStandards);
261264
addPciDss(rule, securityStandards);
262265
addOwaspAsvs(rule, securityStandards);
263266
addStig(rule, securityStandards);
@@ -281,6 +284,15 @@ private void addOwasp(NewRule rule, Map<String, Object> securityStandards) {
281284
}
282285
}
283286

287+
private void addOwaspMobile(NewRule rule, Map<String, Object> securityStandards) {
288+
if (!isSupported(11, 4)) {
289+
return;
290+
}
291+
for (String standard : getStringArray(securityStandards, OWASP_MOBILE_2024)) {
292+
rule.addOwaspMobileTop10(OwaspMobileTop10Version.Y2024, RulesDefinition.OwaspMobileTop10.valueOf(standard));
293+
}
294+
}
295+
284296
private void addPciDss(NewRule rule, Map<String, Object> securityStandards) {
285297
if (!isSupported(9, 5)) {
286298
return;

commons/src/test/java/org/sonarsource/analyzer/commons/RuleMetadataLoaderTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public class RuleMetadataLoaderTest {
7777
private static final SonarRuntime SONAR_RUNTIME_10_1 = SonarRuntimeImpl.forSonarLint(Version.create(10, 1));
7878
private static final SonarRuntime SONAR_RUNTIME_10_10 = SonarRuntimeImpl.forSonarLint(Version.create(10, 10));
7979
private static final SonarRuntime SONAR_RUNTIME_10_11 = SonarRuntimeImpl.forSonarLint(Version.create(10, 11));
80+
private static final SonarRuntime SONAR_RUNTIME_11_4 = SonarRuntimeImpl.forSonarLint(Version.create(11, 4));
8081

8182
@Before
8283
public void setup() {
@@ -532,6 +533,20 @@ class TestRule {
532533
.containsExactlyInAnyOrder("cwe:311", "cwe:315", "cwe:614", "owaspTop10:a2", "owaspTop10:a3", "owaspTop10-2021:a4", "owaspTop10-2021:a5");
533534
}
534535

536+
@Test
537+
public void test_security_standards_on_11_4() {
538+
Set<String> securityStandards = getSecurityStandards(SONAR_RUNTIME_11_4);
539+
assertThat(securityStandards).containsExactlyInAnyOrder(
540+
"cwe:311", "cwe:315", "cwe:614",
541+
"owaspTop10:a2", "owaspTop10:a3",
542+
"owaspTop10-2021:a4", "owaspTop10-2021:a5",
543+
"pciDss-3.2:1.1.1", "pciDss-3.2:1.1.2",
544+
"owaspAsvs-4.0:2.1.1", "owaspAsvs-4.0:2.1.2",
545+
"stig-ASD_V5R3:V-222612",
546+
"owaspMobileTop10-2024:m3", "owaspMobileTop10-2024:m4"
547+
);
548+
}
549+
535550
@Test
536551
public void test_security_standards_on_10_10_return_stig() {
537552
Set<String> securityStandards = getSecurityStandards(SONAR_RUNTIME_10_10);

commons/src/test/resources/org/sonarsource/analyzer/commons/S2092.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
"A4",
3737
"A5"
3838
],
39+
"OWASP Mobile Top 10 2024": [
40+
"M3",
41+
"M4"
42+
],
3943
"PCI DSS 3.2": [
4044
"1.1.1",
4145
"1.1.2"

0 commit comments

Comments
 (0)