Amazon CodeGuru Security: Your Code Review SAST Tool (靜態應用程式安全測試)

Kuro Huang
資安工作者的學習之路
8 min readJun 20, 2024

以往使用 AWS 時候一直缺少合適的 SAST 工具,而 Code Guru 有公開預覽版的 SAST (靜態應用程式安全測試) 功能,在沒有額外使用其他開源或是商業軟體的工具下,可以考慮測試看看是否符合需求,我想正式版發布後,未來應該會加入更多實用的功能。

https://aws.amazon.com/tw/codeguru/

由於公開預覽版關係,目前使用都是免費 !

Amazon CodeGuru Security 是一種靜態應用程式安全測試 (SAST) 工具,結合了機器學習 (ML) 和自動推理功能,以識別程式碼中的漏洞、提供如何修正已識別漏洞的建議,以及追蹤漏洞狀態直到關閉漏洞為止。

原本的 Amazon CodeGuru Profiler 可透過協助開發人員了解應用程式執行期的行為模式來讓他們尋找最昂貴的程式碼行,同時可找出程式碼無效率處並加以移除,提升效能,並且大幅降低運算成本。

支援的程式語言:

CodeGuru Security currently supports scanning Java, Python, JavaScript, TypeScript, C#, CloudFormation, Terraform, Go, and Ruby.

實作步驟

搜尋 Code Guru 找到 左邊的 Security

選擇左方的 Scans,找到右下角的 Create New Scan

上傳原始碼,這邊範例是打包成 zip 後上傳

如果你沒有原始碼可以掃,可以去 GitHub 找 Sample Code 上傳,例如:

掃描的結果會顯示在 Dashbaord

左方選單列的Finding可以列出所有的弱點

我挑一個弱點,例如 CWE-798,259 — Hardcoded credentials 來檢視

會有修復建議,並可以下載 Patch資料

對於有弱點的原始碼會給予修復建議

GitHub 與 AWS CodePipeline 整合

CodeGuru Security 能夠整合到 GitHub 與CodePipeline中。設定完成後,可以執行掃描,然後在 GitHub 上的程式碼掃描部分和結果頁面上查看結果。CodeGuru Security 將對每個Pipeline 執行掃描。

如果有修復完成,Dashboard 有很陽春的 Tracking 的功能能做統計分析

官方參考文件:

CodeGuru Security different than other AWS security services?

Amazon CodeGuru Security, which identifies security vulnerabilities in your application resources, adds to the AWS collection of security services.

  • Amazon Inspector is a vulnerability management service that continuously scans your AWS workloads for software vulnerabilities and unintended network exposure. You can run scans on your AWS Lambda functions that are powered by CodeGuru Security.
  • Amazon GuardDuty monitors network traffic for threat patterns such as unusual data access in Amazon Simple Storage Service or API calls from known malicious IP addresses.
  • Amazon Macie scans data storage locations for unencrypted data such as personally identifiable information (PII) and financial data.
  • AWS Security Hub collects security data from across AWS accounts, services, and supported third-party products and helps you analyze your security trends and identify the highest priority security issues.
  • Amazon CodeGuru Reviewer scans your code repositories for code defects related to quality, maintainability, and security and provides recommendations for how to address them. CodeGuru Security is a rearchitected and redesigned version of CodeGuru Reviewer. CodeGuru Security uses hundreds of new security detectors to scan your code, in addition to the detectors that were developed for CodeGuru Reviewer.

心得:

如果開源的工具部署上很麻煩,商業版的太昂貴,我想之後定價應該不會比商業軟體還高,或許可以考慮 Code Guru 的 SAST 服務,更建議整合到CI/CD 的流程之中 !

本篇如有錯誤請不吝寫信跟我說!

Cloud Computing

我想把各種經驗寫出來做分享教學,希望把社群的分享風氣帶出來給大家。並期望之後有人也可以寫出不同的心得文,如果是自修同學對於申請考試和準備上有任何問題,可以透過 LinkedIn 交朋友與 Facebook 來聯絡我,能力範圍內盡量幫你解決(或是你想認識我出來喝杯咖啡也歡迎,我很喜歡多認識業界的朋友們交流,也真的不少人找我聊聊過了!)。

--

--

Kuro Huang
資安工作者的學習之路

對教育充滿期待的資安從業者,現任ISC2台北分會理監事會成員,喜歡用專業興趣交朋友建立友誼。曾擔任資安管理師與四大會計師事務所資安顧問,希望對資安社群盡一點心力,並期望自己與身旁的人能有所進步,歡迎喝咖啡聊資安。希望保持著定期參與資安社群活動。個人介紹網站https://portaly.cc/kurohuang