provenance 포스트 프로세서

provenance 포스트 프로세서

provenance post-processor는 입력 아티팩트에 대한 in-toto attestation을 만들어요. 소프트웨어 아티팩트용 공급망 레벨(SLSA, Supply-chain Levels for Software Artifacts) provenance와 소프트웨어 자재 명세(SBOM, software bill of materials) attestation을 생성할 수 있죠. PEM 키, 키 관리 서비스(key management service), 또는 Sigstore keyless 서명으로 서명할 수도 있어요.

출처: Packer 공식 문서

본문

예시 (Example)

post-processor "provenance" {
build_type  = "https://packer.io/buildtypes/hcl2/v1"
template    = "ubuntu.pkr.hcl"
only_builds = ["qemu.ubuntu"]
sbom        = true
}

설정 (Configuration)

  • provenance (boolean) — provenance attestation을 출력할지 여부예요. 기본적으로 활성화되어 있고, false로 설정하면 post-processor를 건너뛰고 아티팩트를 변경 없이 그대로 통과시켜요.
  • build_type (string) — provenance predicate에 기록되는 SLSA buildType URI예요. 기본값은 https://packer.io/buildtypes/hcl2/v1이에요.
  • output_dir (string) — attestation 사이드카 파일이 쓰이는 디렉터리예요. 기본값은 아티팩트의 첫 번째 파일이 있는 디렉터리이며, 로컬 파일이 없는 아티팩트의 경우 현재 디렉터리예요.
  • template (string) — 아티팩트를 만든 Packer 템플릿의 경로예요. provenance predicate의 외부 파라미터(external parameter)로 기록돼요.
  • only_builds ([]string) — 이 아티팩트가 나온 빌드 목록이에요. provenance predicate의 외부 파라미터로 기록돼요.
  • user_variables (map[string]string) — provenance predicate의 외부 파라미터로 기록할 추가 사용자 변수예요. packer_sensitive_variables에 이름이 있는 변수의 값은 마스킹(redacted)돼요.
  • source_uri (string) — 해결된 의존성(resolved dependency)으로 기록되는 자동 감지된 소스 저장소 URI를 덮어써요. 기본적으로 소스는 현재 작업 디렉터리를 포함하는 Git 저장소 또는 CI 환경 변수에서 감지돼요.
  • sbom (bool) — provenance statement와 함께 소프트웨어 자재 명세(SBOM)와 해당 SBOM attestation도 생성할지 여부예요.
  • sbom_format (string) — SBOM 출력 포맷으로, cyclonedx(기본값) 또는 spdx예요.
  • sbom_scan_path (string) — SBOM 생성 시 스캔할 경로예요. 기본값은 아티팩트의 파일 또는 그 공통 부모 디렉터리예요. 아티팩트 파일이 여러 디렉터리에 걸쳐 있으면 필수예요.
  • sbom_scope (string) — SBOM 스캔 범위로, squashed(기본값) 또는 all-layers예요.
  • sbom_exclude ([]string) — SBOM 스캔에서 제외할 경로의 Glob 패턴이에요.
  • signing_mode (string) — attestation의 서명 모드예요: none(기본값, 서명되지 않은 JSON), key(로컬 PEM 키), kms(KMS 또는 Vault URI), keyless(Sigstore Fulcio).
  • signer (string) — 서명자 참조예요. key 모드에서는 PEM 개인 키 경로, kms 모드에서는 awskms://..., gcpkms://..., azurekms://..., hashivault://... 같은 KMS 또는 Vault URI예요.
  • key (string) — signer의 별칭이에요. 둘 다 설정되면 같아야 해요.
  • verifier (string) — key와 kms 모드에서 서명을 검증하는 데 사용하는 PEM 검증자 경로예요. 기본값은 signer에서 파생된 공개 키예요.
  • fulcio_url (string) — keyless 서명에 사용되는 Fulcio 인증 기관(certificate authority) URL이에요. 기본값은 https://fulcio.sigstore.dev예요.
  • rekor_url (string) — upload_tlog가 활성화될 때 사용되는 Rekor 투명성 로그(transparency log) URL이에요. 기본값은 https://rekor.sigstore.dev예요.
  • upload_tlog (bool) — keyless 서명을 Rekor 투명성 로그에 업로드하고 투명성 증거를 담은 Sigstore bundle을 출력할지 여부예요.
  • trusted_root_path (string) — keyless 검증을 고정(pin)하는 데 사용되는 Sigstore trusted-root JSON 파일의 선택적 경로예요. 설정하지 않으면 공개 Sigstore trusted root를 가져와요.
  • keyless_identity (string) — keyless 모드에서 기대되는 서명 identity예요. 예: workflow ref https://github.com/OWNER/REPO/.github/workflows/build.yml@refs/heads/main. keyless 서명에는 필수예요.
  • keyless_oidc_issuer (string) — keyless 모드에서 기대되는 OIDC issuer예요. 예: https://token.actions.githubusercontent.com. keyless 서명에는 필수예요.

출력 파일 (Output files)

post-processor는 아티팩트 옆에, 또는 output_dir 인자에 지정된 디렉터리에 사이드카 파일을 써요. 사이드카 파일은 아티팩트 이름을 따서 명명돼요. 예를 들어 image라는 아티팩트에 대해 Packer는 다음과 같은 파일을 만들 수 있어요.

  • image.provenance.json — SLSA provenance attestation.
  • image.provenance.sigstore.json — Sigstore bundle. signing_mode = "keyless"일 때 작성돼요.
  • image.sbom.cdx.json 또는 image.sbom.spdx.json — 원본 SBOM. sbom = true일 때 작성돼요.
  • image.sbom.att.json — SBOM attestation. sbom = true일 때 작성돼요.

attestation 검증하기 (Verify an attestation)

packer verify-attestation 명령을 사용해 서명된 attestation을 검증할 수 있어요. keyless 서명의 경우 Sigstore bundle과 기대되는 서명 identity, OIDC issuer를 제공하고, 정책에 투명성 로그 증거가 요구되면 Rekor 검증을 요구하세요.

다음 예시는 packer verify-attestation 명령을 사용해 keyless 서명으로 attestation을 검증해요.

packer verify-attestation \
-signing-mode=keyless \
-bundle=image.provenance.sigstore.json \
-require-rekor \
-keyless-identity="https://github.com/OWNER/REPO/.github/workflows/build.yml@refs/heads/main" \
-keyless-oidc-issuer="https://token.actions.githubusercontent.com" \
image.provenance.json