Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Modernize and secure temp file creation #32

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

Open
pixeebot wants to merge 1 commit into master
base: master
Choose a base branch
Loading
from pixeebot/drip-2025年08月05日-pixee-java/upgrade-tempfile-to-nio
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
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import com.owncloud.android.operations.CreateFolderOperation;
import com.owncloud.android.operations.UploadFileOperation;
import com.owncloud.android.utils.FileStorageUtils;
import java.nio.file.Files;

import org.apache.commons.io.FileUtils;
import org.junit.After;
Expand Down Expand Up @@ -291,7 +292,7 @@ public static File createFile(String name, int iteration) throws IOException {

protected File getFile(String filename) throws IOException {
InputStream inputStream = getInstrumentation().getContext().getAssets().open(filename);
File temp = File.createTempFile("file", "file");
File temp = Files.createTempFile("file", "file").toFile();
FileUtils.copyInputStreamToFile(inputStream, temp);

return temp;
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.e2ee.CsrHelper;
import com.owncloud.android.utils.EncryptionUtils;
import java.nio.file.Files;

import org.junit.Assert;
import org.junit.Rule;
Expand Down Expand Up @@ -831,7 +832,7 @@ private DecryptedFolderMetadataFileV1 generateFolderMetadataV1_1() throws Except

private boolean cryptFile(String fileName, String md5, byte[] key, byte[] iv)
throws Exception {
File file = File.createTempFile(fileName, "enc");
File file = Files.createTempFile(fileName, "enc").toFile();
String md5BeforeEncryption = getMD5Sum(file);

// Encryption
Expand All @@ -841,7 +842,7 @@ private boolean cryptFile(String fileName, String md5, byte[] key, byte[] iv)

// Decryption
Cipher decryptorCipher = EncryptionUtils.getCipher(Cipher.DECRYPT_MODE, key, iv);
File decryptedFile = File.createTempFile("file", "dec");
File decryptedFile = Files.createTempFile("file", "dec").toFile();
decryptFile(decryptorCipher, file, decryptedFile, encryptorCipherAuthTag, new ArbitraryDataProviderImpl(targetContext), user);

String md5AfterEncryption = getMD5Sum(decryptedFile);
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import com.owncloud.android.lib.resources.status.SendClientDiagnosticRemoteOperation;
import com.owncloud.android.operations.UploadException;
import com.owncloud.android.utils.theme.CapabilityUtils;
import java.nio.file.Files;

import org.apache.commons.httpclient.HttpStatus;

Expand Down Expand Up @@ -553,7 +554,7 @@ public static byte[] decodeStringToBase64Bytes(String string) {

public static EncryptedFile encryptFile(String accountName, File file, Cipher cipher) throws InvalidParameterSpecException, IOException {
File tempEncryptedFolder = FileDataStorageManager.createTempEncryptedFolder(accountName);
File tempEncryptedFile = File.createTempFile(file.getName(), null, tempEncryptedFolder);
File tempEncryptedFile = Files.createTempFile(tempEncryptedFolder.toPath(), file.getName(), null).toFile();
encryptFileWithGivenCipher(file, tempEncryptedFile, cipher);
String authenticationTagString = getAuthenticationTag(cipher);
return new EncryptedFile(tempEncryptedFile, authenticationTagString);
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /