mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 14:02:26 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69692ad901 |
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
set -ue
|
||||||
|
|
||||||
set +xu
|
set +xu
|
||||||
if [ -z "$AC_USERNAME" ]; then
|
if [ -z "$AC_USERNAME" ]; then
|
||||||
@@ -10,33 +11,58 @@ if [ -z "$AC_PASSWORD" ]; then
|
|||||||
fi
|
fi
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
|
# repackage [archive-path]
|
||||||
|
#
|
||||||
|
# returns an archive compatible for Apple's notarization process, repackaging the input archive as needed
|
||||||
|
#
|
||||||
|
repackage() {
|
||||||
|
archive=$1
|
||||||
|
|
||||||
|
case "$archive" in
|
||||||
|
*.tar.gz)
|
||||||
|
new_archive=${archive%.tar.gz}.zip
|
||||||
|
(
|
||||||
|
tmp_dir=$(mktemp -d)
|
||||||
|
cd "$tmp_dir"
|
||||||
|
# redirect stdout to stderr to preserve the return value
|
||||||
|
tar xzf "$archive" && zip "$new_archive" ./* 1>&2
|
||||||
|
rm -rf "$tmp_dir"
|
||||||
|
)
|
||||||
|
echo "$new_archive"
|
||||||
|
;;
|
||||||
|
*.zip)
|
||||||
|
echo "$archive"
|
||||||
|
;;
|
||||||
|
*) return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# notarize [archive-path]
|
# notarize [archive-path]
|
||||||
#
|
#
|
||||||
notarize() {
|
notarize() {
|
||||||
binary_path=$1
|
archive_path=$1
|
||||||
archive_path=${binary_path}-archive-for-notarization.zip
|
|
||||||
|
|
||||||
title "archiving release binary into ${archive_path}"
|
title "notarizing binaries found in the release archive"
|
||||||
|
|
||||||
parent=$(dirname "$binary_path")
|
payload_archive_path=$(repackage "$archive_path")
|
||||||
(
|
if [ "$?" != "0" ]; then
|
||||||
cd "${parent}" && zip "${archive_path}" "$(basename ${binary_path})"
|
exit_with_error "cannot prepare payload for notarization: $archive_path"
|
||||||
)
|
fi
|
||||||
|
|
||||||
if [ ! -f "$archive_path" ]; then
|
if [ ! -f "$payload_archive_path" ]; then
|
||||||
exit_with_error "cannot find payload for notarization: $archive_path"
|
exit_with_error "cannot find payload for notarization: $payload_archive_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install gon
|
# install gon
|
||||||
which gon || (brew tap mitchellh/gon && brew install mitchellh/gon/gon)
|
which gon || (brew tap mitchellh/gon && brew install mitchellh/gon/gon)
|
||||||
|
|
||||||
# create config (note: json via stdin with gon is broken, can only use HCL from file)
|
# create config (note: json via stdin with gon is broken, can only use HCL from file)
|
||||||
hcl_file=$(mktemp).hcl
|
tmp_file=$(mktemp).hcl
|
||||||
|
|
||||||
cat <<EOF > "$hcl_file"
|
cat <<EOF > "$tmp_file"
|
||||||
notarize {
|
notarize {
|
||||||
path = "$archive_path"
|
path = "$payload_archive_path"
|
||||||
bundle_id = "com.anchore.toolbox.syft"
|
bundle_id = "com.anchore.toolbox.syft"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,8 +72,14 @@ apple_id {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
gon -log-level info "$hcl_file"
|
gon -log-level info "$tmp_file"
|
||||||
|
|
||||||
rm "${hcl_file}" "${archive_path}"
|
result="$?"
|
||||||
|
|
||||||
|
rm "$tmp_file"
|
||||||
|
|
||||||
|
if [ "$result" -ne "0" ]; then
|
||||||
|
exit_with_error "notarization failed"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ IS_SNAPSHOT="$1"
|
|||||||
## grab utilities
|
## grab utilities
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
. "$SCRIPT_DIR"/utils.sh
|
. "$SCRIPT_DIR"/utils.sh
|
||||||
mkdir -p "$SCRIPT_DIR/log"
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
|
||||||
@@ -34,13 +33,17 @@ main() {
|
|||||||
echo -n "$MAC_SIGNING_IDENTITY" > "$SCRIPT_DIR/$SIGNING_IDENTITY_FILENAME"
|
echo -n "$MAC_SIGNING_IDENTITY" > "$SCRIPT_DIR/$SIGNING_IDENTITY_FILENAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
# capture all output from a subshell to log output additionally to a file (as well as the terminal)
|
set +u
|
||||||
( (
|
if [ -z "$SCRIPT" ]
|
||||||
set +u
|
then
|
||||||
if [ -n "$SKIP_SIGNING" ]; then
|
|
||||||
commentary "skipping signing setup..."
|
|
||||||
else
|
|
||||||
set -u
|
set -u
|
||||||
main
|
# log all output
|
||||||
fi
|
mkdir -p "$SCRIPT_DIR/log"
|
||||||
) 2>&1) | tee "$SCRIPT_DIR/log/setup.txt"
|
/usr/bin/script "$SCRIPT_DIR/log/setup.txt" /bin/bash -c "$0 $*"
|
||||||
|
exit $?
|
||||||
|
elif [ -n "$SKIP_SIGNING" ]; then
|
||||||
|
commentary "skipping signing setup..."
|
||||||
|
else
|
||||||
|
set -u
|
||||||
|
main
|
||||||
|
fi
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eu -o pipefail
|
set -eu
|
||||||
|
|
||||||
BINARY_PATH="$1"
|
ARCHIVE_PATH="$1"
|
||||||
IS_SNAPSHOT="$2"
|
IS_SNAPSHOT="$2"
|
||||||
TARGET_NAME="$3"
|
|
||||||
|
|
||||||
## grab utilities
|
## grab utilities
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
. "$SCRIPT_DIR"/utils.sh
|
. "$SCRIPT_DIR"/utils.sh
|
||||||
mkdir -p "$SCRIPT_DIR/log"
|
|
||||||
|
|
||||||
|
|
||||||
# sign_binary [binary-path] [signing-identity]
|
# sign_binary [binary-path] [signing-identity]
|
||||||
@@ -40,14 +38,58 @@ sign_binary() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
codesign --verify "$exe_path" --verbose=4
|
codesign --verify "$exe_path" --verbose=4
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
exit_with_error "signing verification failed"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# sign_binaries_in_archive [archive-abs-path] [signing-identity]
|
||||||
|
#
|
||||||
|
# signs all binaries within an archive (there must be at least one)
|
||||||
|
#
|
||||||
|
sign_binaries_in_archive() {
|
||||||
|
archive_abs_path=$1
|
||||||
|
identity=$2
|
||||||
|
|
||||||
|
scratch_path=$(mktemp -d)
|
||||||
|
trap "rm -rf -- $scratch_path" EXIT
|
||||||
|
|
||||||
|
title "getting contents from the release archive: $archive_abs_path"
|
||||||
|
tar -C "$scratch_path" -xvf "$archive_abs_path"
|
||||||
|
|
||||||
|
# invalidate the current archive, we only want an asset with signed binaries from this point forward
|
||||||
|
rm "$archive_abs_path"
|
||||||
|
|
||||||
|
title "signing binaries found in the release archive"
|
||||||
|
|
||||||
|
discovered_binaries=0
|
||||||
|
tmp_pipe=$(mktemp -ut pipe.XXX)
|
||||||
|
mkfifo "$tmp_pipe"
|
||||||
|
|
||||||
|
find "$scratch_path" -perm +111 -type f > "$tmp_pipe" &
|
||||||
|
|
||||||
|
while IFS= read -r binary; do
|
||||||
|
sign_binary "$binary" "$identity"
|
||||||
|
((discovered_binaries++))
|
||||||
|
done < "$tmp_pipe"
|
||||||
|
|
||||||
|
rm "$tmp_pipe"
|
||||||
|
|
||||||
|
if [ "$discovered_binaries" = "0" ]; then
|
||||||
|
exit_with_error "found no binaries to sign"
|
||||||
|
fi
|
||||||
|
|
||||||
|
title "recreating the release archive: $archive_abs_path"
|
||||||
|
(cd "$scratch_path" && tar -czvf "$archive_abs_path" .)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
binary_abs_path=$(realpath "$BINARY_PATH")
|
archive_abs_path=$(realpath "$ARCHIVE_PATH")
|
||||||
|
|
||||||
if [ ! -f "$binary_abs_path" ]; then
|
if [ ! -f "$archive_abs_path" ]; then
|
||||||
echo "archive does not exist: $binary_abs_path"
|
echo "archive does not exist: $archive_abs_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$IS_SNAPSHOT" in
|
case "$IS_SNAPSHOT" in
|
||||||
@@ -72,23 +114,27 @@ main() {
|
|||||||
MAC_SIGNING_IDENTITY=$(cat "$SCRIPT_DIR/$SIGNING_IDENTITY_FILENAME")
|
MAC_SIGNING_IDENTITY=$(cat "$SCRIPT_DIR/$SIGNING_IDENTITY_FILENAME")
|
||||||
|
|
||||||
# sign all of the binaries in the archive and recreate the input archive with the signed binaries
|
# sign all of the binaries in the archive and recreate the input archive with the signed binaries
|
||||||
sign_binary "$binary_abs_path" "$MAC_SIGNING_IDENTITY"
|
sign_binaries_in_archive "$archive_abs_path" "$MAC_SIGNING_IDENTITY"
|
||||||
|
|
||||||
# send all of the binaries off to apple to bless
|
# send all of the binaries off to apple to bless
|
||||||
if $perform_notarization ; then
|
if $perform_notarization ; then
|
||||||
notarize "$binary_abs_path"
|
notarize "$archive_abs_path"
|
||||||
else
|
else
|
||||||
commentary "skipping notarization..."
|
commentary "skipping notarization..."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# capture all output from a subshell to log output additionally to a file (as well as the terminal)
|
set +u
|
||||||
( (
|
if [ -z "$SCRIPT" ]
|
||||||
set +u
|
then
|
||||||
if [ -n "$SKIP_SIGNING" ]; then
|
|
||||||
commentary "skipping signing..."
|
|
||||||
else
|
|
||||||
set -u
|
set -u
|
||||||
main
|
# log all output
|
||||||
fi
|
mkdir -p "$SCRIPT_DIR/log"
|
||||||
) 2>&1) | tee "$SCRIPT_DIR/log/signing-$(basename $BINARY_PATH)-$TARGET_NAME.txt"
|
/usr/bin/script "$SCRIPT_DIR/log/signing-$(basename $ARCHIVE_PATH).txt" /bin/bash -c "$0 $*"
|
||||||
|
exit $?
|
||||||
|
elif [ -n "$SKIP_SIGNING" ]; then
|
||||||
|
commentary "skipping signing..."
|
||||||
|
else
|
||||||
|
set -u
|
||||||
|
main
|
||||||
|
fi
|
||||||
|
|||||||
+10
-5
@@ -41,11 +41,6 @@ builds:
|
|||||||
mod_timestamp: *build-timestamp
|
mod_timestamp: *build-timestamp
|
||||||
env: *build-env
|
env: *build-env
|
||||||
ldflags: *build-ldflags
|
ldflags: *build-ldflags
|
||||||
hooks:
|
|
||||||
post:
|
|
||||||
# we must have signing as a build hook instead of the signs section. The signs section must register a new asset, where we want to replace an existing asset.
|
|
||||||
# a post-build hook has the advantage of not needing to unpackage and repackage a tar.gz with a signed binary
|
|
||||||
- ./.github/scripts/apple-signing/sign.sh "{{ .Path }}" "{{ .IsSnapshot }}" "{{ .Target }}"
|
|
||||||
|
|
||||||
- id: windows-build
|
- id: windows-build
|
||||||
binary: syft
|
binary: syft
|
||||||
@@ -72,6 +67,16 @@ archives:
|
|||||||
builds:
|
builds:
|
||||||
- windows-build
|
- windows-build
|
||||||
|
|
||||||
|
signs:
|
||||||
|
- artifacts: archive
|
||||||
|
ids:
|
||||||
|
- darwin-archives
|
||||||
|
signature: "${artifact}"
|
||||||
|
cmd: ./.github/scripts/apple-signing/sign.sh
|
||||||
|
args:
|
||||||
|
- "${artifact}"
|
||||||
|
- "{{ .IsSnapshot }}"
|
||||||
|
|
||||||
nfpms:
|
nfpms:
|
||||||
- license: "Apache 2.0"
|
- license: "Apache 2.0"
|
||||||
maintainer: "Anchore, Inc"
|
maintainer: "Anchore, Inc"
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ bootstrap-tools: $(TEMPDIR)
|
|||||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TEMPDIR)/ v1.42.1
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TEMPDIR)/ v1.42.1
|
||||||
curl -sSfL https://raw.githubusercontent.com/wagoodman/go-bouncer/master/bouncer.sh | sh -s -- -b $(TEMPDIR)/ v0.3.0
|
curl -sSfL https://raw.githubusercontent.com/wagoodman/go-bouncer/master/bouncer.sh | sh -s -- -b $(TEMPDIR)/ v0.3.0
|
||||||
curl -sSfL https://raw.githubusercontent.com/anchore/chronicle/main/install.sh | sh -s -- -b $(TEMPDIR)/ v0.3.0
|
curl -sSfL https://raw.githubusercontent.com/anchore/chronicle/main/install.sh | sh -s -- -b $(TEMPDIR)/ v0.3.0
|
||||||
.github/scripts/goreleaser-install.sh -d -b $(TEMPDIR)/ v1.4.1
|
.github/scripts/goreleaser-install.sh -d -b $(TEMPDIR)/ v1.3.1
|
||||||
GOBIN="$(shell realpath $(TEMPDIR))" go install github.com/neilpa/yajsv@v1.4.0
|
GOBIN="$(shell realpath $(TEMPDIR))" go install github.com/neilpa/yajsv@v1.4.0
|
||||||
|
|
||||||
.PHONY: bootstrap-go
|
.PHONY: bootstrap-go
|
||||||
@@ -316,11 +316,9 @@ release: clean-dist CHANGELOG.md ## Build and publish final binaries and packag
|
|||||||
|
|
||||||
rm -f .github/scripts/apple-signing/log/*.txt
|
rm -f .github/scripts/apple-signing/log/*.txt
|
||||||
|
|
||||||
# note: notarization cannot be done in parallel, thus --parallelism 1
|
|
||||||
bash -c "\
|
bash -c "\
|
||||||
$(RELEASE_CMD) \
|
$(RELEASE_CMD) \
|
||||||
--config $(TEMPDIR)/goreleaser.yaml \
|
--config $(TEMPDIR)/goreleaser.yaml \
|
||||||
--parallelism 1 \
|
|
||||||
--release-notes <(cat CHANGELOG.md)\
|
--release-notes <(cat CHANGELOG.md)\
|
||||||
|| cat .github/scripts/apple-signing/log/*.txt && false"
|
|| cat .github/scripts/apple-signing/log/*.txt && false"
|
||||||
|
|
||||||
|
|||||||
+8
-7
@@ -6,10 +6,10 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
"github.com/anchore/go-logger/logrus"
|
||||||
"github.com/anchore/stereoscope"
|
"github.com/anchore/stereoscope"
|
||||||
"github.com/anchore/syft/internal/config"
|
"github.com/anchore/syft/internal/config"
|
||||||
"github.com/anchore/syft/internal/log"
|
"github.com/anchore/syft/internal/log"
|
||||||
"github.com/anchore/syft/internal/logger"
|
|
||||||
"github.com/anchore/syft/internal/version"
|
"github.com/anchore/syft/internal/version"
|
||||||
"github.com/anchore/syft/syft"
|
"github.com/anchore/syft/syft"
|
||||||
"github.com/gookit/color"
|
"github.com/gookit/color"
|
||||||
@@ -88,7 +88,7 @@ func initAppConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initLogging() {
|
func initLogging() {
|
||||||
cfg := logger.LogrusConfig{
|
cfg := logrus.Config{
|
||||||
EnableConsole: (appConfig.Log.FileLocation == "" || appConfig.CliOptions.Verbosity > 0) && !appConfig.Quiet,
|
EnableConsole: (appConfig.Log.FileLocation == "" || appConfig.CliOptions.Verbosity > 0) && !appConfig.Quiet,
|
||||||
EnableFile: appConfig.Log.FileLocation != "",
|
EnableFile: appConfig.Log.FileLocation != "",
|
||||||
Level: appConfig.Log.LevelOpt,
|
Level: appConfig.Log.LevelOpt,
|
||||||
@@ -96,11 +96,12 @@ func initLogging() {
|
|||||||
FileLocation: appConfig.Log.FileLocation,
|
FileLocation: appConfig.Log.FileLocation,
|
||||||
}
|
}
|
||||||
|
|
||||||
logWrapper := logger.NewLogrusLogger(cfg)
|
logger, err := logrus.New(cfg)
|
||||||
syft.SetLogger(logWrapper)
|
if err != nil {
|
||||||
stereoscope.SetLogger(&logger.LogrusNestedLogger{
|
panic(err)
|
||||||
Logger: logWrapper.Logger.WithField("from-lib", "stereoscope"),
|
}
|
||||||
})
|
syft.SetLogger(logger)
|
||||||
|
stereoscope.SetLogger(logger.Nested("from-lib", "stereoscope"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func logAppConfig() {
|
func logAppConfig() {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ require (
|
|||||||
github.com/adrg/xdg v0.2.1
|
github.com/adrg/xdg v0.2.1
|
||||||
github.com/alecthomas/jsonschema v0.0.0-20210301060011-54c507b6f074
|
github.com/alecthomas/jsonschema v0.0.0-20210301060011-54c507b6f074
|
||||||
github.com/anchore/client-go v0.0.0-20210222170800-9c70f9b80bcf
|
github.com/anchore/client-go v0.0.0-20210222170800-9c70f9b80bcf
|
||||||
|
github.com/anchore/go-logger v0.0.0
|
||||||
github.com/anchore/go-rpmdb v0.0.0-20210914181456-a9c52348da63
|
github.com/anchore/go-rpmdb v0.0.0-20210914181456-a9c52348da63
|
||||||
github.com/anchore/go-testutils v0.0.0-20200925183923-d5f45b0d3c04
|
github.com/anchore/go-testutils v0.0.0-20200925183923-d5f45b0d3c04
|
||||||
github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b
|
github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b
|
||||||
@@ -29,7 +30,6 @@ require (
|
|||||||
github.com/gookit/color v1.2.7
|
github.com/gookit/color v1.2.7
|
||||||
github.com/hashicorp/go-multierror v1.1.0
|
github.com/hashicorp/go-multierror v1.1.0
|
||||||
github.com/jinzhu/copier v0.3.2
|
github.com/jinzhu/copier v0.3.2
|
||||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
|
||||||
github.com/mholt/archiver/v3 v3.5.1
|
github.com/mholt/archiver/v3 v3.5.1
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2
|
github.com/mitchellh/hashstructure/v2 v2.0.2
|
||||||
@@ -50,10 +50,13 @@ require (
|
|||||||
github.com/wagoodman/go-partybus v0.0.0-20210627031916-db1f5573bbc5
|
github.com/wagoodman/go-partybus v0.0.0-20210627031916-db1f5573bbc5
|
||||||
github.com/wagoodman/go-progress v0.0.0-20200731105512-1020f39e6240
|
github.com/wagoodman/go-progress v0.0.0-20200731105512-1020f39e6240
|
||||||
github.com/wagoodman/jotframe v0.0.0-20211129225309-56b0d0a4aebb
|
github.com/wagoodman/jotframe v0.0.0-20211129225309-56b0d0a4aebb
|
||||||
github.com/x-cray/logrus-prefixed-formatter v0.5.2
|
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0
|
github.com/xeipuuv/gojsonschema v1.2.0
|
||||||
golang.org/x/mod v0.4.2
|
golang.org/x/mod v0.4.2
|
||||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2
|
||||||
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
|
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace github.com/anchore/stereoscope => ../stereoscope
|
||||||
|
|
||||||
|
replace github.com/anchore/go-logger => ../go-logger
|
||||||
|
|||||||
@@ -111,8 +111,6 @@ github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b h1:e1bmaoJfZV
|
|||||||
github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b/go.mod h1:Bkc+JYWjMCF8OyZ340IMSIi2Ebf3uwByOk6ho4wne1E=
|
github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b/go.mod h1:Bkc+JYWjMCF8OyZ340IMSIi2Ebf3uwByOk6ho4wne1E=
|
||||||
github.com/anchore/packageurl-go v0.0.0-20210922164639-b3fa992ebd29 h1:K9LfnxwhqvihqU0+MF325FNy7fsKV9EGaUxdfR4gnWk=
|
github.com/anchore/packageurl-go v0.0.0-20210922164639-b3fa992ebd29 h1:K9LfnxwhqvihqU0+MF325FNy7fsKV9EGaUxdfR4gnWk=
|
||||||
github.com/anchore/packageurl-go v0.0.0-20210922164639-b3fa992ebd29/go.mod h1:Oc1UkGaJwY6ND6vtAqPSlYrptKRJngHwkwB6W7l1uP0=
|
github.com/anchore/packageurl-go v0.0.0-20210922164639-b3fa992ebd29/go.mod h1:Oc1UkGaJwY6ND6vtAqPSlYrptKRJngHwkwB6W7l1uP0=
|
||||||
github.com/anchore/stereoscope v0.0.0-20220201190559-f162f1e96f45 h1:GYwI1qXcGh7fmyUWLK41suUXYfmrvGWWKGh0cw+k6ug=
|
|
||||||
github.com/anchore/stereoscope v0.0.0-20220201190559-f162f1e96f45/go.mod h1:QpDHHV2h1NNfu7klzU75XC8RvSlaPK6HHgi0dy8A6sk=
|
|
||||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
||||||
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||||
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
|
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
|
||||||
@@ -578,12 +576,14 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN
|
|||||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
||||||
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
|
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
|
||||||
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
|
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
|
||||||
|
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mattn/go-isatty v0.0.6 h1:SrwhHcpV4nWrMGdNcC2kXpMfcBVYGDuTArqyhocJgvA=
|
|
||||||
github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||||
|
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||||
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||||
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=
|
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=
|
||||||
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||||
@@ -896,8 +896,9 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
|||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=
|
|
||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||||
|
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 h1:71vQrMauZZhcTVK6KdYM+rklehEEwb3E+ZhaE5jrPrE=
|
||||||
|
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
@@ -1105,6 +1106,7 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08 h1:WecRHqgE09JBkh/584XIE6PMz5KKE/vER4izNUi30AQ=
|
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08 h1:WecRHqgE09JBkh/584XIE6PMz5KKE/vER4izNUi30AQ=
|
||||||
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211110154304-99a53858aa08/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
|||||||
+6
-1
@@ -3,7 +3,7 @@ Package log contains the singleton object and helper functions for facilitating
|
|||||||
*/
|
*/
|
||||||
package log
|
package log
|
||||||
|
|
||||||
import "github.com/anchore/syft/syft/logger"
|
import "github.com/anchore/go-logger"
|
||||||
|
|
||||||
// Log is the singleton used to facilitate logging internally within syft
|
// Log is the singleton used to facilitate logging internally within syft
|
||||||
var Log logger.Logger = &nopLogger{}
|
var Log logger.Logger = &nopLogger{}
|
||||||
@@ -47,3 +47,8 @@ func Debugf(format string, args ...interface{}) {
|
|||||||
func Debug(args ...interface{}) {
|
func Debug(args ...interface{}) {
|
||||||
Log.Debug(args...)
|
Log.Debug(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithFields returns a message logger with multiple key-value fields.
|
||||||
|
func WithFields(fields ...interface{}) logger.MessageLogger {
|
||||||
|
return Log.WithFields(fields...)
|
||||||
|
}
|
||||||
|
|||||||
+14
-8
@@ -1,12 +1,18 @@
|
|||||||
package log
|
package log
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/anchore/go-logger"
|
||||||
|
)
|
||||||
|
|
||||||
type nopLogger struct{}
|
type nopLogger struct{}
|
||||||
|
|
||||||
func (l *nopLogger) Errorf(format string, args ...interface{}) {}
|
func (l *nopLogger) Errorf(format string, args ...interface{}) {}
|
||||||
func (l *nopLogger) Error(args ...interface{}) {}
|
func (l *nopLogger) Error(args ...interface{}) {}
|
||||||
func (l *nopLogger) Warnf(format string, args ...interface{}) {}
|
func (l *nopLogger) Warnf(format string, args ...interface{}) {}
|
||||||
func (l *nopLogger) Warn(args ...interface{}) {}
|
func (l *nopLogger) Warn(args ...interface{}) {}
|
||||||
func (l *nopLogger) Infof(format string, args ...interface{}) {}
|
func (l *nopLogger) Infof(format string, args ...interface{}) {}
|
||||||
func (l *nopLogger) Info(args ...interface{}) {}
|
func (l *nopLogger) Info(args ...interface{}) {}
|
||||||
func (l *nopLogger) Debugf(format string, args ...interface{}) {}
|
func (l *nopLogger) Debugf(format string, args ...interface{}) {}
|
||||||
func (l *nopLogger) Debug(args ...interface{}) {}
|
func (l *nopLogger) Debug(args ...interface{}) {}
|
||||||
|
func (l *nopLogger) WithFields(fields ...interface{}) logger.MessageLogger { return l }
|
||||||
|
func (l *nopLogger) Nested(fields ...interface{}) logger.Logger { return l }
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
/*
|
|
||||||
Package logger contains implementations for the syft.logger.Logger interface.
|
|
||||||
*/
|
|
||||||
package logger
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
package logger
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"io/fs"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
|
||||||
)
|
|
||||||
|
|
||||||
const defaultLogFilePermissions fs.FileMode = 0644
|
|
||||||
|
|
||||||
// LogrusConfig contains all configurable values for the Logrus logger
|
|
||||||
type LogrusConfig struct {
|
|
||||||
EnableConsole bool
|
|
||||||
EnableFile bool
|
|
||||||
Structured bool
|
|
||||||
Level logrus.Level
|
|
||||||
FileLocation string
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogrusLogger contains all runtime values for using Logrus with the configured output target and input configuration values.
|
|
||||||
type LogrusLogger struct {
|
|
||||||
Config LogrusConfig
|
|
||||||
Logger *logrus.Logger
|
|
||||||
Output io.Writer
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogrusNestedLogger is a wrapper for Logrus to enable nested logging configuration (loggers that always attach key-value pairs to all log entries)
|
|
||||||
type LogrusNestedLogger struct {
|
|
||||||
Logger *logrus.Entry
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewLogrusLogger creates a new LogrusLogger with the given configuration
|
|
||||||
func NewLogrusLogger(cfg LogrusConfig) *LogrusLogger {
|
|
||||||
appLogger := logrus.New()
|
|
||||||
|
|
||||||
var output io.Writer
|
|
||||||
switch {
|
|
||||||
case cfg.EnableConsole && cfg.EnableFile:
|
|
||||||
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE, defaultLogFilePermissions)
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("unable to setup log file: %w", err))
|
|
||||||
}
|
|
||||||
output = io.MultiWriter(os.Stderr, logFile)
|
|
||||||
case cfg.EnableConsole:
|
|
||||||
output = os.Stderr
|
|
||||||
case cfg.EnableFile:
|
|
||||||
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE, defaultLogFilePermissions)
|
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Errorf("unable to setup log file: %w", err))
|
|
||||||
}
|
|
||||||
output = logFile
|
|
||||||
default:
|
|
||||||
output = ioutil.Discard
|
|
||||||
}
|
|
||||||
|
|
||||||
appLogger.SetOutput(output)
|
|
||||||
appLogger.SetLevel(cfg.Level)
|
|
||||||
|
|
||||||
if cfg.Structured {
|
|
||||||
appLogger.SetFormatter(&logrus.JSONFormatter{
|
|
||||||
TimestampFormat: "2006-01-02 15:04:05",
|
|
||||||
DisableTimestamp: false,
|
|
||||||
DisableHTMLEscape: false,
|
|
||||||
PrettyPrint: false,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
appLogger.SetFormatter(&prefixed.TextFormatter{
|
|
||||||
TimestampFormat: "2006-01-02 15:04:05",
|
|
||||||
ForceColors: true,
|
|
||||||
ForceFormatting: true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return &LogrusLogger{
|
|
||||||
Config: cfg,
|
|
||||||
Logger: appLogger,
|
|
||||||
Output: output,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debugf takes a formatted template string and template arguments for the debug logging level.
|
|
||||||
func (l *LogrusLogger) Debugf(format string, args ...interface{}) {
|
|
||||||
l.Logger.Debugf(format, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Infof takes a formatted template string and template arguments for the info logging level.
|
|
||||||
func (l *LogrusLogger) Infof(format string, args ...interface{}) {
|
|
||||||
l.Logger.Infof(format, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Warnf takes a formatted template string and template arguments for the warning logging level.
|
|
||||||
func (l *LogrusLogger) Warnf(format string, args ...interface{}) {
|
|
||||||
l.Logger.Warnf(format, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Errorf takes a formatted template string and template arguments for the error logging level.
|
|
||||||
func (l *LogrusLogger) Errorf(format string, args ...interface{}) {
|
|
||||||
l.Logger.Errorf(format, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debug logs the given arguments at the debug logging level.
|
|
||||||
func (l *LogrusLogger) Debug(args ...interface{}) {
|
|
||||||
l.Logger.Debug(args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Info logs the given arguments at the info logging level.
|
|
||||||
func (l *LogrusLogger) Info(args ...interface{}) {
|
|
||||||
l.Logger.Info(args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Warn logs the given arguments at the warning logging level.
|
|
||||||
func (l *LogrusLogger) Warn(args ...interface{}) {
|
|
||||||
l.Logger.Warn(args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error logs the given arguments at the error logging level.
|
|
||||||
func (l *LogrusLogger) Error(args ...interface{}) {
|
|
||||||
l.Logger.Error(args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debugf takes a formatted template string and template arguments for the debug logging level.
|
|
||||||
func (l *LogrusNestedLogger) Debugf(format string, args ...interface{}) {
|
|
||||||
l.Logger.Debugf(format, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Infof takes a formatted template string and template arguments for the info logging level.
|
|
||||||
func (l *LogrusNestedLogger) Infof(format string, args ...interface{}) {
|
|
||||||
l.Logger.Infof(format, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Warnf takes a formatted template string and template arguments for the warning logging level.
|
|
||||||
func (l *LogrusNestedLogger) Warnf(format string, args ...interface{}) {
|
|
||||||
l.Logger.Warnf(format, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Errorf takes a formatted template string and template arguments for the error logging level.
|
|
||||||
func (l *LogrusNestedLogger) Errorf(format string, args ...interface{}) {
|
|
||||||
l.Logger.Errorf(format, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Debug logs the given arguments at the debug logging level.
|
|
||||||
func (l *LogrusNestedLogger) Debug(args ...interface{}) {
|
|
||||||
l.Logger.Debug(args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Info logs the given arguments at the info logging level.
|
|
||||||
func (l *LogrusNestedLogger) Info(args ...interface{}) {
|
|
||||||
l.Logger.Info(args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Warn logs the given arguments at the warning logging level.
|
|
||||||
func (l *LogrusNestedLogger) Warn(args ...interface{}) {
|
|
||||||
l.Logger.Warn(args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Error logs the given arguments at the error logging level.
|
|
||||||
func (l *LogrusNestedLogger) Error(args ...interface{}) {
|
|
||||||
l.Logger.Error(args...)
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
// Code generated by go generate; DO NOT EDIT.
|
// Code generated by go generate; DO NOT EDIT.
|
||||||
// This file was generated by robots at 2022-02-07 09:34:56.622482 -0500 EST m=+0.351558414
|
// This file was generated by robots at 2021-11-15 14:32:22.081911 -0500 EST m=+0.159302107
|
||||||
// using data from https://spdx.org/licenses/licenses.json
|
// using data from https://spdx.org/licenses/licenses.json
|
||||||
package spdxlicense
|
package spdxlicense
|
||||||
|
|
||||||
const Version = "3.16"
|
const Version = "3.15"
|
||||||
|
|
||||||
var licenseIDs = map[string]string{
|
var licenseIDs = map[string]string{
|
||||||
"0bsd": "0BSD",
|
"0bsd": "0BSD",
|
||||||
@@ -64,7 +64,6 @@ var licenseIDs = map[string]string{
|
|||||||
"apl-1": "APL-1.0",
|
"apl-1": "APL-1.0",
|
||||||
"apl-1.0": "APL-1.0",
|
"apl-1.0": "APL-1.0",
|
||||||
"apl-1.0.0": "APL-1.0",
|
"apl-1.0.0": "APL-1.0",
|
||||||
"app-s2p": "App-s2p",
|
|
||||||
"apsl-1": "APSL-1.0",
|
"apsl-1": "APSL-1.0",
|
||||||
"apsl-1.0": "APSL-1.0",
|
"apsl-1.0": "APSL-1.0",
|
||||||
"apsl-1.0.0": "APSL-1.0",
|
"apsl-1.0.0": "APSL-1.0",
|
||||||
@@ -400,9 +399,6 @@ var licenseIDs = map[string]string{
|
|||||||
"d-fsl-1.0": "D-FSL-1.0",
|
"d-fsl-1.0": "D-FSL-1.0",
|
||||||
"d-fsl-1.0.0": "D-FSL-1.0",
|
"d-fsl-1.0.0": "D-FSL-1.0",
|
||||||
"diffmark": "diffmark",
|
"diffmark": "diffmark",
|
||||||
"dl-de-by-2": "DL-DE-BY-2.0",
|
|
||||||
"dl-de-by-2.0": "DL-DE-BY-2.0",
|
|
||||||
"dl-de-by-2.0.0": "DL-DE-BY-2.0",
|
|
||||||
"doc": "DOC",
|
"doc": "DOC",
|
||||||
"dotseqn": "Dotseqn",
|
"dotseqn": "Dotseqn",
|
||||||
"drl-1": "DRL-1.0",
|
"drl-1": "DRL-1.0",
|
||||||
@@ -426,9 +422,6 @@ var licenseIDs = map[string]string{
|
|||||||
"efl-2.0": "EFL-2.0",
|
"efl-2.0": "EFL-2.0",
|
||||||
"efl-2.0.0": "EFL-2.0",
|
"efl-2.0.0": "EFL-2.0",
|
||||||
"egenix": "eGenix",
|
"egenix": "eGenix",
|
||||||
"elastic-2": "Elastic-2.0",
|
|
||||||
"elastic-2.0": "Elastic-2.0",
|
|
||||||
"elastic-2.0.0": "Elastic-2.0",
|
|
||||||
"entessa": "Entessa",
|
"entessa": "Entessa",
|
||||||
"epics": "EPICS",
|
"epics": "EPICS",
|
||||||
"epl-1": "EPL-1.0",
|
"epl-1": "EPL-1.0",
|
||||||
@@ -603,7 +596,6 @@ var licenseIDs = map[string]string{
|
|||||||
"ipl-1.0": "IPL-1.0",
|
"ipl-1.0": "IPL-1.0",
|
||||||
"ipl-1.0.0": "IPL-1.0",
|
"ipl-1.0.0": "IPL-1.0",
|
||||||
"isc": "ISC",
|
"isc": "ISC",
|
||||||
"jam": "Jam",
|
|
||||||
"jasper-2": "JasPer-2.0",
|
"jasper-2": "JasPer-2.0",
|
||||||
"jasper-2.0": "JasPer-2.0",
|
"jasper-2.0": "JasPer-2.0",
|
||||||
"jasper-2.0.0": "JasPer-2.0",
|
"jasper-2.0.0": "JasPer-2.0",
|
||||||
@@ -917,7 +909,6 @@ var licenseIDs = map[string]string{
|
|||||||
"sax-pd": "SAX-PD",
|
"sax-pd": "SAX-PD",
|
||||||
"saxpath": "Saxpath",
|
"saxpath": "Saxpath",
|
||||||
"scea": "SCEA",
|
"scea": "SCEA",
|
||||||
"schemereport": "SchemeReport",
|
|
||||||
"sendmail": "Sendmail",
|
"sendmail": "Sendmail",
|
||||||
"sendmail-8": "Sendmail-8.23",
|
"sendmail-8": "Sendmail-8.23",
|
||||||
"sendmail-8.23": "Sendmail-8.23",
|
"sendmail-8.23": "Sendmail-8.23",
|
||||||
@@ -1016,7 +1007,6 @@ var licenseIDs = map[string]string{
|
|||||||
"wtfpl": "WTFPL",
|
"wtfpl": "WTFPL",
|
||||||
"wxwindows": "wxWindows",
|
"wxwindows": "wxWindows",
|
||||||
"x11": "X11",
|
"x11": "X11",
|
||||||
"x11-distribute-modifications-variant": "X11-distribute-modifications-variant",
|
|
||||||
"xerox": "Xerox",
|
"xerox": "Xerox",
|
||||||
"xfree86-1": "XFree86-1.1",
|
"xfree86-1": "XFree86-1.1",
|
||||||
"xfree86-1.1": "XFree86-1.1",
|
"xfree86-1.1": "XFree86-1.1",
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/anchore/go-logger"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/anchore/syft/internal/log"
|
"github.com/anchore/syft/internal/log"
|
||||||
"github.com/anchore/syft/internal/logger"
|
|
||||||
syftEvent "github.com/anchore/syft/syft/event"
|
syftEvent "github.com/anchore/syft/syft/event"
|
||||||
"github.com/anchore/syft/ui"
|
"github.com/anchore/syft/ui"
|
||||||
"github.com/wagoodman/go-partybus"
|
"github.com/wagoodman/go-partybus"
|
||||||
@@ -59,9 +59,8 @@ func (h *ephemeralTerminalUI) Setup(unsubscribe func() error) error {
|
|||||||
|
|
||||||
// prep the logger to not clobber the screen from now on (logrus only)
|
// prep the logger to not clobber the screen from now on (logrus only)
|
||||||
h.logBuffer = bytes.NewBufferString("")
|
h.logBuffer = bytes.NewBufferString("")
|
||||||
logWrapper, ok := log.Log.(*logger.LogrusLogger)
|
if rootLogger, ok := log.Log.(logger.Controller); ok {
|
||||||
if ok {
|
rootLogger.SetOutput(h.logBuffer)
|
||||||
logWrapper.Logger.SetOutput(h.logBuffer)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return h.openScreen()
|
return h.openScreen()
|
||||||
@@ -129,10 +128,10 @@ func (h *ephemeralTerminalUI) closeScreen(force bool) {
|
|||||||
|
|
||||||
func (h *ephemeralTerminalUI) flushLog() {
|
func (h *ephemeralTerminalUI) flushLog() {
|
||||||
// flush any errors to the screen before the report
|
// flush any errors to the screen before the report
|
||||||
logWrapper, ok := log.Log.(*logger.LogrusLogger)
|
rootLogger, ok := log.Log.(logger.Controller)
|
||||||
if ok {
|
if ok {
|
||||||
fmt.Fprint(logWrapper.Output, h.logBuffer.String())
|
fmt.Fprint(rootLogger.GetOutput(), h.logBuffer.String())
|
||||||
logWrapper.Logger.SetOutput(h.uiOutput)
|
rootLogger.SetOutput(h.uiOutput)
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprint(h.uiOutput, h.logBuffer.String())
|
fmt.Fprint(h.uiOutput, h.logBuffer.String())
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -18,13 +18,12 @@ package syft
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/anchore/go-logger"
|
||||||
"github.com/anchore/syft/syft/artifact"
|
|
||||||
|
|
||||||
"github.com/anchore/syft/internal/bus"
|
"github.com/anchore/syft/internal/bus"
|
||||||
"github.com/anchore/syft/internal/log"
|
"github.com/anchore/syft/internal/log"
|
||||||
|
"github.com/anchore/syft/syft/artifact"
|
||||||
"github.com/anchore/syft/syft/linux"
|
"github.com/anchore/syft/syft/linux"
|
||||||
"github.com/anchore/syft/syft/logger"
|
|
||||||
"github.com/anchore/syft/syft/pkg"
|
"github.com/anchore/syft/syft/pkg"
|
||||||
"github.com/anchore/syft/syft/pkg/cataloger"
|
"github.com/anchore/syft/syft/pkg/cataloger"
|
||||||
"github.com/anchore/syft/syft/source"
|
"github.com/anchore/syft/syft/source"
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
/*
|
|
||||||
Package logger defines the logging interface which is used throughout the syft library.
|
|
||||||
*/
|
|
||||||
package logger
|
|
||||||
|
|
||||||
// Logger represents the behavior for logging within the syft library.
|
|
||||||
type Logger interface {
|
|
||||||
Errorf(format string, args ...interface{})
|
|
||||||
Error(args ...interface{})
|
|
||||||
Warnf(format string, args ...interface{})
|
|
||||||
Warn(args ...interface{})
|
|
||||||
Infof(format string, args ...interface{})
|
|
||||||
Info(args ...interface{})
|
|
||||||
Debugf(format string, args ...interface{})
|
|
||||||
Debug(args ...interface{})
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -202,10 +201,6 @@ func TestPackagesCmdFlags(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRegistryAuth(t *testing.T) {
|
func TestRegistryAuth(t *testing.T) {
|
||||||
host := "localhost:17"
|
|
||||||
image := fmt.Sprintf("%s/something:latest", host)
|
|
||||||
args := []string{"packages", "-vv", fmt.Sprintf("registry:%s", image)}
|
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
@@ -214,55 +209,55 @@ func TestRegistryAuth(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "fallback to keychain",
|
name: "fallback to keychain",
|
||||||
args: args,
|
args: []string{"packages", "-vv", "registry:localhost:5000/something:latest"},
|
||||||
assertions: []traitAssertion{
|
assertions: []traitAssertion{
|
||||||
assertInOutput("source=OciRegistry"),
|
assertInOutput("source=OciRegistry"),
|
||||||
assertInOutput(image),
|
assertInOutput("localhost:5000/something:latest"),
|
||||||
assertInOutput("no registry credentials configured, using the default keychain"),
|
assertInOutput("no registry credentials configured, using the default keychain"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "use creds",
|
name: "use creds",
|
||||||
args: args,
|
args: []string{"packages", "-vv", "registry:localhost:5000/something:latest"},
|
||||||
env: map[string]string{
|
env: map[string]string{
|
||||||
"SYFT_REGISTRY_AUTH_AUTHORITY": host,
|
"SYFT_REGISTRY_AUTH_AUTHORITY": "localhost:5000",
|
||||||
"SYFT_REGISTRY_AUTH_USERNAME": "username",
|
"SYFT_REGISTRY_AUTH_USERNAME": "username",
|
||||||
"SYFT_REGISTRY_AUTH_PASSWORD": "password",
|
"SYFT_REGISTRY_AUTH_PASSWORD": "password",
|
||||||
},
|
},
|
||||||
assertions: []traitAssertion{
|
assertions: []traitAssertion{
|
||||||
assertInOutput("source=OciRegistry"),
|
assertInOutput("source=OciRegistry"),
|
||||||
assertInOutput(image),
|
assertInOutput("localhost:5000/something:latest"),
|
||||||
assertInOutput(fmt.Sprintf(`using basic auth for registry "%s"`, host)),
|
assertInOutput(`using basic auth for registry "localhost:5000"`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "use token",
|
name: "use token",
|
||||||
args: args,
|
args: []string{"packages", "-vv", "registry:localhost:5000/something:latest"},
|
||||||
env: map[string]string{
|
env: map[string]string{
|
||||||
"SYFT_REGISTRY_AUTH_AUTHORITY": host,
|
"SYFT_REGISTRY_AUTH_AUTHORITY": "localhost:5000",
|
||||||
"SYFT_REGISTRY_AUTH_TOKEN": "token",
|
"SYFT_REGISTRY_AUTH_TOKEN": "token",
|
||||||
},
|
},
|
||||||
assertions: []traitAssertion{
|
assertions: []traitAssertion{
|
||||||
assertInOutput("source=OciRegistry"),
|
assertInOutput("source=OciRegistry"),
|
||||||
assertInOutput(image),
|
assertInOutput("localhost:5000/something:latest"),
|
||||||
assertInOutput(fmt.Sprintf(`using token for registry "%s"`, host)),
|
assertInOutput(`using token for registry "localhost:5000"`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "not enough info fallsback to keychain",
|
name: "not enough info fallsback to keychain",
|
||||||
args: args,
|
args: []string{"packages", "-vv", "registry:localhost:5000/something:latest"},
|
||||||
env: map[string]string{
|
env: map[string]string{
|
||||||
"SYFT_REGISTRY_AUTH_AUTHORITY": host,
|
"SYFT_REGISTRY_AUTH_AUTHORITY": "localhost:5000",
|
||||||
},
|
},
|
||||||
assertions: []traitAssertion{
|
assertions: []traitAssertion{
|
||||||
assertInOutput("source=OciRegistry"),
|
assertInOutput("source=OciRegistry"),
|
||||||
assertInOutput(image),
|
assertInOutput("localhost:5000/something:latest"),
|
||||||
assertInOutput(`no registry credentials configured, using the default keychain`),
|
assertInOutput(`no registry credentials configured, using the default keychain`),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "allows insecure http flag",
|
name: "allows insecure http flag",
|
||||||
args: args,
|
args: []string{"packages", "-vv", "registry:localhost:5000/something:latest"},
|
||||||
env: map[string]string{
|
env: map[string]string{
|
||||||
"SYFT_REGISTRY_INSECURE_USE_HTTP": "true",
|
"SYFT_REGISTRY_INSECURE_USE_HTTP": "true",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ setup_snapshot_server() {
|
|||||||
worker_pid=$!
|
worker_pid=$!
|
||||||
|
|
||||||
# it takes some time for the server to be ready...
|
# it takes some time for the server to be ready...
|
||||||
sleep 3
|
sleep 0.5
|
||||||
|
|
||||||
echo "$worker_pid"
|
echo "$worker_pid"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user