Skip to content

Commit 808cf24

Browse files
erikvargacopybara-github
authored andcommitted
Move global plugin-specific CLI flags into the plugin config proto.
PiperOrigin-RevId: 837524500
1 parent 3f8843b commit 808cf24

File tree

10 files changed

+234
-107
lines changed

10 files changed

+234
-107
lines changed

binary/cli/cli.go

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,23 @@ import (
2727
"github.com/google/go-containerregistry/pkg/authn"
2828
v1 "github.com/google/go-containerregistry/pkg/v1"
2929
"github.com/google/go-containerregistry/pkg/v1/remote"
30+
scalibr "github.com/google/osv-scalibr"
3031
scalibrimage "github.com/google/osv-scalibr/artifact/image"
3132
"github.com/google/osv-scalibr/binary/cdx"
3233
"github.com/google/osv-scalibr/binary/platform"
3334
"github.com/google/osv-scalibr/binary/proto"
3435
cpb "github.com/google/osv-scalibr/binary/proto/config_go_proto"
3536
binspdx "github.com/google/osv-scalibr/binary/spdx"
36-
"github.com/google/osv-scalibr/clients/resolution"
3737
"github.com/google/osv-scalibr/converter"
3838
convspdx "github.com/google/osv-scalibr/converter/spdx"
3939
"github.com/google/osv-scalibr/detector"
40-
"github.com/spdx/tools-golang/spdx/v2/common"
41-
"google.golang.org/protobuf/encoding/prototext"
42-
43-
scalibr "github.com/google/osv-scalibr"
44-
"github.com/google/osv-scalibr/enricher/transitivedependency/requirements"
4540
"github.com/google/osv-scalibr/extractor/filesystem"
46-
"github.com/google/osv-scalibr/extractor/filesystem/language/java/pomxmlnet"
4741
scalibrfs "github.com/google/osv-scalibr/fs"
4842
"github.com/google/osv-scalibr/log"
4943
"github.com/google/osv-scalibr/plugin"
5044
pl "github.com/google/osv-scalibr/plugin/list"
45+
"github.com/spdx/tools-golang/spdx/v2/common"
46+
"google.golang.org/protobuf/encoding/prototext"
5147
)
5248

5349
// Array is a type to be passed to flag.Var that supports arrays passed as repeated flags,
@@ -154,8 +150,6 @@ type Flags struct {
154150
StoreAbsolutePath bool
155151
WindowsAllDrives bool
156152
Offline bool
157-
LocalRegistry string
158-
DisableGoogleAuth bool
159153
}
160154

161155
var supportedOutputFormats = []string{
@@ -553,25 +547,6 @@ func (f *Flags) pluginsToRun() ([]plugin.Plugin, *cpb.PluginConfig, error) {
553547
if err != nil {
554548
return nil, nil, err
555549
}
556-
557-
// Apply plugin-specific config.
558-
for _, p := range plugins {
559-
if f.LocalRegistry != "" {
560-
switch p.Name() {
561-
case pomxmlnet.Name:
562-
p.(*pomxmlnet.Extractor).MavenClient.SetLocalRegistry(f.LocalRegistry)
563-
case requirements.Name:
564-
if client, ok := p.(*requirements.Enricher).Client.(*resolution.PyPIRegistryClient); ok {
565-
// The resolution client is the native PyPI registry client.
566-
client.SetLocalRegistry(f.LocalRegistry)
567-
}
568-
}
569-
}
570-
if f.DisableGoogleAuth && p.Name() == pomxmlnet.Name {
571-
p.(*pomxmlnet.Extractor).MavenClient.DisableGoogleAuth()
572-
}
573-
}
574-
575550
result = append(result, plugins...)
576551
}
577552

binary/proto/config.proto

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ message PluginConfig {
3131

3232
// The maximum file size the plugin will process.
3333
int64 max_file_size_bytes = 1;
34+
// The local directory to store the downloaded manifests during dependency
35+
// resolution.
36+
string local_registry = 3;
37+
// If true, do not try to create google.DefaultClient for Artifact Registry
38+
// during dependency resolution.
39+
bool disable_google_auth = 4;
3440

3541
// Config values that only apply to a single plugin.
3642
repeated PluginSpecificConfig plugin_specific = 2;
@@ -45,6 +51,8 @@ message PluginSpecificConfig {
4551
VDIConfig vdi = 5;
4652
VMDKConfig vmdk = 6;
4753
HashiCorpVaultValidatorConfig hashicorp_vault_validator = 7;
54+
SDPInspectConfig sdp_inspect = 8;
55+
POMXMLNetConfig pom_xml_net = 9;
4856
}
4957
}
5058

@@ -92,3 +100,14 @@ message HashiCorpVaultValidatorConfig {
92100
// https://developer.hashicorp.com/vault
93101
string vault_url = 1;
94102
}
103+
104+
message SDPInspectConfig {
105+
// The GCP project id to use for Sensitive Data Protection InspectContent API
106+
// calls.
107+
string project_id = 1;
108+
}
109+
110+
message POMXMLNetConfig {
111+
// The URL of the upstream Maven registry.
112+
string upstream_registry = 1;
113+
}

0 commit comments

Comments
 (0)