All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.junitReport.vsl Maven / Gradle / Ivy

#**
 This file is part of Dependency-Check.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

 Copyright (c) 2019 Jeremy Long. All Rights Reserved.

 @author Jeremy Long 
 @version 1.0

*#
#set($junitFailOnCvss=$settings.getFloat("junit.fail.on.cvss",0))
#set($vulnCount=0)
#set($testCount=0)
#foreach($dependency in $dependencies)
    #if($dependency.getVulnerabilities().size()==0)
        #set($testCount=$testCount + 1)
    #end
    #if($dependency.getVulnerabilities())
        #set($vulnCount=$vulnCount+$dependency.getVulnerabilities().size())
    #end
    #foreach($vuln in $dependency.getVulnerabilities())
        #if(!($vuln.cvssV3 && $vuln.cvssV3.cvssData.baseScore >= $junitFailOnCvss) && !($vuln.cvssV2 && $vuln.cvssV2.cvssData.baseScore >= $junitFailOnCvss) && !($vuln.unscoredSeverity && $rpt.estimateSeverity($vuln.unscoredSeverity) >= $junitFailOnCvss))
            #set($vulnCount=$vulnCount - 1)
        #end
    #end
#end
#set($suiteId=-1)

    #foreach($dependency in $dependencies)
        #set($suiteId=$suiteId+1)
        #if($dependency.getVulnerabilities().size()==0 && $dependency.getSuppressedVulnerabilities().size()==0)
            #set($testCount=1)
            #set($skipped=0)
            #set($failed=0)
        #else
            #set($testCount=$dependency.getVulnerabilities().size() + $dependency.getSuppressedVulnerabilities().size())
            #set($skipped=$dependency.getSuppressedVulnerabilities().size())
            #set($failed=$dependency.getVulnerabilities().size())
            #foreach($vuln in $dependency.getVulnerabilities())
                #if( !($vuln.cvssV3 && $vuln.cvssV3.cvssData.baseScore >= $junitFailOnCvss) && !($vuln.cvssV2 && $vuln.cvssV2.cvssData.baseScore >= $junitFailOnCvss) && !($vuln.unscoredSeverity && $rpt.estimateSeverity($vuln.unscoredSeverity) >= $junitFailOnCvss))
                    #set($skipped=$skipped + 1)
                    #set($failed=$failed - 1)
                #end
            #end
        #end
        
        #if($dependency.getVulnerabilities().size()==0 && $dependency.getSuppressedVulnerabilities().size()==0)
            
        #end
        #foreach($vuln in $dependency.getVulnerabilities(true))
            #if($dependency.getSoftwareIdentifiers().size()>0)
                #set($vulnerableName=$dependency.getSoftwareIdentifiers().toArray()[0])
            #elseif ($vuln.getSource().name().equals("NVD"))
                #set($vulnerableName=$vuln.matchedVulnerableSoftware.toString())
            #else
                #set($vulnerableName=$vuln.getVulnerableSoftware().toArray()[0])
            #end
            #if(! $vulnerableName)
                #set($vulnerableName="")
            #end
            
            #if($vuln.cvssV3 && $vuln.cvssV3.cvssData.baseScore >= $junitFailOnCvss)
                
            #elseif($vuln.cvssV2 && $vuln.cvssV2.cvssData.baseScore >= $junitFailOnCvss)
                
            #elseif($vuln.unscoredSeverity  && $rpt.estimateSeverity($vuln.unscoredSeverity) >= $junitFailOnCvss)
                
            #elseif($vuln.cvssV3 && $vuln.cvssV3.cvssData.baseScore < $junitFailOnCvss)
                
            #elseif($vuln.cvssV2 && $vuln.cvssV2.cvssData.baseScore < $junitFailOnCvss)
                
            #elseif($vuln.unscoredSeverity && $rpt.estimateSeverity($vuln.unscoredSeverity) < $junitFailOnCvss)
                
            #end
            #if($vuln.description)$enc.xml($vuln.description)#else#end
            #set($referencedProjects="")
            #set($projectReferenced=false)
            #foreach($ref in $dependency.projectReferences)
                #if($projectReferenced)
                    #set($referencedProjects="$referencedProjects, $ref")
                #else
                    #set($referencedProjects="$ref")
                    #set($projectReferenced=true)
                #end
            #end
            location: $enc.xml($dependency.FilePath), project-references: [ $enc.xml($referencedProjects) ]
        
        #end
        #foreach($vuln in $dependency.getSuppressedVulnerabilities())
            #if($dependency.getSoftwareIdentifiers().size()>0)
                #set($vulnerableName=$dependency.getSoftwareIdentifiers().toArray()[0])
            #elseif ($vuln.getSource().name().equals("NVD"))
                #set($vulnerableName=$vuln.matchedVulnerableSoftware.toString())
            #else
                #set($vulnerableName=$vuln.getVulnerableSoftware().toArray()[0])
            #end
            #if(! $vulnerableName)
                #set($vulnerableName="")
            #end
            #set($notes="")
            #foreach($id in $dependency.getSuppressedIdentifiers())
                #if ($id.notes)
                    #if($notes)
                        #set($notes=$notes + ". ")
                    #end
                     #set($notes=$notes + $id.notes.trim())
                #end
            #end
            #if ($vuln.notes)
                #if($notes)
                    #set($notes=$notes + ". ")
                #end
                #set($notes=$notes + $vuln.notes.trim())
            #end
        
            
            $enc.xml($vuln.description)
            location: $enc.xml($dependency.FilePath)
        
        #end
    
    #end




© 2015 - 2024 Weber Informatics LLC | Privacy Policy