@@ -21,23 +21,23 @@ class AllowListSanitizerWithJavaUtilSet {
2121 public static final Set <String > goodAllowList2 = Collections .unmodifiableSet (new HashSet <String >(Arrays .asList ("allowed1" ,"allowed2" )));
2222 public static final Set <String > goodAllowList3 ;
2323 public static final Set <String > goodAllowList4 ;
24+ public static final Set <String > goodAllowList5 ;
2425 public static final Set <String > badAllowList1 = Set .of ("allowed1" , "allowed2" , getNonConstantString ());
2526 public static final Set <String > badAllowList2 = Collections .unmodifiableSet (new HashSet <String >(Arrays .asList ("allowed1" , getNonConstantString ())));
2627 public static final Set <String > badAllowList3 ;
2728 public static final Set <String > badAllowList4 ;
28- public static final Set <String > badAllowList5 ;
2929 public static Set <String > badAllowList6 = Set .of ("allowed1" , "allowed2" , "allowed3" );
30- public final Set <String > badAllowList7 = Set .of ("allowed1" , "allowed2" , "allowed3" );
30+ public final Set <String > goodAllowList7 = Set .of ("allowed1" , "allowed2" , "allowed3" );
3131
3232 static {
3333 goodAllowList3 = Set .of ("allowed1" , "allowed2" , "allowed3" );
3434 goodAllowList4 = Collections .unmodifiableSet (new HashSet <String >(Arrays .asList ("allowed1" , "allowed2" )));
3535 badAllowList3 = Set .of (getNonConstantString (), "allowed2" , "allowed3" );
3636 badAllowList4 = Collections .unmodifiableSet (new HashSet <String >(Arrays .asList ("allowed1" , getNonConstantString ())));
37- badAllowList5 = new HashSet <String >();
38- badAllowList5 .add ("allowed1" );
39- badAllowList5 .add ("allowed2" );
40- badAllowList5 .add ("allowed3" );
37+ goodAllowList5 = new HashSet <String >();
38+ goodAllowList5 .add ("allowed1" );
39+ goodAllowList5 .add ("allowed2" );
40+ goodAllowList5 .add ("allowed3" );
4141 }
4242
4343 public static String getNonConstantString () {
@@ -104,8 +104,8 @@ private static void testStaticFields(String[] args) throws IOException, SQLExcep
104104 + tainted + "' ORDER BY PRICE" ;
105105 ResultSet results = connection .createStatement ().executeQuery (query );
106106 }
107- // BAD : an allowlist is used with constant strings
108- if (badAllowList5 .contains (tainted )){
107+ // GOOD : an allowlist is used with constant strings
108+ if (goodAllowList5 .contains (tainted )){
109109 String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='"
110110 + tainted + "' ORDER BY PRICE" ;
111111 ResultSet results = connection .createStatement ().executeQuery (query );
@@ -120,8 +120,8 @@ private static void testStaticFields(String[] args) throws IOException, SQLExcep
120120
121121 private void testNonStaticFields (String [] args ) throws IOException , SQLException {
122122 String tainted = args [1 ];
123- // BAD : the allowlist is in a non-static field
124- if (badAllowList7 .contains (tainted )){
123+ // GOOD : the allowlist is in a non-static field
124+ if (goodAllowList7 .contains (tainted )){
125125 String query = "SELECT ITEM,PRICE FROM PRODUCT WHERE ITEM_CATEGORY='"
126126 + tainted + "' ORDER BY PRICE" ;
127127 ResultSet results = connection .createStatement ().executeQuery (query );
0 commit comments