@@ -205,7 +205,8 @@ public function currBlockTaintHandler($block,$node,$argName,$fileSummary){
205
205
//如果var右边有source项
206
206
if (in_array ($ varName , $ this ->sourcesArr )){
207
207
//报告漏洞
208
- $ this ->report ($ node , $ flow ->getLocation (), $ type ) ;
208
+ $ path = $ fileSummary ->getPath () ;
209
+ $ this ->report ($ path , $ node , $ flow ->getLocation (), $ type ) ;
209
210
return true ;
210
211
}else {
211
212
//首先进行文件夹的分析
@@ -303,7 +304,8 @@ public function multiBlockHandler($block, $argName, $node, $fileSummary){
303
304
//如果var右边有source项
304
305
if (in_array ($ varName , $ this ->sourcesArr )){
305
306
//报告漏洞
306
- $ this ->report ($ node , $ flow ->getLocation (), $ type ) ;
307
+ $ path = $ fileSummary ->getPath () ;
308
+ $ this ->report ($ path , $ node , $ flow ->getLocation (), $ type ) ;
307
309
}else {
308
310
//首先进行文件夹的分析
309
311
//首先根据fileSummary获取到fileSummaryMap
@@ -376,7 +378,8 @@ public function multiBlockHandler($block, $argName, $node, $fileSummary){
376
378
//如果var右边有source项,直接报告漏洞
377
379
if (in_array ($ varName , $ this ->sourcesArr )){
378
380
//报告漏洞
379
- $ this ->report ($ node , $ flow ->getLocation (),$ type ) ;
381
+ $ path = $ fileSummary ->getPath () ;
382
+ $ this ->report ($ path , $ node , $ flow ->getLocation (),$ type ) ;
380
383
return true ;
381
384
}else {
382
385
//首先进行文件夹的分析
@@ -443,7 +446,8 @@ public function multiFileHandler($block, $argName, $node, $fileSummaryMap){
443
446
//如果var右边有source项
444
447
if (in_array ($ varName , $ this ->sourcesArr )){
445
448
//报告漏洞
446
- $ this ->report ($ node , $ flow ->getLocation (),$ type ) ;
449
+ $ path = $ fsummary ->getPath () ;
450
+ $ this ->report ($ path , $ node , $ flow ->getLocation (),$ type ) ;
447
451
}
448
452
}
449
453
@@ -540,17 +544,32 @@ public function analysis($block,$node,$argName,$fileSummary){
540
544
541
545
/**
542
546
* 报告漏洞的函数
547
+ * @param string $path 出现漏洞的文件路径
543
548
* @param Node $node 出现漏洞的node
544
549
* @param Node $var 出现漏洞的变量node
550
+ * @param string 漏洞的类型
545
551
*/
546
- public function report ($ node , $ var , $ type ){
552
+ public function report ($ path , $ node , $ var , $ type ){
547
553
echo "<pre> " ;
548
554
echo "有漏洞=====> " . $ type ."<br/> " ;
549
555
echo "漏洞变量:<br/> " ;
550
556
print_r ($ var ) ;
551
557
echo "漏洞节点:<br/> " ;
552
558
print_r ($ node ) ;
553
- return ;
559
+
560
+ //获取结果集上下文
561
+ $ resultContext = ResultContext::getInstance () ;
562
+
563
+ //加入至上下文中
564
+ $ record = new Result ($ path , $ type , $ node , $ var ) ;
565
+
566
+ //如果存在记录则不添加,反之才添加
567
+ if ($ resultContext ->isRecordExists ($ record )){
568
+ return ;
569
+ }else {
570
+ $ resultContext ->addResElement ($ record ) ;
571
+ }
572
+
554
573
}
555
574
556
575
0 commit comments