Refactor CleartextStorage libraries

This commit is contained in:
Ed Minnix
2023-03-19 23:24:35 -04:00
parent b4130e650d
commit aa7934161a
7 changed files with 71 additions and 77 deletions

View File

@@ -24,16 +24,16 @@ class LocalFileOpenCall extends Storable {
}
override Expr getAnInput() {
exists(FilesystemFlowConfig conf, DataFlow::Node n |
exists(DataFlow::Node n |
filesystemInput(n, result) and
conf.hasFlow(DataFlow::exprNode(this), n)
FilesystemFlow::flow(DataFlow::exprNode(this), n)
)
}
override Expr getAStore() {
exists(FilesystemFlowConfig conf, DataFlow::Node n |
exists(DataFlow::Node n |
closesFile(n, result) and
conf.hasFlow(DataFlow::exprNode(this), n)
FilesystemFlow::flow(DataFlow::exprNode(this), n)
)
}
}
@@ -79,17 +79,15 @@ private class CloseFileMethod extends Method {
}
}
private class FilesystemFlowConfig extends DataFlow::Configuration {
FilesystemFlowConfig() { this = "FilesystemFlowConfig" }
private module FilesystemFlowConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node src) { src.asExpr() instanceof LocalFileOpenCall }
override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof LocalFileOpenCall }
override predicate isSink(DataFlow::Node sink) {
predicate isSink(DataFlow::Node sink) {
filesystemInput(sink, _) or
closesFile(sink, _)
}
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
// Add nested Writer constructors as extra data flow steps
exists(ClassInstanceExpr cie |
cie.getConstructedType().getAnAncestor().hasQualifiedName("java.io", "Writer") and
@@ -98,3 +96,5 @@ private class FilesystemFlowConfig extends DataFlow::Configuration {
)
}
}
private module FilesystemFlow = DataFlow::Global<FilesystemFlowConfig>;