Skip to content

Commit

Permalink
Add test extractor.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvarga committed Apr 29, 2024
1 parent b4c836d commit 680639f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
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 }

0 comments on commit 680639f

Please sign in to comment.