From 271cb9f712eb7f841353f86afaec4bc41a8eb361 Mon Sep 17 00:00:00 2001 From: Javier Santos Date: Wed, 26 Jul 2023 14:10:28 +0200 Subject: [PATCH] Changed example so it only generates one vulnerability --- .../com/datadoghq/system_tests/iast/utils/CryptoExamples.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/utils/build/docker/java/iast-common/src/main/java/com/datadoghq/system_tests/iast/utils/CryptoExamples.java b/utils/build/docker/java/iast-common/src/main/java/com/datadoghq/system_tests/iast/utils/CryptoExamples.java index 8bc58863347..760b12dec6d 100644 --- a/utils/build/docker/java/iast-common/src/main/java/com/datadoghq/system_tests/iast/utils/CryptoExamples.java +++ b/utils/build/docker/java/iast-common/src/main/java/com/datadoghq/system_tests/iast/utils/CryptoExamples.java @@ -73,10 +73,8 @@ public String secureCipher(final String password) { private static String doCipher(final String password, final String algorithm) { try { - KeyGenerator keygenerator = KeyGenerator.getInstance(algorithm); - SecretKey key = keygenerator.generateKey(); Cipher cipher = Cipher.getInstance(algorithm); - cipher.init(Cipher.ENCRYPT_MODE, key); + cipher.init(Cipher.ENCRYPT_MODE, KeyGenerator.getInstance(algorithm).generateKey()); return new String(cipher.doFinal(password.getBytes())); } catch (final Exception e) { throw new UndeclaredThrowableException(e);