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 .AbstractXMLSourceSinkParser .ICategoryFilter ;
8- import soot .jimple .infoflow .sourcesSinks .definitions .ISourceSinkCategory ;
7+ import soot .jimple .infoflow .android .source .parsers .xml .XMLSourceSinkParser .ICategoryFilter ;
98import soot .jimple .infoflow .sourcesSinks .definitions .SourceSinkType ;
109
1110/**
@@ -29,66 +28,61 @@ public ConfigurationBasedCategoryFilter(SourceSinkConfiguration config) {
2928 }
3029
3130 @ Override
32- public boolean acceptsCategory (ISourceSinkCategory category ) {
31+ public boolean acceptsCategory (CategoryDefinition category ) {
3332 // We cannot compare descriptions to the configuration file
34- if (category instanceof CategoryDefinition ) {
35- CategoryDefinition catDef = (CategoryDefinition ) category ;
36- catDef = catDef .getIdOnlyDescription ();
33+ category = category .getIdOnlyDescription ();
3734
38- CategoryMode sourceType = config .getSourceCategoriesAndModes ().get (catDef );
39- CategoryMode sinkType = config .getSinkCategoriesAndModes ().get (catDef );
35+ CategoryMode sourceType = config .getSourceCategoriesAndModes ().get (category );
36+ CategoryMode sinkType = config .getSinkCategoriesAndModes ().get (category );
4037
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 ;
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 ;
4542
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 ;
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 ;
5249
53- return false ;
54- }
50+ return false ;
5551 }
5652
5753 // There is no reason to exclude the category
5854 return true ;
5955 }
6056
6157 @ Override
62- public SourceSinkType filter (ISourceSinkCategory category , SourceSinkType sourceSinkType ) {
58+ public SourceSinkType filter (CategoryDefinition category , SourceSinkType sourceSinkType ) {
6359 // We cannot compare descriptions to the configuration file
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- }
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 );
7772 }
73+ }
7874
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- }
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 );
8782 }
88- return sourceSinkType ;
8983 }
90- return SourceSinkType .Undefined ;
9184
85+ return sourceSinkType ;
9286 }
9387
9488}
0 commit comments