Skip to content

Commit 2cc57a6

Browse files
SONARXML-145 Test minimum SDK version based on scanner property
As detailed in this ticket[0], and used in S6538, the android version that we should check against is the one defined by the scanners and not the original `android:minSdk` property. [0] https://sonarsource.atlassian.net/browse/SCANGRADLE-95
1 parent 4cf7d98 commit 2cc57a6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sonar-xml-plugin/src/main/java/org/sonar/plugins/xml/checks/security/android/AndroidClearTextCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class AndroidClearTextCheck extends AbstractAndroidManifestCheck {
5050
protected void scanAndroidManifest(XmlFile file) {
5151
Document document = file.getDocument();
5252
evaluateAsList(xPathClearTextTrue, document).forEach(node -> reportAtNameLocation(node, MESSAGE));
53-
Integer minSdk = getContext().config().getInt("android:minSdkVersion").orElse(27);
53+
Integer minSdk = getContext().config().getInt("sonar.android.minsdkversion.min").orElse(27);
5454
// As of Android SDK 28, `usesCleartextTraffic` is implicitly set to false by default
5555
// See https://developer.android.com/guide/topics/manifest/application-element
5656
if (minSdk < 28) {

sonar-xml-plugin/src/test/java/org/sonar/plugins/xml/checks/security/android/AndroidClearTextCheckTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void does_not_raise_when_usesCleartextTraffic_is_not_set_and_minSdk_greater_or_e
4040
SonarXmlCheckVerifier.verifyNoIssue(
4141
"implicit/AndroidManifest.xml",
4242
new AndroidClearTextCheck(),
43-
new MapSettings().setProperty("android:minSdkVersion", 28)
43+
new MapSettings().setProperty("sonar.android.minsdkversion.min", 28)
4444
);
4545
}
4646

@@ -49,7 +49,7 @@ void raises_when_usesCleartextTraffic_is_not_set_and_minSdk_is_less_than_28() {
4949
SonarXmlCheckVerifier.verifyIssues(
5050
"implicit/AndroidManifest.xml",
5151
new AndroidClearTextCheck(),
52-
new MapSettings().setProperty("android:minSdkVersion", 27)
52+
new MapSettings().setProperty("sonar.android.minsdkversion.min", 27)
5353
);
5454
}
5555

0 commit comments

Comments
 (0)