2016-12-05 123 views
2
我使用下面的build.gradle配置

運行HP Fortify的掃描:HP Fortify的使用掃描搖籃

// Fortify configuration 
configurations { 
    fortify { extendsFrom compile } 
} 

// pull in the fortify libs for the new configuration 
dependencies { 
    fortify 'com.fortify:sourceanalyzer:3.90' 
} 

task fortifyReport(dependsOn: compileJava) << { 
    ant.properties['build.compiler']='com.fortify.dev.ant.SCACompiler' 
    ant.typedef(name: 'sca', classname: 'com.fortify.dev.ant.SourceanalyzerTask', classpath: configurations.fortify.asPath) 
    ant.sca(jdk:"1.7", 
    debug:true , 
    verbose:true , 
    failonerror:true , 
    scan:true , 
    logFile:file("$buildDir/reports/fortify/Fortify.log"), 
    resultsFile:file("$buildDir/reports/fortify/${project.name}.fpr") 
){ 
    fileset(dir:'src/main') { 
     include(name:'**/*.java') 
    } 
    } 
} 

但在執行的時候我得到了下面:

* What went wrong: 
Execution failed for task ':fortifyReport'. 
> Could not resolve all dependencies for configuration 'detachedConfiguration157'. 
> Could not find com.fortify:sourceanalyzer:3.90. 

我不是能夠找到源分析器:互聯網上的3.90插件。請告知如何解決此問題。

回答

5

從SCA 16.20開始,現在支持Gradle集成。

從官方文檔HPE Security Fortify Static Code Analyzer User Guide - 第13章:構建集成

搖籃集成

可以轉換了與建搖籃無需build.gradle文件的任何修改的項目。當構建運行時,Fortify靜態代碼分析器將在編譯源代碼文件時對它們進行翻譯。有關支持Gradle集成的平臺和語言,請參閱「HPE Security Fortify軟件系統要求」文檔。項目中使用不受支持的語言進行Gradle集成的任何文件都不會被翻譯(沒有錯誤報告)。因此這些文件不會被分析,任何現有的潛在漏洞都不會被發現。

要將Fortify靜態代碼分析器集成到您的Gradle版本中,請確保sourceanalyzer可執行文件位於系統PATH中。在前面加上了sourceanalyzer命令的搖籃命令行,如下所示:

sourceanalyzer -b <build_id> <sca_options> gradle [<gradle_options>] <gradle tasks> 

例如:

sourceanalyzer -b buildxyz gradle clean build 
sourceanalyzer -b buildxyz gradle --info assemble 

注:如果使用Fortify的靜態代碼分析器-verbose選項,則還必須包括-gradle選項。例如:

sourceanalyzer -b buildxyz -gradle -verbose gradle assemble