Repository navigation
Expand file tree
/
Copy pathProperties.qll
More file actions
68 lines (59 loc) · 2.03 KB
/
Copy pathProperties.qll
File metadata and controls
68 lines (59 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/** Definitions related to `java.util.Properties`. */
overlay[local?]
module;
import semmle.code.java.Type
private import semmle.code.java.dataflow.FlowSteps
private import semmle.code.configfiles.ConfigFiles
private import semmle.code.java.dataflow.RangeUtils
/**
* The `java.util.Properties` class.
*/
class TypeProperty extends Class {
TypeProperty() { this.hasQualifiedName("java.util", "Properties") }
}
/** The `getProperty` method of the class `java.util.Properties`. */
class PropertiesGetPropertyMethod extends Method {
PropertiesGetPropertyMethod() {
this.getDeclaringType() instanceof TypeProperty and
this.hasName("getProperty")
}
}
/** The `get` method of the class `java.util.Properties`. */
class PropertiesGetMethod extends Method {
PropertiesGetMethod() {
this.getDeclaringType() instanceof TypeProperty and
this.hasName("get")
}
}
/** The `setProperty` method of the class `java.util.Properties`. */
class PropertiesSetPropertyMethod extends Method {
PropertiesSetPropertyMethod() {
this.getDeclaringType() instanceof TypeProperty and
this.hasName("setProperty")
}
}
/**
* The methods of the class `java.util.Properties` that write the contents to an output.
*/
class PropertiesStoreMethod extends Method {
PropertiesStoreMethod() {
this.getDeclaringType() instanceof TypeProperty and
(this.getName().matches("store%") or this.getName() = "save")
}
}
/**
* A call to the `getProperty` method of the class `java.util.Properties`.
*/
class PropertiesGetPropertyMethodCall extends MethodCall {
PropertiesGetPropertyMethodCall() { this.getMethod() instanceof PropertiesGetPropertyMethod }
private ConfigPair getPair() {
this.getArgument(0).(ConstantStringExpr).getStringValue() = result.getNameElement().getName()
}
/**
* Get the potential string values that can be associated with the given property name.
*/
string getPropertyValue() {
result = this.getPair().getValueElement().getValue() or
result = this.getArgument(1).(ConstantStringExpr).getStringValue()
}
}