diff --git a/java/src/test/files/rules/detection/DetectionWithSubRuleTestFile.java b/java/src/test/files/rules/detection/DetectionWithSubRuleTestFile.java index 8a16d415f..fb3e0f88c 100644 --- a/java/src/test/files/rules/detection/DetectionWithSubRuleTestFile.java +++ b/java/src/test/files/rules/detection/DetectionWithSubRuleTestFile.java @@ -1,10 +1,10 @@ import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; -import java.security.InvalidKeyException; public class DetectionWithSubRuleTestFile { - void test(Cipher cipher) throws InvalidKeyException { - cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec("0123456789ABCDEF".getBytes(), "AES")); // Noncompliant {{2}} + void test() throws Exception { + Cipher cipher = Cipher.getInstance("AES"); // Noncompliant {{AES}} + cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec("0123456789ABCDEF".getBytes(), "AES")); // Noncompliant {{128}} {{2}} {{AES}} } } \ No newline at end of file diff --git a/java/src/test/java/com/ibm/plugin/rules/detection/DetectionWithSubRuleTest.java b/java/src/test/java/com/ibm/plugin/rules/detection/DetectionWithSubRuleTest.java index 84a0719a8..6be32f80f 100644 --- a/java/src/test/java/com/ibm/plugin/rules/detection/DetectionWithSubRuleTest.java +++ b/java/src/test/java/com/ibm/plugin/rules/detection/DetectionWithSubRuleTest.java @@ -21,13 +21,11 @@ import com.ibm.engine.detection.DetectionStore; import com.ibm.engine.detection.Finding; -import com.ibm.engine.utils.DetectionStoreLogger; import com.ibm.mapper.model.INode; import com.ibm.plugin.TestBase; import com.ibm.plugin.rules.detection.jca.cipher.JcaCipherGetInstance; import java.util.List; import javax.annotation.Nonnull; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.sonar.check.Rule; import org.sonar.java.checks.verifier.CheckVerifier; @@ -51,7 +49,6 @@ public void asserts( // nothing } - @Disabled("") @Test void test() { CheckVerifier.newVerifier() @@ -62,15 +59,18 @@ void test() { @Override public void update(@Nonnull Finding finding) { - final DetectionStore detectionStore = - finding.detectionStore(); - (new DetectionStoreLogger()) - .print(detectionStore); - detectionStore - .getDetectionValues() - .forEach( - iValue -> { - this.reportIssue(iValue.getLocation(), iValue.asString()); - }); + reportStore(finding.detectionStore()); + } + + private void reportStore( + DetectionStore store) { + if (store == null) { + return; + } + + store.getDetectionValues() + .forEach(value -> this.reportIssue(value.getLocation(), value.asString())); + + store.getChildren().forEach(this::reportStore); } }