mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 14:02:26 +01:00
Compare commits
+9
-9
@@ -2,7 +2,7 @@ tools:
|
|||||||
# we want to use a pinned version of binny to manage the toolchain (so binny manages itself!)
|
# we want to use a pinned version of binny to manage the toolchain (so binny manages itself!)
|
||||||
- name: binny
|
- name: binny
|
||||||
version:
|
version:
|
||||||
want: v0.11.1
|
want: v0.12.0
|
||||||
method: github-release
|
method: github-release
|
||||||
with:
|
with:
|
||||||
repo: anchore/binny
|
repo: anchore/binny
|
||||||
@@ -18,7 +18,7 @@ tools:
|
|||||||
# used to sign mac binaries at release
|
# used to sign mac binaries at release
|
||||||
- name: quill
|
- name: quill
|
||||||
version:
|
version:
|
||||||
want: v0.5.1
|
want: v0.7.1
|
||||||
method: github-release
|
method: github-release
|
||||||
with:
|
with:
|
||||||
repo: anchore/quill
|
repo: anchore/quill
|
||||||
@@ -26,7 +26,7 @@ tools:
|
|||||||
# used for linting
|
# used for linting
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
version:
|
version:
|
||||||
want: v2.8.0
|
want: v2.11.3
|
||||||
method: github-release
|
method: github-release
|
||||||
with:
|
with:
|
||||||
repo: golangci/golangci-lint
|
repo: golangci/golangci-lint
|
||||||
@@ -42,7 +42,7 @@ tools:
|
|||||||
# used for signing the checksums file at release
|
# used for signing the checksums file at release
|
||||||
- name: cosign
|
- name: cosign
|
||||||
version:
|
version:
|
||||||
want: v3.0.4
|
want: v3.0.5
|
||||||
method: github-release
|
method: github-release
|
||||||
with:
|
with:
|
||||||
repo: sigstore/cosign
|
repo: sigstore/cosign
|
||||||
@@ -58,7 +58,7 @@ tools:
|
|||||||
# used to release all artifacts
|
# used to release all artifacts
|
||||||
- name: goreleaser
|
- name: goreleaser
|
||||||
version:
|
version:
|
||||||
want: v2.13.3
|
want: v2.14.3
|
||||||
method: github-release
|
method: github-release
|
||||||
with:
|
with:
|
||||||
repo: goreleaser/goreleaser
|
repo: goreleaser/goreleaser
|
||||||
@@ -90,7 +90,7 @@ tools:
|
|||||||
# used for running all local and CI tasks
|
# used for running all local and CI tasks
|
||||||
- name: task
|
- name: task
|
||||||
version:
|
version:
|
||||||
want: v3.48.0
|
want: v3.49.1
|
||||||
method: github-release
|
method: github-release
|
||||||
with:
|
with:
|
||||||
repo: go-task/task
|
repo: go-task/task
|
||||||
@@ -98,7 +98,7 @@ tools:
|
|||||||
# used for triggering a release
|
# used for triggering a release
|
||||||
- name: gh
|
- name: gh
|
||||||
version:
|
version:
|
||||||
want: v2.86.0
|
want: v2.88.1
|
||||||
method: github-release
|
method: github-release
|
||||||
with:
|
with:
|
||||||
repo: cli/cli
|
repo: cli/cli
|
||||||
@@ -106,7 +106,7 @@ tools:
|
|||||||
# used to upload test fixture cache
|
# used to upload test fixture cache
|
||||||
- name: oras
|
- name: oras
|
||||||
version:
|
version:
|
||||||
want: v1.3.0
|
want: v1.3.1
|
||||||
method: github-release
|
method: github-release
|
||||||
with:
|
with:
|
||||||
repo: oras-project/oras
|
repo: oras-project/oras
|
||||||
@@ -114,7 +114,7 @@ tools:
|
|||||||
# used to upload test fixture cache
|
# used to upload test fixture cache
|
||||||
- name: yq
|
- name: yq
|
||||||
version:
|
version:
|
||||||
want: v4.52.2
|
want: v4.52.4
|
||||||
method: github-release
|
method: github-release
|
||||||
with:
|
with:
|
||||||
repo: mikefarah/yq
|
repo: mikefarah/yq
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ inputs:
|
|||||||
go-version:
|
go-version:
|
||||||
description: "Go version to install"
|
description: "Go version to install"
|
||||||
required: true
|
required: true
|
||||||
default: ">= 1.24"
|
default: "1.26.x"
|
||||||
go-dependencies:
|
go-dependencies:
|
||||||
description: "Download go dependencies"
|
description: "Download go dependencies"
|
||||||
required: true
|
required: true
|
||||||
@@ -29,15 +29,16 @@ runs:
|
|||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
# note: go mod and build is automatically cached on default with v4+
|
# note: go mod and build is automatically cached on default with v4+
|
||||||
- uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
|
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
|
||||||
if: inputs.go-version != ''
|
if: inputs.go-version != ''
|
||||||
with:
|
with:
|
||||||
go-version: ${{ inputs.go-version }}
|
go-version: ${{ inputs.go-version }}
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
- name: Restore tool cache
|
- name: Restore tool cache
|
||||||
if: inputs.tools == 'true'
|
if: inputs.tools == 'true'
|
||||||
id: tool-cache
|
id: tool-cache
|
||||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
|
||||||
with:
|
with:
|
||||||
path: ${{ github.workspace }}/.tool
|
path: ${{ github.workspace }}/.tool
|
||||||
key: ${{ inputs.cache-key-prefix }}-${{ runner.os }}-tool-${{ hashFiles('.binny.yaml') }}
|
key: ${{ inputs.cache-key-prefix }}-${{ runner.os }}-tool-${{ hashFiles('.binny.yaml') }}
|
||||||
@@ -66,7 +67,7 @@ runs:
|
|||||||
|
|
||||||
- name: Restore ORAS cache from github actions
|
- name: Restore ORAS cache from github actions
|
||||||
if: inputs.download-test-fixture-cache == 'true'
|
if: inputs.download-test-fixture-cache == 'true'
|
||||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
|
||||||
with:
|
with:
|
||||||
path: ${{ github.workspace }}/.tmp/oras-cache
|
path: ${{ github.workspace }}/.tmp/oras-cache
|
||||||
key: ${{ inputs.cache-key-prefix }}-oras-cache
|
key: ${{ inputs.cache-key-prefix }}-oras-cache
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ if [ "$(git status --porcelain | wc -l)" -ne "0" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! make generate-capabilities; then
|
if ! make generate-capabilities REFRESH=false; then
|
||||||
echo "Generating capability descriptions failed"
|
echo "Generating capability descriptions failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ def is_git_tracked_or_untracked(directory):
|
|||||||
|
|
||||||
|
|
||||||
def find_test_fixture_dirs_with_images(base_dir):
|
def find_test_fixture_dirs_with_images(base_dir):
|
||||||
"""Find directories that contain 'test-fixtures' and at least one 'image-*' directory."""
|
"""Find directories that contain 'testdata' and at least one 'image-*' directory."""
|
||||||
for root, dirs, files in os.walk(base_dir):
|
for root, dirs, files in os.walk(base_dir):
|
||||||
if 'test-fixtures' in root:
|
if 'testdata' in root:
|
||||||
image_dirs = [d for d in dirs if d.startswith('image-')]
|
image_dirs = [d for d in dirs if d.startswith('image-')]
|
||||||
if image_dirs:
|
if image_dirs:
|
||||||
yield os.path.realpath(root)
|
yield os.path.realpath(root)
|
||||||
|
|||||||
@@ -41,13 +41,14 @@ jobs:
|
|||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 #v6.2.0
|
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 #v6.3.0
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
|
uses: github/codeql-action/init@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
@@ -58,7 +59,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
|
uses: github/codeql-action/autobuild@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
@@ -72,4 +73,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@cdefb33c0f6224e58673d9004f47f7cb3e328b89 # v4.31.10
|
uses: github/codeql-action/analyze@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6
|
||||||
|
|||||||
@@ -150,13 +150,13 @@ jobs:
|
|||||||
uses: ./.github/actions/bootstrap
|
uses: ./.github/actions/bootstrap
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef #v3.6.0
|
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 #v4.0.0
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.ANCHOREOSSWRITE_DH_USERNAME }}
|
username: ${{ secrets.ANCHOREOSSWRITE_DH_USERNAME }}
|
||||||
password: ${{ secrets.ANCHOREOSSWRITE_DH_PAT }}
|
password: ${{ secrets.ANCHOREOSSWRITE_DH_PAT }}
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef #v3.6.0
|
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 #v4.0.0
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -186,7 +186,7 @@ jobs:
|
|||||||
# for updating brew formula in anchore/homebrew-syft
|
# for updating brew formula in anchore/homebrew-syft
|
||||||
GITHUB_BREW_TOKEN: ${{ secrets.ANCHOREOPS_GITHUB_OSS_WRITE_TOKEN }}
|
GITHUB_BREW_TOKEN: ${{ secrets.ANCHOREOPS_GITHUB_OSS_WRITE_TOKEN }}
|
||||||
|
|
||||||
- uses: anchore/sbom-action@0b82b0b1a22399a1c542d4d656f70cd903571b5c #v0.21.1
|
- uses: anchore/sbom-action@17ae1740179002c89186b61233e0f892c3118b11 #v0.23.0
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
file: go.mod
|
file: go.mod
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: "Run zizmor"
|
- name: "Run zizmor"
|
||||||
uses: zizmorcore/zizmor-action@135698455da5c3b3e55f73f4419e481ab68cdd95 # v0.4.1
|
uses: zizmorcore/zizmor-action@0dce2577a4760a2749d8cfb7a84b7d5585ebcb7d # v0.5.0
|
||||||
with:
|
with:
|
||||||
config: .github/zizmor.yml
|
config: .github/zizmor.yml
|
||||||
# Disable SARIF upload so the step is a simple pass/fail gate
|
# Disable SARIF upload so the step is a simple pass/fail gate
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ jobs:
|
|||||||
- name: Run unit tests
|
- name: Run unit tests
|
||||||
run: make unit
|
run: make unit
|
||||||
|
|
||||||
|
- name: Check for capability drift
|
||||||
|
run: make check-capability-drift
|
||||||
|
|
||||||
Integration-Test:
|
Integration-Test:
|
||||||
# Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
|
# Note: changing this job name requires making the same update in the .github/workflows/release.yaml pipeline
|
||||||
name: "Integration tests"
|
name: "Integration tests"
|
||||||
@@ -106,7 +109,7 @@ jobs:
|
|||||||
run: make snapshot-smoke-test
|
run: make snapshot-smoke-test
|
||||||
|
|
||||||
- name: Upload snapshot artifacts
|
- name: Upload snapshot artifacts
|
||||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f #v6.0.0
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f #v7.0.0
|
||||||
with:
|
with:
|
||||||
name: snapshot
|
name: snapshot
|
||||||
path: snapshot/
|
path: snapshot/
|
||||||
@@ -131,7 +134,7 @@ jobs:
|
|||||||
download-test-fixture-cache: true
|
download-test-fixture-cache: true
|
||||||
|
|
||||||
- name: Download snapshot artifacts
|
- name: Download snapshot artifacts
|
||||||
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 #v7.0.0
|
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 #v8.0.0
|
||||||
with:
|
with:
|
||||||
name: snapshot
|
name: snapshot
|
||||||
path: snapshot
|
path: snapshot
|
||||||
@@ -175,7 +178,7 @@ jobs:
|
|||||||
download-test-fixture-cache: true
|
download-test-fixture-cache: true
|
||||||
|
|
||||||
- name: Download snapshot artifacts
|
- name: Download snapshot artifacts
|
||||||
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 #v7.0.0
|
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 #v8.0.0
|
||||||
with:
|
with:
|
||||||
name: snapshot
|
name: snapshot
|
||||||
path: snapshot
|
path: snapshot
|
||||||
@@ -208,7 +211,7 @@ jobs:
|
|||||||
download-test-fixture-cache: true
|
download-test-fixture-cache: true
|
||||||
|
|
||||||
- name: Download snapshot artifacts
|
- name: Download snapshot artifacts
|
||||||
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 #v7.0.0
|
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 #v8.0.0
|
||||||
with:
|
with:
|
||||||
name: snapshot
|
name: snapshot
|
||||||
path: snapshot
|
path: snapshot
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ VERSION
|
|||||||
coverage.txt
|
coverage.txt
|
||||||
*.log
|
*.log
|
||||||
**/test-fixtures/test-observations.json
|
**/test-fixtures/test-observations.json
|
||||||
|
**/testdata/test-observations.json
|
||||||
|
|
||||||
# probable archives
|
# probable archives
|
||||||
.images
|
.images
|
||||||
|
|||||||
+1
-2
@@ -50,10 +50,9 @@ linters:
|
|||||||
- legacy
|
- legacy
|
||||||
- std-error-handling
|
- std-error-handling
|
||||||
rules:
|
rules:
|
||||||
# internal/os contains OS feature detection logic; the name reflects its purpose
|
# we have multiple packages in syft that might overlap with the stblib; their names reflect their purpose
|
||||||
- linters:
|
- linters:
|
||||||
- revive
|
- revive
|
||||||
path: internal/os/
|
|
||||||
text: "var-naming: avoid package names that conflict"
|
text: "var-naming: avoid package names that conflict"
|
||||||
paths:
|
paths:
|
||||||
- third_party$
|
- third_party$
|
||||||
|
|||||||
+32
-16
@@ -8,7 +8,9 @@ vars:
|
|||||||
OWNER: anchore
|
OWNER: anchore
|
||||||
PROJECT: syft
|
PROJECT: syft
|
||||||
|
|
||||||
CACHE_IMAGE: ghcr.io/{{ .OWNER }}/{{ .PROJECT }}/test-fixture-cache:latest
|
# v1: when fixtures were located at test-fixtures dirs
|
||||||
|
# v2: migration to testdata dirs
|
||||||
|
CACHE_IMAGE: ghcr.io/{{ .OWNER }}/{{ .PROJECT }}/test-fixture-cache:v2
|
||||||
|
|
||||||
# static file dirs
|
# static file dirs
|
||||||
TOOL_DIR: .tool
|
TOOL_DIR: .tool
|
||||||
@@ -73,7 +75,6 @@ tasks:
|
|||||||
- task: check-licenses
|
- task: check-licenses
|
||||||
- task: lint
|
- task: lint
|
||||||
- task: check-json-schema-drift
|
- task: check-json-schema-drift
|
||||||
- task: check-capability-drift
|
|
||||||
- task: check-binary-fixture-size
|
- task: check-binary-fixture-size
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@@ -199,7 +200,7 @@ tasks:
|
|||||||
check-binary-fixture-size:
|
check-binary-fixture-size:
|
||||||
desc: Ensure that the binary test fixtures are not too large
|
desc: Ensure that the binary test fixtures are not too large
|
||||||
cmds:
|
cmds:
|
||||||
- .github/scripts/check_binary_fixture_size.sh syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets
|
- .github/scripts/check_binary_fixture_size.sh syft/pkg/cataloger/binary/testdata/classifiers/snippets
|
||||||
|
|
||||||
|
|
||||||
## Testing tasks #################################
|
## Testing tasks #################################
|
||||||
@@ -266,9 +267,9 @@ tasks:
|
|||||||
fingerprints:
|
fingerprints:
|
||||||
desc: Generate fingerprints for all non-docker test fixture
|
desc: Generate fingerprints for all non-docker test fixture
|
||||||
silent: true
|
silent: true
|
||||||
# this will look for `test-fixtures/Makefile` and invoke the `fingerprint` target to calculate all cache input fingerprint files
|
# this will look for `testdata/Makefile` and invoke the `fingerprint` target to calculate all cache input fingerprint files
|
||||||
generates:
|
generates:
|
||||||
- '**/test-fixtures/**/*.fingerprint'
|
- '**/testdata/**/*.fingerprint'
|
||||||
- test/install/cache.fingerprint
|
- test/install/cache.fingerprint
|
||||||
cmds:
|
cmds:
|
||||||
- |
|
- |
|
||||||
@@ -277,7 +278,7 @@ tasks:
|
|||||||
RESET='\033[0m'
|
RESET='\033[0m'
|
||||||
|
|
||||||
echo -e "${YELLOW}creating fingerprint files for non-docker fixtures...${RESET}"
|
echo -e "${YELLOW}creating fingerprint files for non-docker fixtures...${RESET}"
|
||||||
for dir in $(find . -type d -name 'test-fixtures'); do
|
for dir in $(find . -type d -name 'testdata'); do
|
||||||
if [ -f "$dir/Makefile" ]; then
|
if [ -f "$dir/Makefile" ]; then
|
||||||
# for debugging...
|
# for debugging...
|
||||||
#echo -e "${YELLOW}• calculating fingerprints in $dir... ${RESET}"
|
#echo -e "${YELLOW}• calculating fingerprints in $dir... ${RESET}"
|
||||||
@@ -370,7 +371,7 @@ tasks:
|
|||||||
build-fixtures:
|
build-fixtures:
|
||||||
desc: Generate all non-docker test fixtures
|
desc: Generate all non-docker test fixtures
|
||||||
silent: true
|
silent: true
|
||||||
# this will look for `test-fixtures/Makefile` and invoke the `fixtures` target to generate any and all test fixtures
|
# this will look for `testdata/Makefile` and invoke the `fixtures` target to generate any and all test fixtures
|
||||||
cmds:
|
cmds:
|
||||||
- |
|
- |
|
||||||
# we want to stop on the first build error
|
# we want to stop on the first build error
|
||||||
@@ -381,7 +382,7 @@ tasks:
|
|||||||
RESET='\033[0m'
|
RESET='\033[0m'
|
||||||
|
|
||||||
# Use a for loop with command substitution to avoid subshell issues
|
# Use a for loop with command substitution to avoid subshell issues
|
||||||
for dir in $(find . -type d -name 'test-fixtures'); do
|
for dir in $(find . -type d -name 'testdata'); do
|
||||||
if [ -f "$dir/Makefile" ]; then
|
if [ -f "$dir/Makefile" ]; then
|
||||||
echo -e "${YELLOW}${BOLD}generating fixtures in $dir${RESET}"
|
echo -e "${YELLOW}${BOLD}generating fixtures in $dir${RESET}"
|
||||||
make -C "$dir" fixtures
|
make -C "$dir" fixtures
|
||||||
@@ -435,7 +436,7 @@ tasks:
|
|||||||
- "echo 'Docker daemon cache:'"
|
- "echo 'Docker daemon cache:'"
|
||||||
- "docker images --format '{{`{{.ID}}`}} {{`{{.Repository}}`}}:{{`{{.Tag}}`}}' | grep stereoscope-fixture- | sort"
|
- "docker images --format '{{`{{.ID}}`}} {{`{{.Repository}}`}}:{{`{{.Tag}}`}}' | grep stereoscope-fixture- | sort"
|
||||||
- "echo '\nTar cache:'"
|
- "echo '\nTar cache:'"
|
||||||
- 'find . -type f -wholename "**/test-fixtures/cache/stereoscope-fixture-*.tar" | sort'
|
- 'find . -type f -wholename "**/testdata/cache/stereoscope-fixture-*.tar" | sort'
|
||||||
|
|
||||||
check-docker-cache:
|
check-docker-cache:
|
||||||
desc: Ensure docker caches aren't using too much disk space
|
desc: Ensure docker caches aren't using too much disk space
|
||||||
@@ -469,7 +470,7 @@ tasks:
|
|||||||
- "cd test/install && make ci-test-mac"
|
- "cd test/install && make ci-test-mac"
|
||||||
|
|
||||||
generate-compare-file:
|
generate-compare-file:
|
||||||
cmd: "go run ./cmd/syft {{ .COMPARE_TEST_IMAGE }} -o json > {{ .COMPARE_DIR }}/test-fixtures/acceptance-{{ .COMPARE_TEST_IMAGE }}.json"
|
cmd: "go run ./cmd/syft {{ .COMPARE_TEST_IMAGE }} -o json > {{ .COMPARE_DIR }}/testdata/acceptance-{{ .COMPARE_TEST_IMAGE }}.json"
|
||||||
|
|
||||||
compare-mac:
|
compare-mac:
|
||||||
deps: [tmpdir]
|
deps: [tmpdir]
|
||||||
@@ -537,15 +538,21 @@ tasks:
|
|||||||
deps:
|
deps:
|
||||||
- tmpdir
|
- tmpdir
|
||||||
- fixtures
|
- fixtures
|
||||||
|
vars:
|
||||||
|
# set REFRESH=true to run package tests first and refresh test observations (default: true)
|
||||||
|
REFRESH: '{{ .REFRESH | default "true" }}'
|
||||||
cmds:
|
cmds:
|
||||||
# remove all test observations prior to regenerating
|
# remove all test observations prior to regenerating
|
||||||
- task: clean-test-observations
|
- task: clean-test-observations
|
||||||
|
if: '{{ eq .REFRESH "true" }}'
|
||||||
# this is required to update test observations; such evidence is used to update the packages/*.yaml
|
# this is required to update test observations; such evidence is used to update the packages/*.yaml
|
||||||
- "go test ./syft/pkg/... -count=1"
|
- cmd: "go test ./syft/pkg/... -count=1"
|
||||||
|
if: '{{ eq .REFRESH "true" }}'
|
||||||
- "go generate ./internal/capabilities/..."
|
- "go generate ./internal/capabilities/..."
|
||||||
- "gofmt -s -w ./internal/capabilities"
|
- "gofmt -s -w ./internal/capabilities"
|
||||||
# now that we have the latest capabilities, run completeness tests to ensure this is self-consistent
|
# now that we have the latest capabilities, run completeness tests to ensure this is self-consistent
|
||||||
- "SYFT_ENABLE_COMPLETENESS_TESTS=true go test ./internal/capabilities/... -count=1"
|
# note: -p 1 forces sequential package execution to avoid race between generate (writes) and internal (reads)
|
||||||
|
- "SYFT_ENABLE_COMPLETENESS_TESTS=true go test -p 1 ./internal/capabilities/... -count=1"
|
||||||
|
|
||||||
|
|
||||||
## Build-related targets #################################
|
## Build-related targets #################################
|
||||||
@@ -638,6 +645,15 @@ tasks:
|
|||||||
|
|
||||||
## Cleanup targets #################################
|
## Cleanup targets #################################
|
||||||
|
|
||||||
|
clean:
|
||||||
|
desc: Remove all cache files and old builds
|
||||||
|
cmds:
|
||||||
|
- task: clean-snapshot
|
||||||
|
- task: clean-cache
|
||||||
|
- task: clean-test-observations
|
||||||
|
- task: clean-docker-cache
|
||||||
|
- task: clean-oras-cache
|
||||||
|
|
||||||
clean-snapshot:
|
clean-snapshot:
|
||||||
desc: Remove any snapshot builds
|
desc: Remove any snapshot builds
|
||||||
cmds:
|
cmds:
|
||||||
@@ -647,7 +663,7 @@ tasks:
|
|||||||
clean-docker-cache:
|
clean-docker-cache:
|
||||||
desc: Remove all docker cache tars and images from the daemon
|
desc: Remove all docker cache tars and images from the daemon
|
||||||
cmds:
|
cmds:
|
||||||
- find . -type d -wholename "**/test-fixtures/cache" | xargs rm -rf
|
- find . -type d -wholename "**/testdata/cache" | xargs rm -rf
|
||||||
- docker images --format '{{`{{.ID}}`}} {{`{{.Repository}}`}}' | grep stereoscope-fixture- | awk '{print $1}' | uniq | xargs -r docker rmi --force
|
- docker images --format '{{`{{.ID}}`}} {{`{{.Repository}}`}}' | grep stereoscope-fixture- | awk '{print $1}' | uniq | xargs -r docker rmi --force
|
||||||
|
|
||||||
clean-oras-cache:
|
clean-oras-cache:
|
||||||
@@ -664,7 +680,7 @@ tasks:
|
|||||||
RESET='\033[0m'
|
RESET='\033[0m'
|
||||||
|
|
||||||
# Use a for loop with command substitution to avoid subshell issues
|
# Use a for loop with command substitution to avoid subshell issues
|
||||||
for dir in $(find . -type d -name 'test-fixtures'); do
|
for dir in $(find . -type d -name 'testdata'); do
|
||||||
if [ -f "$dir/Makefile" ]; then
|
if [ -f "$dir/Makefile" ]; then
|
||||||
echo -e "${YELLOW}${BOLD}deleting ephemeral test fixtures in $dir${RESET}"
|
echo -e "${YELLOW}${BOLD}deleting ephemeral test fixtures in $dir${RESET}"
|
||||||
(make -C "$dir" clean)
|
(make -C "$dir" clean)
|
||||||
@@ -674,6 +690,6 @@ tasks:
|
|||||||
- rm -f {{ .LAST_CACHE_PULL_FILE }} {{ .CACHE_PATHS_FILE }}
|
- rm -f {{ .LAST_CACHE_PULL_FILE }} {{ .CACHE_PATHS_FILE }}
|
||||||
|
|
||||||
clean-test-observations:
|
clean-test-observations:
|
||||||
desc: Remove all test observations (i.e. test-fixtures/test-observations.json)
|
desc: Remove all test observations (i.e. testdata/test-observations.json)
|
||||||
cmds:
|
cmds:
|
||||||
- find . -type f -wholename "**/test-fixtures/test-observations.json" | xargs rm -f
|
- find . -type f -wholename "**/testdata/test-observations.json" | xargs rm -f
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ func (l attestLogFrame) View() string {
|
|||||||
sb := strings.Builder{}
|
sb := strings.Builder{}
|
||||||
|
|
||||||
for _, line := range l.lines {
|
for _, line := range l.lines {
|
||||||
sb.WriteString(fmt.Sprintf(" %s %s\n", l.borderStype.Render("░░"), line))
|
fmt.Fprintf(&sb, " %s %s\n", l.borderStype.Render("░░"), line)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.String()
|
return sb.String()
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ func AppClioSetupConfig(id clio.Identification, out io.Writer) *clio.SetupConfig
|
|||||||
},
|
},
|
||||||
).
|
).
|
||||||
WithPostRuns(func(_ *clio.State, _ error) {
|
WithPostRuns(func(_ *clio.State, _ error) {
|
||||||
stereoscope.Cleanup()
|
stereoscope.Cleanup() //nolint:staticcheck // we don't have access to the image object here
|
||||||
})
|
})
|
||||||
return clioCfg
|
return clioCfg
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ const (
|
|||||||
nonImageSchemeHelp = ` {{.appName}} {{.command}} dir:path/to/yourproject read directly from a path on disk (any directory)
|
nonImageSchemeHelp = ` {{.appName}} {{.command}} dir:path/to/yourproject read directly from a path on disk (any directory)
|
||||||
{{.appName}} {{.command}} file:path/to/yourproject/file read directly from a path on disk (any single file)
|
{{.appName}} {{.command}} file:path/to/yourproject/file read directly from a path on disk (any single file)
|
||||||
`
|
`
|
||||||
scanSchemeHelp = "\n " + schemeHelpHeader + "\n" + imageSchemeHelp + nonImageSchemeHelp
|
modelSchemeHelp = ` {{.appName}} {{.command}} oci-model-registry:ai/llama3.2 scan an OCI model artifact from a registry (e.g. Docker Hub AI models)
|
||||||
|
`
|
||||||
|
scanSchemeHelp = "\n " + schemeHelpHeader + "\n" + imageSchemeHelp + modelSchemeHelp + nonImageSchemeHelp
|
||||||
|
|
||||||
scanHelp = scanExample + scanSchemeHelp
|
scanHelp = scanExample + scanSchemeHelp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -19,30 +19,30 @@ func Test_scanOptions_validateLegacyOptionsNotUsed(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "config file with no legacy options",
|
name: "config file with no legacy options",
|
||||||
cfg: "test-fixtures/scan-configs/no-legacy-options.yaml",
|
cfg: "testdata/scan-configs/no-legacy-options.yaml",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "config file with default image pull source legacy option",
|
name: "config file with default image pull source legacy option",
|
||||||
cfg: "test-fixtures/scan-configs/with-default-pull-source.yaml",
|
cfg: "testdata/scan-configs/with-default-pull-source.yaml",
|
||||||
wantErr: assertErrorContains("source.image.default-pull-source"),
|
wantErr: assertErrorContains("source.image.default-pull-source"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "config file with exclude-binary-overlap-by-ownership legacy option",
|
name: "config file with exclude-binary-overlap-by-ownership legacy option",
|
||||||
cfg: "test-fixtures/scan-configs/with-exclude-binary-overlap-by-ownership.yaml",
|
cfg: "testdata/scan-configs/with-exclude-binary-overlap-by-ownership.yaml",
|
||||||
wantErr: assertErrorContains("package.exclude-binary-overlap-by-ownership"),
|
wantErr: assertErrorContains("package.exclude-binary-overlap-by-ownership"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "config file with file string legacy option",
|
name: "config file with file string legacy option",
|
||||||
cfg: "test-fixtures/scan-configs/with-file-string.yaml",
|
cfg: "testdata/scan-configs/with-file-string.yaml",
|
||||||
wantErr: assertErrorContains("outputs"),
|
wantErr: assertErrorContains("outputs"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "config file with file section",
|
name: "config file with file section",
|
||||||
cfg: "test-fixtures/scan-configs/with-file-section.yaml",
|
cfg: "testdata/scan-configs/with-file-section.yaml",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "config file with base-path legacy option",
|
name: "config file with base-path legacy option",
|
||||||
cfg: "test-fixtures/scan-configs/with-base-path.yaml",
|
cfg: "testdata/scan-configs/with-base-path.yaml",
|
||||||
wantErr: assertErrorContains("source.base-path"),
|
wantErr: assertErrorContains("source.base-path"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ func fetchLatestApplicationVersion(id clio.Identification) (*hashiVersion.Versio
|
|||||||
return nil, fmt.Errorf("HTTP %d on fetching latest version: %s", resp.StatusCode, resp.Status)
|
return nil, fmt.Errorf("HTTP %d on fetching latest version: %s", resp.StatusCode, resp.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
versionBytes, err := io.ReadAll(resp.Body)
|
versionBytes, err := io.ReadAll(io.LimitReader(resp.Body, 500))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read latest version: %w", err)
|
return nil, fmt.Errorf("failed to read latest version: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ func formatVersionOptions(nameVersionPairs []string) string {
|
|||||||
for _, name := range sortedAvailableFormats {
|
for _, name := range sortedAvailableFormats {
|
||||||
s.WriteString("\n")
|
s.WriteString("\n")
|
||||||
|
|
||||||
s.WriteString(fmt.Sprintf(" - %s", name))
|
fmt.Fprintf(&s, " - %s", name)
|
||||||
|
|
||||||
if len(availableVersions[name]) > 0 {
|
if len(availableVersions[name]) > 0 {
|
||||||
s.WriteString(" @ ")
|
s.WriteString(" @ ")
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ func TestPkgCoverageImage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPkgCoverageDirectory(t *testing.T) {
|
func TestPkgCoverageDirectory(t *testing.T) {
|
||||||
sbom, _ := catalogDirectory(t, "test-fixtures/image-pkg-coverage")
|
sbom, _ := catalogDirectory(t, "testdata/image-pkg-coverage")
|
||||||
|
|
||||||
observedLanguages := strset.New()
|
observedLanguages := strset.New()
|
||||||
definedLanguages := strset.New()
|
definedLanguages := strset.New()
|
||||||
@@ -261,7 +261,7 @@ func TestPkgCoverageImage_HasEvidence(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPkgCoverageDirectory_HasEvidence(t *testing.T) {
|
func TestPkgCoverageDirectory_HasEvidence(t *testing.T) {
|
||||||
sbom, _ := catalogDirectory(t, "test-fixtures/image-pkg-coverage")
|
sbom, _ := catalogDirectory(t, "testdata/image-pkg-coverage")
|
||||||
|
|
||||||
var cases []testCase
|
var cases []testCase
|
||||||
cases = append(cases, commonTestCases...)
|
cases = append(cases, commonTestCases...)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
func TestFileCataloging_Default(t *testing.T) {
|
func TestFileCataloging_Default(t *testing.T) {
|
||||||
cfg := options.DefaultCatalog().ToSBOMConfig(clio.Identification{})
|
cfg := options.DefaultCatalog().ToSBOMConfig(clio.Identification{})
|
||||||
cfg = cfg.WithFilesConfig(filecataloging.DefaultConfig())
|
cfg = cfg.WithFilesConfig(filecataloging.DefaultConfig())
|
||||||
sbom, _ := catalogDirectoryWithConfig(t, "test-fixtures/files", cfg)
|
sbom, _ := catalogDirectoryWithConfig(t, "testdata/files", cfg)
|
||||||
|
|
||||||
var metadata map[file.Coordinates]file.Metadata
|
var metadata map[file.Coordinates]file.Metadata
|
||||||
|
|
||||||
@@ -48,13 +48,13 @@ func TestFileCataloging_AllFiles(t *testing.T) {
|
|||||||
SkipFilesAboveSize: 30,
|
SkipFilesAboveSize: 30,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
sbom, _ := catalogDirectoryWithConfig(t, "test-fixtures/files", cfg)
|
sbom, _ := catalogDirectoryWithConfig(t, "testdata/files", cfg)
|
||||||
|
|
||||||
pwd, err := os.Getwd()
|
pwd, err := os.Getwd()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
testPath := func(path string) string {
|
testPath := func(path string) string {
|
||||||
return filepath.Join(pwd, "test-fixtures/files", path)
|
return filepath.Join(pwd, "testdata/files", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata := map[file.Coordinates]file.Metadata{
|
metadata := map[file.Coordinates]file.Metadata{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestNpmPackageLockDirectory(t *testing.T) {
|
func TestNpmPackageLockDirectory(t *testing.T) {
|
||||||
sbom, _ := catalogDirectory(t, "test-fixtures/npm-lock")
|
sbom, _ := catalogDirectory(t, "testdata/npm-lock")
|
||||||
|
|
||||||
foundPackages := strset.New()
|
foundPackages := strset.New()
|
||||||
|
|
||||||
@@ -32,10 +32,11 @@ func TestNpmPackageLockDirectory(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestYarnPackageLockDirectory(t *testing.T) {
|
func TestYarnPackageLockDirectory(t *testing.T) {
|
||||||
sbom, _ := catalogDirectory(t, "test-fixtures/yarn-lock")
|
sbom, _ := catalogDirectory(t, "testdata/yarn-lock")
|
||||||
|
|
||||||
foundPackages := strset.New()
|
foundPackages := strset.New()
|
||||||
expectedPackages := strset.New("async@0.9.2", "async@3.2.3", "merge-objects@1.0.5", "should-type@1.3.0", "@4lolo/resize-observer-polyfill@1.5.2")
|
// merge-objects and should-type are devDependencies in package.json and are excluded by default
|
||||||
|
expectedPackages := strset.New("async@0.9.2", "async@3.2.3", "@4lolo/resize-observer-polyfill@1.5.2")
|
||||||
|
|
||||||
for actualPkg := range sbom.Artifacts.Packages.Enumerate(pkg.NpmPkg) {
|
for actualPkg := range sbom.Artifacts.Packages.Enumerate(pkg.NpmPkg) {
|
||||||
for _, actualLocation := range actualPkg.Locations.ToSlice() {
|
for _, actualLocation := range actualPkg.Locations.ToSlice() {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func TestBinaryElfRelationships(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// run the test...
|
// run the test...
|
||||||
sbom, _ := catalogFixtureImage(t, "elf-test-fixtures", source.SquashedScope)
|
sbom, _ := catalogFixtureImage(t, "elf-testdata", source.SquashedScope)
|
||||||
|
|
||||||
// get a mapping of package names to their IDs
|
// get a mapping of package names to their IDs
|
||||||
nameToId := map[string]artifact.ID{}
|
nameToId := map[string]artifact.ID{}
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ func packageCatalogerExports(t *testing.T) map[string]exportTokenSet {
|
|||||||
if info.IsDir() ||
|
if info.IsDir() ||
|
||||||
!strings.HasSuffix(info.Name(), ".go") ||
|
!strings.HasSuffix(info.Name(), ".go") ||
|
||||||
strings.HasSuffix(info.Name(), "_test.go") ||
|
strings.HasSuffix(info.Name(), "_test.go") ||
|
||||||
strings.Contains(path, "test-fixtures") ||
|
strings.Contains(path, "testdata") ||
|
||||||
strings.Contains(path, "internal") {
|
strings.Contains(path, "internal") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
../../../../../../syft/pkg/cataloger/binary/test-fixtures/elf-test-fixtures
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
See the syft/cataloger/java/test-fixtures/java-builds dir to generate test fixtures and copy to here manually.
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# we should strive to not commit blobs to the repo and strive to keep the build process of how blobs are acquired in-repo.
|
# we should strive to not commit blobs to the repo and strive to keep the build process of how blobs are acquired in-repo.
|
||||||
# this blob is generated from syft/syft/catalogers/java/test-fixtures/java-builds , however, preserving the build process
|
# this blob is generated from syft/syft/catalogers/java/testdata/java-builds , however, preserving the build process
|
||||||
# twice in the repo seems redundant (even via symlink). Given that the fixture is a few kilobytes in size, the build process is already
|
# twice in the repo seems redundant (even via symlink). Given that the fixture is a few kilobytes in size, the build process is already
|
||||||
# captured, and integration tests should only be testing if jars can be discovered (not necessarily depth in java detection
|
# captured, and integration tests should only be testing if jars can be discovered (not necessarily depth in java detection
|
||||||
# functionality), committing it seems like an acceptable exception.
|
# functionality), committing it seems like an acceptable exception.
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
../../../../../../syft/pkg/cataloger/binary/testdata/elf-testdata
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
See the syft/cataloger/java/testdata/java-builds dir to generate test fixtures and copy to here manually.
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user