متقدم
البحث فيأدلة التثبيت
طريقة البحث
  • الصق رسالة الخطأ بين علامتي تنصيص، مثل "permission denied"، لتجد جدول الحل.
  • اختر مجالًا وجزءًا من الدليل (التثبيت، أول الإعدادات، الاستخدام اليومي، الأمان، الحلول) لتصل مباشرة إلى الخطوة الصحيحة.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

الدليل 63Syft · Security

Install and set up Syft (SBOM generator)

Syft makes an SBOM (Software Bill of Materials): the full list of packages inside a container image, a folder, an archive or a VM disk — OS packages, Python, npm, Java, Go modules and more. With an SBOM you can answer in minutes "where do we use this vulnerable library?", feed scanners like Grype, and give customers and auditors what they ask for. This guide installs Syft, makes SBOMs in CycloneDX and SPDX, configures what it scans, and adds it to CI with a signed attestation.

  • 8 الدروس
  • 9 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

63.1

Know it before you install

Catalogers read package metadata (rpm/dpkg databases, package-lock.json, requirements.txt, jar manifests, Go binaries …). Syft writes the result in a standard format: CycloneDX or SPDX (JSON), or its own syft-json (the most detailed).

ItemValue
Programsyft (one binary from Anchore)
SourcesIMAGE (from Docker/Podman or a registry), dir:PATH, file:…, oci-archive:…, registry:…
Formatscyclonedx-json, spdx-json, syft-json, table, github-json
Config.syft.yaml in the project, or ~/.syft.yaml
Works withGrype (scan the SBOM), Cosign (attest it), Trivy and Dependency-Track (read it)

الأوامر في هذا الدرس

63.2

Install on RHEL and Ubuntu

The official install script puts the binary where you choose; read it first:

curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh -o syft-install.sh
less syft-install.sh
sh syft-install.sh -b /usr/local/bin
syft version

Or the .rpm / .deb from github.com/anchore/syft/releases, or the container anchore/syft.

63.3

First configuration: make your first SBOMs

syft nginx:1.27
NAME             VERSION          TYPE
bash             5.2.15-2+b7      deb
libssl3          3.0.15-1~deb12u1 deb
…
syft harbor.example.com/shop/shop:1.4.0 -o cyclonedx-json=sbom.cdx.json -o spdx-json=sbom.spdx.json
syft dir:. -o cyclonedx-json=sbom-src.cdx.json
syft registry:harbor.example.com/shop/shop:1.4.0 -o syft-json=sbom.syft.json

registry: reads the image straight from the registry (no Docker needed). Several -o options write several formats at once.

A config file keeps runs the same everywhere:

.syft.yaml
output:
  - cyclonedx-json=sbom.cdx.json
scope: squashed
exclude:
  - ./tests/**
  - ./node_modules/.cache/**
select-catalogers:
  - "+sbom-cataloger"
SettingWhy
scope: squashedOnly what is in the final image (all-layers also shows files deleted in later layers).
excludeSkip test data and caches (faster, less noise).
select-catalogersAdd or remove catalogers (here also read SBOM files found inside the image).
outputThe format your tools and customers need (CycloneDX is common for security tools).

الأوامر في هذا الدرس

63.4

Daily use: the commands and the real uses

syft IMAGE -o table | grep -i log4j
syft IMAGE -o cyclonedx-json | jq '.components | length'
syft convert sbom.syft.json -o spdx-json=sbom.spdx.json
grype sbom:sbom.cdx.json --fail-on high
cosign attest --yes --type cyclonedx --predicate sbom.cdx.json IMAGE@DIGEST
syft cataloger list

A CI step (any CI): build → SBOM → scan the SBOM → attach it to the image:

ci-step.sh
syft "$IMAGE@$DIGEST" -o cyclonedx-json=sbom.cdx.json
grype sbom:sbom.cdx.json --fail-on high
cosign attest --yes --type cyclonedx --predicate sbom.cdx.json "$IMAGE@$DIGEST"

Real uses at work:

  • An SBOM for every release (customers, audits, regulations like the EU Cyber Resilience Act ask for it).
  • Fast impact checks when a new CVE comes out ("which images contain this package?") — keep SBOMs in Dependency-Track or a storage bucket.
  • Scan once, re-scan the SBOM daily with Grype without pulling images again.

63.5

Make it safe

Security checklist:

  • Make the SBOM from the final image digest that you ship, not from a tag or the source only.
  • Sign/attest the SBOM (Cosign) so nobody can swap it.
  • Store SBOMs with the release and keep them as long as the release is supported.
  • Pin the Syft version in CI; registry credentials only from CI secrets.
  • An SBOM shows your components — share it with customers on purpose, not publicly by accident.

63.6

Update and remove

Run the install script again (or install the new package). Remove: rm /usr/local/bin/syft and ~/.cache/syft if present.

الأوامر في هذا الدرس

63.7

Fix common problems

ProblemCauseFix
unable to determine image source / pull access deniedPrivate registry without login.docker login, or SYFT_REGISTRY_AUTH_USERNAME / …PASSWORD; use registry:.
Packages missing from the SBOMNo metadata (for example a copied binary, or a stripped Go binary).Add the needed catalogers; build with dependency metadata; check syft cataloger list.
Very slow on big foldersIt scans everything (node_modules, test data).exclude paths in .syft.yaml.
Different results from TrivyDifferent catalogers and matching.Normal; choose one tool as the source of truth per pipeline.
cannot use docker daemon in CINo Docker in the runner.Use registry:IMAGE or an oci-archive.

63.8

Next steps

1Why make the SBOM from the image digest you ship?

Then the SBOM describes exactly the image that runs, not a different build.

2How do you check a new CVE against last month's images without pulling them again?

Scan the stored SBOMs with Grype (grype sbom:FILE).

الأوامر في هذا الدرس

كل الأوامر في هذا الفصل