From 9d75d09a821adfe2cda386ba59cb88b0703e5aab Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sun, 26 May 2024 13:16:43 +0200 Subject: [PATCH 1/3] fix: allow not validating SBOM --- Library/Homebrew/sbom.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/sbom.rb b/Library/Homebrew/sbom.rb index c57193f1a3836..6b4d559a8b772 100644 --- a/Library/Homebrew/sbom.rb +++ b/Library/Homebrew/sbom.rb @@ -121,12 +121,12 @@ def self.fetch_schema! end end - sig { params(bottling: T::Boolean).returns(T::Boolean) } + sig { params(bottling: T::Boolean).returns(T.nilable(T::Boolean)) } def valid?(bottling: false) unless require? "json_schemer" error_message = "Need json_schemer to validate SBOM, run `brew install-bundler-gems --add-groups=bottle`!" odie error_message if ENV["HOMEBREW_ENFORCE_SBOM"] - return false + return nil end schema = SBOM.fetch_schema! @@ -156,7 +156,8 @@ def write(validate: true, bottling: false) # will no longer be valid. Formula.clear_cache unless spdxfile.exist? - if validate && !valid?(bottling:) + valid = valid?(bottling:) + if validate && valid.present? && !valid opoo "SBOM is not valid, not writing to disk!" return end From fdb347c35f343db9a06553690a85d537ff55729a Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sun, 26 May 2024 13:20:04 +0200 Subject: [PATCH 2/3] Update Library/Homebrew/sbom.rb Co-authored-by: Ruoyu Zhong --- Library/Homebrew/sbom.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Library/Homebrew/sbom.rb b/Library/Homebrew/sbom.rb index 6b4d559a8b772..5e64c208dfe20 100644 --- a/Library/Homebrew/sbom.rb +++ b/Library/Homebrew/sbom.rb @@ -156,8 +156,7 @@ def write(validate: true, bottling: false) # will no longer be valid. Formula.clear_cache unless spdxfile.exist? - valid = valid?(bottling:) - if validate && valid.present? && !valid + if validate && (valid = valid?(bottling:)).present? && !valid opoo "SBOM is not valid, not writing to disk!" return end From 7be26329c5ccfefaba3b718942bef0a81f275d94 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 26 May 2024 15:28:53 +0100 Subject: [PATCH 3/3] Apply suggestions from code review --- Library/Homebrew/sbom.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/sbom.rb b/Library/Homebrew/sbom.rb index 5e64c208dfe20..98f16bb513e6d 100644 --- a/Library/Homebrew/sbom.rb +++ b/Library/Homebrew/sbom.rb @@ -121,12 +121,12 @@ def self.fetch_schema! end end - sig { params(bottling: T::Boolean).returns(T.nilable(T::Boolean)) } + sig { params(bottling: T::Boolean).returns(T::Boolean) } def valid?(bottling: false) unless require? "json_schemer" error_message = "Need json_schemer to validate SBOM, run `brew install-bundler-gems --add-groups=bottle`!" odie error_message if ENV["HOMEBREW_ENFORCE_SBOM"] - return nil + return true end schema = SBOM.fetch_schema! @@ -156,7 +156,7 @@ def write(validate: true, bottling: false) # will no longer be valid. Formula.clear_cache unless spdxfile.exist? - if validate && (valid = valid?(bottling:)).present? && !valid + if validate && !valid?(bottling:) opoo "SBOM is not valid, not writing to disk!" return end