33import com .alibaba .fastjson2 .JSONArray ;
44import io .dongtai .iast .common .config .ConfigBuilder ;
55import io .dongtai .iast .common .config .ConfigKey ;
6+ import io .dongtai .iast .common .config .RequestDenyList ;
67import io .dongtai .iast .common .string .ObjectFormatResult ;
78import io .dongtai .iast .core .EngineManager ;
89import io .dongtai .iast .core .handler .bypass .BlackUrlBypass ;
@@ -97,7 +98,41 @@ public static void collectDubboRequestSource(Object handler, Object invocation,
9798 if (requestMeta == null ) {
9899 return ;
99100 }
100- if (null != headers .get (BlackUrlBypass .getHeaderKey ()) && headers .get (BlackUrlBypass .getHeaderKey ()).equals ("true" )) {
101+
102+ Map <String , String > sHeaders = new HashMap <String , String >();
103+ if (headers != null ) {
104+ for (Map .Entry <String , ?> entry : headers .entrySet ()) {
105+ if (entry .getValue () == null ) {
106+ continue ;
107+ }
108+ sHeaders .put (entry .getKey (), entry .getValue ().toString ());
109+ }
110+ }
111+
112+ Map <String , String > oldHeaders = (Map <String , String >) requestMeta .get ("headers" );
113+ sHeaders .putAll (oldHeaders );
114+ requestMeta .put ("headers" , sHeaders );
115+ if (!sHeaders .isEmpty ()) {
116+ String traceIdKey = ContextManager .getHeaderKey ();
117+ if (sHeaders .containsKey (traceIdKey )) {
118+ ContextManager .parseTraceId (sHeaders .get (traceIdKey ));
119+ } else {
120+ String newTraceId = ContextManager .currentTraceId ();
121+ sHeaders .put (traceIdKey , newTraceId );
122+ }
123+ }
124+ //获取采集黑名单配置集合
125+ RequestDenyList requestDenyList = ConfigBuilder .getInstance ().get (ConfigKey .REQUEST_DENY_LIST );
126+
127+ //不为空开始进行判断
128+ if (requestDenyList != null ){
129+ if (requestDenyList .match (requestMeta .get ("requestURL" ).toString (),sHeaders )) {
130+ BlackUrlBypass .setIsBlackUrl (true );
131+ return ;
132+ }
133+ }
134+ //此判断为节点拉黑判断
135+ if (null != sHeaders .get (BlackUrlBypass .getHeaderKey ()) && sHeaders .get (BlackUrlBypass .getHeaderKey ()).equals ("true" )) {
101136 BlackUrlBypass .setIsBlackUrl (true );
102137 return ;
103138 }
@@ -135,30 +170,10 @@ public static void collectDubboRequestSource(Object handler, Object invocation,
135170 SourceNode sourceNode = new SourceNode (src , tgt , null );
136171 TaintPoolUtils .trackObject (event , sourceNode , arguments , 0 , true );
137172
138- Map <String , String > sHeaders = new HashMap <String , String >();
139- if (headers != null ) {
140- for (Map .Entry <String , ?> entry : headers .entrySet ()) {
141- if (entry .getValue () == null ) {
142- continue ;
143- }
144- sHeaders .put (entry .getKey (), entry .getValue ().toString ());
145- }
146- }
173+
147174
148175// if (handler.toString().startsWith("hessian")) {
149- Map <String , String > oldHeaders = (Map <String , String >) requestMeta .get ("headers" );
150- sHeaders .putAll (oldHeaders );
151- // }
152176
153- if (!sHeaders .isEmpty ()) {
154- String traceIdKey = ContextManager .getHeaderKey ();
155- if (sHeaders .containsKey (traceIdKey )) {
156- ContextManager .parseTraceId (sHeaders .get (traceIdKey ));
157- } else {
158- String newTraceId = ContextManager .currentTraceId ();
159- sHeaders .put (traceIdKey , newTraceId );
160- }
161- }
162177
163178 if (event .getTargetHashes ().isEmpty ()) {
164179 return ;
@@ -175,7 +190,6 @@ public static void collectDubboRequestSource(Object handler, Object invocation,
175190 TaintRanges tr = new TaintRanges (new TaintRange (0 , len ));
176191 event .targetRanges .add (0 , new MethodEvent .MethodEventTargetRange (hash , tr ));
177192
178- requestMeta .put ("headers" , sHeaders );
179193 JSONArray arr = new JSONArray ();
180194 for (Object arg : arguments ) {
181195 // 2023-9-5 11:31:53 直接拿完整的string可能会OOM(排队上报时可能会挤压占用较多的内存),这里只传递format之后的
0 commit comments