Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of .NET Extractors #355

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions binary/proto/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
scalibr "github.com/google/osv-scalibr"
"github.com/google/osv-scalibr/extractor"
ctrdfs "github.com/google/osv-scalibr/extractor/filesystem/containers/containerd"
"github.com/google/osv-scalibr/extractor/filesystem/language/dotnet/depsjson"
"github.com/google/osv-scalibr/extractor/filesystem/language/java/archive"
"github.com/google/osv-scalibr/extractor/filesystem/language/java/javalockfile"
"github.com/google/osv-scalibr/extractor/filesystem/language/javascript/packagejson"
Expand Down Expand Up @@ -246,6 +247,14 @@ func setProtoMetadata(meta any, i *spb.Inventory) {
Maintainers: personsToProto(m.Maintainers),
},
}
case *depsjson.Metadata:
i.Metadata = &spb.Inventory_DepsjsonMetadata{
DepsjsonMetadata: &spb.DEPSJSONMetadata{
PackageName: m.PackageName,
PackageVersion: m.PackageVersion,
Type: m.Type,
},
}
case *apk.Metadata:
i.Metadata = &spb.Inventory_ApkMetadata{
ApkMetadata: &spb.APKPackageMetadata{
Expand Down
37 changes: 37 additions & 0 deletions binary/proto/proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/google/osv-scalibr/detector"
"github.com/google/osv-scalibr/extractor"
ctrdfs "github.com/google/osv-scalibr/extractor/filesystem/containers/containerd"
"github.com/google/osv-scalibr/extractor/filesystem/language/dotnet/depsjson"
"github.com/google/osv-scalibr/extractor/filesystem/language/javascript/packagejson"
"github.com/google/osv-scalibr/extractor/filesystem/language/python/requirements"
"github.com/google/osv-scalibr/extractor/filesystem/language/python/wheelegg"
Expand Down Expand Up @@ -224,6 +225,40 @@ func TestScanResultToProto(t *testing.T) {
Locations: []string{"/file1"},
Extractor: &packagejson.Extractor{},
}

purlDotnetDepsJsonInventory := &extractor.Inventory{
Name: "software",
Version: "1.0.0",
Metadata: &depsjson.Metadata{
PackageName: "software",
PackageVersion: "1.0.0",
Type: "type",
},
Locations: []string{"/file1"},
Extractor: &depsjson.Extractor{},
}

purlDotnetDepsJsonInventoryProto := &spb.Inventory{
Name: "software",
Version: "1.0.0",
Purl: &spb.Purl{
Purl: "pkg:nuget/software@1.0.0",
Type: purl.TypeNuget,
Name: "software",
Version: "1.0.0",
},
Ecosystem: "NuGet",
Locations: []string{"/file1"},
Extractor: "dotnet/depsjson",
Metadata: &spb.Inventory_DepsjsonMetadata{
DepsjsonMetadata: &spb.DEPSJSONMetadata{
PackageName: "software",
PackageVersion: "1.0.0",
Type: "type",
},
},
}

windowsInventory := &extractor.Inventory{
Name: "windows_server_2019",
Version: "10.0.17763.3406",
Expand Down Expand Up @@ -644,6 +679,7 @@ func TestScanResultToProto(t *testing.T) {
purlPythonInventory,
pythonRequirementsInventory,
purlJavascriptInventory,
purlDotnetDepsJsonInventory,
cdxInventory,
windowsInventory,
purlPythonInventoryWithLayerDetails,
Expand Down Expand Up @@ -696,6 +732,7 @@ func TestScanResultToProto(t *testing.T) {
purlPythonInventoryProto,
pythonRequirementsInventoryProto,
purlJavascriptInventoryProto,
purlDotnetDepsJsonInventoryProto,
cdxInventoryProto,
windowsInventoryProto,
purlPythonInventoryWithLayerDetailsProto,
Expand Down
8 changes: 8 additions & 0 deletions binary/proto/scan_result.proto
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ message Inventory {
DPKGPackageMetadata dpkg_metadata = 8;
RPMPackageMetadata rpm_metadata = 9;
COSPackageMetadata cos_metadata = 13;
DEPSJSONMetadata depsjson_metadata = 40;
SPDXPackageMetadata spdx_metadata = 14;
JavaArchiveMetadata java_archive_metadata = 15;
JavaLockfileMetadata java_lockfile_metadata = 31;
Expand Down Expand Up @@ -290,6 +291,13 @@ message PACMANPackageMetadata {
string package_dependencies = 6;
}

// The additional data found in .NET deps json packages.
message DEPSJSONMetadata {
string package_name = 1;
string package_version = 2;
string type = 3;
}

// The additional data found in SNAP packages.
message SNAPPackageMetadata {
string name = 1;
Expand Down
Loading