@@ -111,10 +111,16 @@ private List<SecretFinding> scanFile(File file) {
111111 private List <SecretFinding > scanConstantPool () {
112112 List <SecretFinding > findings = new ArrayList <>();
113113
114- for (SootClass sc : Scene .v ().getApplicationClasses ()) {
114+ // Use a snapshot of classes to avoid ConcurrentModificationException if Soot modifies the chain
115+ List <SootClass > snapshot = new ArrayList <>(Scene .v ().getApplicationClasses ());
116+
117+ for (SootClass sc : snapshot ) {
115118 if (sc .isPhantom ()) continue ;
116119
117- for (SootMethod sm : sc .getMethods ()) {
120+ // Use a snapshot of methods as well, just in case
121+ List <SootMethod > methodSnapshot = new ArrayList <>(sc .getMethods ());
122+
123+ for (SootMethod sm : methodSnapshot ) {
118124 if (!sm .hasActiveBody ()) {
119125 try {
120126 sm .retrieveActiveBody ();
@@ -123,13 +129,18 @@ private List<SecretFinding> scanConstantPool() {
123129 }
124130 }
125131
126- for (Unit u : sm .getActiveBody ().getUnits ()) {
127- for (ValueBox vb : u .getUseBoxes ()) {
128- if (vb .getValue () instanceof StringConstant ) {
129- String value = ((StringConstant ) vb .getValue ()).value ;
130- checkStringSecret (value , sc .getName () + "." + sm .getName (), findings , u );
132+ // Check units safely
133+ try {
134+ for (Unit u : sm .getActiveBody ().getUnits ()) {
135+ for (ValueBox vb : u .getUseBoxes ()) {
136+ if (vb .getValue () instanceof StringConstant ) {
137+ String value = ((StringConstant ) vb .getValue ()).value ;
138+ checkStringSecret (value , sc .getName () + "." + sm .getName (), findings , u );
139+ }
131140 }
132141 }
142+ } catch (Exception e ) {
143+ // Ignore errors during unit iteration (e.g. body modification)
133144 }
134145 }
135146 }
0 commit comments