
threatcl v0.6.1
자신의 위협 모델을 HCL로 문서화하기
threatcl
HCL을 사용한 위협 모델링
hcltm은 어떻게 되었나요?
hcltm이 threatcl로 이름이 변경되었습니다. 환영합니다!
개요
[!TIP] 새 문서를 읽고 싶으신가요? threatcl.dev를 방문하세요.
위협 모델을 문서화하는 방법은 다양합니다. 간단한 텍스트 파일부터 더 상세한 워드 문서, 완전히 계측된 중앙 집중식 솔루션까지 여러 형태가 있습니다. 위협 모델의 가장 가치 있는 두 가지 속성은 위협을 명확하게 문서화하고 가치 있는 변화를 이끌어낼 수 있는 능력입니다.
threatcl은 다음 목표에 중점을 두어 시스템 위협 모델을 문서화하는 DevOps 우선 접근 방식을 제공하는 것을 목표로 합니다:
- 간단한 텍스트 파일 형식
- 간단한 CLI 기반 사용자 경험
- 버전 관리 시스템(VCS) 통합
이 저장소는 threatcl CLI 소프트웨어의 홈입니다. threatcl 명세는 "인간이 읽고 쓰기에 편리하며, 기계가 생성하고 구문 분석하기 쉬운 JSON 기반 변형"을 목표로 하는 HCL2, HashiCorp의 Configuration Language를 기반으로 합니다. threatcl 명세는 github.com/threatcl/spec에 있습니다. threatcl CLI 소프트웨어와 threatcl 명세를 결합하면 실무자가 HCL로 시스템 위협 모델을 정의할 수 있습니다. 예를 들어:```hcl
threatmodel "Tower of London" {
description = "A historic castle"
author = "@xntrik"
attributes { new_initiative = "true" internet_facing = "true" initiative_size = "Small" }
information_asset "crown jewels" { description = "including the imperial state crown" information_classification = "Confidential" }
usecase { description = "The Queen can fetch the crown" }
third_party_dependency "community watch" { description = "The community watch helps guard the premise" uptime_dependency = "degraded" }
threat "Crown theft" { description = "Someone who isn't the Queen steals the crown" impacts = ["Confidentiality"]
control "Guards" {
description = "Trained guards patrol tower"
risk_reduction = 75
}
}
data_flow_diagram_v2 "dfd name" { // ... see below for more information }
}
데이터 흐름 다이어그램을 자동으로 PNG로 변환할 수 있도록 구성하는 방법에 대한 자세한 내용은 [데이터 흐름 다이어그램](#data-flow-diagram)을 참조하세요.
[OWASP Proactive Controls](https://owasp.org/www-project-proactive-controls/) 및 [AWS Security Checklist](https://d1.awsstatic.com/whitepapers/Security/AWS_Security_Checklist.pdf)에 대한 사전 정의된 제어 라이브러리를 참조하는 방법의 예는 [examples/tm3.hcl](https://github.com/threatcl/threatcl/blob/main/examples/tm3.hcl)을 참조하세요. 또한 [MITRE ATT&CK Controls](https://attack.mitre.org/mitigations/enterprise/)가 [여기](https://github.com/threatcl/threatcl/blob/main/examples/MITRE_ATTACK_controls.hcl)에 있습니다.
외부 위협 모델을 자신의 위협 모델에 포함시켜 모든 정보를 참조하고 사용할 수도 있습니다. 예시는 [examples/including-example/corp-app.hcl](https://github.com/threatcl/threatcl/blob/main/examples/including-example/corp-app.hcl)을 참조하세요.
사양의 전체 설명을 보려면 [여기](https://github.com/threatcl/threatcl/blob/main/spec.hcl)를 참조하거나 다음을 실행하세요:```bash
threatcl generate boilerplate
threatcl은 JSON 파일도 처리할 수 있지만, 유일한 단점은 가져오기 모듈과 변수가 작동하지 않는다는 것입니다. 예를 들어 examples/tm1.json을 참조하세요.
왜 HCL인가?
HCL은 HashiCorp 제품에서 사용되는 기본 구성 언어이며, 특히 그들의 오픈소스 Infrastructure-as-Code 소프트웨어인 Terraform에서 사용됩니다. 저는 HashiCorp에서 잠시 근무했는데 그 언어가 정말 마음에 들었습니다. 게다가 DevOps 및 소프트웨어 엔지니어들이 이 언어를 사용하고 있다면, 위협 모델을 문서화하는 방식을 간소화하는 것은 threatcl의 목표와 일치합니다.
threatcl을 JSON과 함께 사용할 수 있지만, 일부 기능이 손실됩니다. 자세한 내용은 examples/ 폴더를 참조하세요.
왜 MD로 문서화하지 않나요?
프로그래밍 방식으로 상호작용할 수 있는 형식을 사용하는 아이디어가 마음에 들었습니다.
감사의 말 및 참고 자료
threatcl의 기능 중 하나는 HCL 파일로부터 데이터 흐름 다이어그램을 자동 생성하는 것입니다. 이는 Marqeta와 Blake Hitchcock의 go-dfd 패키지를 활용합니다. DevOps 속도의 위협 모델에 대한 블로그 게시물을 꼭 확인해보세요.
또한 HashiCorp의 Jamie Finnigan과 Talha Tariq에게 감사드립니다. HashiCorp를 떠난 후에도 이 오픈소스 도구를 계속 개발할 수 있도록 허락해 주셨습니다.
또한 OpenThreatModel 명세를 제공한 IriusRisk 팀에게도 감사드립니다.
threatcl cli
설치
릴리즈 페이지에서 최신 버전을 다운로드하고 threatcl 바이너리를 PATH에 추가하세요.
Homebrew로 설치
Homebrew를 사용하여 threatcl을 설치하세요 — 해당 포뮬러는 homebrew-core에 있습니다:```bash
brew install threatcl
## Docker로 실행하기```bash
docker run --rm -it ghcr.io/threatcl/threatcl:latest
릴리스 검증 (빌드 출처)
모든 태그된 릴리스는 SLSA 빌드 출처를 제공합니다 —
Sigstore 서명, 키리스 증명서는 GitHub Actions 릴리스 파이프라인에 의해 생성됩니다 (GitHub OIDC → Fulcio, 서명 키 없음). GitHub CLI를 사용하여 이진 파일이나 컨테이너 이미지가 이 저장소의 릴리스 워크플로우에서 실제로 빌드되었는지 확인할 수 있습니다 (gh attestation verify — 추가 도구나 신뢰할 수 있는 키를 관리할 필요 없음).
다운로드한 아카이브 (또는 SHA256SUMS 파일)를 검증합니다:```bash
gh attestation verify threatcl_.tar.gz --repo threatcl/threatcl
컨테이너 이미지를 확인하세요 (태그는 자동으로 다이제스트로 해석됩니다):```bash
gh attestation verify oci://ghcr.io/threatcl/threatcl:<version> --repo threatcl/threatcl
실행 중인 정확한 이미지를 고정하려면 직접 다이제스트를 확인하고 다이제스트로 검증(및 풀)하십시오:```bash digest=$(docker buildx imagetools inspect ghcr.io/threatcl/threatcl: --format '{{ .Manifest.Digest }}') gh attestation verify oci://ghcr.io/threatcl/threatcl@${digest} --repo threatcl/threatcl
전체 공급망 상태에 대해서는 [docs/SLSA.md](https://github.com/threatcl/threatcl/blob/main/docs/SLSA.md)를 참조하세요.
## GitHub Actions로 실행하기
`threatcl`은 https://github.com/threatcl/threatcl-action을 사용하여 GitHub 리포지토리에 직접 통합할 수 있습니다. 이는 위협 모델을 관리하는 이상적인 방법 중 하나이며, 버전 관리 시스템에 통합하려는 목표를 달성하는 데 도움이 됩니다.
## 소스에서 빌드하기
1. 이 리포지토리를 클론합니다.
2. `threatcl` 디렉토리로 이동합니다.
3. `make bootstrap`
4. `make build`
`threatcl`에 기여하는 방법에 대한 자세한 내용은 [CHANGELOG.md](https://github.com/threatcl/threatcl/blob/main/CHANGELOG.md)를 참조하세요.
## 사용법
모든 하위 명령어에 대한 도움말은 `-h` 플래그를 사용하세요.```bash
$ threatcl
Usage: threatcl [--version] [--help] <command> [<args>]
Available commands are:
cloud Interact with ThreatCL Cloud services
dashboard Generate markdown files from existing HCL threatmodel file(s)
dfd Generate Data Flow Diagram PNG or DOT files from existing HCL threatmodel file(s)
export Export threat models into other formats
generate Generate an HCL Threat Model
list List Threatmodels found in HCL file(s)
mcp Model Context Protocol (MCP) server for threatcl
mermaid Output raw mermaid source from 'mermaid' blocks in existing HCL threatmodel file(s)
query Execute GraphQL queries against threat model data
server Start a GraphQL API server for threat models
terraform Parse output from 'terraform show -json'
validate Validate existing HCL Threatmodel file(s)
view View existing HCL Threatmodel file(s)
(선택 사항) 설정 파일
대부분의 threatcl 명령어에는 config.hcl 파일을 지정할 수 있는 -config 플래그가 있습니다. 이 파일 내의 HCL을 사용하여 threatcl의 일부 기본 속성을 재정의할 수 있습니다. 다음은 그 목록입니다:
- 이니셔티브 크기 - 기본값: "Undefined", "Small", "Medium", "Large"
- 기본 이니셔티브 크기 - 기본값: "Undefined"
- 정보 분류 - 기본값: "Restricted", "Confidential", "Public"
- 기본 정보 분류 - 기본값: "Confidential"
- 영향 유형 - 기본값: "Confidentiality", "Integrity", "Availability"
- STRIDE 요소 - 기본값: "Spoofing", "Tampering", "Info Disclosure", "Denial Of Service", "Elevation Of Privilege"
- 가동 시간 종속성 분류 - 기본값: "none", "degraded", "hard", "operational"
- 기본 가동 시간 종속성 분류 - 기본값: "none"
예를 들어:```hcl initiative_sizes = ["S", "M", "L"] default_initiative_size = "M" info_classifications = ["1", "2"] default_info_classification = "1" impact_types = ["big", "small"] strides = ["S", "T"] uptime_dep_classifications = ["N", "D"] default_uptime_dep_classification = "N"
이러한 속성을 수정하는 경우, 다른 작업을 위해 설정 파일을 제공해야 함을 기억해야 합니다. 이는 유효성 검사 또는 대시보드 생성에 영향을 줄 수 있습니다.
## Cloud 명령어
자세한 내용은 https://threatcl.dev/cloud/overview/에서 `cloud` 하위 명령어에 대해 읽어보세요.
## 목록 및 보기