44import soot .jimple .infoflow .InfoflowConfiguration .SourceSinkFilterMode ;
55import soot .jimple .infoflow .android .InfoflowAndroidConfiguration .SourceSinkConfiguration ;
66import soot .jimple .infoflow .android .data .CategoryDefinition ;
7- import soot .jimple .infoflow .android .source .parsers .xml .XMLSourceSinkParser .ICategoryFilter ;
7+ import soot .jimple .infoflow .android .source .parsers .xml .AbstractXMLSourceSinkParser .ICategoryFilter ;
8+ import soot .jimple .infoflow .sourcesSinks .definitions .ISourceSinkCategory ;
89import soot .jimple .infoflow .sourcesSinks .definitions .SourceSinkType ;
910
1011/**
@@ -28,61 +29,66 @@ public ConfigurationBasedCategoryFilter(SourceSinkConfiguration config) {
2829 }
2930
3031 @ Override
31- public boolean acceptsCategory (CategoryDefinition category ) {
32+ public boolean acceptsCategory (ISourceSinkCategory category ) {
3233 // We cannot compare descriptions to the configuration file
33- category = category .getIdOnlyDescription ();
34+ if (category instanceof CategoryDefinition ) {
35+ CategoryDefinition catDef = (CategoryDefinition ) category ;
36+ catDef = catDef .getIdOnlyDescription ();
3437
35- CategoryMode sourceType = config .getSourceCategoriesAndModes ().get (category );
36- CategoryMode sinkType = config .getSinkCategoriesAndModes ().get (category );
38+ CategoryMode sourceType = config .getSourceCategoriesAndModes ().get (catDef );
39+ CategoryMode sinkType = config .getSinkCategoriesAndModes ().get (catDef );
3740
38- // Check whether the category is excluded for everything
39- if (sourceType != null && sourceType == CategoryMode .Exclude )
40- if (sinkType != null && sinkType == CategoryMode .Exclude )
41- return false ;
41+ // Check whether the category is excluded for everything
42+ if (sourceType != null && sourceType == CategoryMode .Exclude )
43+ if (sinkType != null && sinkType == CategoryMode .Exclude )
44+ return false ;
4245
43- // Check whether the category is included for something
44- if (config .getSinkFilterMode () == SourceSinkFilterMode .UseOnlyIncluded ) {
45- if (sourceType != null && sourceType == CategoryMode .Include )
46- return true ;
47- if (sinkType != null && sinkType == CategoryMode .Include )
48- return true ;
46+ // Check whether the category is included for something
47+ if (config .getSinkFilterMode () == SourceSinkFilterMode .UseOnlyIncluded ) {
48+ if (sourceType != null && sourceType == CategoryMode .Include )
49+ return true ;
50+ if (sinkType != null && sinkType == CategoryMode .Include )
51+ return true ;
4952
50- return false ;
53+ return false ;
54+ }
5155 }
5256
5357 // There is no reason to exclude the category
5458 return true ;
5559 }
5660
5761 @ Override
58- public SourceSinkType filter (CategoryDefinition category , SourceSinkType sourceSinkType ) {
62+ public SourceSinkType filter (ISourceSinkCategory category , SourceSinkType sourceSinkType ) {
5963 // We cannot compare descriptions to the configuration file
60- category = category .getIdOnlyDescription ();
61-
62- CategoryMode sourceMode = config .getSourceCategoriesAndModes ().get (category );
63- CategoryMode sinkMode = config .getSinkCategoriesAndModes ().get (category );
64-
65- if (sourceSinkType == SourceSinkType .Source || sourceSinkType == SourceSinkType .Both ) {
66- if (config .getSourceFilterMode () == SourceSinkFilterMode .UseAllButExcluded ) {
67- if (sourceMode != null && sourceMode == CategoryMode .Exclude )
68- sourceSinkType = sourceSinkType .removeType (SourceSinkType .Source );
69- } else if (config .getSourceFilterMode () == SourceSinkFilterMode .UseOnlyIncluded ) {
70- if (sourceMode == null || sourceMode != CategoryMode .Include )
71- sourceSinkType = sourceSinkType .removeType (SourceSinkType .Source );
64+ if (category instanceof CategoryDefinition ) {
65+ CategoryDefinition catDef = (CategoryDefinition ) category ;
66+ catDef = catDef .getIdOnlyDescription ();
67+ CategoryMode sourceMode = config .getSourceCategoriesAndModes ().get (category );
68+ CategoryMode sinkMode = config .getSinkCategoriesAndModes ().get (category );
69+ if (sourceSinkType == SourceSinkType .Source || sourceSinkType == SourceSinkType .Both ) {
70+ if (config .getSourceFilterMode () == SourceSinkFilterMode .UseAllButExcluded ) {
71+ if (sourceMode != null && sourceMode == CategoryMode .Exclude )
72+ sourceSinkType = sourceSinkType .removeType (SourceSinkType .Source );
73+ } else if (config .getSourceFilterMode () == SourceSinkFilterMode .UseOnlyIncluded ) {
74+ if (sourceMode == null || sourceMode != CategoryMode .Include )
75+ sourceSinkType = sourceSinkType .removeType (SourceSinkType .Source );
76+ }
7277 }
73- }
7478
75- if (sourceSinkType == SourceSinkType .Sink || sourceSinkType == SourceSinkType .Both ) {
76- if (config .getSinkFilterMode () == SourceSinkFilterMode .UseAllButExcluded ) {
77- if (sinkMode != null && sinkMode == CategoryMode .Exclude )
78- sourceSinkType = sourceSinkType .removeType (SourceSinkType .Sink );
79- } else if (config .getSinkFilterMode () == SourceSinkFilterMode .UseOnlyIncluded ) {
80- if (sinkMode == null || sinkMode != CategoryMode .Include )
81- sourceSinkType = sourceSinkType .removeType (SourceSinkType .Sink );
79+ if (sourceSinkType == SourceSinkType .Sink || sourceSinkType == SourceSinkType .Both ) {
80+ if (config .getSinkFilterMode () == SourceSinkFilterMode .UseAllButExcluded ) {
81+ if (sinkMode != null && sinkMode == CategoryMode .Exclude )
82+ sourceSinkType = sourceSinkType .removeType (SourceSinkType .Sink );
83+ } else if (config .getSinkFilterMode () == SourceSinkFilterMode .UseOnlyIncluded ) {
84+ if (sinkMode == null || sinkMode != CategoryMode .Include )
85+ sourceSinkType = sourceSinkType .removeType (SourceSinkType .Sink );
86+ }
8287 }
88+ return sourceSinkType ;
8389 }
90+ return SourceSinkType .Undefined ;
8491
85- return sourceSinkType ;
8692 }
8793
8894}
0 commit comments