-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Recognize more sensitive data sources #19470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
87218cb
8825eef
a537197
0f36e1d
5f5d6f6
d02d5c5
0a3275e
b907cfe
ac5ec06
682f59f
f04d6fd
65456b5
4bbdc9a
b503b1e
9ac24c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,10 +37,10 @@ private class SensitiveDataFunction extends Function { | |
/** | ||
* A function call data flow node that might produce sensitive data. | ||
*/ | ||
private class SensitiveDataCall extends SensitiveData { | ||
private class SensitiveDataFunctionCall extends SensitiveData { | ||
SensitiveDataClassification classification; | ||
|
||
SensitiveDataCall() { | ||
SensitiveDataFunctionCall() { | ||
classification = | ||
this.asExpr() | ||
.getAstNode() | ||
|
@@ -53,6 +53,33 @@ private class SensitiveDataCall extends SensitiveData { | |
override SensitiveDataClassification getClassification() { result = classification } | ||
} | ||
|
||
/** | ||
* An enum variant that might produce sensitive data. | ||
*/ | ||
private class SensitiveDataVariant extends Variant { | ||
SensitiveDataClassification classification; | ||
|
||
SensitiveDataVariant() { | ||
HeuristicNames::nameIndicatesSensitiveData(this.getName().getText(), classification) | ||
} | ||
|
||
SensitiveDataClassification getClassification() { result = classification } | ||
} | ||
|
||
/** | ||
* An enum variant call data flow node that might produce sensitive data. | ||
*/ | ||
private class SensitiveDataVariantCall extends SensitiveData { | ||
SensitiveDataClassification classification; | ||
|
||
SensitiveDataVariantCall() { | ||
classification = | ||
this.asExpr().getAstNode().(CallExpr).getVariant().(SensitiveDataVariant).getClassification() | ||
} | ||
|
||
override SensitiveDataClassification getClassification() { result = classification } | ||
} | ||
|
||
/** | ||
* A variable that might contain sensitive data. | ||
*/ | ||
|
@@ -67,7 +94,7 @@ private class SensitiveDataVariable extends Variable { | |
} | ||
|
||
/** | ||
* A variable access data flow node that might produce sensitive data. | ||
* A variable access data flow node that might be sensitive data. | ||
*/ | ||
private class SensitiveVariableAccess extends SensitiveData { | ||
SensitiveDataClassification classification; | ||
|
@@ -84,3 +111,20 @@ private class SensitiveVariableAccess extends SensitiveData { | |
|
||
override SensitiveDataClassification getClassification() { result = classification } | ||
} | ||
|
||
private Expr fieldExprParentField(FieldExpr fe) { result = fe.getParentNode() } | ||
|
||
/** | ||
* A field access data flow node that might be sensitive data. | ||
*/ | ||
private class SensitiveFieldAccess extends SensitiveData { | ||
geoffw0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SensitiveDataClassification classification; | ||
|
||
SensitiveFieldAccess() { | ||
exists(FieldExpr fe | fieldExprParentField*(fe) = this.asExpr().getAstNode() | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This walks all the way up the expression tree right? How will that work with things like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It did exactly this in the original PR, which used In the current code There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I see it now :) |
||
HeuristicNames::nameIndicatesSensitiveData(fe.getIdentifier().getText(), classification) | ||
) | ||
} | ||
|
||
override SensitiveDataClassification getClassification() { result = classification } | ||
} |
Uh oh!
There was an error while loading. Please reload this page.