Skip to content

Commit 3c344c1

Browse files
author
Erik Derr
committed
Removed deprecated DB mode
The DB mode is no longer first choice for large-scale evaluations. Use the json mode to process the resulting data.
1 parent 77a6ea2 commit 3c344c1

File tree

6 files changed

+44
-397
lines changed

6 files changed

+44
-397
lines changed

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,9 @@ Analysis results can be written in different formats.
9999
<ol>
100100
<li> the JSON format (-j switch), creates subfolders in the specified directory following the app package, i.e. *com.foo* will create *com/foo* subfolders.
101101
This is useful when coping with a large number of apps. For detailed information about the information stored, please refer to the <a href="https://github.com/reddr/LibScout/wiki#json-output-format-specification">JSON output specification</a>.</li>
102-
<li> the <b>serialization</b> option (-s switch) writes stat files per app to disk that can be used with the database module to create a SQLite database (the DB structure can be found in class
103-
<b>de.infsec.tpl.stats.SQLStats</b></li>
102+
<li> the <b>serialization</b> option (-s switch) writes stat files per app to disk (deprecated)</li>
104103
</ol>
105-
<pre>java -jar LibScout.jar -o match -p <i>path_to_profiles</i> [-a <i>android_sdk_jar</i>] [-u] [-j <i>json_dir</i>] [-s <i>stats_dir</i>] [-m] [-d <i>log_dir</i>] <i>path_to_app(s)</i> </pre>
104+
<pre>java -jar LibScout.jar -o match -p <i>path_to_profiles</i> [-a <i>android_sdk_jar</i>] [-u] [-j <i>json_dir</i>] [-m] [-d <i>log_dir</i>] <i>path_to_app(s)</i> </pre>
106105

107106
### Library API compatibility analysis (-o lib_api_analysis)
108107

@@ -122,12 +121,7 @@ For your convenience use the library scraper. Analysis results are written to di
122121
This mode is an extension to the match mode. It first detects library versions in the provided apps and conducts a library usage analysis (-u is implied). In addition, it requires library API compat data (via the -l switch) as generated in the <i>lib_api_analysis</i> mode . Based on the lib API usage in the app and the compat info, LibScout determines the highest version that is still compatible to the set of used lib APIs.<br>
123122
<b>Note:</b> The new implementation still lacks some features, e.g. the results are currently logged but not yet written to json. See the code comments for more information.
124123

125-
<pre>java -jar LibScout.jar -o updatability [-a <i>android_sdk_jar</i>] [-j <i>json_dir</i>] -l <i>lib_api_data_dir</i> <i>path_to_app(s)<i></pre>
126-
127-
### Database Generator (-o db)
128-
129-
Generates a SQLite database from library profiles and serialized app stats:<br>
130-
<pre>java -jar LibScout.jar -o db -p <i>path_to_profiles</i> -s <i>path_to_app_stats</i> </pre>
124+
<pre>java -jar LibScout.jar -o updatability [-a <i>android_sdk_jar</i>] [-j <i>json_dir</i>] -l <i>lib_api_data_dir</i> <i>path_to_app(s)</i></pre>
131125

132126

133127
## Scientific Publications

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ dependencies {
3737
provided 'org.smali:dexlib2:2.2.6'
3838

3939
provided files('lib/android-xml.jar') // axml relevant classes from Android SDK
40-
provided files('lib/sqlite-jdbc-3.7.15-SNAPSHOT.jar') // loaded via reflection, at that time, the only working version
4140
}
4241

4342
jar {
-3.53 MB
Binary file not shown.

src/de/infsec/tpl/TplCLI.java

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import ch.qos.logback.classic.joran.JoranConfigurator;
4141
import ch.qos.logback.core.joran.spi.JoranException;
4242
import ch.qos.logback.core.util.StatusPrinter;
43-
import de.infsec.tpl.stats.SQLStats;
4443
import de.infsec.tpl.utils.Utils;
4544
import de.infsec.tpl.profile.LibProfile;
4645

@@ -119,7 +118,7 @@ public static void main(String[] args) {
119118
* one time data loading
120119
*/
121120

122-
if (LibScoutConfig.opMatch() || LibScoutConfig.opDB() || LibScoutConfig.opUpdatability())
121+
if (LibScoutConfig.opMatch() || LibScoutConfig.opUpdatability())
123122
profiles = Profile.loadLibraryProfiles(LibScoutConfig.profilesDir);
124123

125124
if (LibScoutConfig.opUpdatability())
@@ -135,12 +134,6 @@ public static void main(String[] args) {
135134
* choose mode of operation
136135
*/
137136

138-
if (LibScoutConfig.opDB()) {
139-
// generate SQLite DB from app stats
140-
SQLStats.stats2DB(profiles);
141-
System.exit(0);
142-
}
143-
144137
// process input files, either library files or apps
145138
for (File inputFile: inputFiles) {
146139
try {
@@ -207,13 +200,13 @@ else if (cmd.hasOption(CliArgs.ARG_LOG_DIR)) {
207200
}
208201

209202
// path to LibScout.toml
210-
if (checkOptionalUse(cmd, CliArgs.ARG_CONFIG, LibScoutConfig.OpMode.PROFILE, LibScoutConfig.OpMode.MATCH, LibScoutConfig.OpMode.LIB_API_ANALYSIS, LibScoutConfig.OpMode.DB, LibScoutConfig.OpMode.UPDATABILITY)) {
203+
if (checkOptionalUse(cmd, CliArgs.ARG_CONFIG, LibScoutConfig.OpMode.PROFILE, LibScoutConfig.OpMode.MATCH, LibScoutConfig.OpMode.LIB_API_ANALYSIS, LibScoutConfig.OpMode.UPDATABILITY)) {
211204
LibScoutConfig.libScoutConfigFileName = cmd.getOptionValue(CliArgs.ARG_CONFIG);
212205
LibScoutConfig.checkIfValidFile(LibScoutConfig.libScoutConfigFileName);
213206
}
214207

215208
// profiles dir option, if provided without argument output is written to default dir
216-
if (checkOptionalUse(cmd, CliArgs.ARG_PROFILES_DIR, LibScoutConfig.OpMode.PROFILE, LibScoutConfig.OpMode.MATCH, LibScoutConfig.OpMode.DB, LibScoutConfig.OpMode.UPDATABILITY)) {
209+
if (checkOptionalUse(cmd, CliArgs.ARG_PROFILES_DIR, LibScoutConfig.OpMode.PROFILE, LibScoutConfig.OpMode.MATCH, LibScoutConfig.OpMode.UPDATABILITY)) {
217210
File profilesDir = new File(cmd.getOptionValue(CliArgs.ARG_PROFILES_DIR));
218211
if (profilesDir.exists() && !profilesDir.isDirectory())
219212
throw new ParseException("Profiles directory " + profilesDir + " already exists and is not a directory");
@@ -252,7 +245,7 @@ else if (cmd.hasOption(CliArgs.ARG_LOG_DIR)) {
252245
}
253246

254247
// enable/disable generation of stats with optional stats directory
255-
if (checkOptionalUse(cmd, CliArgs.ARG_STATS_DIR, LibScoutConfig.OpMode.MATCH, LibScoutConfig.OpMode.DB)) {
248+
if (checkOptionalUse(cmd, CliArgs.ARG_STATS_DIR, LibScoutConfig.OpMode.MATCH)) {
256249
LibScoutConfig.generateStats = true;
257250

258251
if (cmd.getOptionValue(CliArgs.ARG_STATS_DIR) != null) { // stats dir provided?
@@ -292,51 +285,50 @@ else if (cmd.hasOption(CliArgs.ARG_LOG_DIR)) {
292285
* - in profile mode pass *one* library (since it is linked to lib description file)
293286
* - in match mode pass one application file or one directory (including apks)
294287
*/
295-
if (!(LibScoutConfig.opDB())) {
296-
inputFiles = new ArrayList<File>();
297288

298-
if (LibScoutConfig.opLibApiAnalysis()) {
299-
// we require a directory including library packages/descriptions
300-
for (String path: cmd.getArgs()) {
301-
File dir = new File(path);
289+
inputFiles = new ArrayList<File>();
302290

303-
if (dir.isDirectory())
304-
inputFiles.add(dir);
305-
}
291+
if (LibScoutConfig.opLibApiAnalysis()) {
292+
// we require a directory including library packages/descriptions
293+
for (String path: cmd.getArgs()) {
294+
File dir = new File(path);
306295

307-
if (inputFiles.isEmpty()) {
308-
throw new ParseException("You have to provide at least one directory that includes a library package and description");
309-
}
310-
} else {
311-
String[] fileExts = LibScoutConfig.opMatch() || LibScoutConfig.opUpdatability() ? new String[]{"apk"} : new String[]{"jar", "aar"};
312-
313-
for (String inputFile : cmd.getArgs()) {
314-
File arg = new File(inputFile);
315-
316-
if (arg.isDirectory()) {
317-
inputFiles.addAll(Utils.collectFiles(arg, fileExts));
318-
} else if (arg.isFile()) {
319-
if (arg.getName().endsWith("." + fileExts[0]))
320-
inputFiles.add(arg);
321-
else if (fileExts.length > 1 && arg.getName().endsWith("." + fileExts[1]))
322-
inputFiles.add(arg);
323-
else
324-
throw new ParseException("File " + arg.getName() + " is no valid ." + Utils.join(Arrays.asList(fileExts), "/") + " file");
325-
} else {
326-
throw new ParseException("Argument " + inputFile + " is no valid file or directory!");
327-
}
328-
}
296+
if (dir.isDirectory())
297+
inputFiles.add(dir);
298+
}
329299

330-
if (inputFiles.isEmpty()) {
331-
if (LibScoutConfig.opProfile())
332-
throw new ParseException("No libraries (jar|aar files) found to profile in " + cmd.getArgList());
300+
if (inputFiles.isEmpty()) {
301+
throw new ParseException("You have to provide at least one directory that includes a library package and description");
302+
}
303+
} else {
304+
String[] fileExts = LibScoutConfig.opMatch() || LibScoutConfig.opUpdatability() ? new String[]{"apk"} : new String[]{"jar", "aar"};
305+
306+
for (String inputFile : cmd.getArgs()) {
307+
File arg = new File(inputFile);
308+
309+
if (arg.isDirectory()) {
310+
inputFiles.addAll(Utils.collectFiles(arg, fileExts));
311+
} else if (arg.isFile()) {
312+
if (arg.getName().endsWith("." + fileExts[0]))
313+
inputFiles.add(arg);
314+
else if (fileExts.length > 1 && arg.getName().endsWith("." + fileExts[1]))
315+
inputFiles.add(arg);
333316
else
334-
throw new ParseException("No apk files found in " + cmd.getArgList());
335-
} else if (inputFiles.size() > 1 && LibScoutConfig.opProfile())
336-
throw new ParseException("You have to provide a path to a single library file or a directory incl. a single lib file");
317+
throw new ParseException("File " + arg.getName() + " is no valid ." + Utils.join(Arrays.asList(fileExts), "/") + " file");
318+
} else {
319+
throw new ParseException("Argument " + inputFile + " is no valid file or directory!");
320+
}
337321
}
322+
323+
if (inputFiles.isEmpty()) {
324+
if (LibScoutConfig.opProfile())
325+
throw new ParseException("No libraries (jar|aar files) found to profile in " + cmd.getArgList());
326+
else
327+
throw new ParseException("No apk files found in " + cmd.getArgList());
328+
} else if (inputFiles.size() > 1 && LibScoutConfig.opProfile())
329+
throw new ParseException("You have to provide a path to a single library file or a directory incl. a single lib file");
338330
}
339-
331+
340332
} catch (ParseException e) {
341333
System.err.println("Command line parsing failed:\n " + e.getMessage() + "\n");
342334
usage();

src/de/infsec/tpl/config/LibScoutConfig.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ public enum OpMode {
3030
// match lib profiles in provided apps
3131
MATCH("match", "[options] path_to_app(dir)"),
3232

33-
// build sqlite database from app stat files
34-
DB("db", "-p path_to_profiles -s path_to_stats"),
35-
3633
// analyzes library api stability (api additions, removals, changes)
3734
LIB_API_ANALYSIS("lib_api_analysis", "path_to_lib_sdks"),
3835

@@ -63,7 +60,6 @@ public static String getOpModeString() {
6360
public static OpMode opmode = null;
6461
public static boolean opMatch() { return OpMode.MATCH.equals(opmode); }
6562
public static boolean opProfile() { return OpMode.PROFILE.equals(opmode); }
66-
public static boolean opDB() { return OpMode.DB.equals(opmode); }
6763
public static boolean opLibApiAnalysis() { return OpMode.LIB_API_ANALYSIS.equals(opmode); }
6864
public static boolean opUpdatability() { return OpMode.UPDATABILITY.equals(opmode); }
6965

0 commit comments

Comments
 (0)