Skip to content

Commit fcddc76

Browse files
author
exploit
committed
remove duplicate records in ResultContext
1 parent f3751e4 commit fcddc76

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

analyser/TaintAnalyser.class.php

+25-6
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ public function currBlockTaintHandler($block,$node,$argName,$fileSummary){
205205
//如果var右边有source项
206206
if(in_array($varName, $this->sourcesArr)){
207207
//报告漏洞
208-
$this->report($node, $flow->getLocation(), $type) ;
208+
$path = $fileSummary->getPath() ;
209+
$this->report($path, $node, $flow->getLocation(), $type) ;
209210
return true ;
210211
}else{
211212
//首先进行文件夹的分析
@@ -303,7 +304,8 @@ public function multiBlockHandler($block, $argName, $node, $fileSummary){
303304
//如果var右边有source项
304305
if(in_array($varName, $this->sourcesArr)){
305306
//报告漏洞
306-
$this->report($node, $flow->getLocation(), $type) ;
307+
$path = $fileSummary->getPath() ;
308+
$this->report($path, $node, $flow->getLocation(), $type) ;
307309
}else{
308310
//首先进行文件夹的分析
309311
//首先根据fileSummary获取到fileSummaryMap
@@ -376,7 +378,8 @@ public function multiBlockHandler($block, $argName, $node, $fileSummary){
376378
//如果var右边有source项,直接报告漏洞
377379
if(in_array($varName, $this->sourcesArr)){
378380
//报告漏洞
379-
$this->report($node, $flow->getLocation(),$type) ;
381+
$path = $fileSummary->getPath() ;
382+
$this->report($path, $node, $flow->getLocation(),$type) ;
380383
return true ;
381384
}else{
382385
//首先进行文件夹的分析
@@ -443,7 +446,8 @@ public function multiFileHandler($block, $argName, $node, $fileSummaryMap){
443446
//如果var右边有source项
444447
if(in_array($varName, $this->sourcesArr)){
445448
//报告漏洞
446-
$this->report($node, $flow->getLocation(),$type) ;
449+
$path = $fsummary->getPath() ;
450+
$this->report($path, $node, $flow->getLocation(),$type) ;
447451
}
448452
}
449453

@@ -540,17 +544,32 @@ public function analysis($block,$node,$argName,$fileSummary){
540544

541545
/**
542546
* 报告漏洞的函数
547+
* @param string $path 出现漏洞的文件路径
543548
* @param Node $node 出现漏洞的node
544549
* @param Node $var 出现漏洞的变量node
550+
* @param string 漏洞的类型
545551
*/
546-
public function report($node, $var, $type){
552+
public function report($path, $node, $var, $type){
547553
echo "<pre>" ;
548554
echo "有漏洞=====>". $type ."<br/>" ;
549555
echo "漏洞变量:<br/>" ;
550556
print_r($var) ;
551557
echo "漏洞节点:<br/>" ;
552558
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+
554573
}
555574

556575

context/ResultContext.class.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,22 @@ public function addResElement($ele){
2121
}
2222
}
2323

24-
2524
/**
26-
* getter
25+
* 查看一条记录是否在结果集中存在
26+
* @param Result $record
27+
* @return boolean
2728
*/
29+
public function isRecordExists($record){
30+
foreach ($this->resArr as $value){
31+
if($value == $record){
32+
return true ;
33+
}
34+
}
35+
return false ;
36+
}
37+
38+
39+
//getter
2840
public function getResArr() {
2941
return $this->resArr;
3042
}

test/test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
$sql = "xxx". $id ;
1717

18-
echo $sql ;
18+
print $sql ;
1919

2020
?>

0 commit comments

Comments
 (0)