mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
Merge pull request #12731 from michaelnebel/csharp/refactorcleatextstorage
C#: Re-factor CleartextStorage to use the new API.
This commit is contained in:
@@ -24,9 +24,11 @@ abstract class Sink extends DataFlow::ExprNode { }
|
||||
abstract class Sanitizer extends DataFlow::ExprNode { }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `ClearTextStorage` instead.
|
||||
*
|
||||
* A taint-tracking configuration for cleartext storage of sensitive information.
|
||||
*/
|
||||
class TaintTrackingConfiguration extends TaintTracking::Configuration {
|
||||
deprecated class TaintTrackingConfiguration extends TaintTracking::Configuration {
|
||||
TaintTrackingConfiguration() { this = "ClearTextStorage" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) { source instanceof Source }
|
||||
@@ -36,6 +38,22 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
|
||||
override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer }
|
||||
}
|
||||
|
||||
/**
|
||||
* A taint-tracking configuration for cleartext storage of sensitive information.
|
||||
*/
|
||||
private module ClearTextStorageConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) { source instanceof Source }
|
||||
|
||||
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
|
||||
|
||||
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
|
||||
}
|
||||
|
||||
/**
|
||||
* A taint-tracking module for cleartext storage of sensitive information.
|
||||
*/
|
||||
module ClearTextStorage = TaintTracking::Global<ClearTextStorageConfig>;
|
||||
|
||||
/** A source of sensitive data. */
|
||||
class SensitiveExprSource extends Source {
|
||||
SensitiveExprSource() { this.getExpr() instanceof SensitiveExpr }
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
|
||||
import csharp
|
||||
import semmle.code.csharp.security.dataflow.CleartextStorageQuery
|
||||
import semmle.code.csharp.dataflow.DataFlow::DataFlow::PathGraph
|
||||
import ClearTextStorage::PathGraph
|
||||
|
||||
from TaintTrackingConfiguration c, DataFlow::PathNode source, DataFlow::PathNode sink
|
||||
where c.hasFlowPath(source, sink)
|
||||
from ClearTextStorage::PathNode source, ClearTextStorage::PathNode sink
|
||||
where ClearTextStorage::flowPath(source, sink)
|
||||
select sink.getNode(), source, sink, "This stores sensitive data returned by $@ as clear text.",
|
||||
source.getNode(), source.toString()
|
||||
|
||||
Reference in New Issue
Block a user