-
Notifications
You must be signed in to change notification settings - Fork 725
Expand file tree
/
Copy pathAndroidUnencryptedFilesCheckSample.java
More file actions
31 lines (26 loc) · 1.08 KB
/
Copy pathAndroidUnencryptedFilesCheckSample.java
File metadata and controls
31 lines (26 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package checks.security;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
public class AndroidUnencryptedFilesCheckSample {
void fileWrite(Path path) throws IOException {
Files.write(path, "content".getBytes()); // Noncompliant {{Make sure using unencrypted files is safe here.}}
// ^^^^^
}
void fileOutputStreamWrite(File file) throws IOException {
FileOutputStream out = new FileOutputStream(file); // Noncompliant {{Make sure using unencrypted files is safe here.}}
// ^^^^^^^^^^^^^^^^
out.write("content".getBytes());
}
void fileOutputStreamWrite(Writer writer) throws IOException {
FileWriter fw = new FileWriter("outfilename", true); // Noncompliant {{Make sure using unencrypted files is safe here.}}
// ^^^^^^^^^^
BufferedWriter output = new BufferedWriter(fw); // Compliant, reported on
output.write("some test content...");
}
}