@@ -10,10 +10,10 @@ private import semmle.code.java.frameworks.Properties
10
10
* set the `mail.smtp.ssl.socketFactory`/`mail.smtp.ssl.socketFactory.class` property to create an SMTP SSL socket.
11
11
* 2. No `mail.smtp.ssl.checkserveridentity` property is enabled.
12
12
*/
13
- predicate isInsecureMailPropertyConfig ( VarAccess propertiesVarAccess ) {
13
+ predicate isInsecureMailPropertyConfig ( Variable properties ) {
14
14
exists ( MethodAccess ma |
15
15
ma .getMethod ( ) instanceof SetPropertyMethod and
16
- ma .getQualifier ( ) = propertiesVarAccess . getVariable ( ) .getAnAccess ( )
16
+ ma .getQualifier ( ) = properties .getAnAccess ( )
17
17
|
18
18
getStringValue ( ma .getArgument ( 0 ) ) .matches ( "%.auth%" ) and //mail.smtp.auth
19
19
getStringValue ( ma .getArgument ( 1 ) ) = "true"
@@ -22,7 +22,7 @@ predicate isInsecureMailPropertyConfig(VarAccess propertiesVarAccess) {
22
22
) and
23
23
not exists ( MethodAccess ma |
24
24
ma .getMethod ( ) instanceof SetPropertyMethod and
25
- ma .getQualifier ( ) = propertiesVarAccess . getVariable ( ) .getAnAccess ( )
25
+ ma .getQualifier ( ) = properties .getAnAccess ( )
26
26
|
27
27
getStringValue ( ma .getArgument ( 0 ) ) .matches ( "%.ssl.checkserveridentity%" ) and //mail.smtp.ssl.checkserveridentity
28
28
getStringValue ( ma .getArgument ( 1 ) ) = "true"
@@ -39,19 +39,20 @@ predicate enablesEmailSsl(MethodAccess ma) {
39
39
}
40
40
41
41
/**
42
- * Holds if a SSL certificate check is enabled on `va ` with Apache Email
42
+ * Holds if a SSL certificate check is enabled on an access of `apacheEmail ` with Apache Email.
43
43
*/
44
- predicate hasSslCertificateCheck ( VarAccess va ) {
44
+ predicate hasSslCertificateCheck ( Variable apacheEmail ) {
45
45
exists ( MethodAccess ma |
46
- ma .getQualifier ( ) = va . getVariable ( ) .getAnAccess ( ) and
46
+ ma .getQualifier ( ) = apacheEmail .getAnAccess ( ) and
47
47
ma .getMethod ( ) .hasName ( "setSSLCheckServerIdentity" ) and
48
48
ma .getMethod ( ) .getDeclaringType ( ) instanceof ApacheEmail and
49
49
ma .getArgument ( 0 ) .( BooleanLiteral ) .getBooleanValue ( ) = true
50
50
)
51
51
}
52
52
53
53
/**
54
- * Helper method to get string value of an argument
54
+ * Returns the string value of `expr` if it is a `CompileTimeConstantExpr`,
55
+ * or the string value of its operands if it is an `AddExpr`.
55
56
*/
56
57
private string getStringValue ( Expr expr ) {
57
58
result = expr .( CompileTimeConstantExpr ) .getStringValue ( )
@@ -60,7 +61,8 @@ private string getStringValue(Expr expr) {
60
61
}
61
62
62
63
/**
63
- * A method to set Java properties
64
+ * A method to set Java properties, either using the `Properties` class
65
+ * or the `Dictionary` class.
64
66
*/
65
67
private class SetPropertyMethod extends Method {
66
68
SetPropertyMethod ( ) {
0 commit comments