點擊關注公眾號,實用技術文章及時了解


鑽石舞台 發表在 痞客邦 留言(0) 人氣()

關於Reposaur

Reposaur是一款針對開發平台和開源項目的合規性檢測工具,在該工具的幫助下,廣大研究人員可以直接使用預定義或自定義的策略來對目標項目或代碼進行審核跟驗證,並對數據和配置進行合規性檢測。因此,Reposaur能夠確保代碼庫中每一位代碼貢獻者都能夠符合特定的安全標準或最佳實踐準則。
當前版本的Reposaur支持GitHub和GitLab,隨後將添加對Gitea的支持。
功能介紹
1、使用了Rego策略語言實現自定義策略;
2、提供了簡單、易於使用的命令行接口;
3、支持使用簡單的SDK進行擴展(Go編寫);
4、報告遵循標準的SARIF格式,便於與不同系統集成;
5、可以對策略進行單元測試,確保它們按預期工作;
6、支持與主流開發平台集成;
7、支持使用SDK輕鬆集成新平台;
工具安裝源碼獲取
廣大研究人員可以使用下列命令將該項目源碼克隆至本地:
git clone https://github.com/reposaur/reposaur.git
Homebrew安裝
$ brew install reposaur/tap/reposaur
DEB、ROM和APK包
廣大研究人員可以直接從該項目的【Releases頁面】下載.deb、.rmp或.apk包,然後使用特定的工具來安裝它們。
Go安裝
$ go install github.com/reposaur/reposaur/cmd/rsr@latest
腳本安裝
$ curl -o- https://raw.githubusercontent.com/reposaur/reposaur/main/install.sh | bash
工具使用編寫自定義策略
策略可以通過多個模塊(文件)進行組合,必須符合同一命名空間(包),每一個模塊可以定義多個規則。
下面的演示中,我們將通過一個github.repository命名空間下的單一模塊進行演示。命名空間非常重要,因為Reposaur需要通過它來判斷要對目標數據執行哪種規則:
package github.repository
接下來就要定義一個規則來獲取默認的分支保護數據了,GitHub返回的數據不包含這部分內容,因此我們還需要添加額外的請求來獲取:
protection = data {resp := github.request("GET /repos/{owner}/{repo}/branches/{branch}/protection", {"owner": input.owner.login,"repo": input.name,"branch": input.default_branch,})resp.status == 200data := resp.body}
結果如下所示:
violation_default_branch_not_protected {not protection}
接下來,我們可以通過下列規則來檢測默認分支是否啟用了其他保護策略:
violation_default_branch_pull_not_required {not protection.required_pull_request_reviews}violation_default_branch_approvals_not_required {not protection.required_pull_request_reviews.required_approving_review_count}violation_default_branch_approvals_not_required {protection.required_pull_request_reviews.required_approving_review_count < 1}violation_default_branch_code_owners_reviews_not_required {not protection.required_pull_request_reviews.require_code_owner_reviews}violation_default_branch_status_checks_not_required {not protection.required_status_checks}violation_default_branch_up_to_date_not_required {not protection.required_status_checks.strict}
整合所有策略之後,我們的自定義策略將如下所示:
package github.repositoryprotection = data {resp := github.request("GET /repos/{owner}/{repo}/branches/{branch}/protection", {"owner": input.owner.login,"repo": input.name,"branch": input.default_branch,})resp.status == 200data := resp.body}violation_default_branch_not_protected {not protection}violation_default_branch_pull_not_required {not protection.required_pull_request_reviews}violation_default_branch_approvals_not_required {not protection.required_pull_request_reviews.required_approving_review_count}violation_default_branch_approvals_not_required {protection.required_pull_request_reviews.required_approving_review_count < 1}violation_default_branch_code_owners_reviews_not_required {not protection.required_pull_request_reviews.require_code_owner_reviews}violation_default_branch_status_checks_not_required {not protection.required_status_checks}violation_default_branch_up_to_date_not_required {not protection.required_status_checks.strict}
策略執行
現在,我們就可以使用自定義策略來對真實場景中的數據進行合規性檢測了。
下列命令可以單獨對一個項目代碼庫執行檢測:
$ gh api /repos/reposaur/test | rsr exec
或者,也可以對一個組織中的所有代碼庫進行檢測:
$ gh api /orgs/reposaur | rsr exec
SARIF報告生成
工具執行完畢後,將生成如下所示的SARIF報告:
{ "version": "2.1.0", "$schema": "https://json.schemastore.org/sarif-2.1.0-rtm.5.json", "runs": [ { "tool": { "driver": { "informationUri": "https://github.com/reposaur/reposaur", "name": "Reposaur", "rules": [ { "id": "github.repository/note/not_innersource_ready", "name": "Repository is not InnerSource ready", "shortDescription": { "text": "Repository is not InnerSource ready" }, "fullDescription": { "text": "InnerSource repositories (that have the `innersource` topic) must have all of\nthese files: `README.md`, `CONTRIBUTING.md` and `LICENSE`, and at least one\nof them is missing.", "markdown": "InnerSource repositories (that have the `innersource` topic) must have all of\nthese files: `README.md`, `CONTRIBUTING.md` and `LICENSE`, and at least one\nof them is missing." }, "help": { "markdown": "InnerSource repositories (that have the `innersource` topic) must have all of\nthese files: `README.md`, `CONTRIBUTING.md` and `LICENSE`, and at least one\nof them is missing." }, "properties": { "security-severity": "1" } } ] } }, "results": [ { "ruleId": "github.repository/note/not_innersource_ready", "ruleIndex": 0, "level": "note", "message": { "text": "Repository is not InnerSource ready" }, "locations": [ { "physicalLocation": { "artifactLocation": { "uri": "." } } } ] } ], "properties": { "default_branch": "main", "owner": "reposaur", "repo": "test" } } ]}
許可證協議
本項目的開發與發布遵循MIT開源許可證協議。
項目地址
https://github.com/reposaur/reposaur
參考資料
https://www.openpolicyagent.org/docs/latest/policy-language/
https://docs.reposaur.com/guides/writing-your-first-policy


鑽石舞台 發表在 痞客邦 留言(0) 人氣()

這幾天飛友圈的熱議話題:A380回來了!

根據Flightradar24發布對比圖,去年和今年兩個6月1日的北京時間2點時正在飛行的A380數量

鑽石舞台 發表在 痞客邦 留言(0) 人氣()

據央視新聞報道,俄羅斯總統普京當地時間6月3日表示,有人試圖將全球糧食市場的現狀的責任推卸到俄羅斯身上,但這是在嫁禍於人。國際糧食短缺問題早在俄羅斯在烏克蘭開展特別軍事行動之前就已發生。

普京表示,俄羅斯不會阻礙烏克蘭的糧食出口。當烏克蘭清理其港口時,俄羅斯不會從海上進行任何攻擊。

鑽石舞台 發表在 痞客邦 留言(0) 人氣()

點擊上方藍字關注我們

明月別枝驚鵲,清風半夜鳴蟬。Hi,小夥伴們,好久不見!因各種原因有一段時間沒有更新維護了,但依舊珍惜通過這個平台與各位交流和分享,有時間會繼續給大家更新實用內容。今天突然更新這篇文目的也很簡單,只是個人看不慣最近在一些技術群里通過收費來給大家提供修改後的銳捷鏡像來支持在PNETlab運行,而且只提供鏡像不提供方法,對於這種行為不評價對與錯,只想借用一句古話「授人以魚,不如授人以漁」。


鑽石舞台 發表在 痞客邦 留言(0) 人氣()

因微信公眾號調整了推送規則,如果您想繼續接收本公眾號的內容,請將「建築結構」公眾號設為星標,並多點文尾的「在看」和「贊」。
星標設置:進入公眾號主頁,點擊右上角「. . .」,點擊「設為星標」,公眾號名旁就會出現黃色五角星(Android 和 iOS 用戶操作相同)

鑽石舞台 發表在 痞客邦 留言(0) 人氣()

因微信公眾號調整了推送規則,如果您想繼續接收本公眾號的內容,請將「建築結構」公眾號設為星標,並多點文尾的「在看」和「贊」。
星標設置:進入公眾號主頁,點擊右上角「. . .」,點擊「設為星標」,公眾號名旁就會出現黃色五角星(Android 和 iOS 用戶操作相同)

鑽石舞台 發表在 痞客邦 留言(0) 人氣()

鑽石舞台 發表在 痞客邦 留言(0) 人氣()

鑽石舞台 發表在 痞客邦 留言(0) 人氣()

上海終於解封,對於有些小夥伴,壓抑已久的資產配置欲望亟需得到釋放。

鑽石舞台 發表在 痞客邦 留言(0) 人氣()