코드형 인프라(IaC) Security는 IaC 구성 오류를 탐지합니다. 기본적으로 IaC Security는 지원되는 모든 규칙을 사용하여 리포지토리를 스캔합니다. 실행할 규칙과 해당 규칙이 실행될 경로뿐만 아니라 중증도와 규칙 유형도 사용자 지정할 수 있습니다. 이러한 설정은 Datadog 또는 code-security.datadog.yaml 파일의 Code Security 구성에 있는 iac 키 아래에서 구성하세요.
리포지토리 전체의 규칙, 중증도, 규칙 유형 및 경로 설정을 위한 Datadog 또는 code-security.datadog.yaml 파일 동일한 구성을 리포지토리나 조직 전체에 적용하려는 경우 이 방법을 사용하세요.
IaC 파일에 유지해야 하는 로컬 파일별 제외를 위한 인라인 주석 특정 라인, 블록 또는 파일에 예외가 적용될 때 이 방법을 사용하세요.
구성 형식
다음 구성 형식은 모든 구성 위치(조직 수준, 리포지토리 수준 및 리포지토리 수준(파일))에 적용됩니다.
구성 파일은 schema-version: v1.4로 시작해야 하며, 그 뒤에 분석 구성이 포함된 iac 키가 와야 합니다.
전체 구조는 다음과 같습니다.
schema-version:v1.4iac:# Do not run these rules.ignore-rules:- A- B# Run only these rules. If this field is set, all other rules are ignored.use-rules:- Aglobal-config:# Only analyze the following paths/files.only-paths:- "path/example"- "**/*.file"# Do not analyze the following paths/files.ignore-paths:- "path/example/directory"- "**/config.file"# Do not report findings with these severities.ignore-severities:- low- info# Report only findings with these severities.only-severities:- high- critical# Do not report findings with these rule types.ignore-categories:- "Best Practices"# Report only findings with these rule types.only-categories:- "Encryption"# Do not run rules from these platforms.ignore-platforms:- Dockerfile# Only run rules from these platforms.only-platforms:- Terraform- Kubernetes- CICD# Per-rule configurations.rule-configs:terraform-aws-s3-bucket-without-encryption:ignore-paths:- "test/"severity:lowkubernetes-deployment-without-resource-limits:only-paths:- "k8s/production/"cicd-github-unpinned-actions-full-length-commit-sha:arguments:allow:- libbpf/ci/run-qemu
iac 키에서 지원되는 필드는 다음과 같습니다.
속성
유형
설명
ignore-rules
배열
무시할 규칙 ID의 목록입니다.
use-rules
배열
실행할 규칙 ID의 목록입니다. 지정된 경우 이 규칙만 실행됩니다. ignore-rules가 use-rules보다 우선하므로 두 배열에 모두 포함된 규칙은 무시됩니다.
global-config
객체
IaC 스캐너의 전역 설정입니다.
rule-configs
객체
규칙별 구성입니다. 키는 규칙 ID입니다.
규칙 구성
실행할 규칙을 변경하려면 다음 단계를 따르세요.
특정 규칙만 실행: use-rules 아래에 나열합니다.
특정 규칙 비활성화: ignore-rules 아래에 나열합니다.
schema-version:v1.4iac:ignore-rules:- A- B
schema-version:v1.4iac:use-rules:- A
A 및 B와 같은 자리 표시자를 Code Security 규칙 ID로 바꿉니다. 레거시 규칙 ID도 하위 호환성을 위해 지원됩니다.
전역 구성
global-config 객체는 리포지토리 전체의 설정을 제어합니다.
속성
유형
설명
only-paths
배열
파일 경로 또는 glob 패턴입니다. 일치하는 파일만 분석됩니다.
ignore-paths
배열
제외할 파일 경로 또는 glob 패턴입니다. 일치하는 파일은 분석되지 않습니다.
only-severities
배열
보고할 중증도 수준입니다. 다른 중증도의 발견 결과는 보고되지 않습니다.
ignore-severities
배열
무시할 중증도 수준입니다.
only-categories
배열
보고할 규칙 유형입니다. 다른 규칙 유형의 발견 결과는 보고되지 않습니다.
ignore-categories
배열
무시할 규칙 유형입니다.
ignore-platforms
배열
제외할 플랫폼입니다. 이러한 플랫폼의 규칙은 적용되지 않습니다.
only-platforms
배열
스캔할 플랫폼입니다. 다른 플랫폼의 규칙은 적용되지 않습니다.
중증도
ignore-severities를 사용하여 중증도 수준에 따라 발견 결과를 무시하세요. only-severities를 사용하여 특정 중증도 수준만 보고하세요.
rule-configs 아래의 각 키는 규칙 ID입니다. 규칙별로 다음 속성이 지원됩니다.
속성
유형
설명
only-paths
배열
파일 경로 또는 glob 패턴입니다. 이 규칙은 이러한 패턴과 일치하는 파일에만 적용됩니다.
ignore-paths
배열
제외할 파일 경로 또는 glob 패턴입니다. 이 규칙은 이러한 패턴과 일치하는 파일에는 적용되지 않습니다.
arguments
객체
규칙 동작을 조정하는 규칙별 파라미터입니다. 지원되는 인수 이름과 값 유형은 규칙에 따라 다릅니다.
severity
문자열
이 규칙에서 생성된 발견 결과의 중증도를 재정의합니다. 허용되는 값은 critical, high, medium, low, info입니다.
규칙별 경로 범위 지정
규칙을 특정 경로에서 제외하거나 특정 경로에만 적용하세요.
schema-version:v1.4iac:rule-configs:terraform-aws-s3-bucket-without-encryption:# Do not apply this rule in test directories.ignore-paths:- "test/"- "**/testdata/"kubernetes-deployment-without-resource-limits:# Apply this rule only in production manifests.only-paths:- "k8s/production/"