From d4a00708c4b1fb33fa86bc8fd15636278ef714f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Hed=C3=A9n?= Date: Wed, 31 Jul 2024 13:30:58 +0200 Subject: [PATCH] Add regenerate pass through from scan to fingerprint --- build/docker/debian.Dockerfile | 6 +++--- internal/cmd/fingerprint/fingerprint.go | 4 +++- internal/fingerprint/fingerprint.go | 2 -- internal/fingerprint/fingerprint_test.go | 4 ++-- internal/scan/scanner.go | 1 + 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/build/docker/debian.Dockerfile b/build/docker/debian.Dockerfile index 8fff0b02..37071658 100644 --- a/build/docker/debian.Dockerfile +++ b/build/docker/debian.Dockerfile @@ -92,10 +92,10 @@ RUN curl -fsSLO https://dot.net/v1/dotnet-install.sh \ ENV GOLANG_VERSION 1.22 RUN apt -y update && apt -y upgrade && apt -y install \ - python3 \ - python3-venv \ + python3.10 \ + python3.10-venv \ ca-certificates \ - python3-pip && \ + python3.10-pip && \ apt -y install -t unstable \ golang-$GOLANG_VERSION \ openjdk-21-jre && \ diff --git a/internal/cmd/fingerprint/fingerprint.go b/internal/cmd/fingerprint/fingerprint.go index 4da9e15c..32dcbb4f 100644 --- a/internal/cmd/fingerprint/fingerprint.go +++ b/internal/cmd/fingerprint/fingerprint.go @@ -91,11 +91,13 @@ func RunE(f fingerprint.IFingerprint) func(_ *cobra.Command, args []string) erro if errors.Is(err, &fingerprint.FingerprintFileExistsError{}) { fmt.Println( "Fingerprint file exists and command is configured to not overwrite. ", - "To generate new fingerprint file either remove/rename old file or ", + "To generate a new fingerprint file either remove/rename old file or ", "change flag '--regenerate' to 'true'", ) + return nil } + return err } diff --git a/internal/fingerprint/fingerprint.go b/internal/fingerprint/fingerprint.go index 270e1f81..4697d8bb 100644 --- a/internal/fingerprint/fingerprint.go +++ b/internal/fingerprint/fingerprint.go @@ -91,8 +91,6 @@ func (f *Fingerprinter) FingerprintFiles(options DebrickedOptions) (Fingerprints if !errors.Is(err, os.ErrNotExist) { fingerprintFileExists = true } - fmt.Printf("output path=%s", options.OutputPath) - fmt.Printf("regen=%t, file=%t\n", options.Regenerate, fingerprintFileExists) if !options.Regenerate && fingerprintFileExists { return fingerprints, &FingerprintFileExistsError{} } diff --git a/internal/fingerprint/fingerprint_test.go b/internal/fingerprint/fingerprint_test.go index 08c17c5e..a208b2c6 100644 --- a/internal/fingerprint/fingerprint_test.go +++ b/internal/fingerprint/fingerprint_test.go @@ -184,9 +184,9 @@ func TestFingerprintFiles(t *testing.T) { } func TestFingerprintFilesAlreadyExists(t *testing.T) { - temp, err := os.CreateTemp("testdata/fingerprinter", "temp-fingerprint-*.txt") + temp, _ := os.CreateTemp("testdata/fingerprinter", "temp-fingerprint-*.txt") fingerprinter := NewFingerprinter() - _, err = fingerprinter.FingerprintFiles( + _, err := fingerprinter.FingerprintFiles( DebrickedOptions{ OutputPath: temp.Name(), Path: "testdata/fingerprinter", diff --git a/internal/scan/scanner.go b/internal/scan/scanner.go index d55958c5..13f060c3 100644 --- a/internal/scan/scanner.go +++ b/internal/scan/scanner.go @@ -172,6 +172,7 @@ func (dScanner *DebrickedScanner) scanFingerprint(options DebrickedOptions) erro Inclusions: append(options.Inclusions, fingerprint.DefaultInclusionsFingerprint()...), MinFingerprintContentLength: options.MinFingerprintContentLength, FingerprintCompressedContent: false, + Regenerate: options.Regenerate > 0, }, ) if err != nil {