33import io .dongtai .iast .core .EngineManager ;
44import io .dongtai .iast .core .utils .PropertyUtils ;
55import io .dongtai .iast .core .handler .hookpoint .models .MethodEvent ;
6+ import io .dongtai .log .DongTaiLog ;
7+
68import java .util .HashSet ;
79import java .util .Map ;
810import java .util .Set ;
@@ -29,55 +31,59 @@ protected HashSet<Object> initialValue() {
2931 * @param obj source点的污点
3032 */
3133 public void addTaintToPool (Object obj , MethodEvent event , boolean isSource ) {
32- int subHashCode = 0 ;
33- if (obj instanceof String []) {
34- this .get ().add (obj );
35- event .addTargetHash (obj .hashCode ());
34+ try {
35+ int subHashCode = 0 ;
36+ if (obj instanceof String []) {
37+ this .get ().add (obj );
38+ event .addTargetHash (obj .hashCode ());
3639
37- String [] tempObjs = (String []) obj ;
38- if (PROPERTIES .isNormalMode ()) {
39- for (String tempObj : tempObjs ) {
40- this .get ().add (tempObj );
41- subHashCode = System .identityHashCode (tempObj );
42- EngineManager .TAINT_HASH_CODES .get ().add (subHashCode );
43- event .addTargetHash (subHashCode );
44- }
45- } else {
46- for (String tempObj : tempObjs ) {
47- this .get ().add (tempObj );
48- event .addTargetHash (tempObj .hashCode ());
40+ String [] tempObjs = (String []) obj ;
41+ if (PROPERTIES .isNormalMode ()) {
42+ for (String tempObj : tempObjs ) {
43+ this .get ().add (tempObj );
44+ subHashCode = System .identityHashCode (tempObj );
45+ EngineManager .TAINT_HASH_CODES .get ().add (subHashCode );
46+ event .addTargetHash (subHashCode );
47+ }
48+ } else {
49+ for (String tempObj : tempObjs ) {
50+ this .get ().add (tempObj );
51+ event .addTargetHash (tempObj .hashCode ());
52+ }
4953 }
50- }
51- } else if ( obj instanceof Map ) {
52- this . get (). add ( obj );
53- event . addTargetHash ( obj . hashCode ());
54- if ( isSource ) {
55- Map <String , String []> tempMap = ( Map < String , String []>) obj ;
56- Set < Map .Entry <String , String []>> entries = tempMap . entrySet ();
57- for ( Map . Entry < String , String []> entry : entries ) {
58- Object key = entry .getKey ();
59- Object value = entry . getValue ( );
60- addTaintToPool (key , event , true );
61- addTaintToPool ( value , event , true );
54+ } else if ( obj instanceof Map ) {
55+ this . get (). add ( obj );
56+ event . addTargetHash ( obj . hashCode () );
57+ if ( isSource ) {
58+ Map < String , String []> tempMap = ( Map < String , String []>) obj ;
59+ Set < Map . Entry <String , String []>> entries = tempMap . entrySet () ;
60+ for ( Map .Entry <String , String []> entry : entries ) {
61+ Object key = entry . getKey ();
62+ Object value = entry .getValue ();
63+ addTaintToPool ( key , event , true );
64+ addTaintToPool (value , event , true );
65+ }
6266 }
63- }
64- } else if ( obj . getClass (). isArray () && ! obj . getClass (). getComponentType (). isPrimitive ()) {
65- Object [] tempObjs = ( Object []) obj ;
66- if ( tempObjs . length != 0 ) {
67- for ( Object tempObj : tempObjs ) {
68- addTaintToPool ( tempObj , event , isSource );
67+ } else if ( obj . getClass (). isArray () && ! obj . getClass (). getComponentType (). isPrimitive ()) {
68+ Object [] tempObjs = ( Object []) obj ;
69+ if ( tempObjs . length != 0 ) {
70+ for ( Object tempObj : tempObjs ) {
71+ addTaintToPool ( tempObj , event , isSource );
72+ }
6973 }
70- }
71- } else {
72- this .get ().add (obj );
73- if (obj instanceof String && PROPERTIES .isNormalMode ()) {
74- subHashCode = System .identityHashCode (obj );
75- EngineManager .TAINT_HASH_CODES .get ().add (subHashCode );
7674 } else {
77- subHashCode = obj .hashCode ();
78- }
79- event .addTargetHash (subHashCode );
75+ this .get ().add (obj );
76+ if (obj instanceof String && PROPERTIES .isNormalMode ()) {
77+ subHashCode = System .identityHashCode (obj );
78+ EngineManager .TAINT_HASH_CODES .get ().add (subHashCode );
79+ } else {
80+ subHashCode = obj .hashCode ();
81+ }
82+ event .addTargetHash (subHashCode );
8083
84+ }
85+ }catch (Exception e ){
86+ DongTaiLog .debug (e );
8187 }
8288 }
8389
0 commit comments