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

Add test extractor. #28

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion extractor/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"os"
"strings"

"github.com/google/osv-scanner/pkg/lockfile"
"github.com/google/osv-scalibr/extractor"
"github.com/google/osv-scalibr/extractor/language/dotnet/packageslockjson"
"github.com/google/osv-scalibr/extractor/language/golang/gobinary"
Expand All @@ -34,10 +33,12 @@ import (
"github.com/google/osv-scalibr/extractor/os/cos"
"github.com/google/osv-scalibr/extractor/os/dpkg"
"github.com/google/osv-scalibr/extractor/os/rpm"
"github.com/google/osv-scalibr/extractor/os/testractor"
"github.com/google/osv-scalibr/extractor/osv"
"github.com/google/osv-scalibr/extractor/sbom/spdx"
"github.com/google/osv-scalibr/log"
"github.com/google/osv-scalibr/purl"
"github.com/google/osv-scanner/pkg/lockfile"
)

// LINT.IfChange
Expand Down Expand Up @@ -65,6 +66,7 @@ var (
&apk.Extractor{},
rpm.New(rpm.DefaultConfig()),
&cos.Extractor{},
&testractor.Extractor{},
}

// Collections of extractors.
Expand Down
51 changes: 51 additions & 0 deletions extractor/os/testractor/extractor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2024 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 cos extracts OS packages from Container Optimized OSes (go/cos).
package testractor

import (
"context"
"io/fs"

"github.com/google/osv-scalibr/extractor"
"github.com/google/osv-scalibr/purl"
)

// Extractor is a test extractor.
type Extractor struct{}

// Name of the extractor.
func (e Extractor) Name() string { return "os/test" }

// Version of the extractor.
func (e Extractor) Version() int { return 0 }

// FileRequired returns true if the specified file matches cos package info file pattern.
func (e Extractor) FileRequired(path string, _ fs.FileMode) bool {
return false
}

// Extract extracts packages from cos package info files passed through the scan input.
func (e Extractor) Extract(ctx context.Context, input *extractor.ScanInput) ([]*extractor.Inventory, error) {
return nil, nil
}

// ToPURL converts an inventory created by this extractor into a PURL.
func (e Extractor) ToPURL(i *extractor.Inventory) (*purl.PackageURL, error) {
return &purl.PackageURL{}, nil
}

// ToCPEs is not applicable as this extractor does not infer CPEs from the Inventory.
func (e Extractor) ToCPEs(i *extractor.Inventory) ([]string, error) { return []string{}, nil }
Loading