Skip to content

Commit d544b64

Browse files
committed
removed an unnecessary exception declaration
1 parent 2593eaa commit d544b64

File tree

7 files changed

+92
-103
lines changed

7 files changed

+92
-103
lines changed

soot-infoflow-android/src/soot/jimple/infoflow/android/SetupApplication.java

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.slf4j.Logger;
2929
import org.slf4j.LoggerFactory;
3030
import org.xml.sax.SAXException;
31-
import org.xmlpull.v1.XmlPullParserException;
3231

3332
import heros.solver.Pair;
3433
import soot.G;
@@ -466,12 +465,9 @@ public ITaintPropagationWrapper getTaintWrapper() {
466465
/**
467466
* Parses common app resources such as the manifest file
468467
*
469-
* @throws IOException Thrown if the given source/sink file could not
470-
* be read.
471-
* @throws XmlPullParserException Thrown if the Android manifest file could not
472-
* be read.
468+
* @throws IOException Thrown if the given source/sink file could not be read.
473469
*/
474-
protected void parseAppResources() throws IOException, XmlPullParserException {
470+
protected void parseAppResources() throws IOException {
475471
final File targetAPK = config.getAnalysisFileConfig().getTargetAPKFile();
476472
if (!targetAPK.exists())
477473
throw new RuntimeException(
@@ -511,9 +507,8 @@ public ARSCFileParser getResources() {
511507
* @param targetAPK The target APK file
512508
* @return The manifest handler for reading the given app's manifest file
513509
* @throws IOException
514-
* @throws XmlPullParserException
515510
*/
516-
protected IManifestHandler createManifestParser(final File targetAPK) throws IOException, XmlPullParserException {
511+
protected IManifestHandler createManifestParser(final File targetAPK) throws IOException {
517512
return new ProcessManifest(targetAPK, resources);
518513
}
519514

@@ -523,13 +518,9 @@ protected IManifestHandler createManifestParser(final File targetAPK) throws IOE
523518
*
524519
* @param sourcesAndSinks A provider from which the analysis can obtain the list
525520
* of sources and sinks
526-
* @throws IOException Thrown if the given source/sink file could not
527-
* be read.
528-
* @throws XmlPullParserException Thrown if the Android manifest file could not
529-
* be read.
521+
* @throws IOException Thrown if the given source/sink file could not be read.
530522
*/
531-
private void calculateCallbacks(ISourceSinkDefinitionProvider sourcesAndSinks)
532-
throws IOException, XmlPullParserException {
523+
private void calculateCallbacks(ISourceSinkDefinitionProvider sourcesAndSinks) throws IOException {
533524
calculateCallbacks(sourcesAndSinks, null);
534525
}
535526

@@ -541,13 +532,10 @@ private void calculateCallbacks(ISourceSinkDefinitionProvider sourcesAndSinks)
541532
* of sources and sinks
542533
* @param entryPoint The entry point for which to calculate the callbacks.
543534
* Pass null to calculate callbacks for all entry points.
544-
* @throws IOException Thrown if the given source/sink file could not
545-
* be read.
546-
* @throws XmlPullParserException Thrown if the Android manifest file could not
547-
* be read.
535+
* @throws IOException Thrown if the given source/sink file could not be read.
548536
*/
549537
private void calculateCallbacks(ISourceSinkDefinitionProvider sourcesAndSinks, SootClass entryPoint)
550-
throws IOException, XmlPullParserException {
538+
throws IOException {
551539
// Add the callback methods
552540
LayoutFileParser lfp = null;
553541
final CallbackConfiguration callbackConfig = config.getCallbackConfig();
@@ -1462,13 +1450,9 @@ public void constructCallgraph() {
14621450
*
14631451
* @param sources The methods that shall be considered as sources
14641452
* @param sinks The methods that shall be considered as sinks
1465-
* @throws IOException Thrown if the given source/sink file could not
1466-
* be read.
1467-
* @throws XmlPullParserException Thrown if the Android manifest file could not
1468-
* be read.
1453+
* @throws IOException Thrown if the given source/sink file could not be read.
14691454
*/
1470-
public InfoflowResults runInfoflow(Set<AndroidMethod> sources, Set<AndroidMethod> sinks)
1471-
throws IOException, XmlPullParserException {
1455+
public InfoflowResults runInfoflow(Set<AndroidMethod> sources, Set<AndroidMethod> sinks) throws IOException {
14721456
final Set<ISourceSinkDefinition> sourceDefs = new HashSet<>(sources.size());
14731457
final Set<ISourceSinkDefinition> sinkDefs = new HashSet<>(sinks.size());
14741458

@@ -1507,12 +1491,9 @@ public Set<ISourceSinkDefinition> getAllMethods() {
15071491
*
15081492
* @param sourceSinkFile The full path and file name of the file containing the
15091493
* sources and sinks
1510-
* @throws IOException Thrown if the given source/sink file could not
1511-
* be read.
1512-
* @throws XmlPullParserException Thrown if the Android manifest file could not
1513-
* be read.
1494+
* @throws IOException Thrown if the given source/sink file could not be read.
15141495
*/
1515-
public InfoflowResults runInfoflow(File sourceSinkFile) throws IOException, XmlPullParserException {
1496+
public InfoflowResults runInfoflow(File sourceSinkFile) throws IOException {
15161497
if (sourceSinkFile != null && sourceSinkFile.exists())
15171498
config.getAnalysisFileConfig().setSourceSinkFile(sourceSinkFile);
15181499

@@ -1522,12 +1503,9 @@ public InfoflowResults runInfoflow(File sourceSinkFile) throws IOException, XmlP
15221503
/**
15231504
* Runs the data flow analysis.
15241505
*
1525-
* @throws IOException Thrown if the given source/sink file could not
1526-
* be read.
1527-
* @throws XmlPullParserException Thrown if the Android manifest file could not
1528-
* be read.
1506+
* @throws IOException Thrown if the given source/sink file could not be read.
15291507
*/
1530-
public InfoflowResults runInfoflow() throws IOException, XmlPullParserException {
1508+
public InfoflowResults runInfoflow() throws IOException {
15311509
// If we don't have a source/sink file by now, we cannot run the data
15321510
// flow analysis
15331511
File sourceSinkFile = config.getAnalysisFileConfig().getSourceSinkFile();
@@ -1582,7 +1560,7 @@ public InfoflowResults runInfoflow(ISourceSinkDefinitionProvider sourcesAndSinks
15821560
// Perform basic app parsing
15831561
try {
15841562
parseAppResources();
1585-
} catch (IOException | XmlPullParserException e) {
1563+
} catch (IOException e) {
15861564
logger.error("Parse app resource failed", e);
15871565
throw new RuntimeException("Parse app resource failed", e);
15881566
}
@@ -1645,7 +1623,7 @@ protected void processEntryPoint(ISourceSinkDefinitionProvider sourcesAndSinks,
16451623
calculateCallbacks(sourcesAndSinks, entrypoint);
16461624
else
16471625
calculateCallbacks(sourcesAndSinks);
1648-
} catch (IOException | XmlPullParserException e) {
1626+
} catch (IOException e) {
16491627
logger.error("Callgraph construction failed: " + e.getMessage(), e);
16501628
throw new RuntimeException("Callgraph construction failed", e);
16511629
}

soot-infoflow-android/src/soot/jimple/infoflow/android/manifest/BaseProcessManifest.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import java.util.Set;
1212
import java.util.stream.Collectors;
1313

14-
import org.xmlpull.v1.XmlPullParserException;
15-
1614
import pxb.android.axml.AxmlVisitor;
1715
import soot.jimple.infoflow.android.axml.AXmlAttribute;
1816
import soot.jimple.infoflow.android.axml.AXmlDocument;
@@ -105,23 +103,21 @@ protected interface IComponentFactory<A extends IActivity, S extends IService, C
105103
* path.
106104
*
107105
* @param apkPath file path to an APK.
108-
* @throws IOException if an I/O error occurs.
109-
* @throws XmlPullParserException can occur due to a malformed manifest.
106+
* @throws IOException if an I/O error occurs.
110107
*/
111-
public BaseProcessManifest(String apkPath) throws IOException, XmlPullParserException {
108+
public BaseProcessManifest(String apkPath) throws IOException {
112109
this(new File(apkPath));
113110
}
114111

115112
/**
116113
* Processes an AppManifest which is within the given {@link File}.
117114
*
118115
* @param apkFile the AppManifest within the given APK will be parsed.
119-
* @throws IOException if an I/O error occurs.
120-
* @throws XmlPullParserException can occur due to a malformed manifest.
116+
* @throws IOException if an I/O error occurs.
121117
* @see BaseProcessManifest
122118
* {@link BaseProcessManifest#BaseProcessManifest(InputStream,ARSCFileParser)}
123119
*/
124-
public BaseProcessManifest(File apkFile) throws IOException, XmlPullParserException {
120+
public BaseProcessManifest(File apkFile) throws IOException {
125121
this(apkFile, ARSCFileParser.getInstance(apkFile));
126122
}
127123

@@ -130,11 +126,11 @@ public BaseProcessManifest(File apkFile) throws IOException, XmlPullParserExcept
130126
*
131127
* @param apkFile the AppManifest within the given APK will be parsed.
132128
* @param arscParser The parser for the Android resource database
133-
* @throws IOException if an I/O error occurs.
134-
* @throws XmlPullParserException can occur due to a malformed manifest.
135-
* @see BaseProcessManifest {@link BaseProcessManifest#BaseProcessManifest(InputStream,ARSCFileParser)}
129+
* @throws IOException if an I/O error occurs.
130+
* @see BaseProcessManifest
131+
* {@link BaseProcessManifest#BaseProcessManifest(InputStream,ARSCFileParser)}
136132
*/
137-
public BaseProcessManifest(File apkFile, ARSCFileParser arscParser) throws IOException, XmlPullParserException {
133+
public BaseProcessManifest(File apkFile, ARSCFileParser arscParser) throws IOException {
138134
if (!apkFile.exists())
139135
throw new RuntimeException(
140136
String.format("The given APK file %s does not exist", apkFile.getCanonicalPath()));
@@ -155,11 +151,9 @@ public BaseProcessManifest(File apkFile, ARSCFileParser arscParser) throws IOExc
155151
*
156152
* @param manifestIS InputStream for an AppManifest.
157153
* @param arscParser The Android resource file parser
158-
* @throws IOException if an I/O error occurs.
159-
* @throws XmlPullParserException can occur due to a malformed manifest.
154+
* @throws IOException if an I/O error occurs.
160155
*/
161-
public BaseProcessManifest(InputStream manifestIS, ARSCFileParser arscParser)
162-
throws IOException, XmlPullParserException {
156+
public BaseProcessManifest(InputStream manifestIS, ARSCFileParser arscParser) throws IOException {
163157
this.arscParser = arscParser;
164158
this.handle(manifestIS);
165159
}
@@ -172,7 +166,7 @@ public BaseProcessManifest(InputStream manifestIS, ARSCFileParser arscParser)
172166
* @throws IOException if an I/O error occurs.
173167
* @throws XmlPullParserException can occur due to a malformed manifest.
174168
*/
175-
protected void handle(InputStream manifestIS) throws IOException, XmlPullParserException {
169+
protected void handle(InputStream manifestIS) throws IOException {
176170
this.axml = new AXmlHandler(manifestIS);
177171

178172
// get manifest node

soot-infoflow-android/src/soot/jimple/infoflow/android/manifest/ProcessManifest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import java.io.IOException;
55
import java.io.InputStream;
66

7-
import org.xmlpull.v1.XmlPullParserException;
8-
97
import soot.jimple.infoflow.android.axml.AXmlNode;
108
import soot.jimple.infoflow.android.manifest.binary.BinaryManifestActivity;
119
import soot.jimple.infoflow.android.manifest.binary.BinaryManifestBroadcastReceiver;
@@ -27,20 +25,19 @@
2725
public class ProcessManifest extends
2826
BaseProcessManifest<BinaryManifestActivity, BinaryManifestService, BinaryManifestContentProvider, BinaryManifestBroadcastReceiver> {
2927

30-
public ProcessManifest(File apkFile, ARSCFileParser arscParser) throws IOException, XmlPullParserException {
28+
public ProcessManifest(File apkFile, ARSCFileParser arscParser) throws IOException {
3129
super(apkFile, arscParser);
3230
}
3331

34-
public ProcessManifest(File apkFile) throws IOException, XmlPullParserException {
32+
public ProcessManifest(File apkFile) throws IOException {
3533
super(apkFile);
3634
}
3735

38-
public ProcessManifest(InputStream manifestIS, ARSCFileParser arscParser)
39-
throws IOException, XmlPullParserException {
36+
public ProcessManifest(InputStream manifestIS, ARSCFileParser arscParser) throws IOException {
4037
super(manifestIS, arscParser);
4138
}
4239

43-
public ProcessManifest(String apkPath) throws IOException, XmlPullParserException {
40+
public ProcessManifest(String apkPath) throws IOException {
4441
super(apkPath);
4542
}
4643

soot-infoflow-integration/test/soot/jimple/infoflow/collections/test/junit/AndroidTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import org.junit.Assert;
77
import org.junit.Test;
8-
import org.xmlpull.v1.XmlPullParserException;
98

109
import soot.Value;
1110
import soot.jimple.Constant;
@@ -23,7 +22,7 @@ protected void setConfiguration(InfoflowConfiguration config) {
2322
}
2423

2524
@Test
26-
public void testResourceResolving() throws XmlPullParserException, IOException {
25+
public void testResourceResolving() throws IOException {
2726
File rootDir = getIntegrationRoot();
2827
SetupApplication app = initApplication(new File(rootDir, "testAPKs/Collections/StringResourcesTest.apk"));
2928
app.getConfig().getPathConfiguration()
@@ -45,7 +44,7 @@ public void testResourceResolving() throws XmlPullParserException, IOException {
4544
}
4645

4746
@Test
48-
public void testConstants() throws XmlPullParserException, IOException {
47+
public void testConstants() throws IOException {
4948
File rootDir = getIntegrationRoot();
5049
SetupApplication app = initApplication(new File(rootDir, "testAPKs/Collections/AppWithConstantFields.apk"));
5150
app.getConfig().getPathConfiguration()

soot-infoflow-integration/test/soot/jimple/infoflow/integration/test/junit/AndroidRegressionTests.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.junit.Assert;
1616
import org.junit.Assume;
1717
import org.junit.Test;
18-
import org.xmlpull.v1.XmlPullParserException;
1918

2019
import soot.Body;
2120
import soot.SootMethod;
@@ -61,7 +60,7 @@ protected void setConfiguration(InfoflowConfiguration config) {
6160
* Tests that the alias analysis correctly stops when an overwrite happens
6261
*/
6362
@Test
64-
public void testFlowSensitivityWithOverwrite() throws XmlPullParserException, IOException {
63+
public void testFlowSensitivityWithOverwrite() throws IOException {
6564
final File rootDir = getIntegrationRoot();
6665
SetupApplication app = initApplication(new File(rootDir, "testAPKs/flowsensitiveOverwrite.apk"));
6766
InfoflowResults results = app.runInfoflow(new File(rootDir, "../soot-infoflow-android/SourcesAndSinks.txt"));
@@ -75,7 +74,7 @@ public void testFlowSensitivityWithOverwrite() throws XmlPullParserException, IO
7574
* SummaryTaintWrapper#getSummaryDeclaringClass().
7675
*/
7776
@Test
78-
public void testTypeHierarchyFromSummary() throws XmlPullParserException, IOException {
77+
public void testTypeHierarchyFromSummary() throws IOException {
7978
final File rootDir = getIntegrationRoot();
8079
SetupApplication app = initApplication(new File(rootDir, "testAPKs/TypeHierarchyTest.apk"));
8180
InfoflowResults results = app.runInfoflow(new File(rootDir, "../soot-infoflow-android/SourcesAndSinks.txt"));
@@ -120,7 +119,7 @@ public void testKotlinAppWithCollections() throws IOException {
120119
* by a taint wrapper that marked the method as exclusive.
121120
*/
122121
@Test
123-
public void testMapClear() throws XmlPullParserException, IOException {
122+
public void testMapClear() throws IOException {
124123
SetupApplication app = initApplication(new File(getIntegrationRoot(), "testAPKs/MapClearTest.apk"));
125124
InfoflowResults results = app
126125
.runInfoflow(new File(getIntegrationRoot(), "../soot-infoflow-android/SourcesAndSinks.txt"));
@@ -193,7 +192,7 @@ public void XMLCallbackAPI33() throws IOException {
193192
}
194193

195194
@Test
196-
public void testThreadRunnable() throws XmlPullParserException, IOException {
195+
public void testThreadRunnable() throws IOException {
197196
final File rootDir = getIntegrationRoot();
198197
SetupApplication app = initApplication(new File(rootDir, "testAPKs/ThreadRunnable.apk"));
199198
// TODO: add support for parameter mismatch/virtualedges.xml
@@ -204,7 +203,7 @@ public void testThreadRunnable() throws XmlPullParserException, IOException {
204203
}
205204

206205
@Test
207-
public void testThreadRunnableIndirect() throws XmlPullParserException, IOException {
206+
public void testThreadRunnableIndirect() throws IOException {
208207
final File rootDir = getIntegrationRoot();
209208
SetupApplication app = initApplication(new File(rootDir, "testAPKs/ThreadRunnableIndirect.apk"));
210209
// TODO: add support for parameter mismatch/virtualedges.xml

soot-infoflow/src/soot/jimple/infoflow/solver/cfg/BackwardsInfoflowCFG.java

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
package soot.jimple.infoflow.solver.cfg;
22

3-
import com.sun.istack.NotNull;
4-
import soot.*;
3+
import java.util.ArrayList;
4+
import java.util.Collections;
5+
import java.util.HashSet;
6+
import java.util.List;
7+
import java.util.Set;
8+
import java.util.stream.Collectors;
9+
10+
import soot.Body;
11+
import soot.SootField;
12+
import soot.SootMethod;
13+
import soot.Unit;
14+
import soot.Value;
515
import soot.jimple.IfStmt;
616
import soot.jimple.Stmt;
717
import soot.jimple.SwitchStmt;
818
import soot.jimple.toolkits.ide.icfg.BackwardsInterproceduralCFG;
919
import soot.toolkits.graph.DirectedGraph;
1020

11-
import java.util.*;
12-
import java.util.stream.Collectors;
13-
1421
/**
1522
* Inverse interprocedural control-flow graph for the infoflow solver
1623
*
@@ -105,12 +112,12 @@ public List<Unit> getConditionalBranchesInterprocedural(Unit unit) {
105112

106113
/**
107114
* Finds all possible interprocedural conditionals recursive
108-
* @param unit start unit
115+
*
116+
* @param unit start unit
109117
* @param conditionals result list
110-
* @param doneSet already processed units
118+
* @param doneSet already processed units
111119
*/
112-
private void getConditionalsRecursive(@NotNull Unit unit, @NotNull List<Unit> conditionals,
113-
@NotNull Set<Unit> doneSet) {
120+
private void getConditionalsRecursive(Unit unit, List<Unit> conditionals, Set<Unit> doneSet) {
114121
SootMethod sm = getMethodOf(unit);
115122
// Exclude the dummy method
116123
if (sm.getDeclaringClass().getName().equals("dummyMainClass") && sm.getName().equals("dummy"))
@@ -129,7 +136,8 @@ private void getConditionalsRecursive(@NotNull Unit unit, @NotNull List<Unit> co
129136

130137
// call sites
131138
if (item instanceof Stmt && ((Stmt) item).containsInvokeExpr()) {
132-
List<Unit> entryPoints = getPredsOf(item).stream().filter(pred -> getMethodOf(pred) != sm).collect(Collectors.toList());
139+
List<Unit> entryPoints = getPredsOf(item).stream().filter(pred -> getMethodOf(pred) != sm)
140+
.collect(Collectors.toList());
133141
entryPoints.removeIf(doneSet::contains);
134142
for (Unit entryPoint : entryPoints) {
135143
getConditionalsRecursive(entryPoint, conditionals, doneSet);

0 commit comments

Comments
 (0)