기본적으로 Datadog Static Code Analysis(SAST)는 각 프로그래밍 언어에 대하여 Datadog의 기본 규칙 세트를 사용해 리포지토리를 스캔합니다. 심각도, 경로 및 기타 파라미터와 함께 실행할 규칙 세트와 규칙을 사용자 지정할 수 있습니다. 이러한 설정은 Datadog 또는 code-security.datadog.yaml 파일의 Code Security 구성에서 sast 키 아래에 구성하세요.
AI 네이티브 SAST는 다른 정적 코드 분석 규칙과 동일한 sast 구성을 사용하며 Datadog 호스팅 스캔에서만 사용할 수 있습니다. sast 구성은 실행할 AI 네이티브 SAST 규칙 세트를 제어하지만, Datadog 호스팅 스캔을 활성화하거나 AI 네이티브 SAST에 대한 액세스 권한을 부여하지는 않습니다.
AI 네이티브 SAST가 활성화되면 리포지토리에서 감지된 지원 언어에 대해 기본 규칙 세트가 실행됩니다. AI 네이티브 SAST 규칙 세트 이름은 <language>-ai_sast 형식을 사용합니다.
언어
규칙 세트
C#
csharp-ai_sast
C++
cpp-ai_sast
Dart
dart-ai_sast
Elixir
elixir-ai_sast
Go
go-ai_sast
Java
java-ai_sast
JavaScript
javascript-ai_sast
Kotlin
kotlin-ai_sast
PHP
php-ai_sast
Python
python-ai_sast
Ruby
ruby-ai_sast
Rust
rust-ai_sast
Swift
swift-ai_sast
TypeScript
typescript-ai_sast
AI 네이티브 SAST 규칙 ID는 datadog/<rule-name> 형식을 사용합니다(예: datadog/typescript-promptinjection). rule-configs 또는 no-dd-sa 주석에서 특정 AI 네이티브 SAST 규칙을 지정하려면, datadog/ 접두사가 포함된 전체 규칙 ID를 사용하십시오.
use-default-rulesets 설정은 기존 SAST 및 AI 네이티브 SAST 규칙 세트 모두에 적용됩니다. use-default-rulesets: false를 설정하는 경우, 실행하려는 모든 기존 및 AI 네이티브 SAST 규칙 세트를 포함하세요. 예를 들어, 다음 구성은 Ruby Security 및 AI 네이티브 SAST 규칙 세트를 실행합니다.
다음 구성 형식은 모든 구성 위치(조직 수준, 리포지토리 수준 및 리포지토리 수준(파일))에 적용됩니다.
구성 파일은 지원되는 schema-version(v1.0, v1.1, v1.2, v1.3 또는 v1.4)로 시작해야 하며, 그 뒤에 분석 구성이 포함된 sast 키가 와야 합니다. 모든 새 구성에는 v1.4를 사용하세요. 구성은 구조는 아래와 같습니다.
schema-version:v1.4sast:use-default-rulesets:trueuse-rulesets:- ruleset-nameignore-rulesets:# Always ignore these rulesets (even if it is a default ruleset or listed in `use-rulesets`)- ignored-ruleset-nameruleset-configs:ruleset-name:# Only apply this ruleset to the following paths/filesonly-paths:- "path/example"- "**/*.file"# Do not apply this ruleset in the following paths/filesignore-paths:- "path/example/directory"- "**/config.file"rule-configs:rule-name:# Only apply this rule to the following paths/filesonly-paths:- "path/example"- "**/*.file"# Do not apply this rule to the following paths/filesignore-paths:- "path/example/directory"- "**/config.file"arguments:# Set the rule's argument to value.argument-name:valueseverity:ERRORcategory:CODE_STYLErule-name:arguments:# Set different argument values in different subtreesargument-name:# Set the rule's argument to value_1 by default (root path of the repo)/:value_1# Set the rule's argument to value_2 for specific pathspath/example:value_2global-config:# Only analyze the following paths/filesonly-paths:- "path/example"- "**/*.file"# Do not analyze the following paths/filesignore-paths:- "path/example/directory"- "**/config.file"use-gitignore:trueignore-generated-files:truemax-file-size-kb:200
sast 키는 다음 필드를 지원합니다.
속성
유형
설명
기본값
use-default-rulesets
부울
Datadog 기본 규칙 세트를 활성화할지 여부입니다.
true
use-rulesets
배열
활성화할 규칙 세트 이름의 목록입니다.
없음
ignore-rulesets
배열
비활성화할 규칙 세트 이름의 목록입니다. use-rulesets 및 use-default-rulesets보다 우선합니다.
없음
ruleset-configs
객체
규칙 세트 이름에서 해당 구성으로의 맵입니다.
없음
global-config
객체
리포지토리에 대한 전역 설정입니다.
없음
규칙 세트 구성
ruleset-configs 맵의 각 항목은 특정 규칙 세트를 구성합니다. 규칙 세트의 구성이 적용되기 위해 use-rulesets 목록에 있을 필요는 없습니다. 구성은 use-default-rulesets를 포함하여 규칙 세트가 활성화될 때마다 적용됩니다.
속성
유형
설명
기본값
only-paths
배열
파일 경로 또는 glob 패턴입니다. 이 패턴과 일치하는 파일만 이 규칙 세트에서 처리됩니다.
없음
ignore-paths
배열
이 규칙 세트의 분석에서 제외할 파일 경로 또는 glob 패턴입니다.
없음
rule-configs
객체
규칙 이름에서 해당 구성으로의 맵입니다.
없음
규칙 구성
규칙 세트의 rule-configs 맵에 있는 각 항목은 특정 규칙을 구성합니다.
속성
유형
설명
기본값
only-paths
배열
파일 경로 또는 glob 패턴입니다. 이 규칙은 이러한 패턴과 일치하는 파일에만 적용됩니다.
없음
ignore-paths
배열
제외할 파일 경로 또는 glob 패턴입니다. 이 규칙은 이러한 패턴과 일치하는 파일에는 적용되지 않습니다.
없음
arguments
객체
규칙에 대한 파라미터 및 값입니다. 값은 스칼라일 수도 있고 경로별로 정의할 수도 있습니다.
없음
severity
문자열 또는 객체
규칙 심각도입니다. 유효한 값은 ERROR, WARNING, NOTICE, NONE입니다. 단일 값일 수도 있고 경로별로 정의할 수도 있습니다.
없음
category
문자열
규칙 카테고리입니다. 유효한 값은 BEST_PRACTICES, CODE_STYLE, ERROR_PRONE, PERFORMANCE, SECURITY입니다.
없음
인수 및 심각도 구성
인수와 심각도는 다음 두 가지 형식 중 하나로 정의할 수 있습니다.
단일 값: 전체 리포지토리에 적용됩니다.
arguments:argument-name:valueseverity:ERROR
경로별 매핑: 서로 다른 하위 트리에 다른 값을 지정합니다. 일치하는 경로 접두사 중 가장 긴 것이 적용됩니다. /를 포괄적인 기본값으로 사용하세요.
이 예시는 기본 규칙 세트를 비활성화하므로, Python용 AI 네이티브 SAST를 유지하기 위해 python-ai_sast를 명시적으로 포함합니다.
schema-version:v1.4sast:use-default-rulesets:falseuse-rulesets:- python-best-practices- python-security- python-code-style- python-inclusive- python-django- python-ai_sast- custom-python-rulesetruleset-configs:python-code-style:rule-configs:max-function-lines:# Do not apply the rule max-function-lines to the following filesignore-paths:- "src/main/util/process.py"- "src/main/util/datetime.py"arguments:# Set the max-function-lines rule's threshold to 150 linesmax-lines:150# Override this rule's severityseverity:NOTICEmax-class-lines:arguments:# Set different thresholds for the max-class-lines rule in different subtreesmax-lines:# Set the rule's threshold to 200 lines by default (root path of the repo)/:200# Set the rule's threshold to 100 lines in src/main/backendsrc/main/backend:100# Override this rule's severity with different values in different subtreesseverity:# Set the rule's severity to NOTICE by default/:NOTICE# Set the rule's severity to NONE in tests/tests:NONEpython-django:# Only apply the python-django ruleset to the following pathsonly-paths:- "src/main/backend"- "src/main/django"# Do not apply the python-django ruleset in files matching the following patternignore-paths:- "src/main/backend/util/*.py"global-config:# Only analyze source filesonly-paths:- "src/main"- "src/tests"- "**/*.py"# Do not analyze third-party filesignore-paths:- "lib/third_party"
레거시 구성
Datadog 정적 코드 분석(SAST)은 이전에 다른 구성 파일(static-analysis.datadog.yml) 및 스키마를 사용했습니다. 이 스키마는 더 이상 사용되지 않으며 새로 업데이트되지 않지만, datadog-static-analyzer 리포지토리에 문서화되어 있습니다.
두 파일이 모두 존재하는 경우 code-security.datadog.yaml이 static-analysis.datadog.yml보다 우선합니다.
위반 사항 무시
리포지토리에서 무시
code-security.datadog.yaml 파일에 규칙 구성을 추가하세요. 다음 예시는 모든 디렉터리에 대해 규칙 javascript-express/reduce-server-fingerprinting을 무시합니다.
code-security.datadog.yaml 파일에 규칙 구성을 추가하세요. 다음 예시는 특정 파일에 대해 규칙 javascript-express/reduce-server-fingerprinting을 무시합니다. 경로별로 무시하는 방법에 대한 자세한 내용은 구성 사용자 지정을 참조하세요.