Code Security 시작하기

이 제품은 선택한 Datadog 사이트에서 지원되지 않습니다. ().

개요

Datadog Code Security는 개발부터 프로덕션까지 애플리케이션의 퍼스트 파티 코드와 오픈 소스 라이브러리를 보호하고 유지 관리하는 과정을 지원합니다.

이 기능은 소프트웨어 개발 수명 주기 전반에 걸쳐 코드를 보호하는 데 도움이 되는 도구 모음을 제공합니다.

  • **정적 코드 분석(SAST)**은 Static Application Security Testing 방법으로 리포지토리를 스캔하고, 퍼스트 파티 코드의 보안 및 품질 문제를 찾아내고, 이러한 문제가 프로덕션에 도달하지 않도록 수정 사항을 제안합니다.
  • **Software Composition Analysis(SCA)**은 리포지토리에 존재하면서 런타임 중 서비스에 영향을 미치는 취약한 오픈 소스 라이브러리를 탐지하여 소프트웨어 공급망 보호 및 유지 관리를 지원합니다.
  • **런타임 코드 분석(IAST)**은 인터랙티브 애플리케이션 보안 테스트 방법으로 런타임 중 서비스에 영향을 미치는 취약점을 탐지합니다.

Code Security 설정

오픈 소스 라이브러리

Datadog Software Composition Analysis는 라이브러리 취약점을 탐지하고, 코드베이스 및 실행 서비스 내의 종속성을 카탈로그화합니다.

정적/런타임 라이브러리 취약점 탐지를 설정하려면 Software Composition Analysis를 참조하세요.

퍼스트 파티 코드

Datadog으로 퍼스트 파티 코드를 보호하고 유지 관리하는 방법은 두 가지가 있습니다.


개발자 도구 통합

풀 리퀘스트 코멘트 활성화

Datadog은 자동 코드 리뷰어 기능을 수행하여 GitHub 풀 리퀘스트의 취약점과 품질 위반 사항을 표시할 수 있습니다. 자세한 내용은 GitHub Pull Requests를 참조하세요.

GitHub에서의 Datadog 코드 검토

IDE 통합 설치

Datadog IDE Plugins을 설치하여 코드 편집기에서 직접 Code Security 문제를 식별하세요. IDE에 따라 플러그인은 다음 기능을 지원합니다.

  • 정적 코드 분석(SAST)
  • Software Composition Analysis(SCA)
  • 런타임 코드 분석(IAST)
  • 시크릿 스캐닝(Secret Scanning)
  • 코드형 인프라(IaC) 스캐닝

설정 지침과 지원되는 기능에 대한 자세한 내용은 선택한 코드 편집기 설명서를 참조하세요.


리포지토리 설정 사용자 지정

Code Security 설정에서 PR 댓글을 활성화할 리포지토리를 관리하고, 리포지토리 전체/내부에 적용할 정적 코드 분석(SAST) 규칙의 구성 사용자 지정을 수행할 수 있습니다. Datadog에서 제공하는 모든 기본 규칙은 SAST 규칙을 참조하세요.

PR 게이트 설정

Datadog은 코드베이스에 도입되는 변경 사항과 관련해 보안 및 품질 표준을 유지 및 적용할 수 있도록 플랫폼 기능 PR 게이트를 제공합니다. 자세한 내용은 PR 게이트 설정을 참조하세요.

런타임 컨텍스트를 통해 취약점 우선순위 지정

Code Security은 정적 리포지토리 스캔과 런타임 서비스 탐지 과정에서 탐지된 모든 라이브러리 및 코드 취약점에 대한 취약점 중심 보기를 제공합니다.

취약점 탐색

라이브러리 취약점의 경우, 표의 각 행에는 라이브러리 버전에 영향을 미치는 특정 취약점이 표시됩니다. 정적/런타임 탐지 활성화 여부에 따라 Detected In 열에는 이 취약점의 영향을 받는 특정 리포지토리 및 서비스가 표시됩니다.

Datadog은 SCA의 단일 라이브러리 취약점을 보여주는 측면 패널에 취약점 세부 정보 외에도 다음 사항을 표시합니다.

  • 리포지토리 및 서비스 전반에서 관찰된 이 취약점에서 심각도가 가장 높은 인스턴스의 Severity breakdown 리포지토리 및 서비스에서 취약점이 탐지된 각 위치별로, Datadog은 환경적 요인을 기반으로 취약점의 기본 심각도 점수를 조정합니다. 자세한 내용은 Datadog Severity Score를 참조하세요.
  • 리포지토리에서 취약점이 탐지된 모든 인스턴스 관련 Repositories표 각 인스턴스에 대해 Datadog은 종속성이 ‘직접’ 또는 ‘전이적’으로 분류되는지 여부, 취약점의 수정 상태, 구체적인 수정 단계를 표시합니다.
  • 이 라이브러리 취약점의 영향을 받는 모든 실행 서비스 관련 Impacted Services표 라이브러리가 런타임에 로드되고 Datadog의 애플리케이션 SDK에서 탐지된 경우 라이브러리 취약점이 서비스에 영향을 미칩니다.

심각도 점수는 다음과 같습니다.

CVSS 점수질적 등급
0.0없음
0.1 - 3.9낮음
4.0 - 6.9중간
7.0 - 8.9높음
9.0 - 10.0위험

리포지토리별 결과 탐색

또한 Code Security는 정적 스캔 결과에 대한 리포지토리 중심 보기를 제공하여 스캔된 리포지토리의 브랜치 및 커밋 전반에 걸쳐 세분화된 필터링을 지원합니다.

Repositories 페이지에서 리포지토리를 클릭하면 브랜치(기본 브랜치가 먼저 표시됨) 및 커밋(최신 커밋부터 시작) 기준으로 검색 쿼리를 사용자 지정할 수 있는 상세 보기에 액세스할 수 있습니다.

다음과 같은 기본 제공 패싯을 사용하여 Code Quality 탭에서 잘못된 코딩 관행을 식별 및 해결하거나 Code Vulnerabilities 탭에서 보안 위험을 식별 및 해결하기 위한 검색 쿼리를 생성할 수 있습니다.

패싯 이름설명
결과 상태분석 완료 상태를 기준으로 결과를 필터링합니다.
규칙 ID발견 사항을 트리거한 특정 규칙입니다.
도구 이름분석에 기여한 도구를 확인합니다.
CWE(공통 약점 열거)인식된 취약점 카테고리를 기준으로 결과를 필터링합니다.
수정 사항 있음수정 사항이 제안된 문제를 필터링합니다.
결과 메시지발견 사항과 관련이 있는 간결한 설명이나 메시지를 포함합니다.
규칙 설명각 규칙의 근거를 포함합니다.
소스 파일문제가 탐지된 파일을 포함합니다.
도구 버전사용된 도구의 버전을 기준으로 결과를 필터링합니다.

결과 페이지에서 바로 제안된 수정 사항에 액세스하여 보안 취약점을 해결하거나 코드 품질 관행을 개선할 수 있습니다.

코드 분석 결과의 수정 사항 탭의 제안된 코드 수정 사항

다음과 같은 기본 제공 패싯을 사용하여 Library Vulnerabilities 탭에서 타사 라이브러리의 보안 위험을 식별 및 해결하거나 Library Catalog 탭에서 라이브러리 인벤토리를 검토하기 위한 검색 쿼리를 생성할 수 있습니다.

패싯 이름설명
종속성 이름이름을 기준으로 라이브러리를 식별합니다.
종속성 버전특정 라이브러리 버전을 기준으로 필터링합니다.
언어프로그래밍 언어를 기준으로 라이브러리를 정렬합니다.
점수종속성의 위험 또는 품질 점수를 정렬합니다.
심각도심각도 등급을 기준으로 취약점을 필터링합니다.
플랫폼라이브러리가 대상으로 하는 플랫폼을 기준으로 구분합니다.

취약점 보고서에 액세스하고 프로젝트에서 취약점이 발견된 소스 파일의 위치, 그리고 파일의 코드 소유자 관련 정보를 확인할 수 있습니다.

탐지된 라이브러리 취약점에서 GitHub 소스 코드로 직접 연결되는 링크

알리고, 수정하고, 보고하기

Code Security는 발견 사항에 대한 수정 작업을 추적 및 관리하기 위한 워크플로 설정을 지원합니다.

  • Slack, Jira, 이메일 등을 통해 팀에게 새로운 발견 사항을 알리는 알림 규칙을 설정합니다.
  • Code Security Summary 페이지에서 서비스 및 팀별로 취약점을 추적합니다.

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.

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:

  • a repository URL
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.

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.

추가 자료

추가적인 유용한 설명서, 링크 및 기사: