-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make scalibr compatible with Windows (as a standalone binary).
PiperOrigin-RevId: 628049948
- Loading branch information
1 parent
93726cf
commit 092c3d5
Showing
4 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
detector/cis/generic_linux/etcpasswdpermissions/detector_windows.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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. | ||
|
||
//go:build windows | ||
|
||
package etcpasswdpermissions | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/google/osv-scalibr/detector" | ||
"github.com/google/osv-scalibr/inventoryindex" | ||
) | ||
|
||
// Detector is a SCALIBR Detector for the CIS check "Ensure permissions on /etc/passwd- are configured" | ||
// from the CIS Distribution Independent Linux benchmarks. | ||
type Detector struct{} | ||
|
||
// Name of the detector. | ||
func (Detector) Name() string { return "cis/generic_linux/etcpasswdpermissions" } | ||
|
||
// Version of the detector. | ||
func (Detector) Version() int { return 0 } | ||
|
||
// RequiredExtractors returns an empty list as there are no dependencies. | ||
func (Detector) RequiredExtractors() []string { return []string{} } | ||
|
||
// Scan is a no-op for Windows. | ||
func (d Detector) Scan(ctx context.Context, scanRoot string, ix *inventoryindex.InventoryIndex) ([]*detector.Finding, error) { | ||
return nil, fmt.Errorf("Plugin not supported on Windows") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// 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. | ||
|
||
//go:build windows | ||
|
||
package rpm | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"io/fs" | ||
|
||
"github.com/google/osv-scalibr/extractor" | ||
"github.com/google/osv-scalibr/purl" | ||
) | ||
|
||
// Name is the name for the RPM extractor | ||
const Name = "os/rpm" | ||
|
||
// Extractor extracts rpm packages from rpm database. | ||
type Extractor struct{} | ||
|
||
// Config contains RPM specific configuration values | ||
type Config struct{} | ||
|
||
// DefaultConfig returns the default configuration values for the RPM extractor. | ||
func DefaultConfig() Config { return Config{} } | ||
|
||
// New returns an RPM extractor. | ||
// | ||
// For most use cases, initialize with: | ||
// ``` | ||
// e := New(DefaultConfig()) | ||
// ``` | ||
func New(cfg Config) *Extractor { | ||
return &Extractor{} | ||
} | ||
|
||
// Name of the extractor. | ||
func (e Extractor) Name() string { return Name } | ||
|
||
// Version of the extractor. | ||
func (e Extractor) Version() int { return 0 } | ||
|
||
// FileRequired always returns false as RPM extractor is not supported on Windows. | ||
func (e Extractor) FileRequired(path string, _ fs.FileMode) bool { | ||
return false | ||
} | ||
|
||
// Extract extracts packages from rpm status files passed through the scan input. | ||
func (e Extractor) Extract(ctx context.Context, input *extractor.ScanInput) ([]*extractor.Inventory, error) { | ||
return nil, fmt.Errorf("Windows is not supported") | ||
} | ||
|
||
// ToPURL converts an inventory created by this extractor into a PURL. | ||
func (e Extractor) ToPURL(i *extractor.Inventory) (*purl.PackageURL, error) { | ||
return nil, fmt.Errorf("Windows is not supported") | ||
} | ||
|
||
// 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{}, fmt.Errorf("Windows is not supported") | ||
} |