@@ -33,17 +33,17 @@ predicate isInsecureMailPropertyConfig(VarAccess propertiesVarAccess) {
3333 ma .getMethod ( ) instanceof SetPropertyMethod and
3434 ma .getQualifier ( ) = propertiesVarAccess .getVariable ( ) .getAnAccess ( ) and
3535 (
36- getStringValue ( ma .getArgument ( 0 ) ) .indexOf ( " .auth" ) != - 1 and //mail.smtp.auth
36+ getStringValue ( ma .getArgument ( 0 ) ) .matches ( "% .auth%" ) and //mail.smtp.auth
3737 getStringValue ( ma .getArgument ( 1 ) ) = "true"
3838 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
4040 )
4141 ) and
4242 not exists ( MethodAccess ma |
4343 ma .getMethod ( ) instanceof SetPropertyMethod and
4444 ma .getQualifier ( ) = propertiesVarAccess .getVariable ( ) .getAnAccess ( ) and
4545 (
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
4747 getStringValue ( ma .getArgument ( 1 ) ) = "true"
4848 )
4949 )
@@ -53,11 +53,7 @@ predicate isInsecureMailPropertyConfig(VarAccess propertiesVarAccess) {
5353 * Helper method to get string value of an argument
5454 */
5555string 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 ( )
6157 or
6258 result = getStringValue ( expr .( AddExpr ) .getLeftOperand ( ) )
6359 or
@@ -68,14 +64,14 @@ string getStringValue(Expr expr) {
6864 * The JavaMail session class `javax.mail.Session`
6965 */
7066class MailSession extends RefType {
71- MailSession ( ) { this .getQualifiedName ( ) = "javax.mail. Session" }
67+ MailSession ( ) { this .hasQualifiedName ( "javax.mail" , " Session") }
7268}
7369
7470/**
7571 * The class of Apache SimpleMail
7672 */
7773class SimpleMail extends RefType {
78- SimpleMail ( ) { this .getQualifiedName ( ) = "org.apache.commons.mail. SimpleEmail" }
74+ SimpleMail ( ) { this .hasQualifiedName ( "org.apache.commons.mail" , " SimpleEmail") }
7975}
8076
8177/**
@@ -101,7 +97,7 @@ from MethodAccess ma
10197where
10298 ma .getMethod ( ) .getDeclaringType ( ) instanceof MailSession and
10399 ma .getMethod ( ) .getName ( ) = "getInstance" and
104- isInsecureMailPropertyConfig ( ma .getArgument ( 0 ) . ( VarAccess ) )
100+ isInsecureMailPropertyConfig ( ma .getArgument ( 0 ) )
105101 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