Loading...
Loading...
Compare original and translation side by side
syftcdxgengrypecosignsyftcdxgengrypecosigncomparison:
cyclonedx:
standard: "OWASP CycloneDX"
focus: "Application security, vulnerability tracking"
formats: ["JSON", "XML", "Protocol Buffers"]
strengths:
- Vulnerability references (VEX support)
- Service and API dependency tracking
- Hardware BOM support
best_for: "Security-focused SBOM, vulnerability management"
spdx:
standard: "Linux Foundation SPDX (ISO/IEC 5962:2021)"
focus: "License compliance, legal review"
formats: ["JSON", "RDF/XML", "Tag-Value", "YAML"]
strengths:
- ISO standard
- License expression language
- Relationship modeling
best_for: "License compliance, regulatory requirements"comparison:
cyclonedx:
standard: "OWASP CycloneDX"
focus: "Application security, vulnerability tracking"
formats: ["JSON", "XML", "Protocol Buffers"]
strengths:
- Vulnerability references (VEX support)
- Service and API dependency tracking
- Hardware BOM support
best_for: "Security-focused SBOM, vulnerability management"
spdx:
standard: "Linux Foundation SPDX (ISO/IEC 5962:2021)"
focus: "License compliance, legal review"
formats: ["JSON", "RDF/XML", "Tag-Value", "YAML"]
strengths:
- ISO standard
- License expression language
- Relationship modeling
best_for: "License compliance, regulatory requirements"undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
id: build
uses: docker/build-push-action@v5
with:
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.ref_name }}
- name: Install tools
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
- name: Generate SBOM
run: |
syft ghcr.io/${{ github.repository }}@${{ steps.build.outputs.digest }} \
-o cyclonedx-json=sbom-cdx.json \
-o spdx-json=sbom-spdx.json
- name: Scan SBOM for vulnerabilities
run: |
grype sbom:sbom-cdx.json --fail-on critical -o json > vuln-report.json
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Sign image (keyless)
run: |
cosign sign ghcr.io/${{ github.repository }}@${{ steps.build.outputs.digest }}
- name: Attach SBOM attestation
run: |
cosign attest --predicate sbom-cdx.json \
--type cyclonedx \
ghcr.io/${{ github.repository }}@${{ steps.build.outputs.digest }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: sbom-and-reports
path: |
sbom-cdx.json
sbom-spdx.json
vuln-report.jsonundefined - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
id: build
uses: docker/build-push-action@v5
with:
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.ref_name }}
- name: Install tools
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin
- name: Generate SBOM
run: |
syft ghcr.io/${{ github.repository }}@${{ steps.build.outputs.digest }} \
-o cyclonedx-json=sbom-cdx.json \
-o spdx-json=sbom-spdx.json
- name: Scan SBOM for vulnerabilities
run: |
grype sbom:sbom-cdx.json --fail-on critical -o json > vuln-report.json
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Sign image (keyless)
run: |
cosign sign ghcr.io/${{ github.repository }}@${{ steps.build.outputs.digest }}
- name: Attach SBOM attestation
run: |
cosign attest --predicate sbom-cdx.json \
--type cyclonedx \
ghcr.io/${{ github.repository }}@${{ steps.build.outputs.digest }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: sbom-and-reports
path: |
sbom-cdx.json
sbom-spdx.json
vuln-report.jsonundefinedapiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-signed-images-with-sbom
spec:
validationFailureAction: Enforce
webhookTimeoutSeconds: 30
rules:
- name: verify-signature
match:
any:
- resources:
kinds: ["Pod"]
verifyImages:
- imageReferences: ["ghcr.io/acme/*"]
attestors:
- entries:
- keyless:
subject: "https://github.com/acme/*"
issuer: "https://token.actions.githubusercontent.com"
rekor:
url: "https://rekor.sigstore.dev"
attestations:
- type: cyclonedx
conditions:
- all:
- key: "{{ components[].name }}"
operator: AllNotIn
value: ["log4j-core"]apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-signed-images-with-sbom
spec:
validationFailureAction: Enforce
webhookTimeoutSeconds: 30
rules:
- name: verify-signature
match:
any:
- resources:
kinds: ["Pod"]
verifyImages:
- imageReferences: ["ghcr.io/acme/*"]
attestors:
- entries:
- keyless:
subject: "https://github.com/acme/*"
issuer: "https://token.actions.githubusercontent.com"
rekor:
url: "https://rekor.sigstore.dev"
attestations:
- type: cyclonedx
conditions:
- all:
- key: "{{ components[].name }}"
operator: AllNotIn
value: ["log4j-core"]package sbom.verify
import rego.v1
default allow := false
allow if {
sbom_present
no_critical_vulns
signed_by_ci
}
sbom_present if {
input.attestations.cyclonedx != null
count(input.attestations.cyclonedx.components) > 0
}
no_critical_vulns if {
not any_critical
}
any_critical if {
some vuln in input.vulnerability_report.matches
vuln.vulnerability.severity == "Critical"
vuln.vulnerability.fix.state == "fixed"
}
signed_by_ci if {
input.signature.issuer == "https://token.actions.githubusercontent.com"
startswith(input.signature.subject, "https://github.com/acme/")
}package sbom.verify
import rego.v1
default allow := false
allow if {
sbom_present
no_critical_vulns
signed_by_ci
}
sbom_present if {
input.attestations.cyclonedx != null
count(input.attestations.cyclonedx.components) > 0
}
no_critical_vulns if {
not any_critical
}
any_critical if {
some vuln in input.vulnerability_report.matches
vuln.vulnerability.severity == "Critical"
vuln.vulnerability.fix.state == "fixed"
}
signed_by_ci if {
input.signature.issuer == "https://token.actions.githubusercontent.com"
startswith(input.signature.subject, "https://github.com/acme/")
}| Problem | Cause | Solution |
|---|---|---|
| Syft misses dependencies | Unsupported package manager or format | Check syft catalogers list; use |
| Cosign sign fails with "no identity token" | Missing OIDC provider in CI | Ensure |
| Grype reports false positives | Package version detection incorrect | Verify SBOM accuracy; report to grype GitHub; add ignore rules for confirmed FPs |
| SBOM attestation too large | Large image with many dependencies | Compress SBOM; use SPDX compact format; consider splitting per layer |
| Verification fails in admission controller | Wrong identity or issuer URL | Check exact |
| cdxgen produces empty SBOM | Project type not detected | Specify type explicitly with |
| 问题 | 原因 | 解决方案 |
|---|---|---|
| Syft遗漏依赖项 | 不支持的包管理器或格式 | 查看syft目录器列表;使用 |
| Cosign签名失败并提示“no identity token” | CI中缺少OIDC提供者 | 在GitHub Actions中确保 |
| Grype报告误报 | 包版本检测错误 | 验证SBOM准确性;向Grype的GitHub仓库提交报告;为已确认的误报添加忽略规则 |
| SBOM证明过大 | 镜像包含大量依赖项 | 压缩SBOM;使用SPDX紧凑格式;考虑按层拆分 |
| 准入控制器中验证失败 | 身份或发行者URL错误 | 检查 |
| cdxgen生成空SBOM | 未检测到项目类型 | 使用 |