This product is not supported for your selected
Datadog site. (
).
概要
Datadog Code Security は、自社コードとオープンソースライブラリを開発から本番運用まで安全に保ち、メンテナンスするのに役立ちます。
ソフトウェア開発ライフサイクル全体にわたってコードのセキュリティを確保するために、以下のツール群を提供します:
- Static Code Analysis (SAST) は、Static Application Security Testing 方式を用いてリポジトリをスキャンし、自社コードにおけるセキュリティや品質上の問題を検出します。問題が本番環境に到達する前に修正案を提示します。
- Software Composition Analysis (SCA) は、リポジトリ内に存在し、実行時にサービスに影響を与える脆弱なオープンソースライブラリを検出し、ソフトウェアサプライチェーンの安全性を維持するのに役立ちます。
- Runtime Code Analysis (IAST) は、インタラクティブアプリケーションセキュリティテスト方式を用いて、稼働中のサービスに影響を与える脆弱性を検出します。
Code Security のセットアップ
オープンソースライブラリ
Datadog Software Composition Analysis は、コードベースや実行中のサービスで使用されているライブラリの脆弱性を検出し、依存関係をカタログ化します。
静的および/または実行時のライブラリ脆弱性検出を設定するには、Software Composition Analysis を参照してください。
自社コード
Datadog を使用して自社コードを保護して維持するには、2 つの方法があります。
Datadog は自動コードレビュアとして動作し、GitHub のプルリクエストで脆弱性や品質違反をフラグ付けできます。詳細については、GitHub プルリクエストを参照してください。
IDE インテグレーションをインストールする
Datadog IDE プラグインをインストールすると、コードエディター上で直接 Code Security の問題を特定できるようになります。IDE に応じて、プラグインは以下の機能をサポートしています。
- Static Code Analysis (SAST)
- Software Composition Analysis (SCA)
- Runtime Code Analysis (IAST)
- Secret Scanning
- Infrastructure as Code (IaC) スキャン
セットアップ手順やサポートされている機能の詳細については、使用するコードエディターのドキュメントを参照してください。
リポジトリの設定をカスタマイズする
Code Security Settings では、どのリポジトリで PR コメントを有効にするかの管理や、リポジトリ全体またはリポジトリごとに適用する Static Code Analysis (SAST) ルールの構成をカスタマイズできます。Datadog が提供するデフォルトのルール一覧については、SAST Rules を参照してください。
PR Gates をセットアップする
Datadog では、プラットフォーム機能として PR Gates を提供しており、コードベースに対する変更においてセキュリティと品質の基準を維持・適用できます。詳しくは、PR Gate のセットアップを参照してください。
ランタイムコンテキストを活用して脆弱性に優先順位を付ける
Code Security は、静的なリポジトリスキャンおよび実行時のサービス検出の両方から検出されたライブラリとコードの脆弱性を、脆弱性中心のビューで提供します。
脆弱性を調査する
ライブラリの脆弱性については、テーブルの各行がライブラリのバージョンに影響を与える特定の脆弱性を表しています。Detected In 列には、静的検出またはランタイム検出のどちらが有効になっているかに応じて、その脆弱性の影響を受ける特定のリポジトリやサービスが表示されます。
SCA の単一ライブラリ脆弱性を示すサイドパネルには、脆弱性の詳細に加えて、Datadog による以下の情報が示されます。
- リポジトリおよびサービス全体で確認された、この脆弱性の最も深刻なインスタンスの Severity breakdown です。リポジトリやサービス内で脆弱性が検出された場所ごとに、Datadog は環境要因に基づいて脆弱性の基本的な重大度スコアを調整します。詳細については、Datadog 重大度スコアを参照してください。
- リポジトリ内で脆弱性が検出されたすべてのインスタンスを一覧表示する Repositories テーブル。各インスタンスについて、Datadog は、依存関係が直接かトランジティブか、脆弱性の修正状況、具体的な修正手順などを表示します。
- このライブラリの脆弱性の影響を受ける、稼働中のすべてのサービスを示す Impacted Services テーブル。ランタイム時にライブラリが読み込まれ、Datadog のアプリケーション SDK によって検出された場合、そのサービスはライブラリの脆弱性の影響を受けているとみなされます。
重大度は、以下の基準でスコアが決定されます。
| CVSS スコア | 定性的評価 |
|---|
0.0 | なし |
0.1 - 3.9 | Low |
4.0 - 6.9 | Medium |
7.0 - 8.9 | High |
9.0 - 10.0 | Critical |
リポジトリごとの結果を調査する
Code Security では、静的スキャンの結果をリポジトリ中心のビューでも提供しており、スキャン済みリポジトリのすべてのブランチやコミットを詳細にフィルタリングできます。
Repositories ページでリポジトリをクリックすると、より詳細な表示にアクセスでき、デフォルトブランチ (最初に表示される) や最新から始まるコミットなどで検索クエリをカスタマイズできます。
以下のすぐに使えるファセットを使用して、[Code Quality] タブで劣悪なコーディングプラクティスを特定および解決するための検索クエリ、または Code Vulnerabilities タブでセキュリティリスクを特定および解決するための検索クエリを作成できます。
| ファセット名 | 説明 |
|---|
| Result Status | 分析の完了ステータスに基づいて結果をフィルタリングします。 |
| Rule ID | 発見内容のトリガーとなった特定のルール。 |
| Tool Name | どのツールが分析に貢献したかを判断します。 |
| CWE (共通脆弱性列挙) | 認識された脆弱性カテゴリーによって発見内容をフィルタリングします。 |
| Has Fixes | 修正提案が利用可能な問題をフィルタリングします。 |
| Result Message | 発見内容に関連する簡潔な説明やメッセージを含みます。 |
| Rule Description | 各ルールの背後にある根拠を含みます。 |
| Source File | 問題が検出されたファイルが含まれます。 |
| Tool Version | 使用したツールのバージョンによって結果をフィルタリングします。 |
検出結果から直接、提案された修正にアクセスして、セキュリティ脆弱性への対応やコード品質の向上を図ることができます。
以下のすぐに使えるファセットを使用して、[Library Vulnerabilities] タブでサードパーティライブラリのセキュリティリスクを特定して対処するための検索クエリを作成したり、[Library Catalog] タブでライブラリのインベントリを確認したりできます。
| ファセット名 | 説明 |
|---|
| Dependency Name | ライブラリを名前で識別します。 |
| Dependency Version | ライブラリの特定のバージョンでフィルタリングします。 |
| Language | ライブラリをプログラミング言語で並べ替えます。 |
| Score | 依存関係のリスクスコアまたは品質スコアを並べ替えます。 |
| Severity | 重大度評価に基づいて脆弱性をフィルタリングします。 |
| Platform | ライブラリを対象プラットフォームで区別します。 |
脆弱性レポートにアクセスし、ファイルのコード所有者に関する情報とともに、プロジェクト内で脆弱性が発見されたソースファイルを検索できます。
Code Security を使用すると、検出結果の追跡や修正対応の管理を行うためのワークフローを設定できます:
- 通知ルールを設定し、Slack、Jira、E メールなどを介してチームに新たな検出内容を通知します
- Code Security Summary ページでサービスやチームごとに脆弱性を追跡します
Datadog のサービスとチームに検出結果をリンクする
Datadog associates code and library scan results with Datadog services and teams to automatically route findings to the appropriate owners. This enables service-level visibility, ownership-based workflows, and faster remediation.
To determine the service where a vulnerability belongs, Datadog evaluates several mapping mechanisms in the order listed in this section.
Each vulnerability is mapped with one method only: if a mapping mechanism succeeds for a particular finding, Datadog does not attempt the remaining mechanisms for that finding.
Using service definitions that include code locations in the Software Catalog is the only way to explicitly control how static findings are mapped to services. The additional mechanisms described below, such as Error Tracking usage patterns and naming-based inference, are not user-configurable and depend on existing data from other Datadog products. Consequently, these mechanisms might not provide consistent mappings for organizations not using these products.
Mapping using the Software Catalog (recommended)
Services in the Software Catalog identify their codebase content using the codeLocations field. This field is available in the Software Catalog [schema version v3][101] and allows a service to specify:
apiVersion: v3
kind: service
metadata:
name: billing-service
owner: billing-team
datadog:
codeLocations:
- repositoryURL: https://github.com/org/myrepo.git
- one or more code paths inside that repository
apiVersion: v3
kind: service
metadata:
name: billing-service
owner: billing-team
datadog:
codeLocations:
- repositoryURL: https://github.com/org/myrepo.git
paths:
- path/to/service/code/**
If you want all the files in a repository to be associated with a service, you can use the glob ** as follows:
apiVersion: v3
kind: service
metadata:
name: billing-service
owner: billing-team
datadog:
codeLocations:
- repositoryURL: https://github.com/org/myrepo.git
paths:
- path/to/service/code/**
- repositoryURL: https://github.com/org/billing-service.git
paths:
- "**"
The schema for this field is described in the [Software Catalog entity model][102].
Datadog goes through all Software Catalog definitions and checks whether the finding’s file path matches. For a finding to be mapped to a service through codeLocations, it must contain a file path.
Some findings might not contain a file path. In those cases, Datadog cannot evaluate codeLocations for that finding, and this mechanism is skipped.
Services defined with a Software Catalog schema v2.x do not support codeLocations. Existing definitions can be upgraded to the v3 schema in the Software Catalog. After migration is completed, changes might take up to 24 hours to apply to findings. If you are unable to upgrade to v3, Datadog falls back to alternative linking techniques (described below). These rely on less precise heuristics, so accuracy might vary depending on the Code Security product and your use of other Datadog features.
Example (v3 schema)
apiVersion: v3
kind: service
metadata:
name: billing-service
owner: billing-team
datadog:
codeLocations:
- repositoryURL: https://github.com/org/myrepo.git
paths:
- path/to/service/code/**
- repositoryURL: https://github.com/org/billing-service.git
paths:
- "**"
SAST finding
If a vulnerability appeared in github.com/org/myrepo at /src/billing/models/payment.py, then using the codeLocations for billing-service Datadog would add billing-service as an owning service. If your service defines an owner (see above), then Datadog links that team to the finding too. In this case, the finding would be linked to the billing-team.
SCA finding
If a library was declared in github.com/org/myrepo at /go.mod, then Datadog would not match it to billing-service.
Instead, if it was declared in github.com/org/billing-service at /go.mod, then Datadog would match it to billing-service due to the “**” catch-all glob. Consequently, Datadog would link the finding to the billing-team.
Datadog attempts to map a single finding to as many services as possible. If no matches are found, Datadog continues onto the next linking method.
When the Software Catalog cannot determine the service
If the Software Catalog does not provide a match, either because the finding’s file path does not match any codeLocations, or because the service uses the v2.x schema, Datadog evaluates whether Error Tracking can identify the service associated with the code. Datadog uses only the last 30 days of Error Tracking data due to product [data-retention limits][103].
When Error Tracking processes stack traces, the traces often include file paths.
For example, if an error occurs in: /foo/bar/baz.py, Datadog inspects the directory: /foo/bar. Datadog then checks whether the finding’s file path resides under that directory.
If the finding file is under the same directory:
- Datadog treats this as a strong indication that the vulnerability belongs to the same service.
- The finding inherits the service and team associated with that error in Error Tracking.
If this mapping succeeds, Datadog stops here.
Service inference from file paths or repository names
When neither of the above strategies can determine the service, Datadog inspects naming patterns in the repository and file paths.
Datadog evaluates whether:
- The file path contains identifiers matching a known service.
- The repository name corresponds to a service name.
When using the finding’s file path, Datadog performs a reverse search on each path segment until it finds a matching service or exhausts all options.
For example, if a finding occurs in github.com/org/checkout-service at /foo/bar/baz/main.go, Datadog takes the last path segment, main, and sees if any Software Catalog service uses that name. If there is a match, the finding is attributed to that service. If not, the process continues with baz, then bar, and so on.
When all options have been tried, Datadog checks whether the repository name, checkout-service, matches a Software Catalog service name. If no match is found, Datadog is unsuccessful at linking your finding using Software Catalog.
This mechanism ensures that findings receive meaningful service attribution when no explicit metadata exists.
Link findings to teams through Code Owners
If Datadog is able to link your finding to a service using the above strategies, then the team that owns that service (if defined) is associated with that finding automatically.
Regardless of whether Datadog successfully links a finding to a service (and a Datadog team), Datadog uses the CODEOWNERS information from your finding’s repository to link Datadog and GitHub teams to your findings.
You must accurately map your Git provider teams to your
Datadog Teams for team attribution to function properly.
参考資料