Skip to content

Commit 6878d37

Browse files
committed
fixed category copying, fixed description being overwritten and added immutable access path tuple
1 parent ca8c2ca commit 6878d37

File tree

7 files changed

+44
-9
lines changed

7 files changed

+44
-9
lines changed

soot-infoflow-android/src/soot/jimple/infoflow/android/source/parsers/xml/XMLSourceSinkParser.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,15 @@ public void endElement(String uri, String localName, String qName) throws SAXExc
337337

338338
if (sstype != SourceSinkType.Neither) {
339339
AccessPathTuple apt = AccessPathTuple.fromPathElements(pathElements, pathElementTypes, sstype);
340-
apt = apt.simplify();
341340

342341
// Optional description
343342
if (description != null && !description.isEmpty())
344343
apt.setDescription(description);
345344

345+
// Simplify the AP after setting the description for not breaking the generic
346+
// source definition
347+
apt = apt.simplify();
348+
346349
switch (accessPathParentElement) {
347350
case XMLConstants.BASE_TAG:
348351
baseAPs.add(apt);

soot-infoflow/src/soot/jimple/infoflow/sourcesSinks/definitions/AccessPathTuple.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public class AccessPathTuple {
4646
this.sinkSource = sinkSource;
4747
}
4848

49+
AccessPathTuple(AccessPathTuple original) {
50+
this.baseType = original.baseType;
51+
this.fields = original.fields;
52+
this.fieldTypes = original.fields;
53+
this.sinkSource = original.sinkSource;
54+
this.description = original.description;
55+
}
56+
4957
/**
5058
* Simplified factory method for creating an access path that just denotes the
5159
* base object
@@ -124,7 +132,7 @@ public SourceSinkType getSourceSinkType() {
124132
*/
125133
public static AccessPathTuple getBlankSourceTuple() {
126134
if (SOURCE_TUPLE == null)
127-
SOURCE_TUPLE = create(true, false);
135+
SOURCE_TUPLE = new ImmutableAccessPathTuple(create(true, false));
128136
return SOURCE_TUPLE;
129137
}
130138

@@ -135,7 +143,7 @@ public static AccessPathTuple getBlankSourceTuple() {
135143
*/
136144
public static AccessPathTuple getBlankSinkTuple() {
137145
if (SINK_TUPLE == null)
138-
SINK_TUPLE = create(false, true);
146+
SINK_TUPLE = new ImmutableAccessPathTuple(create(false, true));
139147
return SINK_TUPLE;
140148
}
141149

soot-infoflow/src/soot/jimple/infoflow/sourcesSinks/definitions/FieldSourceSinkDefinition.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ protected FieldSourceSinkDefinition buildNewDefinition(Set<AccessPathTuple> acce
104104
* @return The new source/sink definition
105105
*/
106106
protected FieldSourceSinkDefinition buildNewDefinition(String fieldSignature, Set<AccessPathTuple> accessPaths) {
107-
return new FieldSourceSinkDefinition(fieldSignature, accessPaths);
107+
FieldSourceSinkDefinition fssd = new FieldSourceSinkDefinition(fieldSignature, accessPaths);
108+
fssd.setCategory(category);
109+
return fssd;
108110
}
109111

110112
@Override
@@ -143,7 +145,7 @@ public IAccessPathBasedSourceSinkDefinition filter(Collection<AccessPathTuple> t
143145
filteredAPs.add(ap);
144146
}
145147
FieldSourceSinkDefinition def = buildNewDefinition(fieldSignature, filteredAPs);
146-
def.setCategory(category);
148+
def.category = category;
147149
return def;
148150
}
149151

soot-infoflow/src/soot/jimple/infoflow/sourcesSinks/definitions/ISourceSinkDefinition.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
public interface ISourceSinkDefinition {
1010

1111
/**
12-
* Sets the category to which this source or sink belonga
12+
* Sets the category to which this source or sink belongs
1313
*
14-
* @param category The category to which this source or sink belonga
14+
* @param category The category to which this source or sink belongs
1515
*/
1616
public void setCategory(ISourceSinkCategory category);
1717

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package soot.jimple.infoflow.sourcesSinks.definitions;
2+
3+
/**
4+
* Immutable version of the {@link AccessPathTuple}
5+
*
6+
* @author Steven Arzt
7+
*
8+
*/
9+
public class ImmutableAccessPathTuple extends AccessPathTuple {
10+
11+
public ImmutableAccessPathTuple(AccessPathTuple parent) {
12+
super(parent);
13+
}
14+
15+
@Override
16+
public void setDescription(String description) {
17+
throw new RuntimeException("Immutable object cannot be modified");
18+
}
19+
20+
}

soot-infoflow/src/soot/jimple/infoflow/sourcesSinks/definitions/MethodSourceSinkDefinition.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public MethodSourceSinkDefinition getSinkOnlyDefinition() {
322322
protected MethodSourceSinkDefinition buildNewDefinition(Set<AccessPathTuple> baseAPTs,
323323
Set<AccessPathTuple>[] paramAPTs, Set<AccessPathTuple> returnAPTs) {
324324
MethodSourceSinkDefinition def = buildNewDefinition(method, baseAPTs, paramAPTs, returnAPTs, callType);
325-
def.setCategory(category);
325+
def.category = category;
326326
return def;
327327
}
328328

soot-infoflow/src/soot/jimple/infoflow/sourcesSinks/definitions/StatementSourceSinkDefinition.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ public IAccessPathBasedSourceSinkDefinition filter(Collection<AccessPathTuple> t
122122

123123
protected StatementSourceSinkDefinition buildNewDefinition(Stmt stmt, Local local,
124124
Set<AccessPathTuple> accessPaths) {
125-
return new StatementSourceSinkDefinition(stmt, local, accessPaths);
125+
StatementSourceSinkDefinition sssd = new StatementSourceSinkDefinition(stmt, local, accessPaths);
126+
sssd.category = category;
127+
return sssd;
126128
}
127129

128130
@Override

0 commit comments

Comments
 (0)