您好,登錄后才能下訂單哦!
小編給大家分享一下Intercept有什么用,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
INTERCEPT是一套強(qiáng)大的代碼靜態(tài)分析審計(jì)策略,這套策略集簡單易用,占用空間小,可以通過快速且強(qiáng)大的多行掃描工具來掃描你的代碼庫。除此之外,廣大研究人員還可以將其作為數(shù)據(jù)采集器和檢查器,或把它當(dāng)作一款跨平臺(tái)的武器化ripgrep來使用。
代碼即策略;
細(xì)粒度正則策略;
多個(gè)執(zhí)行級別;
靜態(tài)分析,無守護(hù)進(jìn)程;
低占用空間,可自我更新的二進(jìn)制文件;
易于集成在任何CI/CD管道上;
聲明式策略,以降低復(fù)雜性;
無自定義策略語言;
“代碼即策略”的思想來源于策略的管理和自動(dòng)化實(shí)現(xiàn)這方面,通過將策略以YAML文件代碼的形式來呈現(xiàn),是已經(jīng)過驗(yàn)證的軟件開發(fā)最佳實(shí)踐,有助于研究人員實(shí)現(xiàn)版本控制、自動(dòng)測試和自動(dòng)部署。
1、攔截和分析命令行接口代碼;
2、YAML文件策略實(shí)施;
INTERCEPT會(huì)整合環(huán)境標(biāo)記、YAML策略和可選參數(shù)來生成一個(gè)全局配置文件,它可以遞歸掃描目標(biāo)路徑以查找違反策略的代碼,并生成人類可讀的詳細(xì)掃描及分析報(bào)告。
# Standard package (intercept + ripgrep) for individual platforms-- core-intercept-rg-*.zip# Cross Platform Full package (intercept + ripgrep)-- x-intercept.zip# Build package to build on all platforms (Development)-- setup-buildpack.zip# Package of the latest compatible release of ripgrep (doesn't include intercept)-- i-ripgrep-*.zip
首先,根據(jù)自己的平臺(tái)下載最新版本的INTERCEPT:
--- Darwincurl -fSL https://github.com/xfhg/intercept/releases/latest/download/intercept-darwin_amd64 -o intercept--- Linuxcurl -fSL https://github.com/xfhg/intercept/releases/latest/download/intercept-linux_amd64 -o intercept--- Windowscurl -fSL https://github.com/xfhg/intercept/releases/latest/download/intercept-windows_amd64 -o intercept.exe
獲取樣本進(jìn)行快速掃描:
curl -fSLO https://github.com/xfhg/intercept/releases/latest/download/_examples.zip
現(xiàn)在,我們需要分析的代碼已經(jīng)存儲(chǔ)在一個(gè)examples/文件夾中了,在開始之前,我們需要查看策略文件中的可選策略類型:
- scan : where we enforce breaking rules on matched patterns- collect : where we just collect matched patterns
我們給出的演示樣例將會(huì)做以下幾件事情:
1、掃描目標(biāo)代碼中是否存在私鑰:我們需要保證策略的fatal:true,并且不接受任何異常,即enforcement:true。設(shè)置環(huán)境:保證此策略將在所有環(huán)境上強(qiáng)制執(zhí)行。
2、掃描模塊是否來自兼容源而不是本地或git:我們需要保證策略的fatal:true,并且環(huán)境必須為PROD,即environment:prod。這個(gè)策略可以接受本地異常:enforcement:false。
3、收集模塊使用之外的terraform資源實(shí)例。
包含上述掃描策略和收集策略的策略文件如下(examples/policy/simple.yaml):
# This banner is shown on the start of the scanning report,# use it to point out important documentation/warnings/contacts
Banner:| Banner text here, drop documentation link or quick instructions on how to react to the reportRules:# This is the main policy block, all rules will be part of this array# This is a rule structure block# Each rule can have one or more patterns (regex)# The rule is triggered by any of the patterns listed#
# Essential settings :# id : ( must be unique )# type : ( scan | collect )# fatal : ( true | false )# enforcement : ( true | false )# environment : ( all | anystring)# All other settings are free TEXT to complement your final report- name: Private key committed in codeid: 1description: Private key committed to code version controlsolution:error: This violation immediately blocks your code deploymenttype: scanenforcement: trueenvironment: allfatal: true
patterns:- \s*(-----BEGIN PRIVATE KEY-----)- \s*(-----BEGIN RSA PRIVATE KEY-----)- \s*(-----BEGIN DSA PRIVATE KEY-----)- \s*(-----BEGIN EC PRIVATE KEY-----)- \s*(-----BEGIN OPENSSH PRIVATE KEY-----)- \s*(-----BEGIN PGP PRIVATE KEY BLOCK-----)
# Another scan rule- name: Compliant module sourceid: 5description: Modules should not be sourced locally nor from giterror: This breach blocks your deployment on production environmentstype: scansolution:environment: prodfatal: trueenforcement: falsepatterns:- source\s*.*\.git"- \s+source\s*=\s*"((?!https\:).)
# A different type of policy rule that just collects findings matched with the patterns listed- name: Collect sparse TF resources outside of modules.description: The following resources were detected outside of compliant module usagetype: collectpatterns:- (resource)\s*"(.*)"
# These are the messages displayed at the end of the report# Clean for no finds# Warning for at least one non-fatal find# Critical for at least one fatal findExitCritical: "Critical irregularities found in your code"ExitWarning: "Irregularities found in your code"ExitClean: "Clean report"
以上是“Intercept有什么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。