Skip to content

Commit 06f2c03

Browse files
Add tests
1 parent 4bf6c10 commit 06f2c03

5 files changed

Lines changed: 30 additions & 2 deletions

File tree

java/ql/src/Security/CWE/CWE-532/SensitiveInfoLog.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import java
1414
import semmle.code.java.security.SensitiveLoggingQuery
1515
import PathGraph
1616

17-
from LoggerConfiguration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
17+
from SensitiveLoggerConfiguration cfg, DataFlow::PathNode source, DataFlow::PathNode sink
1818
where cfg.hasFlowPath(source, sink)
1919
select sink.getNode(), source, sink, "This $@ is written to a log file.", source.getNode(),
20-
"sensitive information"
20+
"potentially sensitive information"

java/ql/test/query-tests/security/CWE-532/SensitiveLogInfo.expected

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import java
2+
import TestUtilities.InlineFlowTest
3+
import semmle.code.java.security.SensitiveLoggingQuery
4+
5+
class HasFlowTest extends InlineFlowTest {
6+
override DataFlow::Configuration getTaintFlowConfig() {
7+
result instanceof SensitiveLoggerConfiguration
8+
}
9+
10+
override DataFlow::Configuration getValueFlowConfig() { none() }
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import org.apache.logging.log4j.Logger;
2+
3+
class Test {
4+
void test(String password) {
5+
Logger logger = null;
6+
7+
logger.info("User's password is: " + password); // $ hasTaintFlow
8+
}
9+
10+
void test2(String authToken) {
11+
Logger logger = null;
12+
13+
logger.error("Auth failed for: " + authToken); // $ hasTaintFlow
14+
}
15+
16+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../stubs/apache-log4j-1.2.17:${testdir}/../../../stubs/apache-log4j-2.14.1:${testdir}/../../../stubs/apache-commons-logging-1.2:${testdir}/../../../stubs/jboss-logging-3.4.2:${testdir}/../../../stubs/slf4j-2.0.0:${testdir}/../../../stubs/scijava-common-2.87.1:${testdir}/../../../stubs/flogger-0.7.1:${testdir}/../../../stubs/google-android-9.0.0

0 commit comments

Comments
 (0)