Skip to content

Commit b5b0d60

Browse files
authored
Merge pull request #12731 from michaelnebel/csharp/refactorcleatextstorage
C#: Re-factor CleartextStorage to use the new API.
2 parents cc6a923 + fc43a4e commit b5b0d60

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

csharp/ql/lib/semmle/code/csharp/security/dataflow/CleartextStorageQuery.qll

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ abstract class Sink extends DataFlow::ExprNode { }
2424
abstract class Sanitizer extends DataFlow::ExprNode { }
2525

2626
/**
27+
* DEPRECATED: Use `ClearTextStorage` instead.
28+
*
2729
* A taint-tracking configuration for cleartext storage of sensitive information.
2830
*/
29-
class TaintTrackingConfiguration extends TaintTracking::Configuration {
31+
deprecated class TaintTrackingConfiguration extends TaintTracking::Configuration {
3032
TaintTrackingConfiguration() { this = "ClearTextStorage" }
3133

3234
override predicate isSource(DataFlow::Node source) { source instanceof Source }
@@ -36,6 +38,22 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
3638
override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer }
3739
}
3840

41+
/**
42+
* A taint-tracking configuration for cleartext storage of sensitive information.
43+
*/
44+
private module ClearTextStorageConfig implements DataFlow::ConfigSig {
45+
predicate isSource(DataFlow::Node source) { source instanceof Source }
46+
47+
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
48+
49+
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
50+
}
51+
52+
/**
53+
* A taint-tracking module for cleartext storage of sensitive information.
54+
*/
55+
module ClearTextStorage = TaintTracking::Global<ClearTextStorageConfig>;
56+
3957
/** A source of sensitive data. */
4058
class SensitiveExprSource extends Source {
4159
SensitiveExprSource() { this.getExpr() instanceof SensitiveExpr }

csharp/ql/src/Security Features/CWE-312/CleartextStorage.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
import csharp
1717
import semmle.code.csharp.security.dataflow.CleartextStorageQuery
18-
import semmle.code.csharp.dataflow.DataFlow::DataFlow::PathGraph
18+
import ClearTextStorage::PathGraph
1919

20-
from TaintTrackingConfiguration c, DataFlow::PathNode source, DataFlow::PathNode sink
21-
where c.hasFlowPath(source, sink)
20+
from ClearTextStorage::PathNode source, ClearTextStorage::PathNode sink
21+
where ClearTextStorage::flowPath(source, sink)
2222
select sink.getNode(), source, sink, "This stores sensitive data returned by $@ as clear text.",
2323
source.getNode(), source.toString()

0 commit comments

Comments
 (0)