1荠诬、簡(jiǎn)介
OWASP是開源的凭豪、非盈利的全球性安全組織焙蹭,致力于應(yīng)用軟件的安全研究。OWASP的使命是使應(yīng)用軟件更加安全嫂伞,使企業(yè)和組織能夠?qū)?yīng)用安全風(fēng)險(xiǎn)作出更清晰的決策孔厉。OWASP的研究成果被美拯钻、歐、日等多個(gè)國家的32個(gè)政府與行業(yè)組織機(jī)構(gòu)引用成為近百項(xiàng)國際法規(guī)撰豺、標(biāo)準(zhǔn)粪般、指南和行業(yè)行為準(zhǔn)則。
Dependency-Check是OWASP(Open Web Application Security Project)的一個(gè)實(shí)用開源程序污桦,用于識(shí)別項(xiàng)目依賴項(xiàng)并檢查是否存在任何已知的亩歹,公開披露的漏洞。目前凡橱,已支持Java小作、.NET、Ruby稼钩、PHP顾稀、Node.js、Python等語言編寫的程序坝撑,并為C/C++構(gòu)建系統(tǒng)(autoconf和cmake)提供了有限的支持静秆。而且該工具還是OWASP Top 10的解決方案的一部分。
Dependency-Check支持面廣(支持多種語言)绍载、可集成性強(qiáng)诡宗,作為一款開源工具滔蝉,在多年來的發(fā)展中已經(jīng)支持和許多主流的軟件進(jìn)行集成击儡,比如:命令行、Ant蝠引、Maven阳谍、Gradle、Jenkins螃概、Sonar等矫夯;具備使用方便,落地簡(jiǎn)單等優(yōu)勢(shì)吊洼。
OWASP dependency-check is an open source solution the OWASP Top 10 2013 entry: A9 - Using Components with Known Vulnerabilities. Dependency-check can currently be used to scan Java and .NET applications to identify the use of known vulnerable components. Experimental analyzers for Python, Ruby, PHP (composer), and Node.js applications; these are experimental due to the possible false positive and false negative rates. To use the experimental analyzers they must be specifically enabled via the appropriate experimentalconfiguration. In addition, dependency-check has experimental analyzers that can be used to scan some C/C++ source code, including OpenSSL source code and projects that use Autoconf or CMake.
2训貌、實(shí)現(xiàn)原理
依賴性檢查可用于掃描應(yīng)用程序(及其依賴庫),執(zhí)行檢查時(shí)會(huì)將 Common Platform Enumeration (CPE)美帝國家漏洞數(shù)據(jù)庫及NPM Public Advisories庫下載到本地冒窍,再通過核心引擎中的一系列分析器檢查項(xiàng)目依賴性递沪,收集有關(guān)依賴項(xiàng)的信息,然后根據(jù)收集的依賴項(xiàng)信息與本地的CPE&NPM庫數(shù)據(jù)進(jìn)行對(duì)比综液,如果檢查發(fā)現(xiàn)掃描的組件存在已知的易受攻擊的漏洞則標(biāo)識(shí)款慨,最后生成報(bào)告進(jìn)行展示。
3谬莹、以Jenkins插件形式運(yùn)行
1)安裝OWASP Dependency-Check插件
2)全局工具配置下配置dependency插件路徑及版本(可單獨(dú)下載)
3)pipeline流水線中執(zhí)行dependency-check安全掃描
方法1:
dependencyCheck additionalArguments: '', odcInstallation: 'dependency-check’
//可增加參數(shù)具體參數(shù)參考https://bloodzer0.github.io/ossa/other-security-branch/devsecops/sdc/
dependencyCheckPublisher pattern: 'dependency-check-report.xml'
方法2:
sh '/data/jenkins/tools/org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstallation/dependency-check/bin/dependency-check.sh -s PWD/dependency-check-report.xml’ //生成xml報(bào)告
sh '/data/jenkins/tools/org.jenkinsci.plugins.DependencyCheck.tools.DependencyCheckInstallation/dependency-check/bin/dependency-check.sh -s PWD/dependency-check-report.html’ //生成html報(bào)告
結(jié)果查看:
4檩奠、以Sonarqube插件形式運(yùn)行
1)github上下載插件jar包桩了,地址:
https://github.com/dependency-check/dependency-check-sonar-plugin(注意插件版本與soanr版本的兼容關(guān)系)
2)上傳到%SONAR_HOME%/extensions/plugins目錄下
3)重啟sonar
4)驗(yàn)證查看
5)jenkins流水線中執(zhí)行sonar掃描
和本次內(nèi)容無關(guān),不做贅述
6)結(jié)果查看
5埠戳、搭建本地NVD Mirror庫
實(shí)際企業(yè)中內(nèi)網(wǎng)環(huán)境可能CI服務(wù)器不會(huì)開放對(duì)外網(wǎng)的訪問權(quán)限井誉,故需要搭建一個(gè)本地的NVDMirror
具體搭建步驟參考:
https://jeremylong.github.io/DependencyCheck/data/mirrornvd.html
實(shí)際操作步驟如下:
主要需要變更兩個(gè)東西,一個(gè)是nvd庫整胃,還有一個(gè)是jsrepository.json
1送悔、搭建nvd庫:
官方提供了對(duì)應(yīng)jar包來作為mirror的服務(wù),具體github地址:
https://github.com/stevespringett/nist-data-mirror/
1)下載release jar包爪模,如需定制請(qǐng)自行改寫代碼
2)服務(wù)器上執(zhí)行java -jar nist-data-mirror.jar <mirror-directory>欠啤,改命令會(huì)把2002-最近一年的所有*.json.gz 和 *.meta 文件下載下來
3)搭建本地apache服務(wù)
使用官方docker鏡像直接啟動(dòng)即可,具體命令:
docker run -dit --name mirror -p 30006:80 --mount type=bind,source=/data/mirror-repo,target=/usr/local/apache2/htdocs sspringett/nvdmirror:latest
其中source為宿主機(jī)目錄
搭建成功后訪問:
4屋灌、定時(shí)任務(wù)更新jsreponsitory.json
5洁段、搭建成功后執(zhí)行dependency check命令行中添加參數(shù)應(yīng)用mirror地址即可
以pipeline為例:
dependencyCheck additionalArguments: '--cveUrlModified http://x.x.x.x:8080/nvdcve-1.1-2019.json.gz --cveUrlBase http://x.x.x.x:8080/nvdcve-1.1-2019.json.gz ', odcInstallation: 'dependency-check'
參考鏈接
https://bloodzer0.github.io/ossa/other-security-branch/devsecops/sdc/