From 1bb00f7798f9dc4dc0419b9b5f53b56af8b80b29 Mon Sep 17 00:00:00 2001 From: Manasi1305 <77058091+Manasi1305@users.noreply.github.com> Date: Mon, 22 Nov 2021 12:29:48 +0530 Subject: [PATCH 1/4] Create DoNotCallSystemExit.java --- src/main/java/DoNotCallSystemExit.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/DoNotCallSystemExit.java diff --git a/src/main/java/DoNotCallSystemExit.java b/src/main/java/DoNotCallSystemExit.java new file mode 100644 index 0000000..34f0a6d --- /dev/null +++ b/src/main/java/DoNotCallSystemExit.java @@ -0,0 +1,7 @@ +package javacodechecker; +public class DoNotCallSystemExit { + +public static void m() { + System.exit(1); + } + } From 597fbe28d1087f4114ec2b5290dfea6ef91c2b81 Mon Sep 17 00:00:00 2001 From: Manasi1305 <77058091+Manasi1305@users.noreply.github.com> Date: Mon, 22 Nov 2021 12:31:52 +0530 Subject: [PATCH 2/4] Create MissingRequiredCryptographicStep.java --- .../MissingRequiredCryptographicStep.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/MissingRequiredCryptographicStep.java diff --git a/src/main/java/MissingRequiredCryptographicStep.java b/src/main/java/MissingRequiredCryptographicStep.java new file mode 100644 index 0000000..6187ace --- /dev/null +++ b/src/main/java/MissingRequiredCryptographicStep.java @@ -0,0 +1,28 @@ +package javacodechecker; +public class MissingRequiredCryptographicStep { + public void notValid() throws Throwable + { + + final String CIPHER_INPUT = "ABCDEFG123456"; + KeyGenerator kG = KeyGenerator.getInstance("AES"); + SecretKey secretKey = kG.generateKey(); + byte[] byteKey = secretKey.getEncoded(); + SecretKeySpec secretKeySpec = new SecretKeySpec(byteKey, "AES"); + Cipher aesCipher = Cipher.getInstance("AES"); + aesCipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); + byte[] encrypted = aesCipher.doFinal(CIPHER_INPUT.getBytes("UTF-8")); + } + private void inValid() throws Throwable + { + + final String CIPHER_INPUT = "ABCDEFG123456"; + KeyGenerator kGVal = KeyGenerator.getInstance("AES"); + kGVal.equals(kGVal); + SecretKey secretKey = kGVal.generateKey(); + byte[] byteKey = secretKey.getEncoded(); + SecretKeySpec secretKeySpec = new SecretKeySpec(byteKey, "AES"); + Cipher aesCipher = Cipher.getInstance("AES"); + aesCipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); + byte[] encrypted = aesCipher.doFinal(CIPHER_INPUT.getBytes("UTF-8")); + } +} From 44ce3a07a9334032d7762718bba03988b6946b34 Mon Sep 17 00:00:00 2001 From: Manasi1305 <77058091+Manasi1305@users.noreply.github.com> Date: Mon, 22 Nov 2021 12:34:07 +0530 Subject: [PATCH 3/4] Create RedirectWithoutExit.java --- src/main/java/RedirectWithoutExit.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/RedirectWithoutExit.java diff --git a/src/main/java/RedirectWithoutExit.java b/src/main/java/RedirectWithoutExit.java new file mode 100644 index 0000000..e71d2d6 --- /dev/null +++ b/src/main/java/RedirectWithoutExit.java @@ -0,0 +1,10 @@ +package javacodechecker; +public class RedirectWithoutExit { + public void bad(HttpServletRequest request, HttpServletResponse response) throws Throwable { + logger.info("doing some more things here after the redirect"); + logger.info("doing some more things here after the redirect"); + response.sendRedirect("/test"); + Logger.info("doing some more things here after the redirect"); + } +} + From bde7c37c18ecf9a439cccc5380567f98809ea1a7 Mon Sep 17 00:00:00 2001 From: Manasi1305 <77058091+Manasi1305@users.noreply.github.com> Date: Mon, 22 Nov 2021 12:34:38 +0530 Subject: [PATCH 4/4] Update MissingRequiredCryptographicStep.java --- src/main/java/MissingRequiredCryptographicStep.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/MissingRequiredCryptographicStep.java b/src/main/java/MissingRequiredCryptographicStep.java index 6187ace..4c23599 100644 --- a/src/main/java/MissingRequiredCryptographicStep.java +++ b/src/main/java/MissingRequiredCryptographicStep.java @@ -1,4 +1,8 @@ package javacodechecker; +import javax.crypto.Cipher; +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; public class MissingRequiredCryptographicStep { public void notValid() throws Throwable {