@@ -33,17 +33,17 @@ predicate isInsecureMailPropertyConfig(VarAccess propertiesVarAccess) {
33
33
ma .getMethod ( ) instanceof SetPropertyMethod and
34
34
ma .getQualifier ( ) = propertiesVarAccess .getVariable ( ) .getAnAccess ( ) and
35
35
(
36
- getStringValue ( ma .getArgument ( 0 ) ) .indexOf ( " .auth" ) != - 1 and //mail.smtp.auth
36
+ getStringValue ( ma .getArgument ( 0 ) ) .matches ( "% .auth%" ) and //mail.smtp.auth
37
37
getStringValue ( ma .getArgument ( 1 ) ) = "true"
38
38
or
39
- getStringValue ( ma .getArgument ( 0 ) ) .indexOf ( " .socketFactory" ) != - 1 //mail.smtp.socketFactory or mail.smtp.socketFactory.class
39
+ getStringValue ( ma .getArgument ( 0 ) ) .matches ( "% .socketFactory%" ) //mail.smtp.socketFactory or mail.smtp.socketFactory.class
40
40
)
41
41
) and
42
42
not exists ( MethodAccess ma |
43
43
ma .getMethod ( ) instanceof SetPropertyMethod and
44
44
ma .getQualifier ( ) = propertiesVarAccess .getVariable ( ) .getAnAccess ( ) and
45
45
(
46
- getStringValue ( ma .getArgument ( 0 ) ) .indexOf ( " .ssl.checkserveridentity" ) != - 1 and //mail.smtp.ssl.checkserveridentity
46
+ getStringValue ( ma .getArgument ( 0 ) ) .matches ( "% .ssl.checkserveridentity%" ) and //mail.smtp.ssl.checkserveridentity
47
47
getStringValue ( ma .getArgument ( 1 ) ) = "true"
48
48
)
49
49
)
@@ -53,11 +53,7 @@ predicate isInsecureMailPropertyConfig(VarAccess propertiesVarAccess) {
53
53
* Helper method to get string value of an argument
54
54
*/
55
55
string getStringValue ( Expr expr ) {
56
- result = expr .( StringLiteral ) .getRepresentedString ( )
57
- or
58
- exists ( Variable v | expr = v .getAnAccess ( ) |
59
- result = getStringValue ( v .getInitializer ( ) .( CompileTimeConstantExpr ) )
60
- )
56
+ result = expr .( CompileTimeConstantExpr ) .getStringValue ( )
61
57
or
62
58
result = getStringValue ( expr .( AddExpr ) .getLeftOperand ( ) )
63
59
or
@@ -68,14 +64,14 @@ string getStringValue(Expr expr) {
68
64
* The JavaMail session class `javax.mail.Session`
69
65
*/
70
66
class MailSession extends RefType {
71
- MailSession ( ) { this .getQualifiedName ( ) = "javax.mail. Session" }
67
+ MailSession ( ) { this .hasQualifiedName ( "javax.mail" , " Session") }
72
68
}
73
69
74
70
/**
75
71
* The class of Apache SimpleMail
76
72
*/
77
73
class SimpleMail extends RefType {
78
- SimpleMail ( ) { this .getQualifiedName ( ) = "org.apache.commons.mail. SimpleEmail" }
74
+ SimpleMail ( ) { this .hasQualifiedName ( "org.apache.commons.mail" , " SimpleEmail") }
79
75
}
80
76
81
77
/**
@@ -101,7 +97,7 @@ from MethodAccess ma
101
97
where
102
98
ma .getMethod ( ) .getDeclaringType ( ) instanceof MailSession and
103
99
ma .getMethod ( ) .getName ( ) = "getInstance" and
104
- isInsecureMailPropertyConfig ( ma .getArgument ( 0 ) . ( VarAccess ) )
100
+ isInsecureMailPropertyConfig ( ma .getArgument ( 0 ) )
105
101
or
106
- enableTLSWithSimpleMail ( ma ) and hasNoCertCheckWithSimpleMail ( ma .getQualifier ( ) . ( VarAccess ) )
107
- select ma , "Java mailing has insecure SSL configuration"
102
+ enableTLSWithSimpleMail ( ma ) and hasNoCertCheckWithSimpleMail ( ma .getQualifier ( ) )
103
+ select ma , "Java mailing has insecure SSL configuration"
0 commit comments