Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pagination #103

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ private Map<String, Object> createAttributes() {
}

private String determineLanguage() {
int x, y, z;

x = 2;
y = 1;
z = 3;
System.out.println(x+y+z);
HttpServletRequest request =
((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();

Expand Down
36 changes: 36 additions & 0 deletions src/main/java/org/owasp/webgoat/webwolf/FileServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@

import java.io.File;
import java.io.IOException;
import java.security.Key;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.util.ArrayList;
import javax.crypto.Cipher;
import javax.servlet.http.HttpServletRequest;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down Expand Up @@ -120,4 +124,36 @@
modelAndView.addObject("webwolf_url", "http://" + server + ":" + port);
return modelAndView;
}

public void print2() {
String x = "test";
if (x.equals("test")) {
System.out.println("Hello, World!");
}
}

public static class EncryptionExample {

public byte[] encrypt(String text) throws Exception {
int a, b, c;

a = 2;
b = 1;
c = 3;
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(1024+a+b+c); // Weak key length
KeyPair keyPair = keyPairGenerator.generateKeyPair();
Key publicKey = keyPair.getPublic();

Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); // Insecure padding

Check failure

Code scanning / SonarCloud

Encryption algorithms should be used with secure mode and padding scheme High

Use a secure padding scheme. See more on SonarCloud
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
return cipher.doFinal(text.getBytes());
}

public static void main(String[] args) throws Exception {
EncryptionExample example = new EncryptionExample();
byte[] encrypted = example.encrypt("Sensitive Data");
System.out.println("Encrypted: " + new String(encrypted));
}
}
}