Skip to content

Commit

Permalink
FIX: Adding metadata template
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 720795333
  • Loading branch information
SCALIBR Team authored and copybara-github committed Jan 30, 2025
1 parent 358fcf5 commit 20f41b0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions binary/proto/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"github.com/google/osv-scalibr/extractor/filesystem/os/cos"
"github.com/google/osv-scalibr/extractor/filesystem/os/dpkg"
"github.com/google/osv-scalibr/extractor/filesystem/os/flatpak"
"github.com/google/osv-scalibr/extractor/filesystem/os/homebrew"
"github.com/google/osv-scalibr/extractor/filesystem/os/kernel/module"
"github.com/google/osv-scalibr/extractor/filesystem/os/kernel/vmlinuz"
"github.com/google/osv-scalibr/extractor/filesystem/os/macapps"
Expand Down Expand Up @@ -384,6 +385,10 @@ func setProtoMetadata(meta any, i *spb.Inventory) {
UpdateUrl: m.KSUpdateURL,
},
}
case *homebrew.Metadata:
i.Metadata = &spb.Inventory_HomebrewMetadata{

Check failure on line 389 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / lint-just-new

undefined: spb.Inventory_HomebrewMetadata

Check failure on line 389 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / lint-just-new

undefined: spb.Inventory_HomebrewMetadata

Check failure on line 389 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / lint-just-new

undefined: spb.Inventory_HomebrewMetadata

Check failure on line 389 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / lint

undefined: spb.Inventory_HomebrewMetadata

Check failure on line 389 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / lint

undefined: spb.Inventory_HomebrewMetadata

Check failure on line 389 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / lint

undefined: spb.Inventory_HomebrewMetadata

Check failure on line 389 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

undefined: spb.Inventory_HomebrewMetadata

Check failure on line 389 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / tests (macos-latest)

undefined: spb.Inventory_HomebrewMetadata

Check failure on line 389 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / tests (windows-latest)

undefined: spb.Inventory_HomebrewMetadata
HomebrewMetadata: &spb.HomebrewPackageMetadata{},

Check failure on line 390 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / lint-just-new

undefined: spb.HomebrewPackageMetadata) (typecheck)

Check failure on line 390 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / lint-just-new

undefined: spb.HomebrewPackageMetadata (typecheck)

Check failure on line 390 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / lint-just-new

undefined: spb.HomebrewPackageMetadata) (typecheck)

Check failure on line 390 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / lint

undefined: spb.HomebrewPackageMetadata) (typecheck)

Check failure on line 390 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / lint

undefined: spb.HomebrewPackageMetadata (typecheck)

Check failure on line 390 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / lint

undefined: spb.HomebrewPackageMetadata) (typecheck)

Check failure on line 390 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

undefined: spb.HomebrewPackageMetadata

Check failure on line 390 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / tests (macos-latest)

undefined: spb.HomebrewPackageMetadata

Check failure on line 390 in binary/proto/proto.go

View workflow job for this annotation

GitHub Actions / tests (windows-latest)

undefined: spb.HomebrewPackageMetadata
}
case *module.Metadata:
i.Metadata = &spb.Inventory_KernelModuleMetadata{
KernelModuleMetadata: &spb.KernelModuleMetadata{
Expand Down
4 changes: 4 additions & 0 deletions binary/proto/scan_result.proto
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ message Inventory {
25;
CDXPackageMetadata cdx_metadata = 30;
WindowsOSVersion windows_os_version_metadata = 33;
HomebrewPackageMetadata homebrew_metadata = 42;
}

repeated AnnotationEnum annotations = 28;
Expand Down Expand Up @@ -455,3 +456,6 @@ message WindowsOSVersion {
string product = 1;
string full_version = 2;
}

// The additional data found in Homebrew packages.
message HomebrewPackageMetadata {}
1 change: 1 addition & 0 deletions extractor/filesystem/os/homebrew/homebrew.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func (e Extractor) Extract(ctx context.Context, input *filesystem.ScanInput) ([]
Name: p.AppName,
Version: p.AppVersion,
Locations: []string{input.Path},
Metadata: &Metadata{},
},
}, nil
}
Expand Down
3 changes: 3 additions & 0 deletions extractor/filesystem/os/homebrew/homebrew_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func TestExtract(t *testing.T) {
Name: "rclone",
Version: "1.67.0",
Locations: []string{"testdata/Cellar/rclone/1.67.0/INSTALL_RECEIPT.json"},
Metadata: &homebrew.Metadata{},
},
},
},
Expand All @@ -135,6 +136,7 @@ func TestExtract(t *testing.T) {
Name: "testapp",
Version: "1.1.1",
Locations: []string{"testdata/Caskroom/testapp/1.1.1/testapp.wrapper.sh"},
Metadata: &homebrew.Metadata{},
},
},
},
Expand All @@ -151,6 +153,7 @@ func TestExtract(t *testing.T) {
Name: "android-platform-tools",
Version: "35.0.2",
Locations: []string{"testdata/Caskroom/android-platform-tools/35.0.2/platform-tools/source.properties"},
Metadata: &homebrew.Metadata{},
},
},
},
Expand Down
18 changes: 18 additions & 0 deletions extractor/filesystem/os/homebrew/metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package homebrew

// Metadata is the metadata struct for information relating to the homebrew package.
type Metadata struct{}

0 comments on commit 20f41b0

Please sign in to comment.