File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed
test/library-tests/sensitivedata Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,10 @@ private class SensitiveDataFunction extends Function {
3737/**
3838 * A function call data flow node that might produce sensitive data.
3939 */
40- private class SensitiveDataCall extends SensitiveData {
40+ private class SensitiveDataFunctionCall extends SensitiveData {
4141 SensitiveDataClassification classification ;
4242
43- SensitiveDataCall ( ) {
43+ SensitiveDataFunctionCall ( ) {
4444 classification =
4545 this .asExpr ( )
4646 .getAstNode ( )
@@ -53,6 +53,33 @@ private class SensitiveDataCall extends SensitiveData {
5353 override SensitiveDataClassification getClassification ( ) { result = classification }
5454}
5555
56+ /**
57+ * An enum variant that might produce sensitive data.
58+ */
59+ private class SensitiveDataVariant extends Variant {
60+ SensitiveDataClassification classification ;
61+
62+ SensitiveDataVariant ( ) {
63+ HeuristicNames:: nameIndicatesSensitiveData ( this .getName ( ) .getText ( ) , classification )
64+ }
65+
66+ SensitiveDataClassification getClassification ( ) { result = classification }
67+ }
68+
69+ /**
70+ * An enum variant call data flow node that might produce sensitive data.
71+ */
72+ private class SensitiveDataVariantCall extends SensitiveData {
73+ SensitiveDataClassification classification ;
74+
75+ SensitiveDataVariantCall ( ) {
76+ classification =
77+ this .asExpr ( ) .getAstNode ( ) .( CallExpr ) .getVariant ( ) .( SensitiveDataVariant ) .getClassification ( )
78+ }
79+
80+ override SensitiveDataClassification getClassification ( ) { result = classification }
81+ }
82+
5683/**
5784 * A variable that might contain sensitive data.
5885 */
Original file line number Diff line number Diff line change @@ -293,8 +293,8 @@ fn test_private_info(
293293 sink ( info. financials . iban . as_str ( ) ) ; // $ MISSING: sensitive=private
294294 sink ( info. financials . iBAN . as_str ( ) ) ; // $ MISSING: sensitive=private
295295
296- sink ( ContactDetails :: HomePhoneNumber ( "123" . to_string ( ) ) ) ; // $ MISSING: sensitive=private
297- sink ( ContactDetails :: MobileNumber ( "123" . to_string ( ) ) ) ; // $ MISSING: sensitive=private
296+ sink ( ContactDetails :: HomePhoneNumber ( "123" . to_string ( ) ) ) ; // $ sensitive=private
297+ sink ( ContactDetails :: MobileNumber ( "123" . to_string ( ) ) ) ; // $ sensitive=private
298298 sink ( ContactDetails :: Email ( "a@b" . to_string ( ) ) ) ; // $ MISSING: sensitive=private
299299 if let ContactDetails :: MobileNumber ( num) = details {
300300 sink ( num. as_str ( ) ) ; // $ MISSING: sensitive=private
You can’t perform that action at this time.
0 commit comments