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

refactor: Java Security Ultimate Scan 2023 #6

Open
wants to merge 1 commit into
base: master
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 @@ -31,6 +31,7 @@

import java.io.IOException;
import java.io.OutputStream;
import java.security.SecureRandom;
import java.util.Random;

import org.apache.commons.httpclient.methods.RequestEntity;
Expand Down Expand Up @@ -99,7 +100,7 @@ public class MultipartRequestEntity implements RequestEntity {
* @return
*/
private static byte[] generateMultipartBoundary() {
Random rand = new Random();
Random rand = new SecureRandom();
byte[] bytes = new byte[rand.nextInt(11) + 30]; // a random size from 30 to 40
for (int i = 0; i < bytes.length; i++) {
bytes[i] = MULTIPART_CHARS[rand.nextInt(MULTIPART_CHARS.length)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;

import junit.framework.Test;
import junit.framework.TestCase;
Expand Down Expand Up @@ -109,7 +110,7 @@ public void testFilePartNullFileResendsData() throws Exception {
* written to.
*/
private File createTempTestFile() throws IOException {
File file = File.createTempFile("FilePartTest", ".txt");
File file = Files.createTempFile("FilePartTest", ".txt").toFile();
PrintWriter out = new PrintWriter(new FileWriter(file));
out.println(PART_DATA);
out.flush();
Expand Down