diff --git a/cmd/guaccollect/cmd/oci.go b/cmd/guaccollect/cmd/oci.go index b793ad5571..eafeae340f 100644 --- a/cmd/guaccollect/cmd/oci.go +++ b/cmd/guaccollect/cmd/oci.go @@ -18,6 +18,7 @@ package cmd import ( "context" "fmt" + "net" "os" "time" @@ -46,6 +47,19 @@ type ociOptions struct { publishToQueue bool } +type ociRegistryOptions struct { + // datasource for the collector + dataSource datasource.CollectSource + // address for pubsub connection + pubsubAddr string + // address for blob store + blobAddr string + // run as poll collector + poll bool + // enable/disable message publish to queue + publishToQueue bool +} + var ociCmd = &cobra.Command{ Use: "image [flags] image_path1 image_path2...", Short: "takes images to download sbom and attestation stored in OCI to add to GUAC graph utilizing Nats pubsub and blob store", @@ -98,6 +112,43 @@ you have access to read and write to the respective blob store.`, }, } +var ociRegistryCmd = &cobra.Command{ + Use: "registry [flags] registry", + Short: "takes an OCI registry with catalog capability and downloads sbom and attestation stored in OCI to add to GUAC graph", + Args: cobra.MinimumNArgs(1), + Run: func(cmd *cobra.Command, args []string) { + ctx := logging.WithLogger(context.Background()) + logger := logging.FromContext(ctx) + + opts, err := validateOCIRegistryFlags( + viper.GetString("pubsub-addr"), + viper.GetString("blob-addr"), + viper.GetString("csub-addr"), + viper.GetBool("csub-tls"), + viper.GetBool("csub-tls-skip-verify"), + viper.GetBool("use-csub"), + viper.GetBool("service-poll"), + viper.GetBool("publish-to-queue"), + args) + if err != nil { + fmt.Printf("unable to validate flags: %v\n", err) + _ = cmd.Help() + os.Exit(1) + } + + // Register collector + // We probably want a much longer poll interval for registry collectors as the _catalog + // endpoint can be expensive to hit and likely won't change often. + ociRegistryCollector := oci.NewOCIRegistryCollector(ctx, opts.dataSource, opts.poll, 30*time.Minute) + err = collector.RegisterDocumentCollector(ociRegistryCollector, oci.OCIRegistryCollector) + if err != nil { + logger.Errorf("unable to register oci collector: %v", err) + } + + initializeNATsandCollector(ctx, opts.pubsubAddr, opts.blobAddr, opts.publishToQueue) + }, +} + func validateOCIFlags( pubsubAddr, blobAddr, @@ -154,6 +205,65 @@ func validateOCIFlags( return opts, nil } +func validateOCIRegistryFlags( + pubsubAddr, + blobAddr, + csubAddr string, + csubTls, + csubTlsSkipVerify, + useCsub, + poll, + pubToQueue bool, + args []string, +) (ociRegistryOptions, error) { + var opts ociRegistryOptions + opts.pubsubAddr = pubsubAddr + opts.blobAddr = blobAddr + opts.poll = poll + opts.publishToQueue = pubToQueue + + if useCsub { + csubOpts, err := csubclient.ValidateCsubClientFlags(csubAddr, csubTls, csubTlsSkipVerify) + if err != nil { + return opts, fmt.Errorf("unable to validate csub client flags: %w", err) + } + c, err := csubclient.NewClient(csubOpts) + if err != nil { + return opts, err + } + opts.dataSource, err = csubsource.NewCsubDatasource(c, 10*time.Second) + return opts, err + } + + // else direct CLI call, no polling + if len(args) < 1 { + return opts, fmt.Errorf("expected positional argument(s) for registr(y|ies)") + } + + sources := []datasource.Source{} + for _, arg := range args { + // Min check to validate registry by resolving hostname + _, err := net.LookupHost(arg) + if err != nil { + return opts, fmt.Errorf("registry parsing error. require format registry:port") + } + sources = append(sources, datasource.Source{ + Value: arg, + }) + } + + var err error + opts.dataSource, err = inmemsource.NewInmemDataSources(&datasource.DataSources{ + OciDataSources: sources, + }) + if err != nil { + return opts, err + } + + return opts, nil +} + func init() { rootCmd.AddCommand(ociCmd) + rootCmd.AddCommand(ociRegistryCmd) } diff --git a/cmd/guacone/cmd/collectsub_client.go b/cmd/guacone/cmd/collectsub_client.go index 683b6b77ee..8ba86e4af1 100644 --- a/cmd/guacone/cmd/collectsub_client.go +++ b/cmd/guacone/cmd/collectsub_client.go @@ -121,6 +121,10 @@ var getAllFilters = []*collectsub.CollectEntryFilter{ Type: collectsub.CollectDataType_DATATYPE_GITHUB_RELEASE, Glob: "*", }, + { + Type: collectsub.CollectDataType_DATATYPE_OCI_REGISTRY, + Glob: "*", + }, } /* diff --git a/cmd/guacone/cmd/oci.go b/cmd/guacone/cmd/oci.go index 30f62c7dd9..c33d16a092 100644 --- a/cmd/guacone/cmd/oci.go +++ b/cmd/guacone/cmd/oci.go @@ -18,6 +18,7 @@ package cmd import ( "context" "fmt" + "net" "net/http" "os" "time" @@ -25,6 +26,7 @@ import ( "github.com/guacsec/guac/pkg/cli" csub_client "github.com/guacsec/guac/pkg/collectsub/client" "github.com/guacsec/guac/pkg/collectsub/datasource" + "github.com/guacsec/guac/pkg/collectsub/datasource/csubsource" "github.com/guacsec/guac/pkg/collectsub/datasource/inmemsource" "github.com/guacsec/guac/pkg/handler/collector" "github.com/guacsec/guac/pkg/handler/collector/oci" @@ -45,6 +47,19 @@ type ociOptions struct { queryLicenseOnIngestion bool queryEOLOnIngestion bool queryDepsDevOnIngestion bool + useCsub bool +} + +type ociRegistryOptions struct { + graphqlEndpoint string + headerFile string + dataSource datasource.CollectSource + csubClientOptions csub_client.CsubClientOptions + queryVulnOnIngestion bool + queryLicenseOnIngestion bool + queryEOLOnIngestion bool + queryDepsDevOnIngestion bool + useCsub bool } var ociCmd = &cobra.Command{ @@ -52,7 +67,7 @@ var ociCmd = &cobra.Command{ Short: "takes images to download sbom and attestation stored in OCI to add to GUAC graph, this command talks directly to the graphQL endpoint", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - opts, err := validateOCIFlags( + opts, csubClient, err := validateOCIFlags( viper.GetString("gql-addr"), viper.GetString("header-file"), viper.GetString("csub-addr"), @@ -62,6 +77,7 @@ var ociCmd = &cobra.Command{ viper.GetBool("add-license-on-ingest"), viper.GetBool("add-eol-on-ingest"), viper.GetBool("add-depsdev-on-ingest"), + viper.GetBool("use-csub"), args) if err != nil { fmt.Printf("unable to validate flags: %v\n", err) @@ -80,13 +96,82 @@ var ociCmd = &cobra.Command{ logger.Fatalf("unable to register oci collector: %v", err) } - // initialize collectsub client - csubClient, err := csub_client.NewClient(opts.csubClientOptions) - if err != nil { - logger.Infof("collectsub client initialization failed, this ingestion will not pull in any additional data through the collectsub service: %v", err) - csubClient = nil + totalNum := 0 + gotErr := false + // Set emit function to go through the entire pipeline + emit := func(d *processor.Document) error { + totalNum += 1 + _, err := ingestor.Ingest( + ctx, + d, + opts.graphqlEndpoint, + transport, + csubClient, + opts.queryVulnOnIngestion, + opts.queryLicenseOnIngestion, + opts.queryEOLOnIngestion, + opts.queryDepsDevOnIngestion, + ) + if err != nil { + gotErr = true + return fmt.Errorf("unable to ingest document: %w", err) + } + return nil + } + + // Collect + errHandler := func(err error) bool { + if err == nil { + logger.Info("collector ended gracefully") + return true + } + logger.Errorf("collector ended with error: %v", err) + return false + } + if err := collector.Collect(ctx, emit, errHandler); err != nil { + logger.Fatal(err) + } + + if gotErr { + logger.Fatalf("completed ingestion with errors") } else { - defer csubClient.Close() + logger.Infof("completed ingesting %v documents", totalNum) + } + }, +} + +var ociRegistryCmd = &cobra.Command{ + Use: "registry [flags] registry", + Short: "takes an OCI registry with catalog capability and downloads sbom and attestation stored in OCI to add to GUAC graph", + Args: cobra.MinimumNArgs(1), + Run: func(cmd *cobra.Command, args []string) { + opts, csubClient, err := validateOCIRegistryFlags( + viper.GetString("gql-addr"), + viper.GetString("header-file"), + viper.GetString("csub-addr"), + viper.GetBool("csub-tls"), + viper.GetBool("csub-tls-skip-verify"), + viper.GetBool("add-vuln-on-ingest"), + viper.GetBool("add-license-on-ingest"), + viper.GetBool("add-eol-on-ingest"), + viper.GetBool("add-depsdev-on-ingest"), + viper.GetBool("use-csub"), + args) + if err != nil { + fmt.Printf("unable to validate flags: %v\n", err) + _ = cmd.Help() + os.Exit(1) + } + + ctx := logging.WithLogger(context.Background()) + logger := logging.FromContext(ctx) + transport := cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport) + + // Register collector + ociRegistryCollector := oci.NewOCIRegistryCollector(ctx, opts.dataSource, false, 30*time.Second) + err = collector.RegisterDocumentCollector(ociRegistryCollector, oci.OCIRegistryCollector) + if err != nil { + logger.Errorf("unable to register oci collector: %v", err) } totalNum := 0 @@ -94,8 +179,7 @@ var ociCmd = &cobra.Command{ // Set emit function to go through the entire pipeline emit := func(d *processor.Document) error { totalNum += 1 - _, err := ingestor.Ingest( - ctx, + _, err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, @@ -105,6 +189,7 @@ var ociCmd = &cobra.Command{ opts.queryEOLOnIngestion, opts.queryDepsDevOnIngestion, ) + if err != nil { gotErr = true return fmt.Errorf("unable to ingest document: %w", err) @@ -134,7 +219,7 @@ var ociCmd = &cobra.Command{ } func validateOCIFlags(gqlEndpoint, headerFile, csubAddr string, csubTls, csubTlsSkipVerify bool, - queryVulnIngestion bool, queryLicenseIngestion bool, queryEOLIngestion bool, queryDepsDevOnIngestion bool, args []string) (ociOptions, error) { + queryVulnIngestion bool, queryLicenseIngestion bool, queryEOLIngestion bool, queryDepsDevOnIngestion bool, useCsub bool, args []string) (ociOptions, csub_client.Client, error) { var opts ociOptions opts.graphqlEndpoint = gqlEndpoint opts.headerFile = headerFile @@ -142,36 +227,110 @@ func validateOCIFlags(gqlEndpoint, headerFile, csubAddr string, csubTls, csubTls opts.queryLicenseOnIngestion = queryLicenseIngestion opts.queryEOLOnIngestion = queryEOLIngestion opts.queryDepsDevOnIngestion = queryDepsDevOnIngestion + opts.useCsub = useCsub - csubOpts, err := csub_client.ValidateCsubClientFlags(csubAddr, csubTls, csubTlsSkipVerify) - if err != nil { - return opts, fmt.Errorf("unable to validate csub client flags: %w", err) - } - opts.csubClientOptions = csubOpts + var csubClient csub_client.Client - if len(args) < 1 { - return opts, fmt.Errorf("expected positional argument for image_path") - } - sources := []datasource.Source{} - for _, arg := range args { - if _, err := ref.New(arg); err != nil { - return opts, fmt.Errorf("image_path parsing error. require format repo:tag") + if useCsub { + csubOpts, err := csub_client.ValidateCsubClientFlags(csubAddr, csubTls, csubTlsSkipVerify) + if err != nil { + return opts, nil, fmt.Errorf("unable to validate csub client flags: %w", err) + } + opts.csubClientOptions = csubOpts + csubClient, err = csub_client.NewClient(csubOpts) + if err != nil { + return opts, nil, err + } + csubSource, err := csubsource.NewCsubDatasource(csubClient, 10*time.Second) + if err != nil { + return opts, nil, err + } + opts.dataSource = csubSource + return opts, csubClient, nil + } else { + if len(args) < 1 { + return opts, nil, fmt.Errorf("expected positional argument for image_path") } - sources = append(sources, datasource.Source{ - Value: arg, + sources := []datasource.Source{} + for _, arg := range args { + if _, err := ref.New(arg); err != nil { + return opts, nil, fmt.Errorf("image_path parsing error. require format repo:tag") + } + sources = append(sources, datasource.Source{ + Value: arg, + }) + } + + var err error + opts.dataSource, err = inmemsource.NewInmemDataSources(&datasource.DataSources{ + OciDataSources: sources, }) + if err != nil { + return opts, nil, err + } } - opts.dataSource, err = inmemsource.NewInmemDataSources(&datasource.DataSources{ - OciDataSources: sources, - }) - if err != nil { - return opts, err + return opts, nil, nil +} + +func validateOCIRegistryFlags(gqlEndpoint, headerFile, csubAddr string, csubTls, csubTlsSkipVerify bool, + queryVulnIngestion bool, queryLicenseIngestion bool, queryEOLIngestion bool, queryDepsDevOnIngestion bool, useCsub bool, args []string) (ociRegistryOptions, csub_client.Client, error) { + var opts ociRegistryOptions + opts.graphqlEndpoint = gqlEndpoint + opts.headerFile = headerFile + opts.queryVulnOnIngestion = queryVulnIngestion + opts.queryLicenseOnIngestion = queryLicenseIngestion + opts.queryEOLOnIngestion = queryEOLIngestion + opts.queryDepsDevOnIngestion = queryDepsDevOnIngestion + opts.useCsub = useCsub + + var csubClient csub_client.Client + + if useCsub { + csubOpts, err := csub_client.ValidateCsubClientFlags(csubAddr, csubTls, csubTlsSkipVerify) + if err != nil { + return opts, nil, fmt.Errorf("unable to validate csub client flags: %w", err) + } + opts.csubClientOptions = csubOpts + csubClient, err = csub_client.NewClient(csubOpts) + if err != nil { + return opts, nil, err + } + csubSource, err := csubsource.NewCsubDatasource(csubClient, 10*time.Second) + if err != nil { + return opts, nil, err + } + opts.dataSource = csubSource + return opts, csubClient, nil + } else { + if len(args) < 1 { + return opts, nil, fmt.Errorf("expected positional argument(s) for registr(y|ies)") + } + sources := []datasource.Source{} + for _, arg := range args { + // Min check to validate registry by resolving hostname + _, err := net.LookupHost(arg) + if err != nil { + return opts, nil, fmt.Errorf("registry parsing error. require format registry:port") + } + sources = append(sources, datasource.Source{ + Value: arg, + }) + } + + var err error + opts.dataSource, err = inmemsource.NewInmemDataSources(&datasource.DataSources{ + OciRegistryDataSources: sources, + }) + if err != nil { + return opts, nil, err + } } - return opts, nil + return opts, nil, nil } func init() { collectCmd.AddCommand(ociCmd) + collectCmd.AddCommand(ociRegistryCmd) } diff --git a/pkg/collectsub/collectsub/collectsub.pb.go b/pkg/collectsub/collectsub/collectsub.pb.go index f3005ecfa6..c04c0081fe 100644 --- a/pkg/collectsub/collectsub/collectsub.pb.go +++ b/pkg/collectsub/collectsub/collectsub.pb.go @@ -43,6 +43,7 @@ const ( CollectDataType_DATATYPE_OCI CollectDataType = 2 CollectDataType_DATATYPE_PURL CollectDataType = 3 CollectDataType_DATATYPE_GITHUB_RELEASE CollectDataType = 4 + CollectDataType_DATATYPE_OCI_REGISTRY CollectDataType = 5 ) // Enum value maps for CollectDataType. @@ -53,6 +54,7 @@ var ( 2: "DATATYPE_OCI", 3: "DATATYPE_PURL", 4: "DATATYPE_GITHUB_RELEASE", + 5: "DATATYPE_OCI_REGISTRY", } CollectDataType_value = map[string]int32{ "DATATYPE_UNKNOWN": 0, @@ -60,6 +62,7 @@ var ( "DATATYPE_OCI": 2, "DATATYPE_PURL": 3, "DATATYPE_GITHUB_RELEASE": 4, + "DATATYPE_OCI_REGISTRY": 5, } ) @@ -459,39 +462,40 @@ var file_pkg_collectsub_collectsub_collectsub_proto_rawDesc = []byte{ 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x65, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, - 0x2a, 0x7b, 0x0a, 0x0f, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x44, 0x61, 0x74, 0x61, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x44, 0x41, 0x54, 0x41, 0x54, 0x59, 0x50, 0x45, 0x5f, - 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x41, 0x54, - 0x41, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x49, 0x54, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x44, - 0x41, 0x54, 0x41, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4f, 0x43, 0x49, 0x10, 0x02, 0x12, 0x11, 0x0a, - 0x0d, 0x44, 0x41, 0x54, 0x41, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x50, 0x55, 0x52, 0x4c, 0x10, 0x03, - 0x12, 0x1b, 0x0a, 0x17, 0x44, 0x41, 0x54, 0x41, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x49, 0x54, - 0x48, 0x55, 0x42, 0x5f, 0x52, 0x45, 0x4c, 0x45, 0x41, 0x53, 0x45, 0x10, 0x04, 0x32, 0xd2, 0x02, - 0x0a, 0x18, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, - 0x62, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x98, 0x01, 0x0a, 0x11, 0x41, - 0x64, 0x64, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, - 0x12, 0x40, 0x2e, 0x67, 0x75, 0x61, 0x63, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x75, 0x61, 0x63, 0x2e, - 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, - 0x65, 0x72, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6c, - 0x6c, 0x65, 0x63, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x67, 0x75, 0x61, 0x63, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x75, 0x61, - 0x63, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, - 0x69, 0x62, 0x65, 0x72, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x41, 0x64, 0x64, 0x43, - 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x9a, 0x01, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6c, - 0x6c, 0x65, 0x63, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x12, 0x40, 0x2e, 0x67, 0x75, - 0x61, 0x63, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x75, 0x61, 0x63, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, - 0x63, 0x74, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x2e, 0x73, 0x63, - 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x45, - 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, - 0x67, 0x75, 0x61, 0x63, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x75, 0x61, 0x63, 0x2e, 0x63, 0x6f, 0x6c, - 0x6c, 0x65, 0x63, 0x74, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x2e, - 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, - 0x74, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x30, 0x01, 0x42, 0x28, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x67, 0x75, 0x61, 0x63, 0x73, 0x65, 0x63, 0x2f, 0x67, 0x75, 0x61, 0x63, 0x2f, 0x70, 0x6b, - 0x67, 0x2f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x73, 0x75, 0x62, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x2a, 0x96, 0x01, 0x0a, 0x0f, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x44, 0x61, 0x74, 0x61, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x44, 0x41, 0x54, 0x41, 0x54, 0x59, 0x50, 0x45, + 0x5f, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x41, + 0x54, 0x41, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x49, 0x54, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, + 0x44, 0x41, 0x54, 0x41, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4f, 0x43, 0x49, 0x10, 0x02, 0x12, 0x11, + 0x0a, 0x0d, 0x44, 0x41, 0x54, 0x41, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x50, 0x55, 0x52, 0x4c, 0x10, + 0x03, 0x12, 0x1b, 0x0a, 0x17, 0x44, 0x41, 0x54, 0x41, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x49, + 0x54, 0x48, 0x55, 0x42, 0x5f, 0x52, 0x45, 0x4c, 0x45, 0x41, 0x53, 0x45, 0x10, 0x04, 0x12, 0x19, + 0x0a, 0x15, 0x44, 0x41, 0x54, 0x41, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4f, 0x43, 0x49, 0x5f, 0x52, + 0x45, 0x47, 0x49, 0x53, 0x54, 0x52, 0x59, 0x10, 0x05, 0x32, 0xd2, 0x02, 0x0a, 0x18, 0x43, 0x6f, + 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x98, 0x01, 0x0a, 0x11, 0x41, 0x64, 0x64, 0x43, 0x6f, + 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x12, 0x40, 0x2e, 0x67, + 0x75, 0x61, 0x63, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x75, 0x61, 0x63, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, + 0x65, 0x63, 0x74, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x2e, 0x73, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, + 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, + 0x2e, 0x67, 0x75, 0x61, 0x63, 0x73, 0x65, 0x63, 0x2e, 0x67, 0x75, 0x61, 0x63, 0x2e, 0x63, 0x6f, + 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, + 0x2e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6c, 0x6c, 0x65, + 0x63, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x9a, 0x01, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, + 0x45, 0x6e, 0x74, 0x72, 0x69, 0x65, 0x73, 0x12, 0x40, 0x2e, 0x67, 0x75, 0x61, 0x63, 0x73, 0x65, + 0x63, 0x2e, 0x67, 0x75, 0x61, 0x63, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x5f, 0x73, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x2e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, + 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x69, + 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x41, 0x2e, 0x67, 0x75, 0x61, 0x63, + 0x73, 0x65, 0x63, 0x2e, 0x67, 0x75, 0x61, 0x63, 0x2e, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, + 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x2e, 0x73, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x45, 0x6e, 0x74, + 0x72, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x42, 0x28, + 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x75, 0x61, + 0x63, 0x73, 0x65, 0x63, 0x2f, 0x67, 0x75, 0x61, 0x63, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x63, 0x6f, + 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x73, 0x75, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/collectsub/collectsub/collectsub.proto b/pkg/collectsub/collectsub/collectsub.proto index a45b6756f9..a3ca6c37ce 100644 --- a/pkg/collectsub/collectsub/collectsub.proto +++ b/pkg/collectsub/collectsub/collectsub.proto @@ -24,6 +24,7 @@ enum CollectDataType { DATATYPE_OCI = 2; DATATYPE_PURL = 3; DATATYPE_GITHUB_RELEASE = 4; + DATATYPE_OCI_REGISTRY = 5; } // Generic types diff --git a/pkg/collectsub/datasource/csubsource/csubsource.go b/pkg/collectsub/datasource/csubsource/csubsource.go index 21316af4de..f65b878aa9 100644 --- a/pkg/collectsub/datasource/csubsource/csubsource.go +++ b/pkg/collectsub/datasource/csubsource/csubsource.go @@ -52,6 +52,7 @@ func (d *csubDataSources) GetDataSources(ctx context.Context) (*datasource.DataS {Type: pb.CollectDataType_DATATYPE_GIT, Glob: "*"}, {Type: pb.CollectDataType_DATATYPE_PURL, Glob: "*"}, {Type: pb.CollectDataType_DATATYPE_GITHUB_RELEASE, Glob: "*"}, + {Type: pb.CollectDataType_DATATYPE_OCI_REGISTRY, Glob: "*"}, }) if err != nil { return nil, err @@ -115,6 +116,10 @@ func entriesToSources(ctx context.Context, entries []*pb.CollectEntry) *datasour d.GithubReleaseDataSources = append(d.GithubReleaseDataSources, datasource.Source{ Value: e.Value, }) + case pb.CollectDataType_DATATYPE_OCI_REGISTRY: + d.OciRegistryDataSources = append(d.OciRegistryDataSources, datasource.Source{ + Value: e.Value, + }) default: // unhandled datatype, skip