From c0e35bf60ecd19342a41f494bc1fb6fad4279287 Mon Sep 17 00:00:00 2001 From: Nathan Naveen <42319948+nathannaveen@users.noreply.github.com> Date: Mon, 22 Apr 2024 13:54:31 -0500 Subject: [PATCH 01/17] Add GUAC Version to Logs (#1856) - Added GUAC version to logs using a child logger. - Version info comes from `pkg/version/version.go`, set during build by GoReleaser from the Makefile. Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com> --- pkg/logging/logger.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/logging/logger.go b/pkg/logging/logger.go index 1ea78b97313..5da27070507 100644 --- a/pkg/logging/logger.go +++ b/pkg/logging/logger.go @@ -18,6 +18,7 @@ package logging import ( "context" "fmt" + "github.com/guacsec/guac/pkg/version" "strings" "go.uber.org/zap" @@ -41,6 +42,7 @@ const ( Fatal LogLevel = "fatal" ChildLoggerKey contextKey = "childLogger" DocumentHash = "documentHash" + guacVersion = "guac-version" ) type loggerKey struct{} @@ -67,7 +69,7 @@ func InitLogger(level LogLevel) { _ = zapLogger.Sync() }() - logger = zapLogger.Sugar() + logger = zapLogger.Sugar().With(guacVersion, version.Version) if levelErr != nil { logger.Infof("Invalid log level %s: ", level, levelErr) From d90879213c44960a76c1870f3922ed2cbd1e02fb Mon Sep 17 00:00:00 2001 From: Parth Patel <88045217+pxp928@users.noreply.github.com> Date: Mon, 22 Apr 2024 21:03:02 -0400 Subject: [PATCH 02/17] [FIX] implement fixes based on parsing and querying errors for CDX (#1855) * implement fixes based on parsing and querying errors Signed-off-by: pxp928 * add unit test for cdx vex use case Signed-off-by: pxp928 --------- Signed-off-by: pxp928 --- cmd/guacone/cmd/vulnerability.go | 40 ++----- .../cyclonedx-vex-no-analysis.json | 50 ++++++++ internal/testing/testdata/testdata.go | 39 +++++- pkg/assembler/helpers/purl.go | 2 +- pkg/assembler/helpers/purl_test.go | 8 ++ .../parser/cyclonedx/parser_cyclonedx.go | 111 +++++++++++------- .../parser/cyclonedx/parser_cyclonedx_test.go | 44 +++++++ pkg/ingestor/parser/spdx/parse_spdx.go | 2 +- 8 files changed, 216 insertions(+), 80 deletions(-) create mode 100644 internal/testing/testdata/exampledata/cyclonedx-vex-no-analysis.json diff --git a/cmd/guacone/cmd/vulnerability.go b/cmd/guacone/cmd/vulnerability.go index 37380fd5761..0d08fd352e8 100644 --- a/cmd/guacone/cmd/vulnerability.go +++ b/cmd/guacone/cmd/vulnerability.go @@ -22,7 +22,6 @@ import ( "net/http" "os" "strings" - "sync" "github.com/Khan/genqlient/graphql" model "github.com/guacsec/guac/pkg/assembler/clients/generated" @@ -433,24 +432,17 @@ func searchDependencyPackagesReverse(ctx context.Context, gqlclient graphql.Clie } } -func concurrentVulnAndVexNeighbors(ctx context.Context, gqlclient graphql.Client, pkgID string, isDep model.AllHasSBOMTreeIncludedDependenciesIsDependency, resultChan chan<- struct { +type pkgVersionNeighborQueryResults struct { pkgVersionNeighborResponse *model.NeighborsResponse isDep model.AllHasSBOMTreeIncludedDependenciesIsDependency -}, wg *sync.WaitGroup) { - defer wg.Done() +} - logger := logging.FromContext(ctx) +func getVulnAndVexNeighbors(ctx context.Context, gqlclient graphql.Client, pkgID string, isDep model.AllHasSBOMTreeIncludedDependenciesIsDependency) (*pkgVersionNeighborQueryResults, error) { pkgVersionNeighborResponse, err := model.Neighbors(ctx, gqlclient, pkgID, []model.Edge{model.EdgePackageCertifyVuln, model.EdgePackageCertifyVexStatement}) if err != nil { - logger.Errorf("error querying neighbor for vulnerability: %w", err) - return + return nil, fmt.Errorf("failed to get neighbors for pkgID: %s with error %w", pkgID, err) } - - // Send the results to the resultChan - resultChan <- struct { - pkgVersionNeighborResponse *model.NeighborsResponse - isDep model.AllHasSBOMTreeIncludedDependenciesIsDependency - }{pkgVersionNeighborResponse, isDep} + return &pkgVersionNeighborQueryResults{pkgVersionNeighborResponse: pkgVersionNeighborResponse, isDep: isDep}, nil } // searchPkgViaHasSBOM takes in either a purl or URI for the initial value to find the hasSBOM node. @@ -460,7 +452,7 @@ func searchPkgViaHasSBOM(ctx context.Context, gqlclient graphql.Client, searchSt var path []string var tableRows []table.Row checkedPkgIDs := make(map[string]bool) - var wg sync.WaitGroup + var collectedPkgVersionResults []*pkgVersionNeighborQueryResults queue := make([]string, 0) // the queue of nodes in bfs type dfsNode struct { @@ -474,11 +466,6 @@ func searchPkgViaHasSBOM(ctx context.Context, gqlclient graphql.Client, searchSt nodeMap[searchString] = dfsNode{} queue = append(queue, searchString) - resultChan := make(chan struct { - pkgVersionNeighborResponse *model.NeighborsResponse - isDep model.AllHasSBOMTreeIncludedDependenciesIsDependency - }) - for len(queue) > 0 { now := queue[0] queue = queue[1:] @@ -560,8 +547,11 @@ func searchPkgViaHasSBOM(ctx context.Context, gqlclient graphql.Client, searchSt if !dfsN.expanded { queue = append(queue, pkgID) } - wg.Add(1) - go concurrentVulnAndVexNeighbors(ctx, gqlclient, pkgID, isDep, resultChan, &wg) + pkgVersionNeighbors, err := getVulnAndVexNeighbors(ctx, gqlclient, pkgID, isDep) + if err != nil { + return nil, nil, fmt.Errorf("getVulnAndVexNeighbors failed with error: %w", err) + } + collectedPkgVersionResults = append(collectedPkgVersionResults, pkgVersionNeighbors) checkedPkgIDs[pkgID] = true } } @@ -570,16 +560,10 @@ func searchPkgViaHasSBOM(ctx context.Context, gqlclient graphql.Client, searchSt nodeMap[now] = nowNode } - // Close the result channel once all goroutines are done - go func() { - wg.Wait() - close(resultChan) - }() - checkedCertifyVulnIDs := make(map[string]bool) // Collect results from the channel - for result := range resultChan { + for _, result := range collectedPkgVersionResults { for _, neighbor := range result.pkgVersionNeighborResponse.Neighbors { if certifyVuln, ok := neighbor.(*model.NeighborsNeighborsCertifyVuln); ok { if !checkedCertifyVulnIDs[certifyVuln.Id] { diff --git a/internal/testing/testdata/exampledata/cyclonedx-vex-no-analysis.json b/internal/testing/testdata/exampledata/cyclonedx-vex-no-analysis.json new file mode 100644 index 00000000000..5bb4c7584d1 --- /dev/null +++ b/internal/testing/testdata/exampledata/cyclonedx-vex-no-analysis.json @@ -0,0 +1,50 @@ +{ + "bomFormat": "CycloneDX", + "specVersion": "1.4", + "version": 1, + "metadata" : { + "timestamp" : "2022-03-03T00:00:00Z", + "component" : { + "name" : "ABC", + "type" : "application", + "bom-ref" : "product-ABC" + } + }, + "vulnerabilities": [ + { + "id": "CVE-2021-44228", + "source": { + "name": "NVD", + "url": "https://nvd.nist.gov/vuln/detail/CVE-2021-44228" + }, + "ratings": [ + { + "source": { + "name": "NVD", + "url": "https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H&version=3.1" + }, + "score": 10.0, + "severity": "critical", + "method": "CVSSv31", + "vector": "AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H" + } + ], + "description": "com.fasterxml.jackson.core:jackson-databind is a library which contains the general-purpose data-binding functionality and tree-model for Jackson Data Processor.\n\nAffected versions of this package are vulnerable to XML External Entity (XXE) Injection. A flaw was found in FasterXML Jackson Databind, where it does not have entity expansion secured properly in the DOMDeserializer class. The highest threat from this vulnerability is data integrity.", + "affects": [ + { + "ref": "urn:cdx:3e671687-395b-41f5-a30f-a58921a69b79/1#product-ABC", + "versions": [ + { + "version": "2.4", + "status": "affected" + }, + { + "version": "2.6", + "status": "affected" + } + ] + } + ] + } + ] +} diff --git a/internal/testing/testdata/testdata.go b/internal/testing/testdata/testdata.go index f34c09e7eb0..25e35d7f952 100644 --- a/internal/testing/testdata/testdata.go +++ b/internal/testing/testdata/testdata.go @@ -18,7 +18,6 @@ package testdata import ( _ "embed" "encoding/base64" - "fmt" "time" "github.com/google/go-cmp/cmp" @@ -111,6 +110,9 @@ var ( //go:embed exampledata/cyclonedx-vex-affected.json CycloneDXVEXAffected []byte + //go:embed exampledata/cyclonedx-vex-no-analysis.json + CycloneDXVEXWithoutAnalysis []byte + //go:embed exampledata/cyclonedx-vex.xml CyloneDXVEXExampleXML []byte @@ -186,8 +188,8 @@ var ( VexData: &generated.VexStatementInputSpec{ Status: generated.VexStatusNotAffected, VexJustification: generated.VexJustificationVulnerableCodeNotInExecutePath, - Statement: "Automated dataflow analysis and manual code review indicates that the vulnerable code is not reachable, either directly or indirectly.", - StatusNotes: fmt.Sprintf("%s:%s", generated.VexStatusNotAffected, generated.VexJustificationVulnerableCodeNotInExecutePath), + Statement: "com.fasterxml.jackson.core:jackson-databind is a library which contains the general-purpose data-binding functionality and tree-model for Jackson Data Processor.\n\nAffected versions of this package are vulnerable to XML External Entity (XXE) Injection. A flaw was found in FasterXML Jackson Databind, where it does not have entity expansion secured properly in the DOMDeserializer class. The highest threat from this vulnerability is data integrity.", + StatusNotes: "Automated dataflow analysis and manual code review indicates that the vulnerable code is not reachable, either directly or indirectly.", KnownSince: parseUTCTime("2020-12-03T00:00:00.000Z"), }, }, @@ -231,8 +233,15 @@ var ( VexDataAffected = &generated.VexStatementInputSpec{ Status: generated.VexStatusAffected, VexJustification: generated.VexJustificationNotProvided, - Statement: "Versions of Product ABC are affected by the vulnerability. Customers are advised to upgrade to the latest release.", - StatusNotes: fmt.Sprintf("%s:%s", generated.VexStatusAffected, generated.VexJustificationNotProvided), + Statement: "", + StatusNotes: "Versions of Product ABC are affected by the vulnerability. Customers are advised to upgrade to the latest release.", + KnownSince: time.Unix(0, 0), + } + VexDataNoAnalysis = &generated.VexStatementInputSpec{ + Status: generated.VexStatusAffected, + VexJustification: generated.VexJustificationNotProvided, + Statement: "com.fasterxml.jackson.core:jackson-databind is a library which contains the general-purpose data-binding functionality and tree-model for Jackson Data Processor.\n\nAffected versions of this package are vulnerable to XML External Entity (XXE) Injection. A flaw was found in FasterXML Jackson Databind, where it does not have entity expansion secured properly in the DOMDeserializer class. The highest threat from this vulnerability is data integrity.", + StatusNotes: "", KnownSince: time.Unix(0, 0), } CycloneDXAffectedVulnMetadata = []assembler.VulnMetadataIngest{ @@ -245,6 +254,16 @@ var ( }, }, } + CycloneDXNoAnalysisVulnMetadata = []assembler.VulnMetadataIngest{ + { + Vulnerability: VulnSpecAffected, + VulnMetadata: &generated.VulnerabilityMetadataInputSpec{ + ScoreType: generated.VulnerabilityScoreTypeCvssv31, + ScoreValue: 10, + Timestamp: time.Unix(0, 0), + }, + }, + } topLevelPkg, _ = asmhelpers.PurlToPkg("pkg:guac/cdx/ABC") HasSBOMVexAffected = []assembler.HasSBOMIngest{ @@ -257,6 +276,16 @@ var ( }, }, } + HasSBOMVexNoAnalysis = []assembler.HasSBOMIngest{ + { + Pkg: topLevelPkg, + HasSBOM: &model.HasSBOMInputSpec{ + Algorithm: "sha256", + Digest: "265c99f1f9a09b7fc10c14c97ca1a07fc52ae470f5cbcddd9baf5585fb28221c", + KnownSince: parseRfc3339("2022-03-03T00:00:00Z"), + }, + }, + } // DSSE/SLSA Testdata diff --git a/pkg/assembler/helpers/purl.go b/pkg/assembler/helpers/purl.go index ae79695789d..b8327322d22 100644 --- a/pkg/assembler/helpers/purl.go +++ b/pkg/assembler/helpers/purl.go @@ -137,7 +137,7 @@ func purlConvert(p purl.PackageURL) (*model.PkgInputSpec, error) { purl.TypeDebian, purl.TypeGem, purl.TypeGithub, purl.TypeGolang, purl.TypeHackage, purl.TypeHex, purl.TypeMaven, purl.TypeNPM, purl.TypeNuget, purl.TypePyPi, purl.TypeRPM, purl.TypeSwift, - purl.TypeGeneric: + purl.TypeGeneric, purl.TypeYocto, purl.TypeCpan: // some code r := pkg(p.Type, p.Namespace, p.Name, p.Version, p.Subpath, p.Qualifiers.Map()) return r, nil diff --git a/pkg/assembler/helpers/purl_test.go b/pkg/assembler/helpers/purl_test.go index 5623e7c525d..cff4c24f5ea 100644 --- a/pkg/assembler/helpers/purl_test.go +++ b/pkg/assembler/helpers/purl_test.go @@ -208,6 +208,14 @@ func TestPurlConvert(t *testing.T) { expected: pkg("oci", "registry.redhat.io/ubi9", "ubi9-container", "sha256:8614ce95268b970880a1eca97dddfce5154fab35418d839c5f75012cccaca0d9", "", map[string]string{ "tag": "9.2-489", }), + }, { + purlUri: "pkg:yocto/dmidecode@2.12-r0?arch=core2-32", + expected: pkg("yocto", "", "dmidecode", "2.12-r0", "", map[string]string{ + "arch": "core2-32", + }), + }, { + purlUri: "pkg:cpan/Pod-Perldoc@3.20", + expected: pkg("cpan", "", "Pod-Perldoc", "3.20", "", map[string]string{}), }, } diff --git a/pkg/ingestor/parser/cyclonedx/parser_cyclonedx.go b/pkg/ingestor/parser/cyclonedx/parser_cyclonedx.go index cfba980fa8a..4dfd90113ad 100644 --- a/pkg/ingestor/parser/cyclonedx/parser_cyclonedx.go +++ b/pkg/ingestor/parser/cyclonedx/parser_cyclonedx.go @@ -317,49 +317,55 @@ func (c *cyclonedxParser) getVulnerabilities(ctx context.Context) error { logger.Debugf("no vulnerabilities found in CycloneDX BOM") return nil } - - var status model.VexStatus - var justification model.VexJustification - var publishedTime time.Time for _, vulnerability := range *c.cdxBom.Vulnerabilities { vuln, err := asmhelpers.CreateVulnInput(vulnerability.ID) if err != nil { return fmt.Errorf("failed to create vuln input spec %v", err) } + var vd model.VexStatementInputSpec + publishedTime := time.Unix(0, 0) + if vulnerability.Analysis != nil { + if vexStatus, ok := vexStatusMap[vulnerability.Analysis.State]; ok { + vd.Status = vexStatus + } else { + return fmt.Errorf("unknown vulnerability status %s", vulnerability.Analysis.State) + } - if vexStatus, ok := vexStatusMap[vulnerability.Analysis.State]; ok { - status = vexStatus - } else { - return fmt.Errorf("unknown vulnerability status %s", vulnerability.Analysis.State) - } - - if vexJustification, ok := justificationsMap[vulnerability.Analysis.Justification]; ok { - justification = vexJustification - } else { - justification = model.VexJustificationNotProvided - } + if vexJustification, ok := justificationsMap[vulnerability.Analysis.Justification]; ok { + vd.VexJustification = vexJustification + } else { + vd.VexJustification = model.VexJustificationNotProvided + } - if vulnerability.Published != "" { - publishedTime, _ = time.Parse(time.RFC3339, vulnerability.Published) + if vulnerability.Published != "" { + publishedTime, err = time.Parse(time.RFC3339, vulnerability.Published) + if err != nil { + return fmt.Errorf("failed to pase time: %s, with error: %w", vulnerability.Published, err) + } + } + vd.KnownSince = publishedTime + vd.Statement = vulnerability.Description + + if vulnerability.Analysis.Detail != "" { + vd.StatusNotes = vulnerability.Analysis.Detail + } else if vulnerability.Analysis.Response != nil { + var response []string + for _, res := range *vulnerability.Analysis.Response { + response = append(response, string(res)) + } + vd.StatusNotes = strings.Join(response, ",") + } else { + vd.StatusNotes = vulnerability.Detail + } } else { - publishedTime = time.Unix(0, 0) - } - - vd := model.VexStatementInputSpec{ - Status: status, - VexJustification: justification, - KnownSince: publishedTime, - StatusNotes: fmt.Sprintf("%s:%s", string(status), string(justification)), - } - - if vulnerability.Analysis.Detail != "" { - vd.Statement = vulnerability.Analysis.Detail - } else if vulnerability.Analysis.Response != nil { - var response []string - for _, res := range *vulnerability.Analysis.Response { - response = append(response, string(res)) + vd = model.VexStatementInputSpec{ + // if status not specified, assume affected + Status: model.VexStatusAffected, + VexJustification: model.VexJustificationNotProvided, + KnownSince: publishedTime, + StatusNotes: vulnerability.Detail, + Statement: vulnerability.Description, } - vd.Statement = strings.Join(response, ",") } for _, affect := range *vulnerability.Affects { @@ -370,11 +376,11 @@ func (c *cyclonedxParser) getVulnerabilities(ctx context.Context) error { c.vulnData.vex = append(c.vulnData.vex, *vi...) for _, v := range *vi { - if status == model.VexStatusAffected || status == model.VexStatusUnderInvestigation { + if v.VexData.Status == model.VexStatusAffected || v.VexData.Status == model.VexStatusUnderInvestigation { cv := assembler.CertifyVulnIngest{ Vulnerability: vuln, VulnData: &model.ScanMetadataInput{ - TimeScanned: publishedTime, + TimeScanned: v.VexData.KnownSince, }, Pkg: v.Pkg, } @@ -384,18 +390,21 @@ func (c *cyclonedxParser) getVulnerabilities(ctx context.Context) error { } for _, vulnRating := range *vulnerability.Ratings { - vm := assembler.VulnMetadataIngest{ - Vulnerability: vuln, - VulnMetadata: &model.VulnerabilityMetadataInputSpec{ - ScoreType: model.VulnerabilityScoreType(vulnRating.Method), - ScoreValue: *vulnRating.Score, - Timestamp: publishedTime, - }, + if vulnRating.Method != "" { + vm := assembler.VulnMetadataIngest{ + Vulnerability: vuln, + VulnMetadata: &model.VulnerabilityMetadataInputSpec{ + ScoreType: model.VulnerabilityScoreType(vulnRating.Method), + ScoreValue: *vulnRating.Score, + Timestamp: publishedTime, + }, + } + c.vulnData.vulnMetadata = append(c.vulnData.vulnMetadata, vm) + } else { + logger.Debugf("vulnerability method not specified in cdx sbom: %s, skipping", c.doc.SourceInformation.DocumentRef) } - c.vulnData.vulnMetadata = append(c.vulnData.vulnMetadata, vm) } } - return nil } @@ -404,6 +413,18 @@ func (c *cyclonedxParser) getAffectedPackages(ctx context.Context, vulnInput *mo logger := logging.FromContext(ctx) pkgRef := affectsObj.Ref + var foundVexIngest []assembler.VexIngest + + foundPkgElements := c.getPackageElement(affectsObj.Ref) + + for _, foundPkgElement := range foundPkgElements { + foundVexIngest = append(foundVexIngest, assembler.VexIngest{VexData: &vexData, Vulnerability: vulnInput, Pkg: foundPkgElement}) + } + + if len(foundVexIngest) > 0 { + return &foundVexIngest, nil + } + // split ref using # as delimiter. pkgRefInfo := strings.Split(pkgRef, "#") if len(pkgRefInfo) != 2 { diff --git a/pkg/ingestor/parser/cyclonedx/parser_cyclonedx_test.go b/pkg/ingestor/parser/cyclonedx/parser_cyclonedx_test.go index 9e84ee6abfb..1ad93d88a09 100644 --- a/pkg/ingestor/parser/cyclonedx/parser_cyclonedx_test.go +++ b/pkg/ingestor/parser/cyclonedx/parser_cyclonedx_test.go @@ -118,6 +118,15 @@ func Test_cyclonedxParser(t *testing.T) { }, wantPredicates: affectedVexPredicates(), wantErr: false, + }, { + name: "valid CycloneDX VEX document with no analysis", + doc: &processor.Document{ + Blob: testdata.CycloneDXVEXWithoutAnalysis, + Format: processor.FormatJSON, + Type: processor.DocumentCycloneDX, + }, + wantPredicates: noAnalysisVexPredicates(), + wantErr: false, }} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -516,3 +525,38 @@ func affectedVexPredicates() *assembler.IngestPredicates { }, } } + +func noAnalysisVexPredicates() *assembler.IngestPredicates { + return &assembler.IngestPredicates{ + HasSBOM: testdata.HasSBOMVexNoAnalysis, + VulnMetadata: testdata.CycloneDXNoAnalysisVulnMetadata, + Vex: []assembler.VexIngest{ + { + Pkg: guacPkgHelper("product-ABC", "2.4"), + Vulnerability: testdata.VulnSpecAffected, + VexData: testdata.VexDataNoAnalysis, + }, + { + Pkg: guacPkgHelper("product-ABC", "2.6"), + Vulnerability: testdata.VulnSpecAffected, + VexData: testdata.VexDataNoAnalysis, + }, + }, + CertifyVuln: []assembler.CertifyVulnIngest{ + { + Pkg: guacPkgHelper("product-ABC", "2.4"), + Vulnerability: testdata.VulnSpecAffected, + VulnData: &model.ScanMetadataInput{ + TimeScanned: time.Unix(0, 0), + }, + }, + { + Pkg: guacPkgHelper("product-ABC", "2.6"), + Vulnerability: testdata.VulnSpecAffected, + VulnData: &model.ScanMetadataInput{ + TimeScanned: time.Unix(0, 0), + }, + }, + }, + } +} diff --git a/pkg/ingestor/parser/spdx/parse_spdx.go b/pkg/ingestor/parser/spdx/parse_spdx.go index 71e6ac8b64d..fb2a96e9128 100644 --- a/pkg/ingestor/parser/spdx/parse_spdx.go +++ b/pkg/ingestor/parser/spdx/parse_spdx.go @@ -420,7 +420,7 @@ func fixLicense(ctx context.Context, l *generated.LicenseInputSpec, ol []*spdx.O } } if !found { - logger.Error("License identifier %q not found in OtherLicenses", l.Name) + logger.Error("License identifier %s not found in OtherLicenses", l.Name) s := "Not found" l.Inline = &s } From 3577d4dc0f26e3d826c540bee5f7142a0ee6a693 Mon Sep 17 00:00:00 2001 From: Narsimham Chelluri Date: Mon, 22 Apr 2024 22:25:17 -0300 Subject: [PATCH 03/17] Populate SourceInformation.DocumentRef in collectors (#1847) * Add store-blob-url CLI flag to all collectors Signed-off-by: Narsimham Chelluri (Narsa) * Import package only once in file - This clears up a go-staticcheck warning Signed-off-by: Narsimham Chelluri (Narsa) * Make use of setBlobURL flag in all collectors Signed-off-by: Narsimham Chelluri (Narsa) * Remove impossible conditional clause - This clears up a nilness analyzer warning Signed-off-by: Narsimham Chelluri (Narsa) * Import package only once in file - This clears up a go-staticcheck warning Signed-off-by: Narsimham Chelluri (Narsa) * Tweak error message to not end with punctuation - This clears up up a go-staticcheck warning Signed-off-by: Narsimham Chelluri (Narsa) * Add test for collector storeBlobURL flags - TODO: GitHub Signed-off-by: Narsimham Chelluri (Narsa) * Fix typo in filename Signed-off-by: Narsimham Chelluri (Narsa) * Add some TODOs to the GitHub collector test. Signed-off-by: Narsimham Chelluri (Narsa) * Rename flag more appropriately Signed-off-by: Narsimham Chelluri (Narsa) * Always set DocumentRef to blob key - Since we now have the DocumentRef field, there is no reason to gate its usage, and this simplifies the CLI command code. Signed-off-by: Narsimham Chelluri (Narsa) * Fix broken tests (minor) - I forgot to include the DocumentRef values in my want docs. Signed-off-by: Narsimham Chelluri (Narsa) * Minor refactor - Since we no longer branch based on whether or not we want to store blob keys (we always do it), the getDocRef() methods have become funcs instead. Signed-off-by: Narsimham Chelluri (Narsa) * Fix S3 collected doc Source field Signed-off-by: Narsimham Chelluri (Narsa) * Fix SourceInformation assertion Signed-off-by: Narsimham Chelluri (Narsa) * Create helper wrapper func to aid readability - This allows me to stop repeating a call with a comment explaining it multiple time throughout the collector code. It's very minor change. Signed-off-by: Narsimham Chelluri (Narsa) --------- Signed-off-by: Narsimham Chelluri (Narsa) --- cmd/guaccollect/cmd/deps_dev.go | 16 ++++++++-- cmd/guaccollect/cmd/files.go | 19 ++---------- cmd/guaccollect/cmd/gcs.go | 25 +++++++++++----- cmd/guaccollect/cmd/github.go | 21 +++++++++++--- cmd/guaccollect/cmd/oci.go | 11 ++++++- cmd/guaccollect/cmd/root.go | 9 +++++- cmd/guaccollect/cmd/s3.go | 28 ++++++++++++++---- cmd/guacone/cmd/files.go | 2 +- internal/testing/cmd/pubsub_test/cmd/files.go | 2 +- internal/testing/dochelper/dochelper.go | 2 +- pkg/cli/store.go | 3 -- pkg/events/events.go | 5 ++++ pkg/handler/collector/collector_test.go | 12 ++++---- pkg/handler/collector/deps_dev/deps_dev.go | 13 +++++---- .../collector/deps_dev/deps_dev_test.go | 11 +++++++ pkg/handler/collector/file/file.go | 19 ++++-------- pkg/handler/collector/file/file_test.go | 29 ++++--------------- pkg/handler/collector/gcs/gcs.go | 6 ++-- pkg/handler/collector/gcs/gcs_test.go | 11 ++++--- pkg/handler/collector/git/git.go | 2 +- .../collector/github/{READMD.md => README.md} | 0 pkg/handler/collector/github/github.go | 11 ++++--- pkg/handler/collector/github/github_test.go | 6 ++++ pkg/handler/collector/oci/oci.go | 14 +++++++-- pkg/handler/collector/oci/oci_test.go | 14 ++++++++- pkg/handler/collector/s3/s3.go | 19 ++++++------ pkg/handler/collector/s3/s3_test.go | 26 +++++++++++++++-- pkg/ingestor/parser/spdx/parse_spdx.go | 7 ++--- 28 files changed, 219 insertions(+), 124 deletions(-) rename pkg/handler/collector/github/{READMD.md => README.md} (100%) diff --git a/cmd/guaccollect/cmd/deps_dev.go b/cmd/guaccollect/cmd/deps_dev.go index 090c6ceb4f6..72fe0aadcd4 100644 --- a/cmd/guaccollect/cmd/deps_dev.go +++ b/cmd/guaccollect/cmd/deps_dev.go @@ -82,9 +82,9 @@ you have access to read and write to the respective blob store.`, viper.GetBool("use-csub"), viper.GetBool("service-poll"), viper.GetBool("retrieve-dependencies"), - args, viper.GetBool("enable-prometheus"), viper.GetInt("prometheus-port"), + args, ) if err != nil { fmt.Printf("unable to validate flags: %v\n", err) @@ -114,8 +114,18 @@ you have access to read and write to the respective blob store.`, }, } -func validateDepsDevFlags(pubsubAddr string, blobAddr string, csubAddr string, csubTls bool, csubTlsSkipVerify bool, useCsub bool, poll bool, retrieveDependencies bool, args []string, - enablePrometheus bool, prometheusPort int, +func validateDepsDevFlags( + pubsubAddr, + blobAddr, + csubAddr string, + csubTls, + csubTlsSkipVerify, + useCsub, + poll, + retrieveDependencies, + enablePrometheus bool, + prometheusPort int, + args []string, ) (depsDevOptions, error) { var opts depsDevOptions opts.pubsubAddr = pubsubAddr diff --git a/cmd/guaccollect/cmd/files.go b/cmd/guaccollect/cmd/files.go index 0a716c9e23b..e6650f92a68 100644 --- a/cmd/guaccollect/cmd/files.go +++ b/cmd/guaccollect/cmd/files.go @@ -26,7 +26,6 @@ import ( "time" "github.com/guacsec/guac/pkg/blob" - "github.com/guacsec/guac/pkg/cli" "github.com/guacsec/guac/pkg/emitter" "github.com/guacsec/guac/pkg/handler/collector" "github.com/guacsec/guac/pkg/handler/collector/file" @@ -45,8 +44,6 @@ type filesOptions struct { blobAddr string // poll location poll bool - // use blob URL for origin instead of source URL (useful if the blob store is persistent and we want to store the blob source location) - useBlobURL bool } var filesCmd = &cobra.Command{ @@ -73,7 +70,6 @@ you have access to read and write to the respective blob store.`, viper.GetString("pubsub-addr"), viper.GetString("blob-addr"), viper.GetBool("service-poll"), - viper.GetBool("use-blob-url"), args) if err != nil { fmt.Printf("unable to validate flags: %v\n", err) @@ -85,7 +81,7 @@ you have access to read and write to the respective blob store.`, logger := logging.FromContext(ctx) // Register collector - fileCollector := file.NewFileCollector(ctx, opts.path, opts.poll, 30*time.Second, opts.useBlobURL) + fileCollector := file.NewFileCollector(ctx, opts.path, opts.poll, 30*time.Second) err = collector.RegisterDocumentCollector(fileCollector, file.FileCollector) if err != nil { logger.Fatalf("unable to register file collector: %v", err) @@ -95,13 +91,12 @@ you have access to read and write to the respective blob store.`, }, } -func validateFilesFlags(pubsubAddr, blobAddr string, poll, useBlobURL bool, args []string) (filesOptions, error) { +func validateFilesFlags(pubsubAddr, blobAddr string, poll bool, args []string) (filesOptions, error) { var opts filesOptions opts.pubsubAddr = pubsubAddr opts.blobAddr = blobAddr opts.poll = poll - opts.useBlobURL = useBlobURL if len(args) != 1 { return opts, fmt.Errorf("expected positional argument for file_path") @@ -193,15 +188,5 @@ func initializeNATsandCollector(ctx context.Context, pubsubAddr string, blobAddr } func init() { - set, err := cli.BuildFlags([]string{"use-blob-url"}) - if err != nil { - fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err) - os.Exit(1) - } - filesCmd.PersistentFlags().AddFlagSet(set) - if err := viper.BindPFlags(filesCmd.PersistentFlags()); err != nil { - fmt.Fprintf(os.Stderr, "failed to bind flags: %v", err) - os.Exit(1) - } rootCmd.AddCommand(filesCmd) } diff --git a/cmd/guaccollect/cmd/gcs.go b/cmd/guaccollect/cmd/gcs.go index f2a178aa1c7..bf7c88e71ea 100644 --- a/cmd/guaccollect/cmd/gcs.go +++ b/cmd/guaccollect/cmd/gcs.go @@ -1,11 +1,12 @@ package cmd import ( - "cloud.google.com/go/storage" "context" "fmt" + "os" + + "cloud.google.com/go/storage" "github.com/guacsec/guac/pkg/cli" - "github.com/guacsec/guac/pkg/collectsub/client" csub_client "github.com/guacsec/guac/pkg/collectsub/client" "github.com/guacsec/guac/pkg/handler/collector" "github.com/guacsec/guac/pkg/handler/collector/gcs" @@ -14,14 +15,13 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" "google.golang.org/api/option" - "os" ) type gcsOptions struct { pubSubAddr string blobAddr string graphqlEndpoint string - csubClientOptions client.CsubClientOptions + csubClientOptions csub_client.CsubClientOptions bucket string } @@ -41,9 +41,9 @@ var gcsCmd = &cobra.Command{ viper.GetString("blob-addr"), viper.GetString("gql-addr"), viper.GetString("csub-addr"), + viper.GetString(gcsCredentialsPathFlag), viper.GetBool("csub-tls"), viper.GetBool("csub-tls-skip-verify"), - viper.GetString(gcsCredentialsPathFlag), args) if err != nil { fmt.Printf("unable to validate flags: %v\n", err) @@ -66,7 +66,7 @@ var gcsCmd = &cobra.Command{ logger.Fatalf("creating client: %v", err) } - // Register collector by providing a new GCS Client and bucket name + // Register collector gcsCollector, err := gcs.NewGCSCollector(gcs.WithBucket(opts.bucket), gcs.WithClient(client)) if err != nil { logger.Fatalf("unable to create gcs client: %v", err) @@ -90,14 +90,23 @@ var gcsCmd = &cobra.Command{ }, } -func validateGCSFlags(pubSubAddr, blobAddr, gqlEndpoint string, csubAddr string, csubTls bool, csubTlsSkipVerify bool, credentialsPath string, args []string) (gcsOptions, error) { +func validateGCSFlags( + pubSubAddr, + blobAddr, + gqlEndpoint, + csubAddr, + credentialsPath string, + csubTls, + csubTlsSkipVerify bool, + args []string, +) (gcsOptions, error) { opts := gcsOptions{ pubSubAddr: pubSubAddr, blobAddr: blobAddr, graphqlEndpoint: gqlEndpoint, } - csubOpts, err := client.ValidateCsubClientFlags(csubAddr, csubTls, csubTlsSkipVerify) + csubOpts, err := csub_client.ValidateCsubClientFlags(csubAddr, csubTls, csubTlsSkipVerify) if err != nil { return opts, fmt.Errorf("unable to validate csub client flags: %w", err) } diff --git a/cmd/guaccollect/cmd/github.go b/cmd/guaccollect/cmd/github.go index 02af908c156..c790a19ef94 100644 --- a/cmd/guaccollect/cmd/github.go +++ b/cmd/guaccollect/cmd/github.go @@ -18,13 +18,14 @@ package cmd import ( "context" "fmt" - csubclient "github.com/guacsec/guac/pkg/collectsub/client" - "github.com/guacsec/guac/pkg/collectsub/datasource/csubsource" - "github.com/guacsec/guac/pkg/collectsub/datasource/inmemsource" "os" "strings" "time" + csubclient "github.com/guacsec/guac/pkg/collectsub/client" + "github.com/guacsec/guac/pkg/collectsub/datasource/csubsource" + "github.com/guacsec/guac/pkg/collectsub/datasource/inmemsource" + "github.com/guacsec/guac/pkg/cli" "github.com/guacsec/guac/internal/client/githubclient" @@ -153,7 +154,19 @@ you have access to read and write to the respective blob store.`, }, } -func validateGithubFlags(pubsubAddr, blobAddr, csubAddr, githubMode, sbomName, workflowFileName string, csubTls, csubTlsSkipVerify, useCsub, poll bool, args []string) (githubOptions, error) { +func validateGithubFlags( + pubsubAddr, + blobAddr, + csubAddr, + githubMode, + sbomName, + workflowFileName string, + csubTls, + csubTlsSkipVerify, + useCsub, + poll bool, + args []string, +) (githubOptions, error) { var opts githubOptions opts.pubsubAddr = pubsubAddr opts.blobAddr = blobAddr diff --git a/cmd/guaccollect/cmd/oci.go b/cmd/guaccollect/cmd/oci.go index 08768aee719..29e9be5ae3e 100644 --- a/cmd/guaccollect/cmd/oci.go +++ b/cmd/guaccollect/cmd/oci.go @@ -95,7 +95,16 @@ you have access to read and write to the respective blob store.`, }, } -func validateOCIFlags(pubsubAddr string, blobAddr string, csubAddr string, csubTls bool, csubTlsSkipVerify bool, useCsub bool, poll bool, args []string) (ociOptions, error) { +func validateOCIFlags( + pubsubAddr, + blobAddr, + csubAddr string, + csubTls, + csubTlsSkipVerify, + useCsub, + poll bool, + args []string, +) (ociOptions, error) { var opts ociOptions opts.pubsubAddr = pubsubAddr opts.blobAddr = blobAddr diff --git a/cmd/guaccollect/cmd/root.go b/cmd/guaccollect/cmd/root.go index 7f3741bd2a6..4720211dcdd 100644 --- a/cmd/guaccollect/cmd/root.go +++ b/cmd/guaccollect/cmd/root.go @@ -29,7 +29,14 @@ import ( func init() { cobra.OnInitialize(cli.InitConfig) - set, err := cli.BuildFlags([]string{"pubsub-addr", "blob-addr", "csub-addr", "use-csub", "service-poll", "enable-prometheus"}) + set, err := cli.BuildFlags([]string{ + "pubsub-addr", + "blob-addr", + "csub-addr", + "use-csub", + "service-poll", + "enable-prometheus", + }) if err != nil { fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err) os.Exit(1) diff --git a/cmd/guaccollect/cmd/s3.go b/cmd/guaccollect/cmd/s3.go index 10f61664fcf..b1b89da922a 100644 --- a/cmd/guaccollect/cmd/s3.go +++ b/cmd/guaccollect/cmd/s3.go @@ -3,6 +3,10 @@ package cmd import ( "context" "fmt" + "os" + "os/signal" + "syscall" + "github.com/guacsec/guac/pkg/cli" csub_client "github.com/guacsec/guac/pkg/collectsub/client" "github.com/guacsec/guac/pkg/handler/collector" @@ -10,9 +14,6 @@ import ( "github.com/guacsec/guac/pkg/logging" "github.com/spf13/cobra" "github.com/spf13/viper" - "os" - "os/signal" - "syscall" ) // s3Options flags for configuring the command @@ -65,8 +66,6 @@ $ guacone collect s3 --s3-url http://localhost:9000 --s3-bucket guac-test --poll viper.GetString("blob-addr"), viper.GetString("gql-addr"), viper.GetString("csub-addr"), - viper.GetBool("csub-tls"), - viper.GetBool("csub-tls-skip-verify"), viper.GetString("s3-url"), viper.GetString("s3-bucket"), viper.GetString("s3-region"), @@ -74,6 +73,8 @@ $ guacone collect s3 --s3-url http://localhost:9000 --s3-bucket guac-test --poll viper.GetString("s3-mp"), viper.GetString("s3-mp-endpoint"), viper.GetString("s3-queues"), + viper.GetBool("csub-tls"), + viper.GetBool("csub-tls-skip-verify"), viper.GetBool("poll"), ) if err != nil { @@ -112,7 +113,22 @@ $ guacone collect s3 --s3-url http://localhost:9000 --s3-bucket guac-test --poll }, } -func validateS3Opts(pubSubAddr, blobAddr, graphqlEndpoint, csubAddr string, csubTls, csubTlsSkipVerify bool, s3url, s3bucket, region, s3item, mp, mpEndpoint, queues string, poll bool) (s3Options, error) { +func validateS3Opts( + pubSubAddr, + blobAddr, + graphqlEndpoint, + csubAddr, + s3url, + s3bucket, + region, + s3item, + mp, + mpEndpoint, + queues string, + csubTls, + csubTlsSkipVerify, + poll bool, +) (s3Options, error) { var opts s3Options if poll { diff --git a/cmd/guacone/cmd/files.go b/cmd/guacone/cmd/files.go index 29ed727fce7..c9d643d2974 100644 --- a/cmd/guacone/cmd/files.go +++ b/cmd/guacone/cmd/files.go @@ -99,7 +99,7 @@ var filesCmd = &cobra.Command{ } // Register collector - fileCollector := file.NewFileCollector(ctx, opts.path, false, time.Second, false) + fileCollector := file.NewFileCollector(ctx, opts.path, false, time.Second) err = collector.RegisterDocumentCollector(fileCollector, file.FileCollector) if err != nil { logger.Fatalf("unable to register file collector: %v", err) diff --git a/internal/testing/cmd/pubsub_test/cmd/files.go b/internal/testing/cmd/pubsub_test/cmd/files.go index 7544f2d754d..ccea1dc8021 100644 --- a/internal/testing/cmd/pubsub_test/cmd/files.go +++ b/internal/testing/cmd/pubsub_test/cmd/files.go @@ -75,7 +75,7 @@ var filesCmd = &cobra.Command{ logger := logging.FromContext(ctx) // Register collector - fileCollector := file.NewFileCollector(ctx, opts.path, opts.poll, 30*time.Second, false) + fileCollector := file.NewFileCollector(ctx, opts.path, opts.poll, 30*time.Second) err = collector.RegisterDocumentCollector(fileCollector, file.FileCollector) if err != nil { logger.Errorf("unable to register file collector: %v", err) diff --git a/internal/testing/dochelper/dochelper.go b/internal/testing/dochelper/dochelper.go index 3187bac383f..ae4d2da6785 100644 --- a/internal/testing/dochelper/dochelper.go +++ b/internal/testing/dochelper/dochelper.go @@ -80,7 +80,7 @@ func DocTreeEqual(a, b processor.DocumentTree) bool { } } - return true + return reflect.DeepEqual(a.Document.SourceInformation, b.Document.SourceInformation) } // ConsistentJsonBytes makes sure that the blob byte comparison diff --git a/pkg/cli/store.go b/pkg/cli/store.go index c12a616b19a..5c45fd10dc8 100644 --- a/pkg/cli/store.go +++ b/pkg/cli/store.go @@ -129,9 +129,6 @@ func init() { set.String("github-sbom", "", "name of sbom file to look for in github release.") set.String("github-workflow-file", "", "name of workflow file to look for in github workflow. \nThis will be the name of the actual file, not the workflow name (i.e. ci.yaml).") - // Files collector options - set.Bool("use-blob-url", false, "use blob URL for origin instead of source URL (useful if the blob store is persistent and we want to store the blob source location)") - set.String("header-file", "", "a text file containing HTTP headers to send to the GQL server, in RFC 822 format") set.VisitAll(func(f *pflag.Flag) { diff --git a/pkg/events/events.go b/pkg/events/events.go index b8e613d3f64..12e06a7b97f 100644 --- a/pkg/events/events.go +++ b/pkg/events/events.go @@ -64,6 +64,11 @@ func GetKey(blob []byte) string { return fmt.Sprintf("sha256:%s", generatedHash) } +// GetDocRef returns the Document Reference of a blob; i.e. the blob store key for this blob. +func GetDocRef(blob []byte) string { + return GetKey(blob) +} + func getHash(data []byte) string { sha256sum := sha256.Sum256(data) return hex.EncodeToString(sha256sum[:]) diff --git a/pkg/handler/collector/collector_test.go b/pkg/handler/collector/collector_test.go index b57887832c0..180598dced1 100644 --- a/pkg/handler/collector/collector_test.go +++ b/pkg/handler/collector/collector_test.go @@ -20,12 +20,13 @@ import ( "context" "errors" "fmt" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" "reflect" "testing" "time" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" + uuid "github.com/gofrs/uuid" "github.com/guacsec/guac/internal/testing/dochelper" nats_test "github.com/guacsec/guac/internal/testing/nats" @@ -54,14 +55,15 @@ func TestCollect(t *testing.T) { want []*processor.Document }{{ name: "file collector file", - collector: file.NewFileCollector(ctx, "./testdata", false, time.Second, false), + collector: file.NewFileCollector(ctx, "./testdata", false, time.Second), want: []*processor.Document{{ Blob: []byte("hello\n"), Type: processor.DocumentUnknown, Format: processor.FormatUnknown, SourceInformation: processor.SourceInformation{ - Collector: string(file.FileCollector), - Source: "file:///testdata/hello", + Collector: string(file.FileCollector), + Source: "file:///testdata/hello", + DocumentRef: events.GetDocRef([]byte("hello\n")), }}, }, wantErr: false, diff --git a/pkg/handler/collector/deps_dev/deps_dev.go b/pkg/handler/collector/deps_dev/deps_dev.go index b5cf44a97d9..ebb09737552 100644 --- a/pkg/handler/collector/deps_dev/deps_dev.go +++ b/pkg/handler/collector/deps_dev/deps_dev.go @@ -27,6 +27,7 @@ import ( model "github.com/guacsec/guac/pkg/assembler/clients/generated" "github.com/guacsec/guac/pkg/assembler/helpers" "github.com/guacsec/guac/pkg/collectsub/datasource" + "github.com/guacsec/guac/pkg/events" "github.com/guacsec/guac/pkg/handler/processor" "github.com/guacsec/guac/pkg/logging" "github.com/guacsec/guac/pkg/metrics" @@ -81,7 +82,7 @@ type depsCollector struct { var registerOnce sync.Once -func NewDepsCollector(ctx context.Context, collectDataSource datasource.CollectSource, poll bool, retrieveDependencies bool, interval time.Duration) (*depsCollector, error) { +func NewDepsCollector(ctx context.Context, collectDataSource datasource.CollectSource, poll, retrieveDependencies bool, interval time.Duration) (*depsCollector, error) { ctx = metrics.WithMetrics(ctx, prometheusPrefix) // Get the system certificates. sysPool, err := x509.SystemCertPool() @@ -282,8 +283,9 @@ func (d *depsCollector) collectMetadata(ctx context.Context, docChannel chan<- * Type: processor.DocumentDepsDev, Format: processor.FormatJSON, SourceInformation: processor.SourceInformation{ - Collector: DepsCollector, - Source: DepsCollector, + Collector: DepsCollector, + Source: DepsCollector, + DocumentRef: events.GetDocRef(blob), }, } docChannel <- doc @@ -517,8 +519,9 @@ func (d *depsCollector) fetchDependencies(ctx context.Context, purl string, docC Type: processor.DocumentDepsDev, Format: processor.FormatJSON, SourceInformation: processor.SourceInformation{ - Collector: DepsCollector, - Source: DepsCollector, + Collector: DepsCollector, + Source: DepsCollector, + DocumentRef: events.GetDocRef(blob), }, } docChannel <- doc diff --git a/pkg/handler/collector/deps_dev/deps_dev_test.go b/pkg/handler/collector/deps_dev/deps_dev_test.go index 91cb1300a6e..fd05a6741e4 100644 --- a/pkg/handler/collector/deps_dev/deps_dev_test.go +++ b/pkg/handler/collector/deps_dev/deps_dev_test.go @@ -29,6 +29,7 @@ import ( "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/collectsub/datasource" "github.com/guacsec/guac/pkg/collectsub/datasource/inmemsource" + "github.com/guacsec/guac/pkg/events" "github.com/guacsec/guac/pkg/handler/collector" "github.com/guacsec/guac/pkg/handler/processor" ) @@ -262,6 +263,8 @@ func Test_depsCollector_RetrieveArtifacts(t *testing.T) { t.Errorf("Wanted %v elements, but got %v", len(tt.want), len(collectedDocs)) } for i := range collectedDocs { + tt.want[i].SourceInformation.DocumentRef = actualDocRef(collectedDocs[i].Blob) + collectedDocs[i].Blob, err = normalizeTimeStampAndScorecard(collectedDocs[i].Blob) if err != nil { t.Fatalf("unexpected error while normalizing: %v", err) @@ -381,6 +384,14 @@ func TestPerformanceDepsCollector(t *testing.T) { } } +// The blob that we input into the test is not the final blob that +// gets hashed to come up with the blob key; the final blob is +// different. So we run the hashing function on the final blob and +// then set it on our original want doc. +func actualDocRef(blob []byte) string { + return events.GetDocRef(blob) +} + // Scorecard and timestamp data constantly changes, causing CI to keep erroring every few days. // This normalizes the time and removes the scorecard compare func normalizeTimeStampAndScorecard(blob []byte) ([]byte, error) { diff --git a/pkg/handler/collector/file/file.go b/pkg/handler/collector/file/file.go index 13157d66342..56d55edf40c 100644 --- a/pkg/handler/collector/file/file.go +++ b/pkg/handler/collector/file/file.go @@ -36,15 +36,13 @@ type fileCollector struct { lastChecked time.Time poll bool interval time.Duration - useBlobURL bool } -func NewFileCollector(ctx context.Context, path string, poll bool, interval time.Duration, useBlobURL bool) *fileCollector { +func NewFileCollector(ctx context.Context, path string, poll bool, interval time.Duration) *fileCollector { return &fileCollector{ - path: path, - poll: poll, - interval: interval, - useBlobURL: useBlobURL, + path: path, + poll: poll, + interval: interval, } } @@ -90,13 +88,6 @@ func (f *fileCollector) RetrieveArtifacts(ctx context.Context, docChannel chan<- return fmt.Errorf("error reading file: %s, err: %w", path, err) } - var docRef string - if f.useBlobURL { - docRef = events.GetKey(blob) // this is the blob store path - } else { - docRef = "" - } - doc := &processor.Document{ Blob: blob, Type: processor.DocumentUnknown, @@ -104,7 +95,7 @@ func (f *fileCollector) RetrieveArtifacts(ctx context.Context, docChannel chan<- SourceInformation: processor.SourceInformation{ Collector: string(FileCollector), Source: fmt.Sprintf("file:///%s", path), - DocumentRef: docRef, + DocumentRef: events.GetDocRef(blob), }, } diff --git a/pkg/handler/collector/file/file_test.go b/pkg/handler/collector/file/file_test.go index e1ab7845616..f4e5ae31c31 100644 --- a/pkg/handler/collector/file/file_test.go +++ b/pkg/handler/collector/file/file_test.go @@ -22,6 +22,7 @@ import ( "testing" "time" + "github.com/guacsec/guac/pkg/events" "github.com/guacsec/guac/pkg/handler/collector" "github.com/guacsec/guac/pkg/handler/processor" ) @@ -32,7 +33,6 @@ func Test_fileCollector_RetrieveArtifacts(t *testing.T) { lastChecked time.Time poll bool interval time.Duration - useBlobURL bool } tests := []struct { name string @@ -57,25 +57,6 @@ func Test_fileCollector_RetrieveArtifacts(t *testing.T) { poll: false, interval: 0, }, - want: []*processor.Document{{ - Blob: []byte("hello\n"), - Type: processor.DocumentUnknown, - Format: processor.FormatUnknown, - SourceInformation: processor.SourceInformation{ - Collector: string(FileCollector), - Source: "file:///testdata/hello", - }}, - }, - wantErr: false, - }, { - name: "found file with useBlobURL", - fields: fields{ - path: "./testdata", - lastChecked: time.Date(2009, 11, 17, 20, 34, 58, 651387237, time.UTC), - poll: false, - interval: 0, - useBlobURL: true, - }, want: []*processor.Document{{ Blob: []byte("hello\n"), Type: processor.DocumentUnknown, @@ -83,7 +64,7 @@ func Test_fileCollector_RetrieveArtifacts(t *testing.T) { SourceInformation: processor.SourceInformation{ Collector: string(FileCollector), Source: "file:///testdata/hello", - DocumentRef: "sha256:5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03", + DocumentRef: events.GetDocRef([]byte("hello\n")), }}, }, wantErr: false, @@ -100,8 +81,9 @@ func Test_fileCollector_RetrieveArtifacts(t *testing.T) { Type: processor.DocumentUnknown, Format: processor.FormatUnknown, SourceInformation: processor.SourceInformation{ - Collector: string(FileCollector), - Source: "file:///testdata/hello", + Collector: string(FileCollector), + Source: "file:///testdata/hello", + DocumentRef: events.GetDocRef([]byte("hello\n")), }}, }, wantErr: true, @@ -113,7 +95,6 @@ func Test_fileCollector_RetrieveArtifacts(t *testing.T) { lastChecked: tt.fields.lastChecked, poll: tt.fields.poll, interval: tt.fields.interval, - useBlobURL: tt.fields.useBlobURL, } // NOTE: Below is one of the simplest ways to validate the context getting canceled() // This is still brittle if a test for some reason takes longer than a second. diff --git a/pkg/handler/collector/gcs/gcs.go b/pkg/handler/collector/gcs/gcs.go index 48c848969f3..99f51bad8e9 100644 --- a/pkg/handler/collector/gcs/gcs.go +++ b/pkg/handler/collector/gcs/gcs.go @@ -25,6 +25,7 @@ import ( "cloud.google.com/go/storage" "google.golang.org/api/iterator" + "github.com/guacsec/guac/pkg/events" "github.com/guacsec/guac/pkg/handler/processor" "github.com/guacsec/guac/pkg/logging" ) @@ -182,8 +183,9 @@ func (g *gcs) getArtifacts(ctx context.Context, docChannel chan<- *processor.Doc Type: processor.DocumentUnknown, Format: processor.FormatUnknown, SourceInformation: processor.SourceInformation{ - Collector: string(CollectorGCS), - Source: g.bucket + "/" + attrs.Name, + Collector: string(CollectorGCS), + Source: g.bucket + "/" + attrs.Name, + DocumentRef: events.GetDocRef(payload), }, } docChannel <- doc diff --git a/pkg/handler/collector/gcs/gcs_test.go b/pkg/handler/collector/gcs/gcs_test.go index bef9ae46698..52d6d69dcfd 100644 --- a/pkg/handler/collector/gcs/gcs_test.go +++ b/pkg/handler/collector/gcs/gcs_test.go @@ -24,6 +24,7 @@ import ( "cloud.google.com/go/storage" "github.com/fsouza/fake-gcs-server/fakestorage" + "github.com/guacsec/guac/pkg/events" "github.com/guacsec/guac/pkg/handler/collector" "github.com/guacsec/guac/pkg/handler/processor" ) @@ -31,6 +32,7 @@ import ( func TestGCS_RetrieveArtifacts(t *testing.T) { const bucketName = "some-bucket" ctx := context.Background() + blob := []byte("inside the file") server := fakestorage.NewServer([]fakestorage.Object{ { ObjectAttrs: fakestorage.ObjectAttrs{ @@ -38,19 +40,20 @@ func TestGCS_RetrieveArtifacts(t *testing.T) { Name: "some/object/file.txt", Updated: time.Date(2009, 11, 17, 20, 34, 58, 651387237, time.UTC), }, - Content: []byte("inside the file"), + Content: blob, }, }) defer server.Stop() client := server.Client() var doc *processor.Document = &processor.Document{ - Blob: []byte("inside the file"), + Blob: blob, Type: processor.DocumentUnknown, Format: processor.FormatUnknown, SourceInformation: processor.SourceInformation{ - Collector: string(CollectorGCS), - Source: bucketName + "/some/object/file.txt", + Collector: string(CollectorGCS), + Source: bucketName + "/some/object/file.txt", + DocumentRef: events.GetDocRef(blob), }, } diff --git a/pkg/handler/collector/git/git.go b/pkg/handler/collector/git/git.go index f195220e0ad..60ad14f04b9 100644 --- a/pkg/handler/collector/git/git.go +++ b/pkg/handler/collector/git/git.go @@ -47,7 +47,7 @@ type gitDocumentCollector struct { } func NewGitDocumentCollector(ctx context.Context, url string, dir string, poll bool, interval time.Duration) *gitDocumentCollector { - fileCollector := file.NewFileCollector(ctx, dir, false, time.Second, false) + fileCollector := file.NewFileCollector(ctx, dir, false, time.Second) return &gitDocumentCollector{ url: url, diff --git a/pkg/handler/collector/github/READMD.md b/pkg/handler/collector/github/README.md similarity index 100% rename from pkg/handler/collector/github/READMD.md rename to pkg/handler/collector/github/README.md diff --git a/pkg/handler/collector/github/github.go b/pkg/handler/collector/github/github.go index a1cdbdb4388..872a8262a19 100644 --- a/pkg/handler/collector/github/github.go +++ b/pkg/handler/collector/github/github.go @@ -26,6 +26,7 @@ import ( "github.com/guacsec/guac/internal/client/githubclient" "github.com/guacsec/guac/pkg/assembler/helpers" "github.com/guacsec/guac/pkg/collectsub/datasource" + "github.com/guacsec/guac/pkg/events" "github.com/guacsec/guac/pkg/handler/processor" "github.com/guacsec/guac/pkg/logging" ) @@ -286,8 +287,9 @@ func (g *githubCollector) collectAssetsForRelease(ctx context.Context, release c Type: processor.DocumentUnknown, Format: processor.FormatUnknown, SourceInformation: processor.SourceInformation{ - Collector: GithubCollector, - Source: asset.URL, + Collector: GithubCollector, + Source: asset.URL, + DocumentRef: events.GetDocRef(content.Bytes), }, } docChannel <- doc @@ -336,8 +338,9 @@ func (g *githubCollector) fetchWorkflowRunArtifacts(ctx context.Context, docChan Type: processor.DocumentUnknown, Format: processor.FormatUnknown, SourceInformation: processor.SourceInformation{ - Collector: GithubCollector, - Source: artifact.Name, + Collector: GithubCollector, + Source: artifact.Name, + DocumentRef: events.GetDocRef(artifact.Bytes), }, } diff --git a/pkg/handler/collector/github/github_test.go b/pkg/handler/collector/github/github_test.go index b62033b8719..ee3a8f459ca 100644 --- a/pkg/handler/collector/github/github_test.go +++ b/pkg/handler/collector/github/github_test.go @@ -145,14 +145,17 @@ func (m *MockGithubClient) GetReleaseAsset(asset client.ReleaseAsset) (*client.R return &rac, nil } +// TODO: implement this stub. func (m *MockGithubClient) GetWorkflow(ctx context.Context, owner string, repo string, githubWorkflowName string) ([]*client.Workflow, error) { return nil, nil } +// TODO: implement this stub. func (m *MockGithubClient) GetLatestWorkflowRun(ctx context.Context, owner, repo string, workflowId int64) (*client.WorkflowRun, error) { return nil, nil } +// TODO: implement this stub. func (m *MockGithubClient) GetWorkflowRunArtifacts(ctx context.Context, owner, repo, githubSBOMName string, runID int64) ([]*client.WorkflowArtifactContent, error) { return nil, nil } @@ -282,6 +285,9 @@ func Test_githubCollector_RetrieveArtifacts(t *testing.T) { mockClient := &MockGithubClient{} mockData := mockDataSource() + // TODO: Currently, len(collectedDocs) == 0. Fix this, and implement a + // more robust doc comparison, like assert from github.com/stretchr/testify + type fields struct { poll bool interval time.Duration diff --git a/pkg/handler/collector/oci/oci.go b/pkg/handler/collector/oci/oci.go index dfcc454558e..e9de998d97c 100644 --- a/pkg/handler/collector/oci/oci.go +++ b/pkg/handler/collector/oci/oci.go @@ -24,6 +24,7 @@ import ( "time" "github.com/guacsec/guac/pkg/collectsub/datasource" + "github.com/guacsec/guac/pkg/events" "github.com/guacsec/guac/pkg/handler/processor" "github.com/guacsec/guac/pkg/logging" "github.com/guacsec/guac/pkg/version" @@ -398,7 +399,13 @@ func (o *ociCollector) fetchReferrerArtifacts(ctx context.Context, repo string, // It takes a context.Context, a *regclient.RegClient, an artifact string, an artifactType string, and a docChannel chan<- *processor.Document as input. // Note that we are not concurrently fetching the layers since we will usually have 1 layer per artifact. // It returns an error if there was an issue fetching the artifact blobs. -func fetchOCIArtifactBlobs(ctx context.Context, rc *regclient.RegClient, artifact string, artifactType string, docChannel chan<- *processor.Document) error { +func fetchOCIArtifactBlobs( + ctx context.Context, + rc *regclient.RegClient, + artifact, + artifactType string, + docChannel chan<- *processor.Document, +) error { logger := logging.FromContext(ctx) r, err := ref.New(artifact) if err != nil { @@ -455,8 +462,9 @@ func fetchOCIArtifactBlobs(ctx context.Context, rc *regclient.RegClient, artifac Type: docType, Format: docFormat, SourceInformation: processor.SourceInformation{ - Collector: string(OCICollector), - Source: artifact, + Collector: string(OCICollector), + Source: artifact, + DocumentRef: events.GetDocRef(btr1), }, } docChannel <- doc diff --git a/pkg/handler/collector/oci/oci_test.go b/pkg/handler/collector/oci/oci_test.go index b3a531d9bbc..6e4e62ca678 100644 --- a/pkg/handler/collector/oci/oci_test.go +++ b/pkg/handler/collector/oci/oci_test.go @@ -25,6 +25,7 @@ import ( "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/collectsub/datasource" "github.com/guacsec/guac/pkg/collectsub/datasource/inmemsource" + "github.com/guacsec/guac/pkg/events" "github.com/guacsec/guac/pkg/handler/collector" "github.com/guacsec/guac/pkg/handler/processor" "github.com/pkg/errors" @@ -389,8 +390,11 @@ func Test_ociCollector_RetrieveArtifacts(t *testing.T) { for i := range tt.want { collectedDoc := findDocumentBySource(collectedDocs, tt.want[i].SourceInformation.Source) if collectedDoc == nil { - t.Errorf("g.RetrieveArtifacts() = %v, want %v", nil, tt.want[i]) + t.Fatalf("g.RetrieveArtifacts() = %v, want %v", nil, tt.want[i]) } + + tt.want[i].SourceInformation.DocumentRef = actualDocRef(collectedDoc.Blob) + result := dochelper.DocTreeEqual(dochelper.DocNode(collectedDoc), dochelper.DocNode(tt.want[i])) if !result { t.Errorf("g.RetrieveArtifacts() = %v, want %v", string(collectedDocs[i].Blob), string(tt.want[i].Blob)) @@ -419,6 +423,14 @@ func findDocumentBySource(docs []*processor.Document, source string) *processor. return nil } +// The blob that we input into the test is not the final blob that +// gets hashed to come up with the blob key; the final blob is +// different. So we run the hashing function on the final blob and +// then set it on our original want doc. +func actualDocRef(blob []byte) string { + return events.GetDocRef(blob) +} + func toDataSource(ociValues []string) datasource.CollectSource { values := []datasource.Source{} for _, v := range ociValues { diff --git a/pkg/handler/collector/s3/s3.go b/pkg/handler/collector/s3/s3.go index 03eb4fdd8cd..85c922c7c8d 100644 --- a/pkg/handler/collector/s3/s3.go +++ b/pkg/handler/collector/s3/s3.go @@ -21,6 +21,7 @@ import ( "strings" "sync" + "github.com/guacsec/guac/pkg/events" "github.com/guacsec/guac/pkg/handler/collector/s3/bucket" "github.com/guacsec/guac/pkg/handler/collector/s3/messaging" "github.com/guacsec/guac/pkg/handler/processor" @@ -89,8 +90,9 @@ func retrieve(s S3Collector, ctx context.Context, docChannel chan<- *processor.D Format: processor.FormatUnknown, Encoding: bucket.ExtractEncoding(enc, item), SourceInformation: processor.SourceInformation{ - Collector: S3CollectorType, - Source: "S3", + Collector: S3CollectorType, + Source: item, + DocumentRef: events.GetDocRef(blob), }, } docChannel <- doc @@ -124,8 +126,9 @@ func retrieve(s S3Collector, ctx context.Context, docChannel chan<- *processor.D Format: processor.FormatUnknown, Encoding: bucket.ExtractEncoding(enc, item), SourceInformation: processor.SourceInformation{ - Collector: S3CollectorType, - Source: "S3", + Collector: S3CollectorType, + Source: item, + DocumentRef: events.GetDocRef(blob), }, } docChannel <- doc @@ -214,8 +217,9 @@ func retrieveWithPoll(s S3Collector, ctx context.Context, docChannel chan<- *pro Format: processor.FormatUnknown, Encoding: bucket.ExtractEncoding(enc, item), SourceInformation: processor.SourceInformation{ - Collector: S3CollectorType, - Source: "S3", + Collector: S3CollectorType, + Source: item, + DocumentRef: events.GetDocRef(blob), }, } select { @@ -240,9 +244,6 @@ func getMessageProvider(s S3Collector, queue string) (messaging.MessageProvider, mpBuilder = s.config.MpBuilder } else { mpBuilder = messaging.GetDefaultMessageProviderBuilder() - if err != nil { - return nil, fmt.Errorf("error getting message provider: %w", err) - } } mp, err := mpBuilder.GetMessageProvider(messaging.MessageProviderConfig{ diff --git a/pkg/handler/collector/s3/s3_test.go b/pkg/handler/collector/s3/s3_test.go index 3a90799e6d6..5f730415d77 100644 --- a/pkg/handler/collector/s3/s3_test.go +++ b/pkg/handler/collector/s3/s3_test.go @@ -23,6 +23,7 @@ import ( "testing" "time" + "github.com/guacsec/guac/pkg/events" "github.com/guacsec/guac/pkg/handler/collector" "github.com/guacsec/guac/pkg/handler/collector/s3/bucket" "github.com/guacsec/guac/pkg/handler/collector/s3/messaging" @@ -105,8 +106,9 @@ func (td *TestBucketBuilder) GetDownloader(url string, region string) bucket.Buc func TestS3Collector(t *testing.T) { ctx := context.Background() - testNoPolling(t, ctx) - testQueuesSplitPolling(t, ctx) + + t.Run("no polling", func(t *testing.T) { testNoPolling(t, ctx) }) + t.Run("queues split polling", func(t *testing.T) { testQueuesSplitPolling(t, ctx) }) } func testQueuesSplitPolling(t *testing.T, ctx context.Context) { @@ -165,6 +167,8 @@ func testQueuesSplitPolling(t *testing.T, ctx context.Context) { if doc.Encoding != "UNKNOWN" { t.Errorf("wrong encoding returned: %s", doc.Encoding) } + + assertSource(t, "test-message", doc) } } @@ -203,4 +207,22 @@ func testNoPolling(t *testing.T, ctx context.Context) { if s[0].Blob != nil && !bytes.Equal(s[0].Blob, []byte("{\"key\": \"value\"}")) { t.Errorf("wrong item returned") } + + assertSource(t, "no-poll-item", s[0]) +} + +func assertSource(t *testing.T, wantSource string, doc *processor.Document) { + wantDocRef := events.GetDocRef(doc.Blob) + if doc.SourceInformation.DocumentRef != wantDocRef { + t.Errorf("want DocumentRef = %s, got = %s", wantDocRef, doc.SourceInformation.DocumentRef) + } + + if doc.SourceInformation.Source != wantSource { + t.Errorf("want Source = %s, got = %s", wantSource, doc.SourceInformation.Source) + } + + const wantCollector string = "S3CollectorType" + if doc.SourceInformation.Collector != wantCollector { + t.Errorf("want Collector = %s, got = %s", wantCollector, doc.SourceInformation.Collector) + } } diff --git a/pkg/ingestor/parser/spdx/parse_spdx.go b/pkg/ingestor/parser/spdx/parse_spdx.go index fb2a96e9128..0577c79b332 100644 --- a/pkg/ingestor/parser/spdx/parse_spdx.go +++ b/pkg/ingestor/parser/spdx/parse_spdx.go @@ -24,7 +24,6 @@ import ( "time" "github.com/guacsec/guac/pkg/assembler" - "github.com/guacsec/guac/pkg/assembler/clients/generated" model "github.com/guacsec/guac/pkg/assembler/clients/generated" asmhelpers "github.com/guacsec/guac/pkg/assembler/helpers" "github.com/guacsec/guac/pkg/handler/processor" @@ -71,7 +70,7 @@ func (s *spdxParser) Parse(ctx context.Context, doc *processor.Document) error { } s.spdxDoc = spdxDoc if spdxDoc.CreationInfo == nil { - return fmt.Errorf("SPDC documentd missing required \"creationInfo\" section.") + return fmt.Errorf("SPDX document missing required \"creationInfo\" section") } time, err := time.Parse(time.RFC3339, spdxDoc.CreationInfo.Created) if err != nil { @@ -392,7 +391,7 @@ func (s *spdxParser) GetPredicates(ctx context.Context) *assembler.IngestPredica for i := range pkgInputSpecs { hasMetadata := assembler.HasMetadataIngest{ Pkg: pkgInputSpecs[i], - PkgMatchFlag: model.MatchFlags{Pkg: generated.PkgMatchTypeSpecificVersion}, + PkgMatchFlag: model.MatchFlags{Pkg: model.PkgMatchTypeSpecificVersion}, HasMetadata: metadataInputSpec, } preds.HasMetadata = append(preds.HasMetadata, hasMetadata) @@ -404,7 +403,7 @@ func (s *spdxParser) GetPredicates(ctx context.Context) *assembler.IngestPredica return preds } -func fixLicense(ctx context.Context, l *generated.LicenseInputSpec, ol []*spdx.OtherLicense) (string, string) { +func fixLicense(ctx context.Context, l *model.LicenseInputSpec, ol []*spdx.OtherLicense) (string, string) { logger := logging.FromContext(ctx) if !strings.HasPrefix(l.Name, "LicenseRef-") { return "", "" From c6aaf87fd8fcca0eaaab7aeaa4cd845ae1e727b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:35:43 +0000 Subject: [PATCH 04/17] Bump actions/checkout from 4.1.2 to 4.1.3 (#1861) Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.2 to 4.1.3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/9bb56186c3b09b4f86b1c65136769dd318469633...1d96c772d19495a3b5c517cd2bc0cb401ea0529f) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yaml | 12 ++++++------ .github/workflows/db-performance-test.yaml | 4 ++-- .github/workflows/nightly-release.yaml | 2 +- .github/workflows/postmerge.yaml | 2 +- .github/workflows/release.yaml | 6 +++--- .github/workflows/reusable-local-build.yaml | 2 +- .github/workflows/scorecard.yml | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a45ff513ef5..a8e9c2990c2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -36,7 +36,7 @@ jobs: name: CI for integration tests steps: - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v3 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # tag=v3 - name: setup-go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # tag=v3.2.1 with: @@ -65,7 +65,7 @@ jobs: name: CI for unit tests steps: - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v3 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # tag=v3 - name: setup-go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # tag=v3.2.1 with: @@ -84,7 +84,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v3 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # tag=v3 - name: setup-go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # tag=v3.2.1 with: @@ -100,7 +100,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v3 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # tag=v3 - name: setup-go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # tag=v5.0.0 with: @@ -119,7 +119,7 @@ jobs: name: E2E runs-on: ubuntu-latest steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 with: go-version: '~1.21' @@ -174,7 +174,7 @@ jobs: with: install-only: true - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v3 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # tag=v3 - name: setup-go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # tag=v3.2.1 with: diff --git a/.github/workflows/db-performance-test.yaml b/.github/workflows/db-performance-test.yaml index ec3dd123a3e..f09a8b61d1b 100644 --- a/.github/workflows/db-performance-test.yaml +++ b/.github/workflows/db-performance-test.yaml @@ -50,9 +50,9 @@ jobs: name: performance test for backends DBs steps: - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v3 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # tag=v3 - name: Checkout guac-data - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 with: repository: 'guacsec/guac-data' ref: 'main' diff --git a/.github/workflows/nightly-release.yaml b/.github/workflows/nightly-release.yaml index b2d219ad71b..7e4495d6c51 100644 --- a/.github/workflows/nightly-release.yaml +++ b/.github/workflows/nightly-release.yaml @@ -40,7 +40,7 @@ jobs: name: trigger nightly build steps: - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v3 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # tag=v3 - name: Get GitHub App token uses: actions/create-github-app-token@7bfa3a4717ef143a604ee0a99d859b8886a96d00 # v1.9.3 diff --git a/.github/workflows/postmerge.yaml b/.github/workflows/postmerge.yaml index 61b9390b545..34c9ca5eef0 100644 --- a/.github/workflows/postmerge.yaml +++ b/.github/workflows/postmerge.yaml @@ -26,7 +26,7 @@ jobs: name: CI for Integration Merge Test steps: - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v3 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # tag=v3 - name: setup-go uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # tag=v3.2.1 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 294b4b11683..4b5364d8f21 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -37,7 +37,7 @@ jobs: digest: ${{ steps.hash.outputs.digest }} steps: - name: Checkout - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 with: fetch-depth: 0 - name: Login to GitHub Container Registry @@ -108,7 +108,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/') steps: - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v3 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # tag=v3 - name: Login to GitHub Container Registry uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 with: @@ -161,7 +161,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/') steps: - name: Checkout code - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v3 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # tag=v3 - name: Create and publish compose tarball env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/reusable-local-build.yaml b/.github/workflows/reusable-local-build.yaml index 348f397635d..10feb3afb90 100644 --- a/.github/workflows/reusable-local-build.yaml +++ b/.github/workflows/reusable-local-build.yaml @@ -28,7 +28,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 with: repository: ${{ inputs.repository }} ref: ${{ inputs.ref }} diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index a9430630966..dce0fa23506 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -32,7 +32,7 @@ jobs: steps: - name: "Checkout code" - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 with: persist-credentials: false From 1ea2819b84430c7c835ff60f7ad67e165695520f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:35:51 +0000 Subject: [PATCH 05/17] Bump github.com/spdx/tools-golang from 0.5.3 to 0.5.4 (#1860) Bumps [github.com/spdx/tools-golang](https://github.com/spdx/tools-golang) from 0.5.3 to 0.5.4. - [Release notes](https://github.com/spdx/tools-golang/releases) - [Changelog](https://github.com/spdx/tools-golang/blob/main/RELEASE-NOTES.md) - [Commits](https://github.com/spdx/tools-golang/compare/v0.5.3...v0.5.4) --- updated-dependencies: - dependency-name: github.com/spdx/tools-golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index c59706a5d13..23796ee1d72 100644 --- a/go.mod +++ b/go.mod @@ -317,7 +317,7 @@ require ( github.com/segmentio/kafka-go v0.4.47 github.com/segmentio/ksuid v1.0.4 github.com/sigstore/sigstore v1.8.2 - github.com/spdx/tools-golang v0.5.3 + github.com/spdx/tools-golang v0.5.4 github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.9.0 github.com/tikv/client-go/v2 v2.0.8-0.20231115083414-7c96dfd783fb diff --git a/go.sum b/go.sum index af2fc826420..b027db0efe8 100644 --- a/go.sum +++ b/go.sum @@ -706,8 +706,8 @@ github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIK github.com/spdx/gordf v0.0.0-20201111095634-7098f93598fb/go.mod h1:uKWaldnbMnjsSAXRurWqqrdyZen1R7kxl8TkmWk2OyM= github.com/spdx/gordf v0.0.0-20221230105357-b735bd5aac89 h1:dArkMwZ7Mf2JiU8OfdmqIv8QaHT4oyifLIe1UhsF1SY= github.com/spdx/gordf v0.0.0-20221230105357-b735bd5aac89/go.mod h1:uKWaldnbMnjsSAXRurWqqrdyZen1R7kxl8TkmWk2OyM= -github.com/spdx/tools-golang v0.5.3 h1:ialnHeEYUC4+hkm5vJm4qz2x+oEJbS0mAMFrNXdQraY= -github.com/spdx/tools-golang v0.5.3/go.mod h1:/ETOahiAo96Ob0/RAIBmFZw6XN0yTnyr/uFZm2NTMhI= +github.com/spdx/tools-golang v0.5.4 h1:fRW4iz16P1ZCUtWStFqS6YiMgnK7WgfTFU/lrsYlvqY= +github.com/spdx/tools-golang v0.5.4/go.mod h1:MVIsXx8ZZzaRWNQpUDhC4Dud34edUYJYecciXgrw5vE= github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= @@ -1097,4 +1097,4 @@ nhooyr.io/websocket v1.8.10 h1:mv4p+MnGrLDcPlBoWsvPP7XCzTYMXP9F9eIGoKbgx7Q= nhooyr.io/websocket v1.8.10/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= sigs.k8s.io/release-utils v0.7.3 h1:6pS8x6c5RmdUgR9qcg1LO6hjUzuE4Yo9TGZ3DemrZdM= sigs.k8s.io/release-utils v0.7.3/go.mod h1:n0mVez/1PZYZaZUTJmxewxH3RJ/Lf7JUDh7TG1CASOE= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= From a2c12063869668b8cd539ced61583d492e3a7b52 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:36:17 +0000 Subject: [PATCH 06/17] Bump google.golang.org/api from 0.172.0 to 0.176.0 (#1858) Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.172.0 to 0.176.0. - [Release notes](https://github.com/googleapis/google-api-go-client/releases) - [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md) - [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.172.0...v0.176.0) --- updated-dependencies: - dependency-name: google.golang.org/api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 22 +++++++++++----------- go.sum | 44 ++++++++++++++++++++++---------------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/go.mod b/go.mod index 23796ee1d72..e8cc471ecce 100644 --- a/go.mod +++ b/go.mod @@ -12,12 +12,11 @@ require ( github.com/secure-systems-lab/go-securesystemslib v0.8.0 github.com/spf13/cobra v1.8.0 go.uber.org/zap v1.27.0 - google.golang.org/api v0.172.0 + google.golang.org/api v0.176.0 ) require ( cloud.google.com/go v0.112.1 // indirect - cloud.google.com/go/compute v1.25.0 // indirect cloud.google.com/go/iam v1.1.7 // indirect cloud.google.com/go/pubsub v1.37.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect @@ -35,22 +34,23 @@ require ( github.com/spf13/pflag v1.0.5 go.opencensus.io v0.24.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/oauth2 v0.18.0 + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/oauth2 v0.19.0 golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.18.0 // indirect + golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect - google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 // indirect - google.golang.org/grpc v1.62.1 + google.golang.org/grpc v1.63.2 google.golang.org/protobuf v1.33.0 ) require ( ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect + cloud.google.com/go/auth v0.2.2 // indirect + cloud.google.com/go/auth/oauth2adapt v0.2.1 // indirect + cloud.google.com/go/compute/metadata v0.3.0 // indirect dario.cat/mergo v1.0.0 // indirect github.com/Azure/azure-amqp-common-go/v3 v3.2.3 // indirect github.com/Azure/azure-sdk-for-go/sdk/azcore v1.10.0 // indirect @@ -250,12 +250,12 @@ require ( go.opentelemetry.io/otel/trace v1.24.0 // indirect go.uber.org/atomic v1.11.0 // indirect golang.org/x/mod v0.16.0 // indirect - golang.org/x/term v0.18.0 // indirect + golang.org/x/term v0.19.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.19.0 // indirect golang.org/x/vuln v1.0.4 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240314234333-6e1732d8331c // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/go.sum b/go.sum index b027db0efe8..ecc93948dd7 100644 --- a/go.sum +++ b/go.sum @@ -3,10 +3,12 @@ ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43/go.mod h1:uj3pm+hUTVN/X5yfd cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.112.1 h1:uJSeirPke5UNZHIb4SxfZklVSiWWVqW4oXlETwZziwM= cloud.google.com/go v0.112.1/go.mod h1:+Vbu+Y1UU+I1rjmzeMOb/8RfkKJK2Gyxi1X6jJCZLo4= -cloud.google.com/go/compute v1.25.0 h1:H1/4SqSUhjPFE7L5ddzHOfY2bCAvjwNRZPNl6Ni5oYU= -cloud.google.com/go/compute v1.25.0/go.mod h1:GR7F0ZPZH8EhChlMo9FkLd7eUTwEymjqQagxzilIxIE= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= +cloud.google.com/go/auth v0.2.2 h1:gmxNJs4YZYcw6YvKRtVBaF2fyUE6UrWPyzU8jHvYfmI= +cloud.google.com/go/auth v0.2.2/go.mod h1:2bDNJWtWziDT3Pu1URxHHbkHE/BbOCuyUiKIGcNvafo= +cloud.google.com/go/auth/oauth2adapt v0.2.1 h1:VSPmMmUlT8CkIZ2PzD9AlLN+R3+D1clXMWHHa6vG/Ag= +cloud.google.com/go/auth/oauth2adapt v0.2.1/go.mod h1:tOdK/k+D2e4GEwfBRA48dKNQiDsqIXxLh7VU319eV0g= +cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= +cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= cloud.google.com/go/iam v1.1.7 h1:z4VHOhwKLF/+UYXAJDFwGtNF0b6gjsW1Pk9Ml0U/IoM= cloud.google.com/go/iam v1.1.7/go.mod h1:J4PMPg8TtyurAUvSmPj8FF3EDgY1SPRZxcUGrn7WXGA= cloud.google.com/go/kms v1.15.7 h1:7caV9K3yIxvlQPAcaFffhlT7d1qpxjB1wHBtjWa13SM= @@ -860,8 +862,8 @@ golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f h1:3CW0unweImhOzd5FmYuRsD4Y4oQFKZIjAnKbjV4WIrw= golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= @@ -908,11 +910,11 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.18.0 h1:09qnuIAgzdx1XplqJvW6CQqMCtGZykZWcXzPMPUusvI= -golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= +golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg= +golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -964,8 +966,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= @@ -975,8 +977,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -1020,13 +1022,11 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= -google.golang.org/api v0.172.0 h1:/1OcMZGPmW1rX2LCu2CmGUD1KXK1+pfzxotxyRUCCdk= -google.golang.org/api v0.172.0/go.mod h1:+fJZq6QXWfa9pXhnIzsjx4yI22d4aI9ZpLb58gvXjis= +google.golang.org/api v0.176.0 h1:dHj1/yv5Dm/eQTXiP9hNCRT3xzJHWXeNdRq29XbMxoE= +google.golang.org/api v0.176.0/go.mod h1:Rra+ltKu14pps/4xTycZfobMgLpbosoaaL7c+SEMrO8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= -google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= @@ -1035,16 +1035,16 @@ google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 h1:ImUcDPHjTrAqNhl google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7/go.mod h1:/3XmxOjePkvmKrHuBy4zNFw7IzxJXtAgdpXi8Ll990U= google.golang.org/genproto/googleapis/api v0.0.0-20240314234333-6e1732d8331c h1:kaI7oewGK5YnVwj+Y+EJBO/YN1ht8iTL9XkFHtVZLsc= google.golang.org/genproto/googleapis/api v0.0.0-20240314234333-6e1732d8331c/go.mod h1:VQW3tUculP/D4B+xVCo+VgSq8As6wA9ZjHl//pmk+6s= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be h1:LG9vZxsWGOmUKieR8wPAUR3u3MpnYFQZROPIMaXh7/A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From e8e4c30d67c4fc95ea0232deec5d00f13807fcce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 13:36:26 +0000 Subject: [PATCH 07/17] Bump google.golang.org/grpc from 1.62.1 to 1.63.2 (#1859) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.62.1 to 1.63.2. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.62.1...v1.63.2) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From eed71a50722b7214683bcbbf87d322271472c099 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 14:35:03 +0000 Subject: [PATCH 08/17] Bump github.com/99designs/gqlgen from 0.17.44 to 0.17.45 (#1857) * Bump github.com/99designs/gqlgen from 0.17.44 to 0.17.45 Bumps [github.com/99designs/gqlgen](https://github.com/99designs/gqlgen) from 0.17.44 to 0.17.45. - [Release notes](https://github.com/99designs/gqlgen/releases) - [Changelog](https://github.com/99designs/gqlgen/blob/master/CHANGELOG.md) - [Commits](https://github.com/99designs/gqlgen/compare/v0.17.44...v0.17.45) --- updated-dependencies: - dependency-name: github.com/99designs/gqlgen dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * update generated code Signed-off-by: pxp928 --------- Signed-off-by: dependabot[bot] Signed-off-by: pxp928 Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pxp928 --- go.mod | 2 +- go.sum | 12 ++++++------ .../graphql/resolvers/artifact.resolvers.go | 2 +- pkg/assembler/graphql/resolvers/builder.resolvers.go | 2 +- .../graphql/resolvers/certifyBad.resolvers.go | 2 +- .../graphql/resolvers/certifyGood.resolvers.go | 2 +- .../graphql/resolvers/certifyLegal.resolvers.go | 2 +- .../graphql/resolvers/certifyScorecard.resolvers.go | 2 +- .../resolvers/certifyVEXStatement.resolvers.go | 2 +- .../graphql/resolvers/certifyVuln.resolvers.go | 2 +- pkg/assembler/graphql/resolvers/contact.resolvers.go | 2 +- pkg/assembler/graphql/resolvers/hasSBOM.resolvers.go | 2 +- pkg/assembler/graphql/resolvers/hasSLSA.resolvers.go | 2 +- .../graphql/resolvers/hasSourceAt.resolvers.go | 2 +- .../graphql/resolvers/hashEqual.resolvers.go | 2 +- .../graphql/resolvers/isDependency.resolvers.go | 2 +- .../graphql/resolvers/isOccurrence.resolvers.go | 2 +- pkg/assembler/graphql/resolvers/license.resolvers.go | 2 +- .../graphql/resolvers/metadata.resolvers.go | 2 +- pkg/assembler/graphql/resolvers/package.resolvers.go | 2 +- pkg/assembler/graphql/resolvers/path.resolvers.go | 2 +- .../graphql/resolvers/pkgEqual.resolvers.go | 2 +- pkg/assembler/graphql/resolvers/search.resolvers.go | 2 +- pkg/assembler/graphql/resolvers/source.resolvers.go | 2 +- .../graphql/resolvers/vulnEqual.resolvers.go | 2 +- .../graphql/resolvers/vulnMetadata.resolvers.go | 2 +- .../graphql/resolvers/vulnerability.resolvers.go | 2 +- 27 files changed, 32 insertions(+), 32 deletions(-) diff --git a/go.mod b/go.mod index e8cc471ecce..c3fe040a31c 100644 --- a/go.mod +++ b/go.mod @@ -270,7 +270,7 @@ require ( deps.dev/api/v3alpha v0.0.0-20240312000934-38ffc8dd1d92 entgo.io/contrib v0.4.5 entgo.io/ent v0.13.0 - github.com/99designs/gqlgen v0.17.44 + github.com/99designs/gqlgen v0.17.45 github.com/CycloneDX/cyclonedx-go v0.8.0 github.com/Khan/genqlient v0.7.0 github.com/Masterminds/semver v1.5.0 diff --git a/go.sum b/go.sum index ecc93948dd7..ebaed6cd16e 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,8 @@ entgo.io/contrib v0.4.5 h1:BFaOHwFLE8WZjVJadP0XHCIaxgcC1BAtUvAyw7M/GHk= entgo.io/contrib v0.4.5/go.mod h1:wpZyq2DJgthugFvDBlaqMXj9mV4/9ebyGEn7xlTVQqE= entgo.io/ent v0.13.0 h1:DclxWczaCpyiKn6ZWVcJjq1zIKtJ11iNKy+08lNYsJE= entgo.io/ent v0.13.0/go.mod h1:+oU8oGna69xy29O+g+NEz+/TM7yJDhQQGJfuOWq1pT8= -github.com/99designs/gqlgen v0.17.44 h1:OS2wLk/67Y+vXM75XHbwRnNYJcbuJd4OBL76RX3NQQA= -github.com/99designs/gqlgen v0.17.44/go.mod h1:UTCu3xpK2mLI5qcMNw+HKDiEL77it/1XtAjisC4sLwM= +github.com/99designs/gqlgen v0.17.45 h1:bH0AH67vIJo8JKNKPJP+pOPpQhZeuVRQLf53dKIpDik= +github.com/99designs/gqlgen v0.17.45/go.mod h1:Bas0XQ+Jiu/Xm5E33jC8sES3G+iC2esHBMXcq0fUPs0= github.com/Azure/azure-amqp-common-go/v3 v3.2.3 h1:uDF62mbd9bypXWi19V1bN5NZEO84JqgmI5G73ibAmrk= github.com/Azure/azure-amqp-common-go/v3 v3.2.3/go.mod h1:7rPmbSfszeovxGfc5fSAXE4ehlXQZHpMja2OtxC2Tas= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.10.0 h1:n1DH8TPV4qqPTje2RcUBYwtrTWlabVp4n46+74X2pn4= @@ -78,8 +78,8 @@ github.com/ProtonMail/gluon v0.17.0 h1:QfMRUcXd47MANHmoerj1ZHXsNzfW9gjsLmF+7Dim5 github.com/ProtonMail/gluon v0.17.0/go.mod h1:Og5/Dz1MiGpCJn51XujZwxiLG7WzvvjE5PRpZBQmAHo= github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= -github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM= -github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ= +github.com/PuerkitoBio/goquery v1.9.1 h1:mTL6XjbJTZdpfL+Gwl5U2h1l9yEkJjhmlTeV9VPW7UI= +github.com/PuerkitoBio/goquery v1.9.1/go.mod h1:cW1n6TmIMDoORQU5IU/P1T3tGFunOeXEpGP2WHRwkbY= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= @@ -94,8 +94,8 @@ github.com/anchore/go-struct-converter v0.0.0-20230627203149-c72ef8859ca9 h1:6CO github.com/anchore/go-struct-converter v0.0.0-20230627203149-c72ef8859ca9/go.mod h1:rYqSE9HbjzpHTI74vwPvae4ZVYZd1lue2ta6xHPdblA= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c= -github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA= +github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss= +github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= diff --git a/pkg/assembler/graphql/resolvers/artifact.resolvers.go b/pkg/assembler/graphql/resolvers/artifact.resolvers.go index 12ac81e3ef0..f19b633015a 100644 --- a/pkg/assembler/graphql/resolvers/artifact.resolvers.go +++ b/pkg/assembler/graphql/resolvers/artifact.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/builder.resolvers.go b/pkg/assembler/graphql/resolvers/builder.resolvers.go index f03eb0fc77c..d3da8657776 100644 --- a/pkg/assembler/graphql/resolvers/builder.resolvers.go +++ b/pkg/assembler/graphql/resolvers/builder.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/certifyBad.resolvers.go b/pkg/assembler/graphql/resolvers/certifyBad.resolvers.go index 05176e1fed0..860018a55d3 100644 --- a/pkg/assembler/graphql/resolvers/certifyBad.resolvers.go +++ b/pkg/assembler/graphql/resolvers/certifyBad.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/certifyGood.resolvers.go b/pkg/assembler/graphql/resolvers/certifyGood.resolvers.go index cf334b73a4f..93dc519cc6d 100644 --- a/pkg/assembler/graphql/resolvers/certifyGood.resolvers.go +++ b/pkg/assembler/graphql/resolvers/certifyGood.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/certifyLegal.resolvers.go b/pkg/assembler/graphql/resolvers/certifyLegal.resolvers.go index e0776a63b58..c60ed51cd6a 100644 --- a/pkg/assembler/graphql/resolvers/certifyLegal.resolvers.go +++ b/pkg/assembler/graphql/resolvers/certifyLegal.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/certifyScorecard.resolvers.go b/pkg/assembler/graphql/resolvers/certifyScorecard.resolvers.go index c75ab242117..13ca9c02e33 100644 --- a/pkg/assembler/graphql/resolvers/certifyScorecard.resolvers.go +++ b/pkg/assembler/graphql/resolvers/certifyScorecard.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers.go b/pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers.go index 6fd652f9b8c..9ac8808e32f 100644 --- a/pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers.go +++ b/pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/certifyVuln.resolvers.go b/pkg/assembler/graphql/resolvers/certifyVuln.resolvers.go index 57861b97a64..44a8c3fe576 100644 --- a/pkg/assembler/graphql/resolvers/certifyVuln.resolvers.go +++ b/pkg/assembler/graphql/resolvers/certifyVuln.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/contact.resolvers.go b/pkg/assembler/graphql/resolvers/contact.resolvers.go index 8cd84f78711..5ad0103143b 100644 --- a/pkg/assembler/graphql/resolvers/contact.resolvers.go +++ b/pkg/assembler/graphql/resolvers/contact.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/hasSBOM.resolvers.go b/pkg/assembler/graphql/resolvers/hasSBOM.resolvers.go index afac4ce52e0..6db0c7a5294 100644 --- a/pkg/assembler/graphql/resolvers/hasSBOM.resolvers.go +++ b/pkg/assembler/graphql/resolvers/hasSBOM.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/hasSLSA.resolvers.go b/pkg/assembler/graphql/resolvers/hasSLSA.resolvers.go index 91df822279f..2f43b98ebee 100644 --- a/pkg/assembler/graphql/resolvers/hasSLSA.resolvers.go +++ b/pkg/assembler/graphql/resolvers/hasSLSA.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/hasSourceAt.resolvers.go b/pkg/assembler/graphql/resolvers/hasSourceAt.resolvers.go index 89690f2997f..133e3f25fce 100644 --- a/pkg/assembler/graphql/resolvers/hasSourceAt.resolvers.go +++ b/pkg/assembler/graphql/resolvers/hasSourceAt.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/hashEqual.resolvers.go b/pkg/assembler/graphql/resolvers/hashEqual.resolvers.go index ec1c2f1659a..34ecec830b5 100644 --- a/pkg/assembler/graphql/resolvers/hashEqual.resolvers.go +++ b/pkg/assembler/graphql/resolvers/hashEqual.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/isDependency.resolvers.go b/pkg/assembler/graphql/resolvers/isDependency.resolvers.go index 502b5546988..cc0c3120633 100644 --- a/pkg/assembler/graphql/resolvers/isDependency.resolvers.go +++ b/pkg/assembler/graphql/resolvers/isDependency.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/isOccurrence.resolvers.go b/pkg/assembler/graphql/resolvers/isOccurrence.resolvers.go index 94e3c664459..0b65238cce1 100644 --- a/pkg/assembler/graphql/resolvers/isOccurrence.resolvers.go +++ b/pkg/assembler/graphql/resolvers/isOccurrence.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/license.resolvers.go b/pkg/assembler/graphql/resolvers/license.resolvers.go index f0f53594578..8093a7c6218 100644 --- a/pkg/assembler/graphql/resolvers/license.resolvers.go +++ b/pkg/assembler/graphql/resolvers/license.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/metadata.resolvers.go b/pkg/assembler/graphql/resolvers/metadata.resolvers.go index 4cda8caee0e..95a389396f6 100644 --- a/pkg/assembler/graphql/resolvers/metadata.resolvers.go +++ b/pkg/assembler/graphql/resolvers/metadata.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/package.resolvers.go b/pkg/assembler/graphql/resolvers/package.resolvers.go index 9aa57c1fa8e..b9745a9cd05 100644 --- a/pkg/assembler/graphql/resolvers/package.resolvers.go +++ b/pkg/assembler/graphql/resolvers/package.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/path.resolvers.go b/pkg/assembler/graphql/resolvers/path.resolvers.go index b847008018a..bd6d232238f 100644 --- a/pkg/assembler/graphql/resolvers/path.resolvers.go +++ b/pkg/assembler/graphql/resolvers/path.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/pkgEqual.resolvers.go b/pkg/assembler/graphql/resolvers/pkgEqual.resolvers.go index 96116ef6908..84230e19386 100644 --- a/pkg/assembler/graphql/resolvers/pkgEqual.resolvers.go +++ b/pkg/assembler/graphql/resolvers/pkgEqual.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/search.resolvers.go b/pkg/assembler/graphql/resolvers/search.resolvers.go index 52741cc469d..e7c2cff422b 100644 --- a/pkg/assembler/graphql/resolvers/search.resolvers.go +++ b/pkg/assembler/graphql/resolvers/search.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/source.resolvers.go b/pkg/assembler/graphql/resolvers/source.resolvers.go index 3cfaa7803be..6a74499962e 100644 --- a/pkg/assembler/graphql/resolvers/source.resolvers.go +++ b/pkg/assembler/graphql/resolvers/source.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/vulnEqual.resolvers.go b/pkg/assembler/graphql/resolvers/vulnEqual.resolvers.go index 8a188cd7316..d4350fa65a9 100644 --- a/pkg/assembler/graphql/resolvers/vulnEqual.resolvers.go +++ b/pkg/assembler/graphql/resolvers/vulnEqual.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/vulnMetadata.resolvers.go b/pkg/assembler/graphql/resolvers/vulnMetadata.resolvers.go index d48f2e97d0f..b18780a5b45 100644 --- a/pkg/assembler/graphql/resolvers/vulnMetadata.resolvers.go +++ b/pkg/assembler/graphql/resolvers/vulnMetadata.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" diff --git a/pkg/assembler/graphql/resolvers/vulnerability.resolvers.go b/pkg/assembler/graphql/resolvers/vulnerability.resolvers.go index 4a1cafda8c7..7003107ae94 100644 --- a/pkg/assembler/graphql/resolvers/vulnerability.resolvers.go +++ b/pkg/assembler/graphql/resolvers/vulnerability.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.44 +// Code generated by github.com/99designs/gqlgen version v0.17.45 import ( "context" From 5ff8e903085f3a10ce6cbfbde454757dde2c095c Mon Sep 17 00:00:00 2001 From: Parth Patel <88045217+pxp928@users.noreply.github.com> Date: Wed, 24 Apr 2024 03:45:40 -0400 Subject: [PATCH 09/17] [ENT] fix trie output for package, source and vulnerability (#1863) * fix trie output for package, source and vulnerability Signed-off-by: pxp928 * fix IDs for type and namespace. Fix neighbors query Signed-off-by: pxp928 * use guac-split-@@ to concatenate type and namespace for ID Signed-off-by: pxp928 --------- Signed-off-by: pxp928 --- pkg/assembler/backends/ent/backend/helpers.go | 5 + .../backends/ent/backend/neighbors.go | 10 +- pkg/assembler/backends/ent/backend/package.go | 47 +++++---- pkg/assembler/backends/ent/backend/search.go | 2 +- pkg/assembler/backends/ent/backend/source.go | 99 +++++++++++++++---- .../backends/ent/backend/transforms.go | 66 ++++++++++++- .../backends/ent/backend/vulnerability.go | 19 ++-- 7 files changed, 192 insertions(+), 56 deletions(-) diff --git a/pkg/assembler/backends/ent/backend/helpers.go b/pkg/assembler/backends/ent/backend/helpers.go index 514089076a6..61f55bfca00 100644 --- a/pkg/assembler/backends/ent/backend/helpers.go +++ b/pkg/assembler/backends/ent/backend/helpers.go @@ -25,6 +25,11 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +const ( + // guacIDSplit is used as a separator to concatenate the type and namespace to create an ID + guacIDSplit = "guac-split-@@" +) + type globalID struct { nodeType string id string diff --git a/pkg/assembler/backends/ent/backend/neighbors.go b/pkg/assembler/backends/ent/backend/neighbors.go index 81355a10196..a85e0eb6567 100644 --- a/pkg/assembler/backends/ent/backend/neighbors.go +++ b/pkg/assembler/backends/ent/backend/neighbors.go @@ -148,12 +148,12 @@ func (b *EntBackend) Neighbors(ctx context.Context, nodeID string, usingOnly []m return []model.Node{}, fmt.Errorf("failed to get pkgName neighbors with id: %s with error: %w", nodeID, err) } case pkgNamespaceString: - neighbors, err = b.packageNamespaceNeighbors(ctx, nodeID, processUsingOnly(usingOnly)) + neighbors, err = b.packageNamespaceNeighbors(ctx, foundGlobalID.id, processUsingOnly(usingOnly)) if err != nil { return []model.Node{}, fmt.Errorf("failed to get pkgNamespace neighbors with id: %s with error: %w", nodeID, err) } case pkgTypeString: - neighbors, err = b.packageTypeNeighbors(ctx, nodeID, processUsingOnly(usingOnly)) + neighbors, err = b.packageTypeNeighbors(ctx, foundGlobalID.id, processUsingOnly(usingOnly)) if err != nil { return []model.Node{}, fmt.Errorf("failed to get pkgType neighbors with id: %s with error: %w", nodeID, err) } @@ -163,12 +163,12 @@ func (b *EntBackend) Neighbors(ctx context.Context, nodeID string, usingOnly []m return []model.Node{}, fmt.Errorf("failed to get source name neighbors with id: %s with error: %w", nodeID, err) } case srcNamespaceString: - neighbors, err = b.srcNamespaceNeighbors(ctx, nodeID, processUsingOnly(usingOnly)) + neighbors, err = b.srcNamespaceNeighbors(ctx, foundGlobalID.id, processUsingOnly(usingOnly)) if err != nil { return []model.Node{}, fmt.Errorf("failed to get source namespace neighbors with id: %s with error: %w", nodeID, err) } case srcTypeString: - neighbors, err = b.srcTypeNeighbors(ctx, nodeID, processUsingOnly(usingOnly)) + neighbors, err = b.srcTypeNeighbors(ctx, foundGlobalID.id, processUsingOnly(usingOnly)) if err != nil { return []model.Node{}, fmt.Errorf("failed to get source type neighbors with id: %s with error: %w", nodeID, err) } @@ -178,7 +178,7 @@ func (b *EntBackend) Neighbors(ctx context.Context, nodeID string, usingOnly []m return []model.Node{}, fmt.Errorf("failed to get vulnID neighbors with id: %s with error: %w", nodeID, err) } case vulnTypeString: - neighbors, err = b.vulnTypeNeighbors(ctx, nodeID, processUsingOnly(usingOnly)) + neighbors, err = b.vulnTypeNeighbors(ctx, foundGlobalID.id, processUsingOnly(usingOnly)) if err != nil { return []model.Node{}, fmt.Errorf("failed to get vuln type neighbors with id: %s with error: %w", nodeID, err) } diff --git a/pkg/assembler/backends/ent/backend/package.go b/pkg/assembler/backends/ent/backend/package.go index 4dca758b4d2..5d27dc51659 100644 --- a/pkg/assembler/backends/ent/backend/package.go +++ b/pkg/assembler/backends/ent/backend/package.go @@ -22,6 +22,7 @@ import ( stdsql "database/sql" "fmt" "sort" + "strings" "entgo.io/ent/dialect/sql" "github.com/google/uuid" @@ -38,8 +39,8 @@ import ( ) const ( - pkgTypeString = "pkgType" - pkgNamespaceString = "pkgNamespace" + pkgTypeString = "package_types" + pkgNamespaceString = "package_namespaces" ) func (b *EntBackend) Packages(ctx context.Context, pkgSpec *model.PkgSpec) ([]*model.Package, error) { @@ -61,7 +62,7 @@ func (b *EntBackend) Packages(ctx context.Context, pkgSpec *model.PkgSpec) ([]*m pkgNames = append(pkgNames, backReferencePackageVersion(collectedPkgVersion)) } - return collect(pkgNames, toModelPackage), nil + return toModelPackageTrie(pkgNames), nil } func packageQueryPredicates(pkgSpec *model.PkgSpec) predicate.PackageVersion { @@ -138,6 +139,8 @@ func upsertBulkPackage(ctx context.Context, tx *ent.Tx, pkgInputs []*model.IDorP batches := chunk(pkgInputs, MaxBatchSize) pkgNameIDs := make([]string, 0) pkgVersionIDs := make([]string, 0) + pkgTypes := map[string]string{} + pkgNamespaces := map[string]string{} for _, pkgs := range batches { pkgNameCreates := make([]*ent.PackageNameCreate, len(pkgs)) @@ -153,6 +156,8 @@ func upsertBulkPackage(ctx context.Context, tx *ent.Tx, pkgInputs []*model.IDorP pkgVersionCreates[i] = generatePackageVersionCreate(tx, &pkgVersionID, &pkgNameID, pkgInput) pkgNameIDs = append(pkgNameIDs, pkgNameID.String()) + pkgTypes[pkgNameID.String()] = pkgInput.PackageInput.Type + pkgNamespaces[pkgNameID.String()] = strings.Join([]string{pkgInput.PackageInput.Type, stringOrEmpty(pkgInput.PackageInput.Namespace)}, guacIDSplit) pkgVersionIDs = append(pkgVersionIDs, pkgVersionID.String()) } @@ -182,8 +187,8 @@ func upsertBulkPackage(ctx context.Context, tx *ent.Tx, pkgInputs []*model.IDorP var collectedPkgIDs []model.PackageIDs for i := range pkgVersionIDs { collectedPkgIDs = append(collectedPkgIDs, model.PackageIDs{ - PackageTypeID: toGlobalID(pkgTypeString, pkgNameIDs[i]), - PackageNamespaceID: toGlobalID(pkgNamespaceString, pkgNameIDs[i]), + PackageTypeID: toGlobalID(pkgTypeString, pkgTypes[pkgNameIDs[i]]), + PackageNamespaceID: toGlobalID(pkgNamespaceString, pkgNamespaces[pkgNameIDs[i]]), PackageNameID: toGlobalID(ent.TypePackageName, pkgNameIDs[i]), PackageVersionID: toGlobalID(ent.TypePackageVersion, pkgVersionIDs[i])}) } @@ -227,8 +232,8 @@ func upsertPackage(ctx context.Context, tx *ent.Tx, pkg model.IDorPkgInput) (*mo } return &model.PackageIDs{ - PackageTypeID: toGlobalID(pkgTypeString, pkgNameID.String()), - PackageNamespaceID: toGlobalID(pkgNamespaceString, pkgNameID.String()), + PackageTypeID: toGlobalID(pkgTypeString, pkg.PackageInput.Type), + PackageNamespaceID: toGlobalID(pkgNamespaceString, strings.Join([]string{pkg.PackageInput.Type, stringOrEmpty(pkg.PackageInput.Namespace)}, guacIDSplit)), PackageNameID: toGlobalID(packagename.Table, pkgNameID.String()), PackageVersionID: toGlobalID(packageversion.Table, pkgVersionID.String())}, nil } @@ -401,7 +406,7 @@ func (b *EntBackend) packageTypeNeighbors(ctx context.Context, nodeID string, al if allowedEdges[model.EdgePackageTypePackageNamespace] { query := b.client.PackageName.Query(). Where([]predicate.PackageName{ - optionalPredicate(&nodeID, IDEQ), + optionalPredicate(&nodeID, packagename.TypeEQ), }...). Limit(MaxPageSize) @@ -412,11 +417,11 @@ func (b *EntBackend) packageTypeNeighbors(ctx context.Context, nodeID string, al for _, foundPkgName := range pkgNames { out = append(out, &model.Package{ - ID: toGlobalID(pkgTypeString, foundPkgName.ID.String()), + ID: toGlobalID(pkgTypeString, foundPkgName.Type), Type: foundPkgName.Type, Namespaces: []*model.PackageNamespace{ { - ID: toGlobalID(pkgNamespaceString, foundPkgName.ID.String()), + ID: toGlobalID(pkgNamespaceString, strings.Join([]string{foundPkgName.Type, foundPkgName.Namespace}, guacIDSplit)), Namespace: foundPkgName.Namespace, Names: []*model.PackageName{}, }, @@ -430,9 +435,15 @@ func (b *EntBackend) packageTypeNeighbors(ctx context.Context, nodeID string, al func (b *EntBackend) packageNamespaceNeighbors(ctx context.Context, nodeID string, allowedEdges edgeMap) ([]model.Node, error) { var out []model.Node + // split to find the type and namespace value + splitQueryValue := strings.Split(nodeID, guacIDSplit) + if len(splitQueryValue) != 2 { + return out, fmt.Errorf("invalid query for packageNamespaceNeighbors with ID %s", nodeID) + } query := b.client.PackageName.Query(). Where([]predicate.PackageName{ - optionalPredicate(&nodeID, IDEQ), + optionalPredicate(&splitQueryValue[0], packagename.TypeEQ), + optionalPredicate(&splitQueryValue[1], packagename.NamespaceEQ), }...). Limit(MaxPageSize) @@ -444,11 +455,11 @@ func (b *EntBackend) packageNamespaceNeighbors(ctx context.Context, nodeID strin for _, foundPkgName := range pkgNames { if allowedEdges[model.EdgePackageNamespacePackageName] { out = append(out, &model.Package{ - ID: toGlobalID(pkgTypeString, foundPkgName.ID.String()), + ID: toGlobalID(pkgTypeString, foundPkgName.Type), Type: foundPkgName.Type, Namespaces: []*model.PackageNamespace{ { - ID: toGlobalID(pkgNamespaceString, foundPkgName.ID.String()), + ID: toGlobalID(pkgNamespaceString, strings.Join([]string{foundPkgName.Type, foundPkgName.Namespace}, ":")), Namespace: foundPkgName.Namespace, Names: []*model.PackageName{{ ID: toGlobalID(packagename.Table, foundPkgName.ID.String()), @@ -461,7 +472,7 @@ func (b *EntBackend) packageNamespaceNeighbors(ctx context.Context, nodeID strin } if allowedEdges[model.EdgePackageNamespacePackageType] { out = append(out, &model.Package{ - ID: toGlobalID(pkgTypeString, foundPkgName.ID.String()), + ID: toGlobalID(pkgTypeString, foundPkgName.Type), Type: foundPkgName.Type, Namespaces: []*model.PackageNamespace{}, }) @@ -552,11 +563,11 @@ func (b *EntBackend) packageNameNeighbors(ctx context.Context, nodeID string, al for _, foundPkgName := range pkgNames { if allowedEdges[model.EdgePackageNamePackageNamespace] { out = append(out, &model.Package{ - ID: toGlobalID(pkgTypeString, foundPkgName.ID.String()), + ID: toGlobalID(pkgTypeString, foundPkgName.Type), Type: foundPkgName.Type, Namespaces: []*model.PackageNamespace{ { - ID: toGlobalID(pkgNamespaceString, foundPkgName.ID.String()), + ID: toGlobalID(pkgNamespaceString, strings.Join([]string{foundPkgName.Type, foundPkgName.Namespace}, guacIDSplit)), Namespace: foundPkgName.Namespace, Names: []*model.PackageName{}, }, @@ -692,11 +703,11 @@ func (b *EntBackend) packageVersionNeighbors(ctx context.Context, nodeID string, pkgNames = append(pkgNames, backReferencePackageVersion(foundPkgVersion)) for _, foundPkgName := range pkgNames { out = append(out, &model.Package{ - ID: toGlobalID(pkgTypeString, foundPkgName.ID.String()), + ID: toGlobalID(pkgTypeString, foundPkgName.Type), Type: foundPkgName.Type, Namespaces: []*model.PackageNamespace{ { - ID: toGlobalID(pkgNamespaceString, foundPkgName.ID.String()), + ID: toGlobalID(pkgNamespaceString, strings.Join([]string{foundPkgName.Type, foundPkgName.Namespace}, guacIDSplit)), Namespace: foundPkgName.Namespace, Names: []*model.PackageName{{ ID: toGlobalID(packagename.Table, foundPkgName.ID.String()), diff --git a/pkg/assembler/backends/ent/backend/search.go b/pkg/assembler/backends/ent/backend/search.go index 0105732894a..1983495aa89 100644 --- a/pkg/assembler/backends/ent/backend/search.go +++ b/pkg/assembler/backends/ent/backend/search.go @@ -80,7 +80,7 @@ func (b *EntBackend) FindSoftware(ctx context.Context, searchText string) ([]mod return nil, err } results = append(results, collect(sources, func(v *ent.SourceName) model.PackageSourceOrArtifact { - return toModelSourceName(v) + return toModelSource(v) })...) artifacts, err := b.client.Artifact.Query().Where( diff --git a/pkg/assembler/backends/ent/backend/source.go b/pkg/assembler/backends/ent/backend/source.go index 2a8c3bb1b2d..5ee5635bb94 100644 --- a/pkg/assembler/backends/ent/backend/source.go +++ b/pkg/assembler/backends/ent/backend/source.go @@ -19,6 +19,7 @@ import ( "context" stdsql "database/sql" "fmt" + "strings" "entgo.io/ent/dialect/sql" "github.com/google/uuid" @@ -35,8 +36,8 @@ import ( ) const ( - srcTypeString = "srcType" - srcNamespaceString = "srcNamespace" + srcTypeString = "source_types" + srcNamespaceString = "source_namespaces" ) func (b *EntBackend) HasSourceAt(ctx context.Context, filter *model.HasSourceAtSpec) ([]*model.HasSourceAt, error) { @@ -329,7 +330,7 @@ func (b *EntBackend) Sources(ctx context.Context, filter *model.SourceSpec) ([]* return nil, err } - return collect(records, toModelSourceName), nil + return toModelSourceTrie(records), nil } func (b *EntBackend) IngestSources(ctx context.Context, sources []*model.IDorSourceInput) ([]*model.SourceIDs, error) { @@ -369,6 +370,8 @@ func (b *EntBackend) IngestSource(ctx context.Context, source model.IDorSourceIn func upsertBulkSource(ctx context.Context, tx *ent.Tx, srcInputs []*model.IDorSourceInput) (*[]model.SourceIDs, error) { batches := chunk(srcInputs, MaxBatchSize) srcNameIDs := make([]string, 0) + srcTypes := map[string]string{} + srcNamespaces := map[string]string{} for _, srcs := range batches { srcNameCreates := make([]*ent.SourceNameCreate, len(srcs)) @@ -380,6 +383,8 @@ func upsertBulkSource(ctx context.Context, tx *ent.Tx, srcInputs []*model.IDorSo srcNameCreates[i] = generateSourceNameCreate(tx, &srcNameID, s) srcNameIDs = append(srcNameIDs, srcNameID.String()) + srcTypes[srcNameID.String()] = s.SourceInput.Type + srcNamespaces[srcNameID.String()] = strings.Join([]string{s.SourceInput.Type, s.SourceInput.Namespace}, guacIDSplit) } if err := tx.SourceName.CreateBulk(srcNameCreates...). @@ -401,8 +406,8 @@ func upsertBulkSource(ctx context.Context, tx *ent.Tx, srcInputs []*model.IDorSo var collectedSrcIDs []model.SourceIDs for i := range srcNameIDs { collectedSrcIDs = append(collectedSrcIDs, model.SourceIDs{ - SourceTypeID: toGlobalID(srcTypeString, srcNameIDs[i]), - SourceNamespaceID: toGlobalID(srcNamespaceString, srcNameIDs[i]), + SourceTypeID: toGlobalID(srcTypeString, srcTypes[srcNameIDs[i]]), + SourceNamespaceID: toGlobalID(srcNamespaceString, srcNamespaces[srcNameIDs[i]]), SourceNameID: toGlobalID(sourcename.Table, srcNameIDs[i])}) } @@ -443,8 +448,8 @@ func upsertSource(ctx context.Context, tx *ent.Tx, src model.IDorSourceInput) (* } return &model.SourceIDs{ - SourceTypeID: toGlobalID(srcTypeString, srcNameID.String()), - SourceNamespaceID: toGlobalID(srcNamespaceString, srcNameID.String()), + SourceTypeID: toGlobalID(srcTypeString, src.SourceInput.Type), + SourceNamespaceID: toGlobalID(srcNamespaceString, strings.Join([]string{src.SourceInput.Type, src.SourceInput.Namespace}, guacIDSplit)), SourceNameID: toGlobalID(sourcename.Table, srcNameID.String())}, nil } @@ -486,7 +491,7 @@ func toModelHasSourceAt(record *ent.HasSourceAt) *model.HasSourceAt { } return &model.HasSourceAt{ - Source: toModelSourceName(record.Edges.Source), + Source: toModelSource(record.Edges.Source), Package: pkg, ID: toGlobalID(hassourceat.Table, record.ID.String()), KnownSince: record.KnownSince, @@ -497,8 +502,54 @@ func toModelHasSourceAt(record *ent.HasSourceAt) *model.HasSourceAt { } } -func toModelSourceName(s *ent.SourceName) *model.Source { - return toModelSource(s) +func toModelSourceTrie(collectedSrcNames []*ent.SourceName) []*model.Source { + srcTypes := map[string]map[string][]*model.SourceName{} + + for _, srcName := range collectedSrcNames { + + namespaceString := srcName.Namespace + "," + toGlobalID(srcNamespaceString, strings.Join([]string{srcName.Type, srcName.Namespace}, guacIDSplit)) + typeString := srcName.Type + "," + toGlobalID(srcTypeString, srcName.Type) + + sourceName := &model.SourceName{ + ID: toGlobalID(sourcename.Table, srcName.ID.String()), + Name: srcName.Name, + } + if srcName.Tag != "" { + sourceName.Tag = &srcName.Tag + } + if srcName.Commit != "" { + sourceName.Commit = &srcName.Commit + } + if srcNamespaces, ok := srcTypes[typeString]; ok { + srcNamespaces[namespaceString] = append(srcNamespaces[namespaceString], sourceName) + } else { + srcNamespaces := map[string][]*model.SourceName{} + srcNamespaces[namespaceString] = append(srcNamespaces[namespaceString], sourceName) + srcTypes[typeString] = srcNamespaces + } + } + var sources []*model.Source + for srcType, namespaces := range srcTypes { + var sourceNamespaces []*model.SourceNamespace + for namespace, sourceNames := range namespaces { + namespaceValues := strings.Split(namespace, ",") + srcNamespace := &model.SourceNamespace{ + ID: namespaceValues[1], + Namespace: namespaceValues[0], + Names: sourceNames, + } + sourceNamespaces = append(sourceNamespaces, srcNamespace) + } + typeValues := strings.Split(srcType, ",") + source := &model.Source{ + ID: typeValues[1], + Type: typeValues[0], + Namespaces: sourceNamespaces, + } + sources = append(sources, source) + } + + return sources } func toModelSource(s *ent.SourceName) *model.Source { @@ -519,10 +570,10 @@ func toModelSource(s *ent.SourceName) *model.Source { } return &model.Source{ - ID: toGlobalID(srcTypeString, s.ID.String()), + ID: toGlobalID(srcTypeString, s.Type), Type: s.Type, Namespaces: []*model.SourceNamespace{{ - ID: toGlobalID(srcNamespaceString, s.ID.String()), + ID: toGlobalID(srcNamespaceString, strings.Join([]string{s.Type, s.Namespace}, guacIDSplit)), Namespace: s.Namespace, Names: []*model.SourceName{sourceName}, }}, @@ -537,7 +588,7 @@ func (b *EntBackend) srcTypeNeighbors(ctx context.Context, nodeID string, allowe var out []model.Node if allowedEdges[model.EdgeSourceTypeSourceNamespace] { query := b.client.SourceName.Query(). - Where(sourceQuery(&model.SourceSpec{ID: &nodeID})). + Where(sourceQuery(&model.SourceSpec{Type: &nodeID})). Limit(MaxPageSize) srcNames, err := query.All(ctx) @@ -547,11 +598,11 @@ func (b *EntBackend) srcTypeNeighbors(ctx context.Context, nodeID string, allowe for _, foundSrcName := range srcNames { out = append(out, &model.Source{ - ID: toGlobalID(srcTypeString, foundSrcName.ID.String()), + ID: toGlobalID(srcTypeString, foundSrcName.Type), Type: foundSrcName.Type, Namespaces: []*model.SourceNamespace{ { - ID: toGlobalID(srcNamespaceString, foundSrcName.ID.String()), + ID: toGlobalID(srcNamespaceString, strings.Join([]string{foundSrcName.Type, foundSrcName.Namespace}, guacIDSplit)), Namespace: foundSrcName.Namespace, Names: []*model.SourceName{}, }, @@ -565,8 +616,14 @@ func (b *EntBackend) srcTypeNeighbors(ctx context.Context, nodeID string, allowe func (b *EntBackend) srcNamespaceNeighbors(ctx context.Context, nodeID string, allowedEdges edgeMap) ([]model.Node, error) { var out []model.Node + // split to find the type and namespace value + splitQueryValue := strings.Split(nodeID, guacIDSplit) + if len(splitQueryValue) != 2 { + return out, fmt.Errorf("invalid query for srcNamespaceNeighbors with ID %s", nodeID) + } + query := b.client.SourceName.Query(). - Where(sourceQuery(&model.SourceSpec{ID: &nodeID})). + Where(sourceQuery(&model.SourceSpec{Type: &splitQueryValue[0], Namespace: &splitQueryValue[1]})). Limit(MaxPageSize) srcNames, err := query.All(ctx) @@ -577,11 +634,11 @@ func (b *EntBackend) srcNamespaceNeighbors(ctx context.Context, nodeID string, a if allowedEdges[model.EdgeSourceNamespaceSourceName] { for _, foundSrcName := range srcNames { out = append(out, &model.Source{ - ID: toGlobalID(srcTypeString, foundSrcName.ID.String()), + ID: toGlobalID(srcTypeString, foundSrcName.Type), Type: foundSrcName.Type, Namespaces: []*model.SourceNamespace{ { - ID: toGlobalID(srcNamespaceString, foundSrcName.ID.String()), + ID: toGlobalID(srcNamespaceString, strings.Join([]string{foundSrcName.Type, foundSrcName.Namespace}, guacIDSplit)), Namespace: foundSrcName.Namespace, Names: []*model.SourceName{ { @@ -597,7 +654,7 @@ func (b *EntBackend) srcNamespaceNeighbors(ctx context.Context, nodeID string, a if allowedEdges[model.EdgeSourceNamespaceSourceType] { for _, foundSrcName := range srcNames { out = append(out, &model.Source{ - ID: toGlobalID(srcTypeString, foundSrcName.ID.String()), + ID: toGlobalID(srcTypeString, foundSrcName.Type), Type: foundSrcName.Type, Namespaces: []*model.SourceNamespace{}, }) @@ -674,11 +731,11 @@ func (b *EntBackend) srcNameNeighbors(ctx context.Context, nodeID string, allowe for _, foundSrcName := range srcNames { if allowedEdges[model.EdgeSourceNameSourceNamespace] { out = append(out, &model.Source{ - ID: toGlobalID(srcTypeString, foundSrcName.ID.String()), + ID: toGlobalID(srcTypeString, foundSrcName.Type), Type: foundSrcName.Type, Namespaces: []*model.SourceNamespace{ { - ID: toGlobalID(srcNamespaceString, foundSrcName.ID.String()), + ID: toGlobalID(srcNamespaceString, strings.Join([]string{foundSrcName.Type, foundSrcName.Namespace}, guacIDSplit)), Namespace: foundSrcName.Namespace, Names: []*model.SourceName{}, }, diff --git a/pkg/assembler/backends/ent/backend/transforms.go b/pkg/assembler/backends/ent/backend/transforms.go index 8cc97ee1030..f7264f142ef 100644 --- a/pkg/assembler/backends/ent/backend/transforms.go +++ b/pkg/assembler/backends/ent/backend/transforms.go @@ -16,6 +16,8 @@ package backend import ( + "strings" + "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/pkg/assembler/backends/ent" "github.com/guacsec/guac/pkg/assembler/backends/ent/artifact" @@ -45,12 +47,72 @@ func toModelBuilder(b *ent.Builder) *model.Builder { } } +func toModelPackageTrie(collectedPkgNames []*ent.PackageName) []*model.Package { + pkgTypes := map[string]map[string]map[string][]*model.PackageVersion{} + + for _, pkgName := range collectedPkgNames { + nameString := pkgName.Name + "," + toGlobalID(packagename.Table, pkgName.ID.String()) + + namespaceString := pkgName.Namespace + "," + toGlobalID(pkgNamespaceString, strings.Join([]string{pkgName.Type, pkgName.Namespace}, guacIDSplit)) + typeString := pkgName.Type + "," + toGlobalID(pkgTypeString, pkgName.Type) + + if pkgNamespaces, ok := pkgTypes[typeString]; ok { + if pkgNames, ok := pkgNamespaces[namespaceString]; ok { + pkgNames[nameString] = append(pkgNames[nameString], collect(pkgName.Edges.Versions, toModelPackageVersion)...) + } else { + pkgNames := map[string][]*model.PackageVersion{} + pkgNames[nameString] = append(pkgNames[nameString], collect(pkgName.Edges.Versions, toModelPackageVersion)...) + pkgNamespaces[namespaceString] = pkgNames + pkgTypes[typeString] = pkgNamespaces + } + } else { + pkgNames := map[string][]*model.PackageVersion{} + pkgNames[nameString] = append(pkgNames[nameString], collect(pkgName.Edges.Versions, toModelPackageVersion)...) + pkgNamespaces := map[string]map[string][]*model.PackageVersion{} + pkgNamespaces[namespaceString] = pkgNames + pkgTypes[typeString] = pkgNamespaces + } + } + var packages []*model.Package + for pkgType, pkgNamespaces := range pkgTypes { + collectedPkgNamespaces := []*model.PackageNamespace{} + for namespace, pkgNames := range pkgNamespaces { + var collectedPkgNames []*model.PackageName + for name, versions := range pkgNames { + nameValues := strings.Split(name, ",") + pkgName := &model.PackageName{ + ID: nameValues[1], + Name: nameValues[0], + Versions: versions, + } + collectedPkgNames = append(collectedPkgNames, pkgName) + } + namespaceValues := strings.Split(namespace, ",") + pkgNamespace := &model.PackageNamespace{ + ID: namespaceValues[1], + Namespace: namespaceValues[0], + Names: collectedPkgNames, + } + collectedPkgNamespaces = append(collectedPkgNamespaces, pkgNamespace) + } + typeValues := strings.Split(pkgType, ",") + collectedPackage := &model.Package{ + ID: typeValues[1], + Type: typeValues[0], + Namespaces: collectedPkgNamespaces, + } + packages = append(packages, collectedPackage) + } + + return packages +} + func toModelPackage(p *ent.PackageName) *model.Package { if p == nil { return nil } return &model.Package{ - ID: toGlobalID(pkgTypeString, p.ID.String()), + ID: toGlobalID(pkgTypeString, p.Type), Type: p.Type, Namespaces: collect([]*ent.PackageName{p}, toModelNamespace), } @@ -61,7 +123,7 @@ func toModelNamespace(n *ent.PackageName) *model.PackageNamespace { return nil } return &model.PackageNamespace{ - ID: toGlobalID(pkgNamespaceString, n.ID.String()), + ID: toGlobalID(pkgNamespaceString, strings.Join([]string{n.Type, n.Namespace}, guacIDSplit)), Namespace: n.Namespace, Names: collect([]*ent.PackageName{n}, toModelPackageName), } diff --git a/pkg/assembler/backends/ent/backend/vulnerability.go b/pkg/assembler/backends/ent/backend/vulnerability.go index 3930300a887..809064ed0a4 100644 --- a/pkg/assembler/backends/ent/backend/vulnerability.go +++ b/pkg/assembler/backends/ent/backend/vulnerability.go @@ -34,7 +34,7 @@ import ( ) const ( - vulnTypeString = "vulnType" + vulnTypeString = "vulnerability_types" NoVuln = "novuln" ) @@ -134,7 +134,7 @@ func upsertBulkVulnerability(ctx context.Context, tx *ent.Tx, vulnInputs []*mode creates[i] = generateVulnerabilityIDCreate(tx, &vulnID, v) ids = append(ids, model.VulnerabilityIDs{ - VulnerabilityTypeID: toGlobalID(vulnTypeString, vulnID.String()), + VulnerabilityTypeID: toGlobalID(vulnTypeString, v.VulnerabilityInput.Type), VulnerabilityNodeID: toGlobalID(ent.TypeVulnerabilityID, vulnID.String())}) } @@ -176,7 +176,7 @@ func upsertVulnerability(ctx context.Context, tx *ent.Tx, spec model.IDorVulnera } return &model.VulnerabilityIDs{ - VulnerabilityTypeID: toGlobalID(vulnTypeString, vulnID.String()), + VulnerabilityTypeID: toGlobalID(vulnTypeString, spec.VulnerabilityInput.Type), VulnerabilityNodeID: toGlobalID(vulnerabilityid.Table, vulnID.String()), }, nil } @@ -185,7 +185,7 @@ func toModelVulnerability(collectedVulnID []*ent.VulnerabilityID) []*model.Vulne vulnTypes := map[string][]*model.VulnerabilityID{} for _, vulnID := range collectedVulnID { - typeString := vulnID.Type + typeString := vulnID.Type + "," + toGlobalID(vulnTypeString, vulnID.Type) vulnID := &model.VulnerabilityID{ ID: toGlobalID(vulnerabilityid.Table, vulnID.ID.String()), VulnerabilityID: vulnID.VulnerabilityID, @@ -200,9 +200,10 @@ func toModelVulnerability(collectedVulnID []*ent.VulnerabilityID) []*model.Vulne } var vulnerabilities []*model.Vulnerability for vulnType, vulnIDs := range vulnTypes { + typeValues := strings.Split(vulnType, ",") vuln := &model.Vulnerability{ - ID: vulnType, - Type: vulnType, + ID: typeValues[1], + Type: typeValues[0], VulnerabilityIDs: vulnIDs, } vulnerabilities = append(vulnerabilities, vuln) @@ -221,7 +222,7 @@ func (b *EntBackend) vulnTypeNeighbors(ctx context.Context, nodeID string, allow var out []model.Node if allowedEdges[model.EdgeVulnerabilityTypeVulnerabilityID] { query := b.client.VulnerabilityID.Query(). - Where(vulnerabilityQueryPredicates(model.VulnerabilitySpec{ID: &nodeID})...). + Where(vulnerabilityQueryPredicates(model.VulnerabilitySpec{Type: &nodeID})...). Limit(MaxPageSize) vulnIDs, err := query.All(ctx) @@ -231,7 +232,7 @@ func (b *EntBackend) vulnTypeNeighbors(ctx context.Context, nodeID string, allow for _, foundVulnID := range vulnIDs { out = append(out, &model.Vulnerability{ - ID: toGlobalID(vulnTypeString, foundVulnID.ID.String()), + ID: toGlobalID(vulnTypeString, foundVulnID.Type), Type: foundVulnID.Type, VulnerabilityIDs: []*model.VulnerabilityID{ { @@ -289,7 +290,7 @@ func (b *EntBackend) vulnIdNeighbors(ctx context.Context, nodeID string, allowed for _, foundVulnID := range vulnIDs { if allowedEdges[model.EdgeVulnerabilityIDVulnerabilityType] { out = append(out, &model.Vulnerability{ - ID: toGlobalID(vulnTypeString, foundVulnID.ID.String()), + ID: toGlobalID(vulnTypeString, foundVulnID.Type), Type: foundVulnID.Type, VulnerabilityIDs: []*model.VulnerabilityID{}, }) From d86124178bfda3bcc54fdc9441f958c0d2a40734 Mon Sep 17 00:00:00 2001 From: Parth Patel <88045217+pxp928@users.noreply.github.com> Date: Thu, 25 Apr 2024 12:06:04 -0400 Subject: [PATCH 10/17] Update graphQL, resolvers and add backend stubs for pagination (#1862) * implement pagination for artifact Signed-off-by: pxp928 * implement artifactList for keyvalue and ent Signed-off-by: pxp928 * add builder pagination for keyvalue and ent Signed-off-by: pxp928 * gql schema changes for pagination for certifyBad, certifyGood, certifyLegal and certifyScorecard Signed-off-by: pxp928 * gql schema changes for pagination for certifyVex and certifyVuln Signed-off-by: pxp928 * gql schema changes for pagination for poc or hashEqual Signed-off-by: pxp928 * gql schema changes for pagination for hashSBOM and hasSLSA Signed-off-by: pxp928 * gql schema changes for pagination for hasSourceAt, isDep, isOccur, license Signed-off-by: pxp928 * gql schema changes for pagination for meta, package, pkgEqual, source, vulnEqual, vuln, vulnMeta Signed-off-by: pxp928 * add to backends interface Signed-off-by: pxp928 * add stubs to all backends for paginated query Signed-off-by: pxp928 * add search and neighbor pagination Signed-off-by: pxp928 --------- Signed-off-by: pxp928 --- internal/testing/mocks/backend.go | 375 ++ pkg/assembler/backends/arangodb/artifact.go | 4 + pkg/assembler/backends/arangodb/builder.go | 4 + pkg/assembler/backends/arangodb/certifyBad.go | 4 + .../backends/arangodb/certifyGood.go | 4 + .../backends/arangodb/certifyLegal.go | 4 + .../backends/arangodb/certifyScorecard.go | 4 + .../backends/arangodb/certifyVEXStatement.go | 4 + .../backends/arangodb/certifyVuln.go | 4 + .../backends/arangodb/hasMetadata.go | 4 + pkg/assembler/backends/arangodb/hasSBOM.go | 4 + pkg/assembler/backends/arangodb/hasSLSA.go | 4 + .../backends/arangodb/hasSourceAt.go | 4 + pkg/assembler/backends/arangodb/hashEqual.go | 4 + .../backends/arangodb/isDependency.go | 4 + .../backends/arangodb/isOccurrence.go | 5 + pkg/assembler/backends/arangodb/license.go | 4 + pkg/assembler/backends/arangodb/path.go | 4 + pkg/assembler/backends/arangodb/pkg.go | 4 + pkg/assembler/backends/arangodb/pkgEqual.go | 4 + .../backends/arangodb/pointOfContact.go | 4 + pkg/assembler/backends/arangodb/search.go | 4 + pkg/assembler/backends/arangodb/src.go | 4 + pkg/assembler/backends/arangodb/vulnEqual.go | 5 + .../backends/arangodb/vulnMetadata.go | 4 + .../backends/arangodb/vulnerability.go | 4 + pkg/assembler/backends/backends.go | 28 + .../backends/ent/backend/artifact.go | 47 + .../backends/ent/backend/builders.go | 45 + pkg/assembler/backends/ent/backend/certify.go | 8 + .../backends/ent/backend/certifyLegal.go | 4 + .../ent/backend/certifyVEXStatement.go | 4 + .../backends/ent/backend/certifyVuln.go | 4 + .../backends/ent/backend/dependency.go | 4 + .../backends/ent/backend/hasMetadata.go | 4 + .../backends/ent/backend/hashequal.go | 4 + pkg/assembler/backends/ent/backend/license.go | 4 + .../backends/ent/backend/neighbors.go | 4 + .../backends/ent/backend/occurrence.go | 4 + pkg/assembler/backends/ent/backend/package.go | 4 + .../backends/ent/backend/pkgequal.go | 4 + .../backends/ent/backend/pointOfContact.go | 4 + pkg/assembler/backends/ent/backend/sbom.go | 4 + .../backends/ent/backend/scorecard.go | 4 + pkg/assembler/backends/ent/backend/search.go | 5 + pkg/assembler/backends/ent/backend/slsa.go | 4 + pkg/assembler/backends/ent/backend/source.go | 8 + .../backends/ent/backend/vulnEqual.go | 4 + .../backends/ent/backend/vulnMetadata.go | 4 + .../backends/ent/backend/vulnerability.go | 4 + pkg/assembler/backends/keyvalue/artifact.go | 113 + pkg/assembler/backends/keyvalue/builder.go | 92 + pkg/assembler/backends/keyvalue/certifyBad.go | 6 + .../backends/keyvalue/certifyGood.go | 6 + .../backends/keyvalue/certifyLegal.go | 4 + .../backends/keyvalue/certifyScorecard.go | 5 + .../backends/keyvalue/certifyVEXStatement.go | 6 + .../backends/keyvalue/certifyVuln.go | 6 + .../backends/keyvalue/hasMetadata.go | 6 + pkg/assembler/backends/keyvalue/hasSBOM.go | 4 + pkg/assembler/backends/keyvalue/hasSLSA.go | 4 + .../backends/keyvalue/hasSourceAt.go | 6 + pkg/assembler/backends/keyvalue/hashEqual.go | 4 + .../backends/keyvalue/isDependency.go | 6 + .../backends/keyvalue/isOccurrence.go | 5 + pkg/assembler/backends/keyvalue/license.go | 5 + pkg/assembler/backends/keyvalue/path.go | 4 + pkg/assembler/backends/keyvalue/pkg.go | 5 + pkg/assembler/backends/keyvalue/pkgEqual.go | 4 + .../backends/keyvalue/pointOfContact.go | 6 + pkg/assembler/backends/keyvalue/search.go | 4 + pkg/assembler/backends/keyvalue/src.go | 4 + pkg/assembler/backends/keyvalue/vulnEqual.go | 5 + .../backends/keyvalue/vulnMetadata.go | 5 + .../backends/keyvalue/vulnerability.go | 5 + pkg/assembler/backends/neo4j/artifact.go | 4 + pkg/assembler/backends/neo4j/backend.go | 10 + pkg/assembler/backends/neo4j/builder.go | 4 + pkg/assembler/backends/neo4j/certifyBad.go | 4 + pkg/assembler/backends/neo4j/certifyGood.go | 4 + .../backends/neo4j/certifyScorecard.go | 4 + .../backends/neo4j/certifyVEXStatement.go | 4 + pkg/assembler/backends/neo4j/certifyVuln.go | 4 + pkg/assembler/backends/neo4j/contact.go | 4 + pkg/assembler/backends/neo4j/hasMetadata.go | 4 + pkg/assembler/backends/neo4j/hasSBOM.go | 4 + pkg/assembler/backends/neo4j/hasSLSA.go | 4 + pkg/assembler/backends/neo4j/hasSourceAt.go | 4 + pkg/assembler/backends/neo4j/hashEqual.go | 4 + pkg/assembler/backends/neo4j/isDependency.go | 4 + pkg/assembler/backends/neo4j/isOccurrence.go | 4 + pkg/assembler/backends/neo4j/path.go | 4 + pkg/assembler/backends/neo4j/pkg.go | 4 + pkg/assembler/backends/neo4j/pkgEqual.go | 4 + pkg/assembler/backends/neo4j/search.go | 4 + pkg/assembler/backends/neo4j/src.go | 4 + pkg/assembler/backends/neo4j/vulnEqual.go | 4 + pkg/assembler/backends/neo4j/vulnMetadata.go | 4 + pkg/assembler/backends/neo4j/vulnerability.go | 4 + .../graphql/examples/artifact_builder.gql | 26 + .../graphql/generated/artifact.generated.go | 5118 +++++++++++++---- .../graphql/generated/builder.generated.go | 380 ++ .../graphql/generated/certifyBad.generated.go | 389 ++ .../generated/certifyGood.generated.go | 390 ++ .../generated/certifyLegal.generated.go | 399 ++ .../generated/certifyScorecard.generated.go | 381 ++ .../certifyVEXStatement.generated.go | 397 ++ .../generated/certifyVuln.generated.go | 383 ++ .../graphql/generated/contact.generated.go | 394 ++ .../graphql/generated/hasSBOM.generated.go | 401 ++ .../graphql/generated/hasSLSA.generated.go | 381 ++ .../generated/hasSourceAt.generated.go | 391 ++ .../graphql/generated/hashEqual.generated.go | 387 ++ .../generated/isDependency.generated.go | 393 ++ .../generated/isOccurrence.generated.go | 389 ++ .../graphql/generated/license.generated.go | 384 ++ .../graphql/generated/metadata.generated.go | 394 ++ .../graphql/generated/package.generated.go | 381 ++ .../graphql/generated/pagination.generated.go | 216 + .../graphql/generated/path.generated.go | 376 ++ .../graphql/generated/pkgEqual.generated.go | 387 ++ .../graphql/generated/prelude.generated.go | 16 + .../graphql/generated/root_.generated.go | 2374 +++++++- .../graphql/generated/search.generated.go | 421 ++ .../graphql/generated/source.generated.go | 381 ++ .../graphql/generated/vulnEqual.generated.go | 387 ++ .../generated/vulnMetadata.generated.go | 391 ++ .../generated/vulnerability.generated.go | 381 ++ pkg/assembler/graphql/model/nodes.go | 590 ++ .../graphql/resolvers/artifact.resolvers.go | 5 + .../graphql/resolvers/builder.resolvers.go | 5 + .../graphql/resolvers/certifyBad.resolvers.go | 8 + .../resolvers/certifyGood.resolvers.go | 8 + .../resolvers/certifyLegal.resolvers.go | 9 + .../resolvers/certifyScorecard.resolvers.go | 5 + .../certifyVEXStatement.resolvers.go | 45 + .../resolvers/certifyVuln.resolvers.go | 48 + .../graphql/resolvers/contact.resolvers.go | 8 + .../graphql/resolvers/hasSBOM.resolvers.go | 8 + .../graphql/resolvers/hasSLSA.resolvers.go | 5 + .../resolvers/hasSourceAt.resolvers.go | 5 + .../graphql/resolvers/hashEqual.resolvers.go | 8 + .../resolvers/isDependency.resolvers.go | 10 + .../resolvers/isOccurrence.resolvers.go | 8 + .../graphql/resolvers/license.resolvers.go | 5 + .../graphql/resolvers/metadata.resolvers.go | 8 + .../graphql/resolvers/package.resolvers.go | 5 + .../graphql/resolvers/path.resolvers.go | 5 + .../graphql/resolvers/pkgEqual.resolvers.go | 8 + .../graphql/resolvers/search.resolvers.go | 5 + .../graphql/resolvers/source.resolvers.go | 11 + .../graphql/resolvers/vulnEqual.resolvers.go | 44 + .../resolvers/vulnMetadata.resolvers.go | 52 +- .../resolvers/vulnerability.resolvers.go | 24 + pkg/assembler/graphql/schema/artifact.graphql | 29 + pkg/assembler/graphql/schema/builder.graphql | 29 + .../graphql/schema/certifyBad.graphql | 29 + .../graphql/schema/certifyGood.graphql | 29 + .../graphql/schema/certifyLegal.graphql | 29 + .../graphql/schema/certifyScorecard.graphql | 29 + .../schema/certifyVEXStatement.graphql | 29 + .../graphql/schema/certifyVuln.graphql | 29 + pkg/assembler/graphql/schema/contact.graphql | 29 + pkg/assembler/graphql/schema/hasSBOM.graphql | 29 + pkg/assembler/graphql/schema/hasSLSA.graphql | 29 + .../graphql/schema/hasSourceAt.graphql | 29 + .../graphql/schema/hashEqual.graphql | 29 + .../graphql/schema/isDependency.graphql | 29 + .../graphql/schema/isOccurrence.graphql | 29 + pkg/assembler/graphql/schema/license.graphql | 29 + pkg/assembler/graphql/schema/metadata.graphql | 29 + pkg/assembler/graphql/schema/package.graphql | 29 + .../graphql/schema/pagination.graphql | 35 + pkg/assembler/graphql/schema/path.graphql | 31 + pkg/assembler/graphql/schema/pkgEqual.graphql | 29 + pkg/assembler/graphql/schema/search.graphql | 30 + pkg/assembler/graphql/schema/source.graphql | 29 + .../graphql/schema/vulnEqual.graphql | 29 + .../graphql/schema/vulnMetadata.graphql | 29 + .../graphql/schema/vulnerability.graphql | 29 + 180 files changed, 18861 insertions(+), 1044 deletions(-) create mode 100644 pkg/assembler/graphql/generated/pagination.generated.go create mode 100644 pkg/assembler/graphql/generated/search.generated.go create mode 100644 pkg/assembler/graphql/schema/pagination.graphql diff --git a/internal/testing/mocks/backend.go b/internal/testing/mocks/backend.go index 8023492db4d..81ab3247173 100644 --- a/internal/testing/mocks/backend.go +++ b/internal/testing/mocks/backend.go @@ -50,6 +50,21 @@ func (mr *MockBackendMockRecorder) Artifacts(ctx, artifactSpec interface{}) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Artifacts", reflect.TypeOf((*MockBackend)(nil).Artifacts), ctx, artifactSpec) } +// ArtifactsList mocks base method. +func (m *MockBackend) ArtifactsList(ctx context.Context, artifactSpec model.ArtifactSpec, after *string, first *int) (*model.ArtifactConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ArtifactsList", ctx, artifactSpec, after, first) + ret0, _ := ret[0].(*model.ArtifactConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ArtifactsList indicates an expected call of ArtifactsList. +func (mr *MockBackendMockRecorder) ArtifactsList(ctx, artifactSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ArtifactsList", reflect.TypeOf((*MockBackend)(nil).ArtifactsList), ctx, artifactSpec, after, first) +} + // Builders mocks base method. func (m *MockBackend) Builders(ctx context.Context, builderSpec *model.BuilderSpec) ([]*model.Builder, error) { m.ctrl.T.Helper() @@ -65,6 +80,21 @@ func (mr *MockBackendMockRecorder) Builders(ctx, builderSpec interface{}) *gomoc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Builders", reflect.TypeOf((*MockBackend)(nil).Builders), ctx, builderSpec) } +// BuildersList mocks base method. +func (m *MockBackend) BuildersList(ctx context.Context, builderSpec model.BuilderSpec, after *string, first *int) (*model.BuilderConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BuildersList", ctx, builderSpec, after, first) + ret0, _ := ret[0].(*model.BuilderConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// BuildersList indicates an expected call of BuildersList. +func (mr *MockBackendMockRecorder) BuildersList(ctx, builderSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BuildersList", reflect.TypeOf((*MockBackend)(nil).BuildersList), ctx, builderSpec, after, first) +} + // CertifyBad mocks base method. func (m *MockBackend) CertifyBad(ctx context.Context, certifyBadSpec *model.CertifyBadSpec) ([]*model.CertifyBad, error) { m.ctrl.T.Helper() @@ -80,6 +110,21 @@ func (mr *MockBackendMockRecorder) CertifyBad(ctx, certifyBadSpec interface{}) * return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyBad", reflect.TypeOf((*MockBackend)(nil).CertifyBad), ctx, certifyBadSpec) } +// CertifyBadList mocks base method. +func (m *MockBackend) CertifyBadList(ctx context.Context, certifyBadSpec model.CertifyBadSpec, after *string, first *int) (*model.CertifyBadConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CertifyBadList", ctx, certifyBadSpec, after, first) + ret0, _ := ret[0].(*model.CertifyBadConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CertifyBadList indicates an expected call of CertifyBadList. +func (mr *MockBackendMockRecorder) CertifyBadList(ctx, certifyBadSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyBadList", reflect.TypeOf((*MockBackend)(nil).CertifyBadList), ctx, certifyBadSpec, after, first) +} + // CertifyGood mocks base method. func (m *MockBackend) CertifyGood(ctx context.Context, certifyGoodSpec *model.CertifyGoodSpec) ([]*model.CertifyGood, error) { m.ctrl.T.Helper() @@ -95,6 +140,21 @@ func (mr *MockBackendMockRecorder) CertifyGood(ctx, certifyGoodSpec interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyGood", reflect.TypeOf((*MockBackend)(nil).CertifyGood), ctx, certifyGoodSpec) } +// CertifyGoodList mocks base method. +func (m *MockBackend) CertifyGoodList(ctx context.Context, certifyGoodSpec model.CertifyGoodSpec, after *string, first *int) (*model.CertifyGoodConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CertifyGoodList", ctx, certifyGoodSpec, after, first) + ret0, _ := ret[0].(*model.CertifyGoodConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CertifyGoodList indicates an expected call of CertifyGoodList. +func (mr *MockBackendMockRecorder) CertifyGoodList(ctx, certifyGoodSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyGoodList", reflect.TypeOf((*MockBackend)(nil).CertifyGoodList), ctx, certifyGoodSpec, after, first) +} + // CertifyLegal mocks base method. func (m *MockBackend) CertifyLegal(ctx context.Context, certifyLegalSpec *model.CertifyLegalSpec) ([]*model.CertifyLegal, error) { m.ctrl.T.Helper() @@ -110,6 +170,21 @@ func (mr *MockBackendMockRecorder) CertifyLegal(ctx, certifyLegalSpec interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyLegal", reflect.TypeOf((*MockBackend)(nil).CertifyLegal), ctx, certifyLegalSpec) } +// CertifyLegalList mocks base method. +func (m *MockBackend) CertifyLegalList(ctx context.Context, certifyLegalSpec model.CertifyLegalSpec, after *string, first *int) (*model.CertifyLegalConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CertifyLegalList", ctx, certifyLegalSpec, after, first) + ret0, _ := ret[0].(*model.CertifyLegalConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CertifyLegalList indicates an expected call of CertifyLegalList. +func (mr *MockBackendMockRecorder) CertifyLegalList(ctx, certifyLegalSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyLegalList", reflect.TypeOf((*MockBackend)(nil).CertifyLegalList), ctx, certifyLegalSpec, after, first) +} + // CertifyVEXStatement mocks base method. func (m *MockBackend) CertifyVEXStatement(ctx context.Context, certifyVEXStatementSpec *model.CertifyVEXStatementSpec) ([]*model.CertifyVEXStatement, error) { m.ctrl.T.Helper() @@ -125,6 +200,21 @@ func (mr *MockBackendMockRecorder) CertifyVEXStatement(ctx, certifyVEXStatementS return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyVEXStatement", reflect.TypeOf((*MockBackend)(nil).CertifyVEXStatement), ctx, certifyVEXStatementSpec) } +// CertifyVEXStatementList mocks base method. +func (m *MockBackend) CertifyVEXStatementList(ctx context.Context, certifyVEXStatementSpec model.CertifyVEXStatementSpec, after *string, first *int) (*model.VEXConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CertifyVEXStatementList", ctx, certifyVEXStatementSpec, after, first) + ret0, _ := ret[0].(*model.VEXConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CertifyVEXStatementList indicates an expected call of CertifyVEXStatementList. +func (mr *MockBackendMockRecorder) CertifyVEXStatementList(ctx, certifyVEXStatementSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyVEXStatementList", reflect.TypeOf((*MockBackend)(nil).CertifyVEXStatementList), ctx, certifyVEXStatementSpec, after, first) +} + // CertifyVuln mocks base method. func (m *MockBackend) CertifyVuln(ctx context.Context, certifyVulnSpec *model.CertifyVulnSpec) ([]*model.CertifyVuln, error) { m.ctrl.T.Helper() @@ -140,6 +230,21 @@ func (mr *MockBackendMockRecorder) CertifyVuln(ctx, certifyVulnSpec interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyVuln", reflect.TypeOf((*MockBackend)(nil).CertifyVuln), ctx, certifyVulnSpec) } +// CertifyVulnList mocks base method. +func (m *MockBackend) CertifyVulnList(ctx context.Context, certifyVulnSpec model.CertifyVulnSpec, after *string, first *int) (*model.CertifyVulnConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CertifyVulnList", ctx, certifyVulnSpec, after, first) + ret0, _ := ret[0].(*model.CertifyVulnConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CertifyVulnList indicates an expected call of CertifyVulnList. +func (mr *MockBackendMockRecorder) CertifyVulnList(ctx, certifyVulnSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyVulnList", reflect.TypeOf((*MockBackend)(nil).CertifyVulnList), ctx, certifyVulnSpec, after, first) +} + // FindSoftware mocks base method. func (m *MockBackend) FindSoftware(ctx context.Context, searchText string) ([]model.PackageSourceOrArtifact, error) { m.ctrl.T.Helper() @@ -155,6 +260,21 @@ func (mr *MockBackendMockRecorder) FindSoftware(ctx, searchText interface{}) *go return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindSoftware", reflect.TypeOf((*MockBackend)(nil).FindSoftware), ctx, searchText) } +// FindSoftwareList mocks base method. +func (m *MockBackend) FindSoftwareList(ctx context.Context, searchText string, after *string, first *int) (*model.FindSoftwareConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "FindSoftwareList", ctx, searchText, after, first) + ret0, _ := ret[0].(*model.FindSoftwareConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// FindSoftwareList indicates an expected call of FindSoftwareList. +func (mr *MockBackendMockRecorder) FindSoftwareList(ctx, searchText, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindSoftwareList", reflect.TypeOf((*MockBackend)(nil).FindSoftwareList), ctx, searchText, after, first) +} + // HasMetadata mocks base method. func (m *MockBackend) HasMetadata(ctx context.Context, hasMetadataSpec *model.HasMetadataSpec) ([]*model.HasMetadata, error) { m.ctrl.T.Helper() @@ -170,6 +290,21 @@ func (mr *MockBackendMockRecorder) HasMetadata(ctx, hasMetadataSpec interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasMetadata", reflect.TypeOf((*MockBackend)(nil).HasMetadata), ctx, hasMetadataSpec) } +// HasMetadataList mocks base method. +func (m *MockBackend) HasMetadataList(ctx context.Context, hasMetadataSpec model.HasMetadataSpec, after *string, first *int) (*model.HasMetadataConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasMetadataList", ctx, hasMetadataSpec, after, first) + ret0, _ := ret[0].(*model.HasMetadataConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// HasMetadataList indicates an expected call of HasMetadataList. +func (mr *MockBackendMockRecorder) HasMetadataList(ctx, hasMetadataSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasMetadataList", reflect.TypeOf((*MockBackend)(nil).HasMetadataList), ctx, hasMetadataSpec, after, first) +} + // HasSBOM mocks base method. func (m *MockBackend) HasSBOM(ctx context.Context, hasSBOMSpec *model.HasSBOMSpec) ([]*model.HasSbom, error) { m.ctrl.T.Helper() @@ -185,6 +320,36 @@ func (mr *MockBackendMockRecorder) HasSBOM(ctx, hasSBOMSpec interface{}) *gomock return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSBOM", reflect.TypeOf((*MockBackend)(nil).HasSBOM), ctx, hasSBOMSpec) } +// HasSBOMList mocks base method. +func (m *MockBackend) HasSBOMList(ctx context.Context, hasSBOMSpec model.HasSBOMSpec, after *string, first *int) (*model.HasSBOMConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasSBOMList", ctx, hasSBOMSpec, after, first) + ret0, _ := ret[0].(*model.HasSBOMConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// HasSBOMList indicates an expected call of HasSBOMList. +func (mr *MockBackendMockRecorder) HasSBOMList(ctx, hasSBOMSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSBOMList", reflect.TypeOf((*MockBackend)(nil).HasSBOMList), ctx, hasSBOMSpec, after, first) +} + +// HasSLSAList mocks base method. +func (m *MockBackend) HasSLSAList(ctx context.Context, hasSLSASpec model.HasSLSASpec, after *string, first *int) (*model.HasSLSAConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasSLSAList", ctx, hasSLSASpec, after, first) + ret0, _ := ret[0].(*model.HasSLSAConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// HasSLSAList indicates an expected call of HasSLSAList. +func (mr *MockBackendMockRecorder) HasSLSAList(ctx, hasSLSASpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSLSAList", reflect.TypeOf((*MockBackend)(nil).HasSLSAList), ctx, hasSLSASpec, after, first) +} + // HasSlsa mocks base method. func (m *MockBackend) HasSlsa(ctx context.Context, hasSLSASpec *model.HasSLSASpec) ([]*model.HasSlsa, error) { m.ctrl.T.Helper() @@ -215,6 +380,21 @@ func (mr *MockBackendMockRecorder) HasSourceAt(ctx, hasSourceAtSpec interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSourceAt", reflect.TypeOf((*MockBackend)(nil).HasSourceAt), ctx, hasSourceAtSpec) } +// HasSourceAtList mocks base method. +func (m *MockBackend) HasSourceAtList(ctx context.Context, hasSourceAtSpec model.HasSourceAtSpec, after *string, first *int) (*model.HasSourceAtConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasSourceAtList", ctx, hasSourceAtSpec, after, first) + ret0, _ := ret[0].(*model.HasSourceAtConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// HasSourceAtList indicates an expected call of HasSourceAtList. +func (mr *MockBackendMockRecorder) HasSourceAtList(ctx, hasSourceAtSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSourceAtList", reflect.TypeOf((*MockBackend)(nil).HasSourceAtList), ctx, hasSourceAtSpec, after, first) +} + // HashEqual mocks base method. func (m *MockBackend) HashEqual(ctx context.Context, hashEqualSpec *model.HashEqualSpec) ([]*model.HashEqual, error) { m.ctrl.T.Helper() @@ -230,6 +410,21 @@ func (mr *MockBackendMockRecorder) HashEqual(ctx, hashEqualSpec interface{}) *go return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HashEqual", reflect.TypeOf((*MockBackend)(nil).HashEqual), ctx, hashEqualSpec) } +// HashEqualList mocks base method. +func (m *MockBackend) HashEqualList(ctx context.Context, hashEqualSpec model.HashEqualSpec, after *string, first *int) (*model.HashEqualConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HashEqualList", ctx, hashEqualSpec, after, first) + ret0, _ := ret[0].(*model.HashEqualConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// HashEqualList indicates an expected call of HashEqualList. +func (mr *MockBackendMockRecorder) HashEqualList(ctx, hashEqualSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HashEqualList", reflect.TypeOf((*MockBackend)(nil).HashEqualList), ctx, hashEqualSpec, after, first) +} + // IngestArtifact mocks base method. func (m *MockBackend) IngestArtifact(ctx context.Context, artifact *model.IDorArtifactInput) (string, error) { m.ctrl.T.Helper() @@ -935,6 +1130,21 @@ func (mr *MockBackendMockRecorder) IsDependency(ctx, isDependencySpec interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDependency", reflect.TypeOf((*MockBackend)(nil).IsDependency), ctx, isDependencySpec) } +// IsDependencyList mocks base method. +func (m *MockBackend) IsDependencyList(ctx context.Context, isDependencySpec model.IsDependencySpec, after *string, first *int) (*model.IsDependencyConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsDependencyList", ctx, isDependencySpec, after, first) + ret0, _ := ret[0].(*model.IsDependencyConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsDependencyList indicates an expected call of IsDependencyList. +func (mr *MockBackendMockRecorder) IsDependencyList(ctx, isDependencySpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDependencyList", reflect.TypeOf((*MockBackend)(nil).IsDependencyList), ctx, isDependencySpec, after, first) +} + // IsOccurrence mocks base method. func (m *MockBackend) IsOccurrence(ctx context.Context, isOccurrenceSpec *model.IsOccurrenceSpec) ([]*model.IsOccurrence, error) { m.ctrl.T.Helper() @@ -950,6 +1160,36 @@ func (mr *MockBackendMockRecorder) IsOccurrence(ctx, isOccurrenceSpec interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOccurrence", reflect.TypeOf((*MockBackend)(nil).IsOccurrence), ctx, isOccurrenceSpec) } +// IsOccurrenceList mocks base method. +func (m *MockBackend) IsOccurrenceList(ctx context.Context, isOccurrenceSpec model.IsOccurrenceSpec, after *string, first *int) (*model.IsOccurrenceConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsOccurrenceList", ctx, isOccurrenceSpec, after, first) + ret0, _ := ret[0].(*model.IsOccurrenceConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// IsOccurrenceList indicates an expected call of IsOccurrenceList. +func (mr *MockBackendMockRecorder) IsOccurrenceList(ctx, isOccurrenceSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOccurrenceList", reflect.TypeOf((*MockBackend)(nil).IsOccurrenceList), ctx, isOccurrenceSpec, after, first) +} + +// LicenseList mocks base method. +func (m *MockBackend) LicenseList(ctx context.Context, licenseSpec model.LicenseSpec, after *string, first *int) (*model.LicenseConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "LicenseList", ctx, licenseSpec, after, first) + ret0, _ := ret[0].(*model.LicenseConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// LicenseList indicates an expected call of LicenseList. +func (mr *MockBackendMockRecorder) LicenseList(ctx, licenseSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LicenseList", reflect.TypeOf((*MockBackend)(nil).LicenseList), ctx, licenseSpec, after, first) +} + // Licenses mocks base method. func (m *MockBackend) Licenses(ctx context.Context, licenseSpec *model.LicenseSpec) ([]*model.License, error) { m.ctrl.T.Helper() @@ -980,6 +1220,21 @@ func (mr *MockBackendMockRecorder) Neighbors(ctx, node, usingOnly interface{}) * return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Neighbors", reflect.TypeOf((*MockBackend)(nil).Neighbors), ctx, node, usingOnly) } +// NeighborsList mocks base method. +func (m *MockBackend) NeighborsList(ctx context.Context, node string, usingOnly []model.Edge, after *string, first *int) (*model.NeighborConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NeighborsList", ctx, node, usingOnly, after, first) + ret0, _ := ret[0].(*model.NeighborConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// NeighborsList indicates an expected call of NeighborsList. +func (mr *MockBackendMockRecorder) NeighborsList(ctx, node, usingOnly, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NeighborsList", reflect.TypeOf((*MockBackend)(nil).NeighborsList), ctx, node, usingOnly, after, first) +} + // Node mocks base method. func (m *MockBackend) Node(ctx context.Context, node string) (model.Node, error) { m.ctrl.T.Helper() @@ -1025,6 +1280,21 @@ func (mr *MockBackendMockRecorder) Packages(ctx, pkgSpec interface{}) *gomock.Ca return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Packages", reflect.TypeOf((*MockBackend)(nil).Packages), ctx, pkgSpec) } +// PackagesList mocks base method. +func (m *MockBackend) PackagesList(ctx context.Context, pkgSpec model.PkgSpec, after *string, first *int) (*model.PackageConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PackagesList", ctx, pkgSpec, after, first) + ret0, _ := ret[0].(*model.PackageConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PackagesList indicates an expected call of PackagesList. +func (mr *MockBackendMockRecorder) PackagesList(ctx, pkgSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackagesList", reflect.TypeOf((*MockBackend)(nil).PackagesList), ctx, pkgSpec, after, first) +} + // Path mocks base method. func (m *MockBackend) Path(ctx context.Context, subject, target string, maxPathLength int, usingOnly []model.Edge) ([]model.Node, error) { m.ctrl.T.Helper() @@ -1055,6 +1325,21 @@ func (mr *MockBackendMockRecorder) PkgEqual(ctx, pkgEqualSpec interface{}) *gomo return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PkgEqual", reflect.TypeOf((*MockBackend)(nil).PkgEqual), ctx, pkgEqualSpec) } +// PkgEqualList mocks base method. +func (m *MockBackend) PkgEqualList(ctx context.Context, pkgEqualSpec model.PkgEqualSpec, after *string, first *int) (*model.PkgEqualConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PkgEqualList", ctx, pkgEqualSpec, after, first) + ret0, _ := ret[0].(*model.PkgEqualConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PkgEqualList indicates an expected call of PkgEqualList. +func (mr *MockBackendMockRecorder) PkgEqualList(ctx, pkgEqualSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PkgEqualList", reflect.TypeOf((*MockBackend)(nil).PkgEqualList), ctx, pkgEqualSpec, after, first) +} + // PointOfContact mocks base method. func (m *MockBackend) PointOfContact(ctx context.Context, pointOfContactSpec *model.PointOfContactSpec) ([]*model.PointOfContact, error) { m.ctrl.T.Helper() @@ -1070,6 +1355,21 @@ func (mr *MockBackendMockRecorder) PointOfContact(ctx, pointOfContactSpec interf return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PointOfContact", reflect.TypeOf((*MockBackend)(nil).PointOfContact), ctx, pointOfContactSpec) } +// PointOfContactList mocks base method. +func (m *MockBackend) PointOfContactList(ctx context.Context, pointOfContactSpec model.PointOfContactSpec, after *string, first *int) (*model.PointOfContactConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PointOfContactList", ctx, pointOfContactSpec, after, first) + ret0, _ := ret[0].(*model.PointOfContactConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PointOfContactList indicates an expected call of PointOfContactList. +func (mr *MockBackendMockRecorder) PointOfContactList(ctx, pointOfContactSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PointOfContactList", reflect.TypeOf((*MockBackend)(nil).PointOfContactList), ctx, pointOfContactSpec, after, first) +} + // Scorecards mocks base method. func (m *MockBackend) Scorecards(ctx context.Context, certifyScorecardSpec *model.CertifyScorecardSpec) ([]*model.CertifyScorecard, error) { m.ctrl.T.Helper() @@ -1085,6 +1385,21 @@ func (mr *MockBackendMockRecorder) Scorecards(ctx, certifyScorecardSpec interfac return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Scorecards", reflect.TypeOf((*MockBackend)(nil).Scorecards), ctx, certifyScorecardSpec) } +// ScorecardsList mocks base method. +func (m *MockBackend) ScorecardsList(ctx context.Context, scorecardSpec model.CertifyScorecardSpec, after *string, first *int) (*model.CertifyScorecardConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ScorecardsList", ctx, scorecardSpec, after, first) + ret0, _ := ret[0].(*model.CertifyScorecardConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ScorecardsList indicates an expected call of ScorecardsList. +func (mr *MockBackendMockRecorder) ScorecardsList(ctx, scorecardSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ScorecardsList", reflect.TypeOf((*MockBackend)(nil).ScorecardsList), ctx, scorecardSpec, after, first) +} + // Sources mocks base method. func (m *MockBackend) Sources(ctx context.Context, sourceSpec *model.SourceSpec) ([]*model.Source, error) { m.ctrl.T.Helper() @@ -1100,6 +1415,21 @@ func (mr *MockBackendMockRecorder) Sources(ctx, sourceSpec interface{}) *gomock. return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sources", reflect.TypeOf((*MockBackend)(nil).Sources), ctx, sourceSpec) } +// SourcesList mocks base method. +func (m *MockBackend) SourcesList(ctx context.Context, sourceSpec model.SourceSpec, after *string, first *int) (*model.SourceConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SourcesList", ctx, sourceSpec, after, first) + ret0, _ := ret[0].(*model.SourceConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// SourcesList indicates an expected call of SourcesList. +func (mr *MockBackendMockRecorder) SourcesList(ctx, sourceSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SourcesList", reflect.TypeOf((*MockBackend)(nil).SourcesList), ctx, sourceSpec, after, first) +} + // VulnEqual mocks base method. func (m *MockBackend) VulnEqual(ctx context.Context, vulnEqualSpec *model.VulnEqualSpec) ([]*model.VulnEqual, error) { m.ctrl.T.Helper() @@ -1115,6 +1445,21 @@ func (mr *MockBackendMockRecorder) VulnEqual(ctx, vulnEqualSpec interface{}) *go return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VulnEqual", reflect.TypeOf((*MockBackend)(nil).VulnEqual), ctx, vulnEqualSpec) } +// VulnEqualList mocks base method. +func (m *MockBackend) VulnEqualList(ctx context.Context, vulnEqualSpec model.VulnEqualSpec, after *string, first *int) (*model.VulnEqualConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "VulnEqualList", ctx, vulnEqualSpec, after, first) + ret0, _ := ret[0].(*model.VulnEqualConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// VulnEqualList indicates an expected call of VulnEqualList. +func (mr *MockBackendMockRecorder) VulnEqualList(ctx, vulnEqualSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VulnEqualList", reflect.TypeOf((*MockBackend)(nil).VulnEqualList), ctx, vulnEqualSpec, after, first) +} + // Vulnerabilities mocks base method. func (m *MockBackend) Vulnerabilities(ctx context.Context, vulnSpec *model.VulnerabilitySpec) ([]*model.Vulnerability, error) { m.ctrl.T.Helper() @@ -1130,6 +1475,21 @@ func (mr *MockBackendMockRecorder) Vulnerabilities(ctx, vulnSpec interface{}) *g return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Vulnerabilities", reflect.TypeOf((*MockBackend)(nil).Vulnerabilities), ctx, vulnSpec) } +// VulnerabilityList mocks base method. +func (m *MockBackend) VulnerabilityList(ctx context.Context, vulnSpec model.VulnerabilitySpec, after *string, first *int) (*model.VulnerabilityConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "VulnerabilityList", ctx, vulnSpec, after, first) + ret0, _ := ret[0].(*model.VulnerabilityConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// VulnerabilityList indicates an expected call of VulnerabilityList. +func (mr *MockBackendMockRecorder) VulnerabilityList(ctx, vulnSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VulnerabilityList", reflect.TypeOf((*MockBackend)(nil).VulnerabilityList), ctx, vulnSpec, after, first) +} + // VulnerabilityMetadata mocks base method. func (m *MockBackend) VulnerabilityMetadata(ctx context.Context, vulnerabilityMetadataSpec *model.VulnerabilityMetadataSpec) ([]*model.VulnerabilityMetadata, error) { m.ctrl.T.Helper() @@ -1145,6 +1505,21 @@ func (mr *MockBackendMockRecorder) VulnerabilityMetadata(ctx, vulnerabilityMetad return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VulnerabilityMetadata", reflect.TypeOf((*MockBackend)(nil).VulnerabilityMetadata), ctx, vulnerabilityMetadataSpec) } +// VulnerabilityMetadataList mocks base method. +func (m *MockBackend) VulnerabilityMetadataList(ctx context.Context, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec, after *string, first *int) (*model.VulnerabilityMetadataConnection, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "VulnerabilityMetadataList", ctx, vulnerabilityMetadataSpec, after, first) + ret0, _ := ret[0].(*model.VulnerabilityMetadataConnection) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// VulnerabilityMetadataList indicates an expected call of VulnerabilityMetadataList. +func (mr *MockBackendMockRecorder) VulnerabilityMetadataList(ctx, vulnerabilityMetadataSpec, after, first interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VulnerabilityMetadataList", reflect.TypeOf((*MockBackend)(nil).VulnerabilityMetadataList), ctx, vulnerabilityMetadataSpec, after, first) +} + // MockBackendArgs is a mock of BackendArgs interface. type MockBackendArgs struct { ctrl *gomock.Controller diff --git a/pkg/assembler/backends/arangodb/artifact.go b/pkg/assembler/backends/arangodb/artifact.go index 238266f2a2a..acb45c33a23 100644 --- a/pkg/assembler/backends/arangodb/artifact.go +++ b/pkg/assembler/backends/arangodb/artifact.go @@ -25,6 +25,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +func (c *arangoClient) ArtifactsList(ctx context.Context, artifactSpec model.ArtifactSpec, after *string, first *int) (*model.ArtifactConnection, error) { + return nil, fmt.Errorf("not implemented: ArtifactsList") +} + func (c *arangoClient) Artifacts(ctx context.Context, artifactSpec *model.ArtifactSpec) ([]*model.Artifact, error) { values := map[string]any{} diff --git a/pkg/assembler/backends/arangodb/builder.go b/pkg/assembler/backends/arangodb/builder.go index aa3777819da..785e70b8bfd 100644 --- a/pkg/assembler/backends/arangodb/builder.go +++ b/pkg/assembler/backends/arangodb/builder.go @@ -25,6 +25,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +func (c *arangoClient) BuildersList(ctx context.Context, builderSpec model.BuilderSpec, after *string, first *int) (*model.BuilderConnection, error) { + return nil, fmt.Errorf("not implemented: BuildersList") +} + func (c *arangoClient) Builders(ctx context.Context, builderSpec *model.BuilderSpec) ([]*model.Builder, error) { values := map[string]any{} arangoQueryBuilder := setBuilderMatchValues(builderSpec, values) diff --git a/pkg/assembler/backends/arangodb/certifyBad.go b/pkg/assembler/backends/arangodb/certifyBad.go index 4a8ecc4e59a..55bc519ecd4 100644 --- a/pkg/assembler/backends/arangodb/certifyBad.go +++ b/pkg/assembler/backends/arangodb/certifyBad.go @@ -27,6 +27,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/helpers" ) +func (c *arangoClient) CertifyBadList(ctx context.Context, certifyBadSpec model.CertifyBadSpec, after *string, first *int) (*model.CertifyBadConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyBadList") +} + func (c *arangoClient) CertifyBad(ctx context.Context, certifyBadSpec *model.CertifyBadSpec) ([]*model.CertifyBad, error) { if certifyBadSpec != nil && certifyBadSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/certifyGood.go b/pkg/assembler/backends/arangodb/certifyGood.go index b0bba769e9d..d283236eafa 100644 --- a/pkg/assembler/backends/arangodb/certifyGood.go +++ b/pkg/assembler/backends/arangodb/certifyGood.go @@ -27,6 +27,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/helpers" ) +func (c *arangoClient) CertifyGoodList(ctx context.Context, certifyGoodSpec model.CertifyGoodSpec, after *string, first *int) (*model.CertifyGoodConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyBadList") +} + func (c *arangoClient) CertifyGood(ctx context.Context, certifyGoodSpec *model.CertifyGoodSpec) ([]*model.CertifyGood, error) { if certifyGoodSpec != nil && certifyGoodSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/certifyLegal.go b/pkg/assembler/backends/arangodb/certifyLegal.go index b99cf744ac5..44c026f73af 100644 --- a/pkg/assembler/backends/arangodb/certifyLegal.go +++ b/pkg/assembler/backends/arangodb/certifyLegal.go @@ -27,6 +27,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/helpers" ) +func (c *arangoClient) CertifyLegalList(ctx context.Context, certifyLegalSpec model.CertifyLegalSpec, after *string, first *int) (*model.CertifyLegalConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyBadList") +} + func (c *arangoClient) CertifyLegal(ctx context.Context, certifyLegalSpec *model.CertifyLegalSpec) ([]*model.CertifyLegal, error) { if certifyLegalSpec != nil && certifyLegalSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/certifyScorecard.go b/pkg/assembler/backends/arangodb/certifyScorecard.go index 2fe9d017fe6..da9072ca4b1 100644 --- a/pkg/assembler/backends/arangodb/certifyScorecard.go +++ b/pkg/assembler/backends/arangodb/certifyScorecard.go @@ -39,6 +39,10 @@ const ( // Query Scorecards +func (c *arangoClient) ScorecardsList(ctx context.Context, scorecardSpec model.CertifyScorecardSpec, after *string, first *int) (*model.CertifyScorecardConnection, error) { + return nil, fmt.Errorf("not implemented: ScorecardsList") +} + func (c *arangoClient) Scorecards(ctx context.Context, certifyScorecardSpec *model.CertifyScorecardSpec) ([]*model.CertifyScorecard, error) { if certifyScorecardSpec != nil && certifyScorecardSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/certifyVEXStatement.go b/pkg/assembler/backends/arangodb/certifyVEXStatement.go index f5e27e65e1e..1e5a58704a2 100644 --- a/pkg/assembler/backends/arangodb/certifyVEXStatement.go +++ b/pkg/assembler/backends/arangodb/certifyVEXStatement.go @@ -35,6 +35,10 @@ const ( knownSinceStr string = "knownSince" ) +func (c *arangoClient) CertifyVEXStatementList(ctx context.Context, certifyVEXStatementSpec model.CertifyVEXStatementSpec, after *string, first *int) (*model.VEXConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyVEXStatementList") +} + func (c *arangoClient) CertifyVEXStatement(ctx context.Context, certifyVEXStatementSpec *model.CertifyVEXStatementSpec) ([]*model.CertifyVEXStatement, error) { if certifyVEXStatementSpec != nil && certifyVEXStatementSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/certifyVuln.go b/pkg/assembler/backends/arangodb/certifyVuln.go index 654a3956a19..b67850ee9cc 100644 --- a/pkg/assembler/backends/arangodb/certifyVuln.go +++ b/pkg/assembler/backends/arangodb/certifyVuln.go @@ -34,6 +34,10 @@ const ( scannerVersionStr string = "scannerVersion" ) +func (c *arangoClient) CertifyVulnList(ctx context.Context, certifyVulnSpec model.CertifyVulnSpec, after *string, first *int) (*model.CertifyVulnConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyVulnList") +} + func (c *arangoClient) CertifyVuln(ctx context.Context, certifyVulnSpec *model.CertifyVulnSpec) ([]*model.CertifyVuln, error) { if certifyVulnSpec != nil && certifyVulnSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/hasMetadata.go b/pkg/assembler/backends/arangodb/hasMetadata.go index a64aa1f1381..936d0b12896 100644 --- a/pkg/assembler/backends/arangodb/hasMetadata.go +++ b/pkg/assembler/backends/arangodb/hasMetadata.go @@ -32,6 +32,10 @@ const ( valueStr string = "value" ) +func (c *arangoClient) HasMetadataList(ctx context.Context, hasMetadataSpec model.HasMetadataSpec, after *string, first *int) (*model.HasMetadataConnection, error) { + return nil, fmt.Errorf("not implemented: HasMetadataList") +} + func (c *arangoClient) HasMetadata(ctx context.Context, hasMetadataSpec *model.HasMetadataSpec) ([]*model.HasMetadata, error) { if hasMetadataSpec != nil && hasMetadataSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/hasSBOM.go b/pkg/assembler/backends/arangodb/hasSBOM.go index 4028d23fb9a..31ab01755d9 100644 --- a/pkg/assembler/backends/arangodb/hasSBOM.go +++ b/pkg/assembler/backends/arangodb/hasSBOM.go @@ -29,6 +29,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/helpers" ) +func (c *arangoClient) HasSBOMList(ctx context.Context, hasSBOMSpec model.HasSBOMSpec, after *string, first *int) (*model.HasSBOMConnection, error) { + return nil, fmt.Errorf("not implemented: HasSBOMList") +} + func (c *arangoClient) HasSBOM(ctx context.Context, hasSBOMSpec *model.HasSBOMSpec) ([]*model.HasSbom, error) { if hasSBOMSpec != nil && hasSBOMSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/hasSLSA.go b/pkg/assembler/backends/arangodb/hasSLSA.go index ab45cdd9fbd..c83ce06e248 100644 --- a/pkg/assembler/backends/arangodb/hasSLSA.go +++ b/pkg/assembler/backends/arangodb/hasSLSA.go @@ -37,6 +37,10 @@ const ( builtFromStr string = "builtFrom" ) +func (c *arangoClient) HasSLSAList(ctx context.Context, hasSLSASpec model.HasSLSASpec, after *string, first *int) (*model.HasSLSAConnection, error) { + return nil, fmt.Errorf("not implemented: HasSLSAList") +} + func (c *arangoClient) HasSlsa(ctx context.Context, hasSLSASpec *model.HasSLSASpec) ([]*model.HasSlsa, error) { if hasSLSASpec != nil && hasSLSASpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/hasSourceAt.go b/pkg/assembler/backends/arangodb/hasSourceAt.go index 25c8da813a5..9dfb9c7d2bc 100644 --- a/pkg/assembler/backends/arangodb/hasSourceAt.go +++ b/pkg/assembler/backends/arangodb/hasSourceAt.go @@ -27,6 +27,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/helpers" ) +func (c *arangoClient) HasSourceAtList(ctx context.Context, hasSourceAtSpec model.HasSourceAtSpec, after *string, first *int) (*model.HasSourceAtConnection, error) { + return nil, fmt.Errorf("not implemented: HasSourceAtList") +} + func (c *arangoClient) HasSourceAt(ctx context.Context, hasSourceAtSpec *model.HasSourceAtSpec) ([]*model.HasSourceAt, error) { if hasSourceAtSpec != nil && hasSourceAtSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/hashEqual.go b/pkg/assembler/backends/arangodb/hashEqual.go index ccbac484fd1..ac19c09392d 100644 --- a/pkg/assembler/backends/arangodb/hashEqual.go +++ b/pkg/assembler/backends/arangodb/hashEqual.go @@ -26,6 +26,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +func (c *arangoClient) HashEqualList(ctx context.Context, hashEqualSpec model.HashEqualSpec, after *string, first *int) (*model.HashEqualConnection, error) { + return nil, fmt.Errorf("not implemented: HashEqualList") +} + func (c *arangoClient) HashEqual(ctx context.Context, hashEqualSpec *model.HashEqualSpec) ([]*model.HashEqual, error) { if hashEqualSpec != nil && hashEqualSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/isDependency.go b/pkg/assembler/backends/arangodb/isDependency.go index fe41059f301..fa52794b443 100644 --- a/pkg/assembler/backends/arangodb/isDependency.go +++ b/pkg/assembler/backends/arangodb/isDependency.go @@ -54,6 +54,10 @@ func checkPkgNameDependency(isDependencySpec *model.IsDependencySpec) bool { // Query IsDependency +func (c *arangoClient) IsDependencyList(ctx context.Context, isDependencySpec model.IsDependencySpec, after *string, first *int) (*model.IsDependencyConnection, error) { + return nil, fmt.Errorf("not implemented: IsDependencyList") +} + func (c *arangoClient) IsDependency(ctx context.Context, isDependencySpec *model.IsDependencySpec) ([]*model.IsDependency, error) { if isDependencySpec != nil && isDependencySpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/isOccurrence.go b/pkg/assembler/backends/arangodb/isOccurrence.go index e3349b4163c..f602a45c366 100644 --- a/pkg/assembler/backends/arangodb/isOccurrence.go +++ b/pkg/assembler/backends/arangodb/isOccurrence.go @@ -28,6 +28,11 @@ import ( ) // Query IsOccurrence + +func (c *arangoClient) IsOccurrenceList(ctx context.Context, isOccurrenceSpec model.IsOccurrenceSpec, after *string, first *int) (*model.IsOccurrenceConnection, error) { + return nil, fmt.Errorf("not implemented: IsOccurrenceList") +} + func (c *arangoClient) IsOccurrence(ctx context.Context, isOccurrenceSpec *model.IsOccurrenceSpec) ([]*model.IsOccurrence, error) { if isOccurrenceSpec != nil && isOccurrenceSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/license.go b/pkg/assembler/backends/arangodb/license.go index b92b7df55a0..490c1f136f2 100644 --- a/pkg/assembler/backends/arangodb/license.go +++ b/pkg/assembler/backends/arangodb/license.go @@ -25,6 +25,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +func (c *arangoClient) LicenseList(ctx context.Context, licenseSpec model.LicenseSpec, after *string, first *int) (*model.LicenseConnection, error) { + return nil, fmt.Errorf("not implemented: LicenseList") +} + func (c *arangoClient) Licenses(ctx context.Context, licenseSpec *model.LicenseSpec) ([]*model.License, error) { values := map[string]any{} aqb := setLicenseMatchValues(licenseSpec, values) diff --git a/pkg/assembler/backends/arangodb/path.go b/pkg/assembler/backends/arangodb/path.go index 605ae1f0a9d..20d95d277b7 100644 --- a/pkg/assembler/backends/arangodb/path.go +++ b/pkg/assembler/backends/arangodb/path.go @@ -124,6 +124,10 @@ IN 1..@maxLength ANY K_PATHS return foundNodes, nil } +func (c *arangoClient) NeighborsList(ctx context.Context, node string, usingOnly []model.Edge, after *string, first *int) (*model.NeighborConnection, error) { + return nil, fmt.Errorf("not implemented: NeighborsList") +} + // TODO (pxp928): investigate if the individual neighbor queries (within nouns and verbs) can be done co-currently func (c *arangoClient) Neighbors(ctx context.Context, nodeID string, usingOnly []model.Edge) ([]model.Node, error) { var neighborsID []string diff --git a/pkg/assembler/backends/arangodb/pkg.go b/pkg/assembler/backends/arangodb/pkg.go index a260df8eaa7..38cf6c443cb 100644 --- a/pkg/assembler/backends/arangodb/pkg.go +++ b/pkg/assembler/backends/arangodb/pkg.go @@ -368,6 +368,10 @@ func setPkgVersionMatchValues(pkgSpec *model.PkgSpec, queryValues map[string]any return arangoQueryBuilder } +func (c *arangoClient) PackagesList(ctx context.Context, pkgSpec model.PkgSpec, after *string, first *int) (*model.PackageConnection, error) { + return nil, fmt.Errorf("not implemented: PackagesList") +} + func (c *arangoClient) Packages(ctx context.Context, pkgSpec *model.PkgSpec) ([]*model.Package, error) { if pkgSpec != nil && pkgSpec.ID != nil { p, err := c.buildPackageResponseFromID(ctx, *pkgSpec.ID, pkgSpec) diff --git a/pkg/assembler/backends/arangodb/pkgEqual.go b/pkg/assembler/backends/arangodb/pkgEqual.go index 0b47c2717bf..c717ad90e58 100644 --- a/pkg/assembler/backends/arangodb/pkgEqual.go +++ b/pkg/assembler/backends/arangodb/pkgEqual.go @@ -28,6 +28,10 @@ import ( purl "github.com/package-url/packageurl-go" ) +func (c *arangoClient) PkgEqualList(ctx context.Context, pkgEqualSpec model.PkgEqualSpec, after *string, first *int) (*model.PkgEqualConnection, error) { + return nil, fmt.Errorf("not implemented: PkgEqualList") +} + func (c *arangoClient) PkgEqual(ctx context.Context, pkgEqualSpec *model.PkgEqualSpec) ([]*model.PkgEqual, error) { if pkgEqualSpec != nil && pkgEqualSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/pointOfContact.go b/pkg/assembler/backends/arangodb/pointOfContact.go index b4eb1e1ba36..557a4bd14e0 100644 --- a/pkg/assembler/backends/arangodb/pointOfContact.go +++ b/pkg/assembler/backends/arangodb/pointOfContact.go @@ -33,6 +33,10 @@ const ( sinceStr string = "since" ) +func (c *arangoClient) PointOfContactList(ctx context.Context, pointOfContactSpec model.PointOfContactSpec, after *string, first *int) (*model.PointOfContactConnection, error) { + return nil, fmt.Errorf("not implemented: PointOfContactList") +} + func (c *arangoClient) PointOfContact(ctx context.Context, pointOfContactSpec *model.PointOfContactSpec) ([]*model.PointOfContact, error) { if pointOfContactSpec != nil && pointOfContactSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/search.go b/pkg/assembler/backends/arangodb/search.go index 004e979ff8b..e2f138a7cd7 100644 --- a/pkg/assembler/backends/arangodb/search.go +++ b/pkg/assembler/backends/arangodb/search.go @@ -23,6 +23,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +func (c *arangoClient) FindSoftwareList(ctx context.Context, searchText string, after *string, first *int) (*model.FindSoftwareConnection, error) { + return nil, fmt.Errorf("not implemented: FindSoftwareList") +} + // TODO(lumjjb): add source when it is implemented in arango backend func (c *arangoClient) FindSoftware(ctx context.Context, searchText string) ([]model.PackageSourceOrArtifact, error) { diff --git a/pkg/assembler/backends/arangodb/src.go b/pkg/assembler/backends/arangodb/src.go index 439766faaab..68e47a9b664 100644 --- a/pkg/assembler/backends/arangodb/src.go +++ b/pkg/assembler/backends/arangodb/src.go @@ -270,6 +270,10 @@ func setSrcMatchValues(srcSpec *model.SourceSpec, queryValues map[string]any) *a return arangoQueryBuilder } +func (c *arangoClient) SourcesList(ctx context.Context, sourceSpec model.SourceSpec, after *string, first *int) (*model.SourceConnection, error) { + return nil, fmt.Errorf("not implemented: SourcesList") +} + func (c *arangoClient) Sources(ctx context.Context, sourceSpec *model.SourceSpec) ([]*model.Source, error) { if sourceSpec != nil && sourceSpec.ID != nil { p, err := c.buildSourceResponseFromID(ctx, *sourceSpec.ID, sourceSpec) diff --git a/pkg/assembler/backends/arangodb/vulnEqual.go b/pkg/assembler/backends/arangodb/vulnEqual.go index 542c21414a8..aba3d7ea370 100644 --- a/pkg/assembler/backends/arangodb/vulnEqual.go +++ b/pkg/assembler/backends/arangodb/vulnEqual.go @@ -28,6 +28,11 @@ import ( ) // Query VulnEqual + +func (c *arangoClient) VulnEqualList(ctx context.Context, vulnEqualSpec model.VulnEqualSpec, after *string, first *int) (*model.VulnEqualConnection, error) { + return nil, fmt.Errorf("not implemented: VulnEqualList") +} + func (c *arangoClient) VulnEqual(ctx context.Context, vulnEqualSpec *model.VulnEqualSpec) ([]*model.VulnEqual, error) { if vulnEqualSpec != nil && vulnEqualSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/vulnMetadata.go b/pkg/assembler/backends/arangodb/vulnMetadata.go index 841706bfb6e..974987f5da5 100644 --- a/pkg/assembler/backends/arangodb/vulnMetadata.go +++ b/pkg/assembler/backends/arangodb/vulnMetadata.go @@ -33,6 +33,10 @@ const ( timeStampStr string = "timestamp" ) +func (c *arangoClient) VulnerabilityMetadataList(ctx context.Context, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec, after *string, first *int) (*model.VulnerabilityMetadataConnection, error) { + return nil, fmt.Errorf("not implemented: VulnerabilityMetadataList") +} + func (c *arangoClient) VulnerabilityMetadata(ctx context.Context, vulnerabilityMetadataSpec *model.VulnerabilityMetadataSpec) ([]*model.VulnerabilityMetadata, error) { if vulnerabilityMetadataSpec != nil && vulnerabilityMetadataSpec.ID != nil { diff --git a/pkg/assembler/backends/arangodb/vulnerability.go b/pkg/assembler/backends/arangodb/vulnerability.go index 03a9f757885..cd6ed18ef23 100644 --- a/pkg/assembler/backends/arangodb/vulnerability.go +++ b/pkg/assembler/backends/arangodb/vulnerability.go @@ -44,6 +44,10 @@ type dbVulnType struct { VulnType string `json:"type"` } +func (c *arangoClient) VulnerabilityList(ctx context.Context, vulnSpec model.VulnerabilitySpec, after *string, first *int) (*model.VulnerabilityConnection, error) { + return nil, fmt.Errorf("not implemented: VulnerabilityList") +} + func (c *arangoClient) Vulnerabilities(ctx context.Context, vulnSpec *model.VulnerabilitySpec) ([]*model.Vulnerability, error) { if vulnSpec != nil && vulnSpec.NoVuln != nil && *vulnSpec.NoVuln { diff --git a/pkg/assembler/backends/backends.go b/pkg/assembler/backends/backends.go index 012718f586a..45c7581d801 100644 --- a/pkg/assembler/backends/backends.go +++ b/pkg/assembler/backends/backends.go @@ -33,6 +33,32 @@ type Backend interface { Sources(ctx context.Context, sourceSpec *model.SourceSpec) ([]*model.Source, error) Vulnerabilities(ctx context.Context, vulnSpec *model.VulnerabilitySpec) ([]*model.Vulnerability, error) + // Paginated Retrieval read-only queries for software trees + ArtifactsList(ctx context.Context, artifactSpec model.ArtifactSpec, after *string, first *int) (*model.ArtifactConnection, error) + BuildersList(ctx context.Context, builderSpec model.BuilderSpec, after *string, first *int) (*model.BuilderConnection, error) + LicenseList(ctx context.Context, licenseSpec model.LicenseSpec, after *string, first *int) (*model.LicenseConnection, error) + PackagesList(ctx context.Context, pkgSpec model.PkgSpec, after *string, first *int) (*model.PackageConnection, error) + SourcesList(ctx context.Context, sourceSpec model.SourceSpec, after *string, first *int) (*model.SourceConnection, error) + VulnerabilityList(ctx context.Context, vulnSpec model.VulnerabilitySpec, after *string, first *int) (*model.VulnerabilityConnection, error) + + CertifyBadList(ctx context.Context, certifyBadSpec model.CertifyBadSpec, after *string, first *int) (*model.CertifyBadConnection, error) + CertifyGoodList(ctx context.Context, certifyGoodSpec model.CertifyGoodSpec, after *string, first *int) (*model.CertifyGoodConnection, error) + CertifyLegalList(ctx context.Context, certifyLegalSpec model.CertifyLegalSpec, after *string, first *int) (*model.CertifyLegalConnection, error) + ScorecardsList(ctx context.Context, scorecardSpec model.CertifyScorecardSpec, after *string, first *int) (*model.CertifyScorecardConnection, error) + CertifyVEXStatementList(ctx context.Context, certifyVEXStatementSpec model.CertifyVEXStatementSpec, after *string, first *int) (*model.VEXConnection, error) + CertifyVulnList(ctx context.Context, certifyVulnSpec model.CertifyVulnSpec, after *string, first *int) (*model.CertifyVulnConnection, error) + PointOfContactList(ctx context.Context, pointOfContactSpec model.PointOfContactSpec, after *string, first *int) (*model.PointOfContactConnection, error) + HashEqualList(ctx context.Context, hashEqualSpec model.HashEqualSpec, after *string, first *int) (*model.HashEqualConnection, error) + HasSBOMList(ctx context.Context, hasSBOMSpec model.HasSBOMSpec, after *string, first *int) (*model.HasSBOMConnection, error) + HasSLSAList(ctx context.Context, hasSLSASpec model.HasSLSASpec, after *string, first *int) (*model.HasSLSAConnection, error) + HasSourceAtList(ctx context.Context, hasSourceAtSpec model.HasSourceAtSpec, after *string, first *int) (*model.HasSourceAtConnection, error) + IsDependencyList(ctx context.Context, isDependencySpec model.IsDependencySpec, after *string, first *int) (*model.IsDependencyConnection, error) + IsOccurrenceList(ctx context.Context, isOccurrenceSpec model.IsOccurrenceSpec, after *string, first *int) (*model.IsOccurrenceConnection, error) + HasMetadataList(ctx context.Context, hasMetadataSpec model.HasMetadataSpec, after *string, first *int) (*model.HasMetadataConnection, error) + PkgEqualList(ctx context.Context, pkgEqualSpec model.PkgEqualSpec, after *string, first *int) (*model.PkgEqualConnection, error) + VulnEqualList(ctx context.Context, vulnEqualSpec model.VulnEqualSpec, after *string, first *int) (*model.VulnEqualConnection, error) + VulnerabilityMetadataList(ctx context.Context, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec, after *string, first *int) (*model.VulnerabilityMetadataConnection, error) + // Retrieval read-only queries for evidence trees CertifyBad(ctx context.Context, certifyBadSpec *model.CertifyBadSpec) ([]*model.CertifyBad, error) CertifyGood(ctx context.Context, certifyGoodSpec *model.CertifyGoodSpec) ([]*model.CertifyGood, error) @@ -104,12 +130,14 @@ type Backend interface { // Topological queries: queries where node connectivity matters more than node type Neighbors(ctx context.Context, node string, usingOnly []model.Edge) ([]model.Node, error) + NeighborsList(ctx context.Context, node string, usingOnly []model.Edge, after *string, first *int) (*model.NeighborConnection, error) Node(ctx context.Context, node string) (model.Node, error) Nodes(ctx context.Context, nodes []string) ([]model.Node, error) Path(ctx context.Context, subject string, target string, maxPathLength int, usingOnly []model.Edge) ([]model.Node, error) // Search queries: queries to help find data in GUAC based on text search FindSoftware(ctx context.Context, searchText string) ([]model.PackageSourceOrArtifact, error) + FindSoftwareList(ctx context.Context, searchText string, after *string, first *int) (*model.FindSoftwareConnection, error) } // BackendArgs interface allows each backend to specify the arguments needed to diff --git a/pkg/assembler/backends/ent/backend/artifact.go b/pkg/assembler/backends/ent/backend/artifact.go index 27e268c8c46..e9b936bb642 100644 --- a/pkg/assembler/backends/ent/backend/artifact.go +++ b/pkg/assembler/backends/ent/backend/artifact.go @@ -21,6 +21,7 @@ import ( "fmt" "strings" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -34,6 +35,52 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) ArtifactsList(ctx context.Context, artifactSpec model.ArtifactSpec, after *string, first *int) (*model.ArtifactConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + afterUUID, err := uuid.Parse(*after) + if err != nil { + return nil, err + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + query, err := b.client.Artifact.Query(). + Where(artifactQueryPredicates(&artifactSpec)). + Limit(MaxPageSize). + Paginate(ctx, afterCursor, first, nil, nil) + + if err != nil { + return nil, err + } + + var edges []*model.ArtifactEdge + for _, edge := range query.Edges { + edges = append(edges, &model.ArtifactEdge{ + Cursor: edge.Cursor.ID.String(), + Node: toModelArtifact(edge.Node), + }) + } + + if query.PageInfo.StartCursor != nil { + return &model.ArtifactConnection{ + TotalCount: query.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: query.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(query.PageInfo.StartCursor.ID.String()), + EndCursor: ptrfrom.String(query.PageInfo.EndCursor.ID.String()), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } +} + func (b *EntBackend) Artifacts(ctx context.Context, artifactSpec *model.ArtifactSpec) ([]*model.Artifact, error) { if artifactSpec == nil { artifactSpec = &model.ArtifactSpec{} diff --git a/pkg/assembler/backends/ent/backend/builders.go b/pkg/assembler/backends/ent/backend/builders.go index 4b0d9543701..0437302e527 100644 --- a/pkg/assembler/backends/ent/backend/builders.go +++ b/pkg/assembler/backends/ent/backend/builders.go @@ -20,6 +20,7 @@ import ( stdsql "database/sql" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -31,6 +32,50 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) BuildersList(ctx context.Context, builderSpec model.BuilderSpec, after *string, first *int) (*model.BuilderConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + afterUUID, err := uuid.Parse(*after) + if err != nil { + return nil, err + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + query, err := b.client.Builder.Query(). + Where(builderQueryPredicate(&builderSpec)). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, err + } + + var edges []*model.BuilderEdge + for _, edge := range query.Edges { + edges = append(edges, &model.BuilderEdge{ + Cursor: edge.Cursor.ID.String(), + Node: toModelBuilder(edge.Node), + }) + } + + if query.PageInfo.StartCursor != nil { + return &model.BuilderConnection{ + TotalCount: query.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: query.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(query.PageInfo.StartCursor.ID.String()), + EndCursor: ptrfrom.String(query.PageInfo.EndCursor.ID.String()), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } +} + func (b *EntBackend) Builders(ctx context.Context, builderSpec *model.BuilderSpec) ([]*model.Builder, error) { if builderSpec == nil { builderSpec = &model.BuilderSpec{} diff --git a/pkg/assembler/backends/ent/backend/certify.go b/pkg/assembler/backends/ent/backend/certify.go index 902558cbcc5..7fabf755fe2 100644 --- a/pkg/assembler/backends/ent/backend/certify.go +++ b/pkg/assembler/backends/ent/backend/certify.go @@ -39,6 +39,10 @@ type certificationInputSpec interface { model.CertifyGoodInputSpec | model.CertifyBadInputSpec } +func (b *EntBackend) CertifyBadList(ctx context.Context, certifyBadSpec model.CertifyBadSpec, after *string, first *int) (*model.CertifyBadConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyBadList") +} + func (b *EntBackend) CertifyBad(ctx context.Context, filter *model.CertifyBadSpec) ([]*model.CertifyBad, error) { if filter == nil { filter = &model.CertifyBadSpec{} @@ -57,6 +61,10 @@ func (b *EntBackend) CertifyBad(ctx context.Context, filter *model.CertifyBadSpe return collect(records, toModelCertifyBad), nil } +func (b *EntBackend) CertifyGoodList(ctx context.Context, certifyGoodSpec model.CertifyGoodSpec, after *string, first *int) (*model.CertifyGoodConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyGoodList") +} + func (b *EntBackend) CertifyGood(ctx context.Context, filter *model.CertifyGoodSpec) ([]*model.CertifyGood, error) { if filter == nil { filter = &model.CertifyGoodSpec{} diff --git a/pkg/assembler/backends/ent/backend/certifyLegal.go b/pkg/assembler/backends/ent/backend/certifyLegal.go index b5a5e190d74..e9e7cd3a655 100644 --- a/pkg/assembler/backends/ent/backend/certifyLegal.go +++ b/pkg/assembler/backends/ent/backend/certifyLegal.go @@ -31,6 +31,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) CertifyLegalList(ctx context.Context, certifyLegalSpec model.CertifyLegalSpec, after *string, first *int) (*model.CertifyLegalConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyLegalList") +} + func (b *EntBackend) CertifyLegal(ctx context.Context, spec *model.CertifyLegalSpec) ([]*model.CertifyLegal, error) { if spec == nil { spec = &model.CertifyLegalSpec{} diff --git a/pkg/assembler/backends/ent/backend/certifyVEXStatement.go b/pkg/assembler/backends/ent/backend/certifyVEXStatement.go index a86f96169f6..44ca19e188e 100644 --- a/pkg/assembler/backends/ent/backend/certifyVEXStatement.go +++ b/pkg/assembler/backends/ent/backend/certifyVEXStatement.go @@ -256,6 +256,10 @@ func upsertBulkVEX(ctx context.Context, tx *ent.Tx, subjects model.PackageOrArti return &ids, nil } +func (b *EntBackend) CertifyVEXStatementList(ctx context.Context, certifyVEXStatementSpec model.CertifyVEXStatementSpec, after *string, first *int) (*model.VEXConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyVEXStatementList") +} + func (b *EntBackend) CertifyVEXStatement(ctx context.Context, spec *model.CertifyVEXStatementSpec) ([]*model.CertifyVEXStatement, error) { if spec == nil { spec = &model.CertifyVEXStatementSpec{} diff --git a/pkg/assembler/backends/ent/backend/certifyVuln.go b/pkg/assembler/backends/ent/backend/certifyVuln.go index b5905208542..654c9bf7816 100644 --- a/pkg/assembler/backends/ent/backend/certifyVuln.go +++ b/pkg/assembler/backends/ent/backend/certifyVuln.go @@ -191,6 +191,10 @@ func upsertBulkCertifyVuln(ctx context.Context, tx *ent.Tx, pkgs []*model.IDorPk return &ids, nil } +func (b *EntBackend) CertifyVulnList(ctx context.Context, certifyVulnSpec model.CertifyVulnSpec, after *string, first *int) (*model.CertifyVulnConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyVulnList") +} + func (b *EntBackend) CertifyVuln(ctx context.Context, spec *model.CertifyVulnSpec) ([]*model.CertifyVuln, error) { if spec == nil { spec = &model.CertifyVulnSpec{} diff --git a/pkg/assembler/backends/ent/backend/dependency.go b/pkg/assembler/backends/ent/backend/dependency.go index eb0d2ce9154..69fb61f972e 100644 --- a/pkg/assembler/backends/ent/backend/dependency.go +++ b/pkg/assembler/backends/ent/backend/dependency.go @@ -30,6 +30,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) IsDependencyList(ctx context.Context, isDependencySpec model.IsDependencySpec, after *string, first *int) (*model.IsDependencyConnection, error) { + return nil, fmt.Errorf("not implemented: IsDependencyList") +} + func (b *EntBackend) IsDependency(ctx context.Context, spec *model.IsDependencySpec) ([]*model.IsDependency, error) { funcName := "IsDependency" if spec == nil { diff --git a/pkg/assembler/backends/ent/backend/hasMetadata.go b/pkg/assembler/backends/ent/backend/hasMetadata.go index 4ec2310ac3b..39e7334a998 100644 --- a/pkg/assembler/backends/ent/backend/hasMetadata.go +++ b/pkg/assembler/backends/ent/backend/hasMetadata.go @@ -30,6 +30,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) HasMetadataList(ctx context.Context, hasMetadataSpec model.HasMetadataSpec, after *string, first *int) (*model.HasMetadataConnection, error) { + return nil, fmt.Errorf("not implemented: HasMetadataList") +} + func (b *EntBackend) HasMetadata(ctx context.Context, filter *model.HasMetadataSpec) ([]*model.HasMetadata, error) { if filter == nil { filter = &model.HasMetadataSpec{} diff --git a/pkg/assembler/backends/ent/backend/hashequal.go b/pkg/assembler/backends/ent/backend/hashequal.go index 08d7d2fddb4..dd59cde015a 100644 --- a/pkg/assembler/backends/ent/backend/hashequal.go +++ b/pkg/assembler/backends/ent/backend/hashequal.go @@ -34,6 +34,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) HashEqualList(ctx context.Context, hashEqualSpec model.HashEqualSpec, after *string, first *int) (*model.HashEqualConnection, error) { + return nil, fmt.Errorf("not implemented: HashEqualList") +} + func (b *EntBackend) HashEqual(ctx context.Context, spec *model.HashEqualSpec) ([]*model.HashEqual, error) { if spec == nil { spec = &model.HashEqualSpec{} diff --git a/pkg/assembler/backends/ent/backend/license.go b/pkg/assembler/backends/ent/backend/license.go index 1ec423cbfea..89068d72dfe 100644 --- a/pkg/assembler/backends/ent/backend/license.go +++ b/pkg/assembler/backends/ent/backend/license.go @@ -66,6 +66,10 @@ func (b *EntBackend) IngestLicense(ctx context.Context, licenseInput *model.IDor return toGlobalID(license.Table, *record), nil } +func (b *EntBackend) LicenseList(ctx context.Context, licenseSpec model.LicenseSpec, after *string, first *int) (*model.LicenseConnection, error) { + return nil, fmt.Errorf("not implemented: LicenseList") +} + func (b *EntBackend) Licenses(ctx context.Context, filter *model.LicenseSpec) ([]*model.License, error) { if filter == nil { filter = &model.LicenseSpec{} diff --git a/pkg/assembler/backends/ent/backend/neighbors.go b/pkg/assembler/backends/ent/backend/neighbors.go index a85e0eb6567..812c9d74131 100644 --- a/pkg/assembler/backends/ent/backend/neighbors.go +++ b/pkg/assembler/backends/ent/backend/neighbors.go @@ -128,6 +128,10 @@ func (b *EntBackend) bfs(ctx context.Context, from, to string, maxLength int, us return b.Nodes(ctx, path) } +func (b *EntBackend) NeighborsList(ctx context.Context, node string, usingOnly []model.Edge, after *string, first *int) (*model.NeighborConnection, error) { + return nil, fmt.Errorf("not implemented: NeighborsList") +} + func (b *EntBackend) Neighbors(ctx context.Context, nodeID string, usingOnly []model.Edge) ([]model.Node, error) { var neighbors []model.Node var err error diff --git a/pkg/assembler/backends/ent/backend/occurrence.go b/pkg/assembler/backends/ent/backend/occurrence.go index 9a1b7a1c4d0..b13e1178408 100644 --- a/pkg/assembler/backends/ent/backend/occurrence.go +++ b/pkg/assembler/backends/ent/backend/occurrence.go @@ -30,6 +30,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) IsOccurrenceList(ctx context.Context, isOccurrenceSpec model.IsOccurrenceSpec, after *string, first *int) (*model.IsOccurrenceConnection, error) { + return nil, fmt.Errorf("not implemented: IsOccurrenceList") +} + func (b *EntBackend) IsOccurrence(ctx context.Context, query *model.IsOccurrenceSpec) ([]*model.IsOccurrence, error) { if query == nil { query = &model.IsOccurrenceSpec{} diff --git a/pkg/assembler/backends/ent/backend/package.go b/pkg/assembler/backends/ent/backend/package.go index 5d27dc51659..d4cc87f5f24 100644 --- a/pkg/assembler/backends/ent/backend/package.go +++ b/pkg/assembler/backends/ent/backend/package.go @@ -43,6 +43,10 @@ const ( pkgNamespaceString = "package_namespaces" ) +func (b *EntBackend) PackagesList(ctx context.Context, pkgSpec model.PkgSpec, after *string, first *int) (*model.PackageConnection, error) { + return nil, fmt.Errorf("not implemented: PackagesList") +} + func (b *EntBackend) Packages(ctx context.Context, pkgSpec *model.PkgSpec) ([]*model.Package, error) { if pkgSpec == nil { pkgSpec = &model.PkgSpec{} diff --git a/pkg/assembler/backends/ent/backend/pkgequal.go b/pkg/assembler/backends/ent/backend/pkgequal.go index a89d9b01501..6b5b5c45ae3 100644 --- a/pkg/assembler/backends/ent/backend/pkgequal.go +++ b/pkg/assembler/backends/ent/backend/pkgequal.go @@ -34,6 +34,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) PkgEqualList(ctx context.Context, pkgEqualSpec model.PkgEqualSpec, after *string, first *int) (*model.PkgEqualConnection, error) { + return nil, fmt.Errorf("not implemented: PkgEqualList") +} + func (b *EntBackend) PkgEqual(ctx context.Context, spec *model.PkgEqualSpec) ([]*model.PkgEqual, error) { if spec == nil { spec = &model.PkgEqualSpec{} diff --git a/pkg/assembler/backends/ent/backend/pointOfContact.go b/pkg/assembler/backends/ent/backend/pointOfContact.go index 4405caa6c0d..6fe2eb630c4 100644 --- a/pkg/assembler/backends/ent/backend/pointOfContact.go +++ b/pkg/assembler/backends/ent/backend/pointOfContact.go @@ -30,6 +30,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) PointOfContactList(ctx context.Context, pointOfContactSpec model.PointOfContactSpec, after *string, first *int) (*model.PointOfContactConnection, error) { + return nil, fmt.Errorf("not implemented: PointOfContactList") +} + func (b *EntBackend) PointOfContact(ctx context.Context, filter *model.PointOfContactSpec) ([]*model.PointOfContact, error) { if filter == nil { filter = &model.PointOfContactSpec{} diff --git a/pkg/assembler/backends/ent/backend/sbom.go b/pkg/assembler/backends/ent/backend/sbom.go index c7c04347a7c..c3bdd607666 100644 --- a/pkg/assembler/backends/ent/backend/sbom.go +++ b/pkg/assembler/backends/ent/backend/sbom.go @@ -33,6 +33,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) HasSBOMList(ctx context.Context, hasSBOMSpec model.HasSBOMSpec, after *string, first *int) (*model.HasSBOMConnection, error) { + return nil, fmt.Errorf("not implemented: HasSBOMList") +} + func (b *EntBackend) HasSBOM(ctx context.Context, spec *model.HasSBOMSpec) ([]*model.HasSbom, error) { funcName := "HasSBOM" if spec == nil { diff --git a/pkg/assembler/backends/ent/backend/scorecard.go b/pkg/assembler/backends/ent/backend/scorecard.go index c67f3422945..559c8331c92 100644 --- a/pkg/assembler/backends/ent/backend/scorecard.go +++ b/pkg/assembler/backends/ent/backend/scorecard.go @@ -34,6 +34,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) ScorecardsList(ctx context.Context, scorecardSpec model.CertifyScorecardSpec, after *string, first *int) (*model.CertifyScorecardConnection, error) { + return nil, fmt.Errorf("not implemented: ScorecardsList") +} + func (b *EntBackend) Scorecards(ctx context.Context, filter *model.CertifyScorecardSpec) ([]*model.CertifyScorecard, error) { if filter == nil { filter = &model.CertifyScorecardSpec{} diff --git a/pkg/assembler/backends/ent/backend/search.go b/pkg/assembler/backends/ent/backend/search.go index 1983495aa89..c2f21ce73a0 100644 --- a/pkg/assembler/backends/ent/backend/search.go +++ b/pkg/assembler/backends/ent/backend/search.go @@ -17,6 +17,7 @@ package backend import ( "context" + "fmt" "github.com/guacsec/guac/pkg/assembler/backends/ent" "github.com/guacsec/guac/pkg/assembler/backends/ent/artifact" @@ -98,3 +99,7 @@ func (b *EntBackend) FindSoftware(ctx context.Context, searchText string) ([]mod return results, nil } + +func (b *EntBackend) FindSoftwareList(ctx context.Context, searchText string, after *string, first *int) (*model.FindSoftwareConnection, error) { + return nil, fmt.Errorf("not implemented: FindSoftwareList") +} diff --git a/pkg/assembler/backends/ent/backend/slsa.go b/pkg/assembler/backends/ent/backend/slsa.go index 2fc25cc67b2..0f01402e932 100644 --- a/pkg/assembler/backends/ent/backend/slsa.go +++ b/pkg/assembler/backends/ent/backend/slsa.go @@ -35,6 +35,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) HasSLSAList(ctx context.Context, hasSLSASpec model.HasSLSASpec, after *string, first *int) (*model.HasSLSAConnection, error) { + return nil, fmt.Errorf("not implemented: HasSLSAList") +} + func (b *EntBackend) HasSlsa(ctx context.Context, spec *model.HasSLSASpec) ([]*model.HasSlsa, error) { if spec == nil { spec = &model.HasSLSASpec{} diff --git a/pkg/assembler/backends/ent/backend/source.go b/pkg/assembler/backends/ent/backend/source.go index 5ee5635bb94..82600b559ac 100644 --- a/pkg/assembler/backends/ent/backend/source.go +++ b/pkg/assembler/backends/ent/backend/source.go @@ -40,6 +40,10 @@ const ( srcNamespaceString = "source_namespaces" ) +func (b *EntBackend) HasSourceAtList(ctx context.Context, hasSourceAtSpec model.HasSourceAtSpec, after *string, first *int) (*model.HasSourceAtConnection, error) { + return nil, fmt.Errorf("not implemented: HasSourceAtList") +} + func (b *EntBackend) HasSourceAt(ctx context.Context, filter *model.HasSourceAtSpec) ([]*model.HasSourceAt, error) { if filter == nil { filter = &model.HasSourceAtSpec{} @@ -318,6 +322,10 @@ func (b *EntBackend) hasSourceAtNeighbors(ctx context.Context, nodeID string, al return out, nil } +func (b *EntBackend) SourcesList(ctx context.Context, sourceSpec model.SourceSpec, after *string, first *int) (*model.SourceConnection, error) { + return nil, fmt.Errorf("not implemented: SourcesList") +} + func (b *EntBackend) Sources(ctx context.Context, filter *model.SourceSpec) ([]*model.Source, error) { if filter == nil { filter = &model.SourceSpec{} diff --git a/pkg/assembler/backends/ent/backend/vulnEqual.go b/pkg/assembler/backends/ent/backend/vulnEqual.go index 3afdbd13e55..c6d4b6409c5 100644 --- a/pkg/assembler/backends/ent/backend/vulnEqual.go +++ b/pkg/assembler/backends/ent/backend/vulnEqual.go @@ -34,6 +34,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) VulnEqualList(ctx context.Context, vulnEqualSpec model.VulnEqualSpec, after *string, first *int) (*model.VulnEqualConnection, error) { + return nil, fmt.Errorf("not implemented: VulnEqualList") +} + func (b *EntBackend) VulnEqual(ctx context.Context, filter *model.VulnEqualSpec) ([]*model.VulnEqual, error) { if filter == nil { filter = &model.VulnEqualSpec{} diff --git a/pkg/assembler/backends/ent/backend/vulnMetadata.go b/pkg/assembler/backends/ent/backend/vulnMetadata.go index 5d028d004cd..1d82ac40e51 100644 --- a/pkg/assembler/backends/ent/backend/vulnMetadata.go +++ b/pkg/assembler/backends/ent/backend/vulnMetadata.go @@ -31,6 +31,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (b *EntBackend) VulnerabilityMetadataList(ctx context.Context, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec, after *string, first *int) (*model.VulnerabilityMetadataConnection, error) { + return nil, fmt.Errorf("not implemented: VulnerabilityMetadataList") +} + func (b *EntBackend) VulnerabilityMetadata(ctx context.Context, filter *model.VulnerabilityMetadataSpec) ([]*model.VulnerabilityMetadata, error) { if filter == nil { filter = &model.VulnerabilityMetadataSpec{} diff --git a/pkg/assembler/backends/ent/backend/vulnerability.go b/pkg/assembler/backends/ent/backend/vulnerability.go index 809064ed0a4..6d2440512f4 100644 --- a/pkg/assembler/backends/ent/backend/vulnerability.go +++ b/pkg/assembler/backends/ent/backend/vulnerability.go @@ -73,6 +73,10 @@ func (b *EntBackend) IngestVulnerabilities(ctx context.Context, vulns []*model.I return collectedVulnIDs, nil } +func (b *EntBackend) VulnerabilityList(ctx context.Context, vulnSpec model.VulnerabilitySpec, after *string, first *int) (*model.VulnerabilityConnection, error) { + return nil, fmt.Errorf("not implemented: VulnerabilityList") +} + func (b *EntBackend) Vulnerabilities(ctx context.Context, filter *model.VulnerabilitySpec) ([]*model.Vulnerability, error) { if filter == nil { filter = &model.VulnerabilitySpec{} diff --git a/pkg/assembler/backends/keyvalue/artifact.go b/pkg/assembler/backends/keyvalue/artifact.go index 484b77fe5e3..65bbd93b26e 100644 --- a/pkg/assembler/backends/keyvalue/artifact.go +++ b/pkg/assembler/backends/keyvalue/artifact.go @@ -19,10 +19,12 @@ import ( "context" "errors" "fmt" + "sort" "strings" "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/kv" ) @@ -225,6 +227,117 @@ func (c *demoClient) artifactExact(ctx context.Context, artifactSpec *model.Arti // Query Artifacts +func (c *demoClient) ArtifactsList(ctx context.Context, artifactSpec model.ArtifactSpec, after *string, first *int) (*model.ArtifactConnection, error) { + c.m.RLock() + defer c.m.RUnlock() + aExact, err := c.artifactExact(ctx, &artifactSpec) + if err != nil { + return nil, gqlerror.Errorf("Artifacts :: invalid spec %s", err) + } + if aExact != nil { + return &model.ArtifactConnection{ + TotalCount: 1, + PageInfo: &model.PageInfo{ + HasNextPage: false, + StartCursor: ptrfrom.String(aExact.ID()), + EndCursor: ptrfrom.String(aExact.ID()), + }, + Edges: []*model.ArtifactEdge{{ + Cursor: aExact.ID(), + Node: c.convArtifact(aExact), + }}}, nil + } + + edges := make([]*model.ArtifactEdge, 0) + count := 0 + currentPage := false + + // If no cursor present start from the top + if after == nil { + currentPage = true + } + hasNextPage := false + + algorithm := strings.ToLower(nilToEmpty(artifactSpec.Algorithm)) + digest := strings.ToLower(nilToEmpty(artifactSpec.Digest)) + var done bool + scn := c.kv.Keys(artCol) + var artKeys []string + for !done { + artKeys, done, err = scn.Scan(ctx) + if err != nil { + return nil, err + } + sort.Strings(artKeys) + for i, ak := range artKeys { + a, err := byKeykv[*artStruct](ctx, artCol, ak, c) + if err != nil { + return nil, err + } + convArt := c.convArtifact(a) + if after != nil && !currentPage { + if convArt.ID == *after { + currentPage = true + continue + } else { + continue + } + } + if first != nil { + if currentPage && count < *first { + artEdge := createArtifactEdges(algorithm, a, digest, convArt) + if artEdge != nil { + edges = append(edges, artEdge) + count++ + } + } + // If there are any elements left after the current page we indicate that in the response + if count == *first && i < len(artKeys) { + hasNextPage = true + } + } else { + artEdge := createArtifactEdges(algorithm, a, digest, convArt) + if artEdge != nil { + edges = append(edges, artEdge) + count++ + } + } + } + } + if len(edges) > 0 { + return &model.ArtifactConnection{ + TotalCount: len(artKeys), + PageInfo: &model.PageInfo{ + HasNextPage: hasNextPage, + StartCursor: ptrfrom.String(edges[0].Node.ID), + EndCursor: ptrfrom.String(edges[count-1].Node.ID), + }, + Edges: edges}, nil + } else { + return nil, nil + } +} + +func createArtifactEdges(algorithm string, a *artStruct, digest string, convArt *model.Artifact) *model.ArtifactEdge { + matchAlgorithm := false + if algorithm == "" || algorithm == a.Algorithm { + matchAlgorithm = true + } + + matchDigest := false + if digest == "" || digest == a.Digest { + matchDigest = true + } + + if matchDigest && matchAlgorithm { + return &model.ArtifactEdge{ + Cursor: convArt.ID, + Node: convArt, + } + } + return nil +} + func (c *demoClient) Artifacts(ctx context.Context, artifactSpec *model.ArtifactSpec) ([]*model.Artifact, error) { c.m.RLock() defer c.m.RUnlock() diff --git a/pkg/assembler/backends/keyvalue/builder.go b/pkg/assembler/backends/keyvalue/builder.go index eece28bd06f..d74dd45e512 100644 --- a/pkg/assembler/backends/keyvalue/builder.go +++ b/pkg/assembler/backends/keyvalue/builder.go @@ -18,9 +18,11 @@ package keyvalue import ( "context" "errors" + "sort" "github.com/vektah/gqlparser/v2/gqlerror" + "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/kv" ) @@ -113,6 +115,96 @@ func (c *demoClient) ingestBuilder(ctx context.Context, builder *model.IDorBuild } // Query Builder + +func (c *demoClient) BuildersList(ctx context.Context, builderSpec model.BuilderSpec, after *string, first *int) (*model.BuilderConnection, error) { + c.m.RLock() + defer c.m.RUnlock() + b, err := c.exactBuilder(ctx, &builderSpec) + if err != nil { + return nil, err + } + if b != nil { + exactBuilder := c.convBuilder(b) + return &model.BuilderConnection{ + TotalCount: 1, + PageInfo: &model.PageInfo{ + HasNextPage: false, + StartCursor: ptrfrom.String(exactBuilder.ID), + EndCursor: ptrfrom.String(exactBuilder.ID), + }, + Edges: []*model.BuilderEdge{{ + Cursor: exactBuilder.ID, + Node: exactBuilder, + }}}, nil + } + edges := make([]*model.BuilderEdge, 0) + count := 0 + currentPage := false + + // If no cursor present start from the top + if after == nil { + currentPage = true + } + hasNextPage := false + var done bool + + scn := c.kv.Keys(builderCol) + var bKeys []string + for !done { + bKeys, done, err = scn.Scan(ctx) + if err != nil { + return nil, err + } + sort.Strings(bKeys) + for i, bk := range bKeys { + b, err := byKeykv[*builderStruct](ctx, builderCol, bk, c) + if err != nil { + return nil, err + } + convBuild := c.convBuilder(b) + if after != nil && !currentPage { + if convBuild.ID == *after { + currentPage = true + continue + } else { + continue + } + } + if first != nil { + if currentPage && count < *first { + edges = append(edges, &model.BuilderEdge{ + Cursor: convBuild.ID, + Node: convBuild, + }) + count++ + } + // If there are any elements left after the current page we indicate that in the response + if count == *first && i < len(bKeys) { + hasNextPage = true + } + } else { + edges = append(edges, &model.BuilderEdge{ + Cursor: convBuild.ID, + Node: convBuild, + }) + count++ + } + } + } + if len(edges) > 0 { + return &model.BuilderConnection{ + TotalCount: len(bKeys), + PageInfo: &model.PageInfo{ + HasNextPage: hasNextPage, + StartCursor: ptrfrom.String(edges[0].Node.ID), + EndCursor: ptrfrom.String(edges[count-1].Node.ID), + }, + Edges: edges}, nil + } else { + return nil, nil + } +} + func (c *demoClient) Builders(ctx context.Context, builderSpec *model.BuilderSpec) ([]*model.Builder, error) { c.m.RLock() defer c.m.RUnlock() diff --git a/pkg/assembler/backends/keyvalue/certifyBad.go b/pkg/assembler/backends/keyvalue/certifyBad.go index 51001f4eae4..dbb79902eb7 100644 --- a/pkg/assembler/backends/keyvalue/certifyBad.go +++ b/pkg/assembler/backends/keyvalue/certifyBad.go @@ -18,6 +18,7 @@ package keyvalue import ( "context" "errors" + "fmt" "strings" "time" @@ -189,6 +190,11 @@ func (c *demoClient) ingestCertifyBad(ctx context.Context, subject model.Package } // Query CertifyBad + +func (c *demoClient) CertifyBadList(ctx context.Context, certifyBadSpec model.CertifyBadSpec, after *string, first *int) (*model.CertifyBadConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyBadList") +} + func (c *demoClient) CertifyBad(ctx context.Context, filter *model.CertifyBadSpec) ([]*model.CertifyBad, error) { funcName := "CertifyBad" diff --git a/pkg/assembler/backends/keyvalue/certifyGood.go b/pkg/assembler/backends/keyvalue/certifyGood.go index d9261794985..4179e8e8e6e 100644 --- a/pkg/assembler/backends/keyvalue/certifyGood.go +++ b/pkg/assembler/backends/keyvalue/certifyGood.go @@ -18,6 +18,7 @@ package keyvalue import ( "context" "errors" + "fmt" "strings" "time" @@ -188,6 +189,11 @@ func (c *demoClient) ingestCertifyGood(ctx context.Context, subject model.Packag } // Query CertifyGood + +func (c *demoClient) CertifyGoodList(ctx context.Context, certifyGoodSpec model.CertifyGoodSpec, after *string, first *int) (*model.CertifyGoodConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyGoodList") +} + func (c *demoClient) CertifyGood(ctx context.Context, filter *model.CertifyGoodSpec) ([]*model.CertifyGood, error) { funcName := "CertifyGood" diff --git a/pkg/assembler/backends/keyvalue/certifyLegal.go b/pkg/assembler/backends/keyvalue/certifyLegal.go index 4896887d825..8e3811ae051 100644 --- a/pkg/assembler/backends/keyvalue/certifyLegal.go +++ b/pkg/assembler/backends/keyvalue/certifyLegal.go @@ -265,6 +265,10 @@ func (c *demoClient) convLegal(ctx context.Context, in *certifyLegalStruct) (*mo return cl, nil } +func (c *demoClient) CertifyLegalList(ctx context.Context, certifyLegalSpec model.CertifyLegalSpec, after *string, first *int) (*model.CertifyLegalConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyLegalList") +} + func (c *demoClient) CertifyLegal(ctx context.Context, filter *model.CertifyLegalSpec) ([]*model.CertifyLegal, error) { funcName := "CertifyLegal" diff --git a/pkg/assembler/backends/keyvalue/certifyScorecard.go b/pkg/assembler/backends/keyvalue/certifyScorecard.go index d52c2b25328..8b5c6fb72f8 100644 --- a/pkg/assembler/backends/keyvalue/certifyScorecard.go +++ b/pkg/assembler/backends/keyvalue/certifyScorecard.go @@ -142,6 +142,11 @@ func (c *demoClient) certifyScorecard(ctx context.Context, source model.IDorSour } // Query CertifyScorecard + +func (c *demoClient) ScorecardsList(ctx context.Context, scorecardSpec model.CertifyScorecardSpec, after *string, first *int) (*model.CertifyScorecardConnection, error) { + return nil, fmt.Errorf("not implemented: ScorecardsList") +} + func (c *demoClient) Scorecards(ctx context.Context, filter *model.CertifyScorecardSpec) ([]*model.CertifyScorecard, error) { c.m.RLock() defer c.m.RUnlock() diff --git a/pkg/assembler/backends/keyvalue/certifyVEXStatement.go b/pkg/assembler/backends/keyvalue/certifyVEXStatement.go index 5c063534f37..41766d96dab 100644 --- a/pkg/assembler/backends/keyvalue/certifyVEXStatement.go +++ b/pkg/assembler/backends/keyvalue/certifyVEXStatement.go @@ -18,6 +18,7 @@ package keyvalue import ( "context" "errors" + "fmt" "strings" "time" @@ -191,6 +192,11 @@ func (c *demoClient) ingestVEXStatement(ctx context.Context, subject model.Packa } // Query CertifyVex + +func (c *demoClient) CertifyVEXStatementList(ctx context.Context, certifyVEXStatementSpec model.CertifyVEXStatementSpec, after *string, first *int) (*model.VEXConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyVEXStatementList") +} + func (c *demoClient) CertifyVEXStatement(ctx context.Context, filter *model.CertifyVEXStatementSpec) ([]*model.CertifyVEXStatement, error) { c.m.RLock() defer c.m.RUnlock() diff --git a/pkg/assembler/backends/keyvalue/certifyVuln.go b/pkg/assembler/backends/keyvalue/certifyVuln.go index 2302cb4fe8d..2ad332b842a 100644 --- a/pkg/assembler/backends/keyvalue/certifyVuln.go +++ b/pkg/assembler/backends/keyvalue/certifyVuln.go @@ -18,6 +18,7 @@ package keyvalue import ( "context" "errors" + "fmt" "reflect" "strings" "time" @@ -155,6 +156,11 @@ func (c *demoClient) ingestVulnerability(ctx context.Context, packageArg model.I } // Query CertifyVuln + +func (c *demoClient) CertifyVulnList(ctx context.Context, certifyVulnSpec model.CertifyVulnSpec, after *string, first *int) (*model.CertifyVulnConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyVulnList") +} + func (c *demoClient) CertifyVuln(ctx context.Context, filter *model.CertifyVulnSpec) ([]*model.CertifyVuln, error) { c.m.RLock() defer c.m.RUnlock() diff --git a/pkg/assembler/backends/keyvalue/hasMetadata.go b/pkg/assembler/backends/keyvalue/hasMetadata.go index 5f3713d042f..bf4c6232192 100644 --- a/pkg/assembler/backends/keyvalue/hasMetadata.go +++ b/pkg/assembler/backends/keyvalue/hasMetadata.go @@ -18,6 +18,7 @@ package keyvalue import ( "context" "errors" + "fmt" "strings" "time" @@ -198,6 +199,11 @@ func (c *demoClient) ingestHasMetadata(ctx context.Context, subject model.Packag } // Query HasMetadata + +func (c *demoClient) HasMetadataList(ctx context.Context, hasMetadataSpec model.HasMetadataSpec, after *string, first *int) (*model.HasMetadataConnection, error) { + return nil, fmt.Errorf("not implemented: HasMetadataList") +} + func (c *demoClient) HasMetadata(ctx context.Context, filter *model.HasMetadataSpec) ([]*model.HasMetadata, error) { funcName := "HasMetadata" diff --git a/pkg/assembler/backends/keyvalue/hasSBOM.go b/pkg/assembler/backends/keyvalue/hasSBOM.go index b55ea22c2c6..7228c6ef490 100644 --- a/pkg/assembler/backends/keyvalue/hasSBOM.go +++ b/pkg/assembler/backends/keyvalue/hasSBOM.go @@ -321,6 +321,10 @@ func (c *demoClient) convHasSBOM(ctx context.Context, in *hasSBOMStruct) (*model // Query HasSBOM +func (c *demoClient) HasSBOMList(ctx context.Context, hasSBOMSpec model.HasSBOMSpec, after *string, first *int) (*model.HasSBOMConnection, error) { + return nil, fmt.Errorf("not implemented: HasSBOMList") +} + func (c *demoClient) HasSBOM(ctx context.Context, filter *model.HasSBOMSpec) ([]*model.HasSbom, error) { funcName := "HasSBOM" c.m.RLock() diff --git a/pkg/assembler/backends/keyvalue/hasSLSA.go b/pkg/assembler/backends/keyvalue/hasSLSA.go index 411eb2f0f60..b7e6a679f67 100644 --- a/pkg/assembler/backends/keyvalue/hasSLSA.go +++ b/pkg/assembler/backends/keyvalue/hasSLSA.go @@ -91,6 +91,10 @@ func (n *hasSLSAStruct) BuildModelNode(ctx context.Context, c *demoClient) (mode // Query HasSlsa +func (c *demoClient) HasSLSAList(ctx context.Context, hasSLSASpec model.HasSLSASpec, after *string, first *int) (*model.HasSLSAConnection, error) { + return nil, fmt.Errorf("not implemented: HasSLSAList") +} + func (c *demoClient) HasSlsa(ctx context.Context, filter *model.HasSLSASpec) ([]*model.HasSlsa, error) { funcName := "HasSlsa" c.m.RLock() diff --git a/pkg/assembler/backends/keyvalue/hasSourceAt.go b/pkg/assembler/backends/keyvalue/hasSourceAt.go index 3aae162bc3c..bc687da60e9 100644 --- a/pkg/assembler/backends/keyvalue/hasSourceAt.go +++ b/pkg/assembler/backends/keyvalue/hasSourceAt.go @@ -18,6 +18,7 @@ package keyvalue import ( "context" "errors" + "fmt" "strings" "time" @@ -148,6 +149,11 @@ func (c *demoClient) ingestHasSourceAt(ctx context.Context, packageArg model.IDo } // Query HasSourceAt + +func (c *demoClient) HasSourceAtList(ctx context.Context, hasSourceAtSpec model.HasSourceAtSpec, after *string, first *int) (*model.HasSourceAtConnection, error) { + return nil, fmt.Errorf("not implemented: HasSourceAtList") +} + func (c *demoClient) HasSourceAt(ctx context.Context, filter *model.HasSourceAtSpec) ([]*model.HasSourceAt, error) { c.m.RLock() defer c.m.RUnlock() diff --git a/pkg/assembler/backends/keyvalue/hashEqual.go b/pkg/assembler/backends/keyvalue/hashEqual.go index e899d484c1e..76a09a97d67 100644 --- a/pkg/assembler/backends/keyvalue/hashEqual.go +++ b/pkg/assembler/backends/keyvalue/hashEqual.go @@ -183,6 +183,10 @@ func (c *demoClient) matchArtifacts(ctx context.Context, filter []*model.Artifac // Query HashEqual +func (c *demoClient) HashEqualList(ctx context.Context, hashEqualSpec model.HashEqualSpec, after *string, first *int) (*model.HashEqualConnection, error) { + return nil, fmt.Errorf("not implemented: HashEqualList") +} + func (c *demoClient) HashEqual(ctx context.Context, filter *model.HashEqualSpec) ([]*model.HashEqual, error) { funcName := "HashEqual" c.m.RLock() diff --git a/pkg/assembler/backends/keyvalue/isDependency.go b/pkg/assembler/backends/keyvalue/isDependency.go index 193c649f44d..e7f5909ae19 100644 --- a/pkg/assembler/backends/keyvalue/isDependency.go +++ b/pkg/assembler/backends/keyvalue/isDependency.go @@ -18,6 +18,7 @@ package keyvalue import ( "context" "errors" + "fmt" "strings" "github.com/vektah/gqlparser/v2/gqlerror" @@ -149,6 +150,11 @@ func (c *demoClient) ingestDependency(ctx context.Context, packageArg model.IDor } // Query IsDependency + +func (c *demoClient) IsDependencyList(ctx context.Context, isDependencySpec model.IsDependencySpec, after *string, first *int) (*model.IsDependencyConnection, error) { + return nil, fmt.Errorf("not implemented: IsDependencyList") +} + func (c *demoClient) IsDependency(ctx context.Context, filter *model.IsDependencySpec) ([]*model.IsDependency, error) { c.m.RLock() defer c.m.RUnlock() diff --git a/pkg/assembler/backends/keyvalue/isOccurrence.go b/pkg/assembler/backends/keyvalue/isOccurrence.go index fe94b488feb..551f1e04d76 100644 --- a/pkg/assembler/backends/keyvalue/isOccurrence.go +++ b/pkg/assembler/backends/keyvalue/isOccurrence.go @@ -18,6 +18,7 @@ package keyvalue import ( "context" "errors" + "fmt" "strings" "github.com/vektah/gqlparser/v2/gqlerror" @@ -235,6 +236,10 @@ func (c *demoClient) artifactMatch(ctx context.Context, aID string, artifactSpec // Query IsOccurrence +func (c *demoClient) IsOccurrenceList(ctx context.Context, isOccurrenceSpec model.IsOccurrenceSpec, after *string, first *int) (*model.IsOccurrenceConnection, error) { + return nil, fmt.Errorf("not implemented: IsOccurrenceList") +} + func (c *demoClient) IsOccurrence(ctx context.Context, filter *model.IsOccurrenceSpec) ([]*model.IsOccurrence, error) { funcName := "IsOccurrence" diff --git a/pkg/assembler/backends/keyvalue/license.go b/pkg/assembler/backends/keyvalue/license.go index 722e034c618..8d6b197cf13 100644 --- a/pkg/assembler/backends/keyvalue/license.go +++ b/pkg/assembler/backends/keyvalue/license.go @@ -18,6 +18,7 @@ package keyvalue import ( "context" "errors" + "fmt" "strings" "github.com/vektah/gqlparser/v2/gqlerror" @@ -157,6 +158,10 @@ func (c *demoClient) licenseExact(ctx context.Context, licenseSpec *model.Licens // Query Licenses +func (c *demoClient) LicenseList(ctx context.Context, licenseSpec model.LicenseSpec, after *string, first *int) (*model.LicenseConnection, error) { + return nil, fmt.Errorf("not implemented: LicenseList") +} + func (c *demoClient) Licenses(ctx context.Context, licenseSpec *model.LicenseSpec) ([]*model.License, error) { c.m.RLock() defer c.m.RUnlock() diff --git a/pkg/assembler/backends/keyvalue/path.go b/pkg/assembler/backends/keyvalue/path.go index 355431c2964..5b12dd6364a 100644 --- a/pkg/assembler/backends/keyvalue/path.go +++ b/pkg/assembler/backends/keyvalue/path.go @@ -45,6 +45,10 @@ func (c *demoClient) Path(ctx context.Context, source string, target string, max return c.bfs(ctx, source, target, maxPathLength, processUsingOnly(usingOnly)) } +func (c *demoClient) NeighborsList(ctx context.Context, node string, usingOnly []model.Edge, after *string, first *int) (*model.NeighborConnection, error) { + return nil, fmt.Errorf("not implemented: NeighborsList") +} + func (c *demoClient) Neighbors(ctx context.Context, source string, usingOnly []model.Edge) ([]model.Node, error) { c.m.RLock() neighbors, err := c.neighborsFromId(ctx, source, processUsingOnly(usingOnly)) diff --git a/pkg/assembler/backends/keyvalue/pkg.go b/pkg/assembler/backends/keyvalue/pkg.go index c3814213b82..ea126fe06f3 100644 --- a/pkg/assembler/backends/keyvalue/pkg.go +++ b/pkg/assembler/backends/keyvalue/pkg.go @@ -521,6 +521,11 @@ func hashVersionHelper(version string, subpath string, qualifiers map[string]str } // Query Package + +func (c *demoClient) PackagesList(ctx context.Context, pkgSpec model.PkgSpec, after *string, first *int) (*model.PackageConnection, error) { + return nil, fmt.Errorf("not implemented: PackagesList") +} + func (c *demoClient) Packages(ctx context.Context, filter *model.PkgSpec) ([]*model.Package, error) { c.m.RLock() defer c.m.RUnlock() diff --git a/pkg/assembler/backends/keyvalue/pkgEqual.go b/pkg/assembler/backends/keyvalue/pkgEqual.go index 70dfe3e6171..404cc2be826 100644 --- a/pkg/assembler/backends/keyvalue/pkgEqual.go +++ b/pkg/assembler/backends/keyvalue/pkgEqual.go @@ -153,6 +153,10 @@ func (c *demoClient) ingestPkgEqual(ctx context.Context, pkg model.IDorPkgInput, // Query PkgEqual +func (c *demoClient) PkgEqualList(ctx context.Context, pkgEqualSpec model.PkgEqualSpec, after *string, first *int) (*model.PkgEqualConnection, error) { + return nil, fmt.Errorf("not implemented: PkgEqualList") +} + func (c *demoClient) PkgEqual(ctx context.Context, filter *model.PkgEqualSpec) ([]*model.PkgEqual, error) { funcName := "PkgEqual" c.m.RLock() diff --git a/pkg/assembler/backends/keyvalue/pointOfContact.go b/pkg/assembler/backends/keyvalue/pointOfContact.go index cc2c60895b6..1dda7e3e4a2 100644 --- a/pkg/assembler/backends/keyvalue/pointOfContact.go +++ b/pkg/assembler/backends/keyvalue/pointOfContact.go @@ -18,6 +18,7 @@ package keyvalue import ( "context" "errors" + "fmt" "strings" "time" @@ -196,6 +197,11 @@ func (c *demoClient) ingestPointOfContact(ctx context.Context, subject model.Pac } // Query PointOfContact + +func (c *demoClient) PointOfContactList(ctx context.Context, pointOfContactSpec model.PointOfContactSpec, after *string, first *int) (*model.PointOfContactConnection, error) { + return nil, fmt.Errorf("not implemented: PointOfContactList") +} + func (c *demoClient) PointOfContact(ctx context.Context, filter *model.PointOfContactSpec) ([]*model.PointOfContact, error) { funcName := "PointOfContact" diff --git a/pkg/assembler/backends/keyvalue/search.go b/pkg/assembler/backends/keyvalue/search.go index d040e6c9ee7..40daf0b26c2 100644 --- a/pkg/assembler/backends/keyvalue/search.go +++ b/pkg/assembler/backends/keyvalue/search.go @@ -23,6 +23,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +func (c *demoClient) FindSoftwareList(ctx context.Context, searchText string, after *string, first *int) (*model.FindSoftwareConnection, error) { + return nil, fmt.Errorf("not implemented: FindSoftwareList") +} + func (c *demoClient) FindSoftware(ctx context.Context, searchText string) ([]model.PackageSourceOrArtifact, error) { scanner := c.kv.Keys("artifacts") var res []model.PackageSourceOrArtifact diff --git a/pkg/assembler/backends/keyvalue/src.go b/pkg/assembler/backends/keyvalue/src.go index 57b42a30ad4..caa2d011d5c 100644 --- a/pkg/assembler/backends/keyvalue/src.go +++ b/pkg/assembler/backends/keyvalue/src.go @@ -311,6 +311,10 @@ func (c *demoClient) IngestSource(ctx context.Context, input model.IDorSourceInp // Query Source +func (c *demoClient) SourcesList(ctx context.Context, sourceSpec model.SourceSpec, after *string, first *int) (*model.SourceConnection, error) { + return nil, fmt.Errorf("not implemented: SourcesList") +} + func (c *demoClient) Sources(ctx context.Context, filter *model.SourceSpec) ([]*model.Source, error) { c.m.RLock() defer c.m.RUnlock() diff --git a/pkg/assembler/backends/keyvalue/vulnEqual.go b/pkg/assembler/backends/keyvalue/vulnEqual.go index 13ce5432e89..683639ea6b2 100644 --- a/pkg/assembler/backends/keyvalue/vulnEqual.go +++ b/pkg/assembler/backends/keyvalue/vulnEqual.go @@ -153,6 +153,11 @@ func (c *demoClient) convVulnEqual(ctx context.Context, in *vulnerabilityEqualLi } // Query VulnEqual + +func (c *demoClient) VulnEqualList(ctx context.Context, vulnEqualSpec model.VulnEqualSpec, after *string, first *int) (*model.VulnEqualConnection, error) { + return nil, fmt.Errorf("not implemented: VulnEqualList") +} + func (c *demoClient) VulnEqual(ctx context.Context, filter *model.VulnEqualSpec) ([]*model.VulnEqual, error) { funcName := "VulnEqual" c.m.RLock() diff --git a/pkg/assembler/backends/keyvalue/vulnMetadata.go b/pkg/assembler/backends/keyvalue/vulnMetadata.go index 7d0ae0ce11e..7145ce1a04e 100644 --- a/pkg/assembler/backends/keyvalue/vulnMetadata.go +++ b/pkg/assembler/backends/keyvalue/vulnMetadata.go @@ -131,6 +131,11 @@ func (c *demoClient) ingestVulnerabilityMetadata(ctx context.Context, vulnerabil } // Query VulnerabilityMetadata + +func (c *demoClient) VulnerabilityMetadataList(ctx context.Context, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec, after *string, first *int) (*model.VulnerabilityMetadataConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyBadList") +} + func (c *demoClient) VulnerabilityMetadata(ctx context.Context, filter *model.VulnerabilityMetadataSpec) ([]*model.VulnerabilityMetadata, error) { c.m.RLock() defer c.m.RUnlock() diff --git a/pkg/assembler/backends/keyvalue/vulnerability.go b/pkg/assembler/backends/keyvalue/vulnerability.go index 40b7e90ecf9..91b5ae7a13e 100644 --- a/pkg/assembler/backends/keyvalue/vulnerability.go +++ b/pkg/assembler/backends/keyvalue/vulnerability.go @@ -213,6 +213,11 @@ func (c *demoClient) IngestVulnerability(ctx context.Context, input model.IDorVu } // Query Vulnerabilities + +func (c *demoClient) VulnerabilityList(ctx context.Context, vulnSpec model.VulnerabilitySpec, after *string, first *int) (*model.VulnerabilityConnection, error) { + return nil, fmt.Errorf("not implemented: VulnerabilityList") +} + func (c *demoClient) Vulnerabilities(ctx context.Context, filter *model.VulnerabilitySpec) ([]*model.Vulnerability, error) { c.m.RLock() defer c.m.RUnlock() diff --git a/pkg/assembler/backends/neo4j/artifact.go b/pkg/assembler/backends/neo4j/artifact.go index a0117ef47d4..6890d98a728 100644 --- a/pkg/assembler/backends/neo4j/artifact.go +++ b/pkg/assembler/backends/neo4j/artifact.go @@ -139,3 +139,7 @@ func generateModelArtifact(algorithm, digest string) *model.Artifact { } return &artifact } + +func (c *neo4jClient) ArtifactsList(ctx context.Context, artifactSpec model.ArtifactSpec, after *string, first *int) (*model.ArtifactConnection, error) { + return nil, fmt.Errorf("not implemented: ArtifactsList") +} diff --git a/pkg/assembler/backends/neo4j/backend.go b/pkg/assembler/backends/neo4j/backend.go index cbb40ab0952..e5f9a053e8d 100644 --- a/pkg/assembler/backends/neo4j/backend.go +++ b/pkg/assembler/backends/neo4j/backend.go @@ -166,12 +166,22 @@ func getPreloadString(prefix, name string) string { func (c *neo4jClient) Licenses(ctx context.Context, licenseSpec *model.LicenseSpec) ([]*model.License, error) { panic(fmt.Errorf("not implemented: Licenses")) } + +func (c *neo4jClient) LicenseList(ctx context.Context, licenseSpec model.LicenseSpec, after *string, first *int) (*model.LicenseConnection, error) { + panic(fmt.Errorf("not implemented: LicenseList")) +} + func (c *neo4jClient) IngestLicense(ctx context.Context, license *model.IDorLicenseInput) (string, error) { panic(fmt.Errorf("not implemented: IngestLicense")) } func (c *neo4jClient) IngestLicenses(ctx context.Context, licenses []*model.IDorLicenseInput) ([]string, error) { panic(fmt.Errorf("not implemented: IngestLicenses")) } + +func (c *neo4jClient) CertifyLegalList(ctx context.Context, certifyLegalSpec model.CertifyLegalSpec, after *string, first *int) (*model.CertifyLegalConnection, error) { + panic(fmt.Errorf("not implemented: CertifyLegalList")) +} + func (c *neo4jClient) CertifyLegal(ctx context.Context, certifyLegalSpec *model.CertifyLegalSpec) ([]*model.CertifyLegal, error) { panic(fmt.Errorf("not implemented: CertifyLegal")) } diff --git a/pkg/assembler/backends/neo4j/builder.go b/pkg/assembler/backends/neo4j/builder.go index d0927e732ce..6b5689dfea8 100644 --- a/pkg/assembler/backends/neo4j/builder.go +++ b/pkg/assembler/backends/neo4j/builder.go @@ -23,6 +23,10 @@ import ( "github.com/neo4j/neo4j-go-driver/v4/neo4j" ) +func (c *neo4jClient) BuildersList(ctx context.Context, builderSpec model.BuilderSpec, after *string, first *int) (*model.BuilderConnection, error) { + return nil, fmt.Errorf("not implemented: BuildersList") +} + func (c *neo4jClient) Builders(ctx context.Context, builderSpec *model.BuilderSpec) ([]*model.Builder, error) { session := c.driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeRead}) defer session.Close() diff --git a/pkg/assembler/backends/neo4j/certifyBad.go b/pkg/assembler/backends/neo4j/certifyBad.go index 617257e1bb3..20cfdadf0a2 100644 --- a/pkg/assembler/backends/neo4j/certifyBad.go +++ b/pkg/assembler/backends/neo4j/certifyBad.go @@ -28,6 +28,10 @@ import ( // query certifyBad +func (c *neo4jClient) CertifyBadList(ctx context.Context, certifyBadSpec model.CertifyBadSpec, after *string, first *int) (*model.CertifyBadConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyBadList") +} + func (c *neo4jClient) CertifyBad(ctx context.Context, certifyBadSpec *model.CertifyBadSpec) ([]*model.CertifyBad, error) { session := c.driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeRead}) defer session.Close() diff --git a/pkg/assembler/backends/neo4j/certifyGood.go b/pkg/assembler/backends/neo4j/certifyGood.go index 1423dcef1e4..65f7b0744ba 100644 --- a/pkg/assembler/backends/neo4j/certifyGood.go +++ b/pkg/assembler/backends/neo4j/certifyGood.go @@ -28,6 +28,10 @@ import ( // query certifyGood +func (c *neo4jClient) CertifyGoodList(ctx context.Context, certifyGoodSpec model.CertifyGoodSpec, after *string, first *int) (*model.CertifyGoodConnection, error) { + return nil, fmt.Errorf("not implemented: BuildersList") +} + func (c *neo4jClient) CertifyGood(ctx context.Context, certifyGoodSpec *model.CertifyGoodSpec) ([]*model.CertifyGood, error) { session := c.driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeRead}) defer session.Close() diff --git a/pkg/assembler/backends/neo4j/certifyScorecard.go b/pkg/assembler/backends/neo4j/certifyScorecard.go index 7342534f9b8..9276d35a4c2 100644 --- a/pkg/assembler/backends/neo4j/certifyScorecard.go +++ b/pkg/assembler/backends/neo4j/certifyScorecard.go @@ -39,6 +39,10 @@ const ( // Query Scorecards +func (c *neo4jClient) ScorecardsList(ctx context.Context, scorecardSpec model.CertifyScorecardSpec, after *string, first *int) (*model.CertifyScorecardConnection, error) { + return nil, fmt.Errorf("not implemented: BuildersList") +} + func (c *neo4jClient) Scorecards(ctx context.Context, certifyScorecardSpec *model.CertifyScorecardSpec) ([]*model.CertifyScorecard, error) { session := c.driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeRead}) defer session.Close() diff --git a/pkg/assembler/backends/neo4j/certifyVEXStatement.go b/pkg/assembler/backends/neo4j/certifyVEXStatement.go index c0f5d5fa07b..76af6e88a40 100644 --- a/pkg/assembler/backends/neo4j/certifyVEXStatement.go +++ b/pkg/assembler/backends/neo4j/certifyVEXStatement.go @@ -22,6 +22,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +func (c *neo4jClient) CertifyVEXStatementList(ctx context.Context, certifyVEXStatementSpec model.CertifyVEXStatementSpec, after *string, first *int) (*model.VEXConnection, error) { + return nil, fmt.Errorf("not implemented: BuildersList") +} + // TODO (pxp928): fix for new vulnerability func (c *neo4jClient) CertifyVEXStatement(ctx context.Context, certifyVEXStatementSpec *model.CertifyVEXStatementSpec) ([]*model.CertifyVEXStatement, error) { diff --git a/pkg/assembler/backends/neo4j/certifyVuln.go b/pkg/assembler/backends/neo4j/certifyVuln.go index 178e11777c2..8cea267557b 100644 --- a/pkg/assembler/backends/neo4j/certifyVuln.go +++ b/pkg/assembler/backends/neo4j/certifyVuln.go @@ -31,6 +31,10 @@ const ( // Query CertifyVuln +func (c *neo4jClient) CertifyVulnList(ctx context.Context, certifyVulnSpec model.CertifyVulnSpec, after *string, first *int) (*model.CertifyVulnConnection, error) { + return nil, fmt.Errorf("not implemented: CertifyVulnList") +} + // TODO (pxp928): fix for new vulnerability func (c *neo4jClient) CertifyVuln(ctx context.Context, certifyVulnSpec *model.CertifyVulnSpec) ([]*model.CertifyVuln, error) { diff --git a/pkg/assembler/backends/neo4j/contact.go b/pkg/assembler/backends/neo4j/contact.go index 84d35ad4efd..560099e7c02 100644 --- a/pkg/assembler/backends/neo4j/contact.go +++ b/pkg/assembler/backends/neo4j/contact.go @@ -22,6 +22,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +func (c *neo4jClient) PointOfContactList(ctx context.Context, pointOfContactSpec model.PointOfContactSpec, after *string, first *int) (*model.PointOfContactConnection, error) { + return nil, fmt.Errorf("not implemented: PointOfContactList") +} + func (c *neo4jClient) IngestPointOfContact(ctx context.Context, subject model.PackageSourceOrArtifactInput, pkgMatchType *model.MatchFlags, pointOfContact model.PointOfContactInputSpec) (string, error) { return "", fmt.Errorf("not implemented: IngestPointOfContact") } diff --git a/pkg/assembler/backends/neo4j/hasMetadata.go b/pkg/assembler/backends/neo4j/hasMetadata.go index 15f4d9b0f84..3e8219a8870 100644 --- a/pkg/assembler/backends/neo4j/hasMetadata.go +++ b/pkg/assembler/backends/neo4j/hasMetadata.go @@ -22,6 +22,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +func (c *neo4jClient) HasMetadataList(ctx context.Context, hasMetadataSpec model.HasMetadataSpec, after *string, first *int) (*model.HasMetadataConnection, error) { + return nil, fmt.Errorf("not implemented: HasMetadataList") +} + func (c *neo4jClient) IngestHasMetadata(ctx context.Context, subject model.PackageSourceOrArtifactInput, pkgMatchType *model.MatchFlags, hasMetadata model.HasMetadataInputSpec) (string, error) { return "", fmt.Errorf("not implemented: IngestHasMetadata") } diff --git a/pkg/assembler/backends/neo4j/hasSBOM.go b/pkg/assembler/backends/neo4j/hasSBOM.go index 2003165f583..4e999a9c526 100644 --- a/pkg/assembler/backends/neo4j/hasSBOM.go +++ b/pkg/assembler/backends/neo4j/hasSBOM.go @@ -30,6 +30,10 @@ const ( uri string = "uri" ) +func (c *neo4jClient) HasSBOMList(ctx context.Context, hasSBOMSpec model.HasSBOMSpec, after *string, first *int) (*model.HasSBOMConnection, error) { + return nil, fmt.Errorf("not implemented: HasSBOMList") +} + // TODO: noe4j backend does not match the schema. This needs updating before use! func (c *neo4jClient) HasSBOM(ctx context.Context, hasSBOMSpec *model.HasSBOMSpec) ([]*model.HasSbom, error) { diff --git a/pkg/assembler/backends/neo4j/hasSLSA.go b/pkg/assembler/backends/neo4j/hasSLSA.go index 3f46e540089..f9bba78861d 100644 --- a/pkg/assembler/backends/neo4j/hasSLSA.go +++ b/pkg/assembler/backends/neo4j/hasSLSA.go @@ -30,6 +30,10 @@ const ( finishedOn string = "finishedOn" ) +func (c *neo4jClient) HasSLSAList(ctx context.Context, hasSLSASpec model.HasSLSASpec, after *string, first *int) (*model.HasSLSAConnection, error) { + return nil, fmt.Errorf("not implemented: HasSLSAList") +} + func (c *neo4jClient) HasSlsa(ctx context.Context, hasSLSASpec *model.HasSLSASpec) ([]*model.HasSlsa, error) { // TODO update to not use PackageSourceOrArtifact // session := c.driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeRead}) diff --git a/pkg/assembler/backends/neo4j/hasSourceAt.go b/pkg/assembler/backends/neo4j/hasSourceAt.go index d1d76df3c2a..f078df2af94 100644 --- a/pkg/assembler/backends/neo4j/hasSourceAt.go +++ b/pkg/assembler/backends/neo4j/hasSourceAt.go @@ -31,6 +31,10 @@ const ( knownSince string = "knownSince" ) +func (c *neo4jClient) HasSourceAtList(ctx context.Context, hasSourceAtSpec model.HasSourceAtSpec, after *string, first *int) (*model.HasSourceAtConnection, error) { + return nil, fmt.Errorf("not implemented: HasSourceAtList") +} + func (c *neo4jClient) HasSourceAt(ctx context.Context, hasSourceAtSpec *model.HasSourceAtSpec) ([]*model.HasSourceAt, error) { session := c.driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeRead}) defer session.Close() diff --git a/pkg/assembler/backends/neo4j/hashEqual.go b/pkg/assembler/backends/neo4j/hashEqual.go index 3e5cff95bbb..3a0fab5c6cc 100644 --- a/pkg/assembler/backends/neo4j/hashEqual.go +++ b/pkg/assembler/backends/neo4j/hashEqual.go @@ -26,6 +26,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (c *neo4jClient) HashEqualList(ctx context.Context, hashEqualSpec model.HashEqualSpec, after *string, first *int) (*model.HashEqualConnection, error) { + return nil, fmt.Errorf("not implemented: HashEqualList") +} + func (c *neo4jClient) HashEqual(ctx context.Context, hashEqualSpec *model.HashEqualSpec) ([]*model.HashEqual, error) { session := c.driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeRead}) diff --git a/pkg/assembler/backends/neo4j/isDependency.go b/pkg/assembler/backends/neo4j/isDependency.go index e3b476c200d..395a84fca14 100644 --- a/pkg/assembler/backends/neo4j/isDependency.go +++ b/pkg/assembler/backends/neo4j/isDependency.go @@ -34,6 +34,10 @@ const ( // Query IsDependency +func (c *neo4jClient) IsDependencyList(ctx context.Context, isDependencySpec model.IsDependencySpec, after *string, first *int) (*model.IsDependencyConnection, error) { + return nil, fmt.Errorf("not implemented: IsDependencyList") +} + func (c *neo4jClient) IsDependency(ctx context.Context, isDependencySpec *model.IsDependencySpec) ([]*model.IsDependency, error) { session := c.driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeRead}) defer session.Close() diff --git a/pkg/assembler/backends/neo4j/isOccurrence.go b/pkg/assembler/backends/neo4j/isOccurrence.go index e0309fc40fb..aa912b0a789 100644 --- a/pkg/assembler/backends/neo4j/isOccurrence.go +++ b/pkg/assembler/backends/neo4j/isOccurrence.go @@ -29,6 +29,10 @@ import ( // Query IsOccurrence +func (c *neo4jClient) IsOccurrenceList(ctx context.Context, isOccurrenceSpec model.IsOccurrenceSpec, after *string, first *int) (*model.IsOccurrenceConnection, error) { + return nil, fmt.Errorf("not implemented: IsOccurrenceList") +} + func (c *neo4jClient) IsOccurrence(ctx context.Context, isOccurrenceSpec *model.IsOccurrenceSpec) ([]*model.IsOccurrence, error) { session := c.driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeRead}) diff --git a/pkg/assembler/backends/neo4j/path.go b/pkg/assembler/backends/neo4j/path.go index 427be5de31e..cb6492a4c9e 100644 --- a/pkg/assembler/backends/neo4j/path.go +++ b/pkg/assembler/backends/neo4j/path.go @@ -26,6 +26,10 @@ func (c *neo4jClient) Path(ctx context.Context, subject string, target string, m panic(fmt.Errorf("not implemented: Path - path")) } +func (c *neo4jClient) NeighborsList(ctx context.Context, node string, usingOnly []model.Edge, after *string, first *int) (*model.NeighborConnection, error) { + return nil, fmt.Errorf("not implemented: NeighborsList") +} + func (c *neo4jClient) Neighbors(ctx context.Context, node string, usingOnly []model.Edge) ([]model.Node, error) { panic(fmt.Errorf("not implemented: Neighbors - neighbors")) } diff --git a/pkg/assembler/backends/neo4j/pkg.go b/pkg/assembler/backends/neo4j/pkg.go index 2f59db9d386..b7375951de0 100644 --- a/pkg/assembler/backends/neo4j/pkg.go +++ b/pkg/assembler/backends/neo4j/pkg.go @@ -25,6 +25,10 @@ import ( "github.com/neo4j/neo4j-go-driver/v4/neo4j" ) +func (c *neo4jClient) PackagesList(ctx context.Context, pkgSpec model.PkgSpec, after *string, first *int) (*model.PackageConnection, error) { + return nil, fmt.Errorf("not implemented: PackagesList") +} + func (c *neo4jClient) Packages(ctx context.Context, pkgSpec *model.PkgSpec) ([]*model.Package, error) { // fields: [type namespaces namespaces.namespace namespaces.names namespaces.names.name namespaces.names.versions // namespaces.names.versions.version namespaces.names.versions.qualifiers namespaces.names.versions.qualifiers.key diff --git a/pkg/assembler/backends/neo4j/pkgEqual.go b/pkg/assembler/backends/neo4j/pkgEqual.go index 187325d3b4e..7f4b09b5a33 100644 --- a/pkg/assembler/backends/neo4j/pkgEqual.go +++ b/pkg/assembler/backends/neo4j/pkgEqual.go @@ -29,6 +29,10 @@ import ( // Query PkgEqual +func (c *neo4jClient) PkgEqualList(ctx context.Context, pkgEqualSpec model.PkgEqualSpec, after *string, first *int) (*model.PkgEqualConnection, error) { + return nil, fmt.Errorf("not implemented: PkgEqualList") +} + func (c *neo4jClient) PkgEqual(ctx context.Context, pkgEqualSpec *model.PkgEqualSpec) ([]*model.PkgEqual, error) { session := c.driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeRead}) diff --git a/pkg/assembler/backends/neo4j/search.go b/pkg/assembler/backends/neo4j/search.go index 37711865468..5562285a65c 100644 --- a/pkg/assembler/backends/neo4j/search.go +++ b/pkg/assembler/backends/neo4j/search.go @@ -25,3 +25,7 @@ import ( func (c *neo4jClient) FindSoftware(ctx context.Context, searchText string) ([]model.PackageSourceOrArtifact, error) { return []model.PackageSourceOrArtifact{}, fmt.Errorf("not implemented: FindSoftware") } + +func (c *neo4jClient) FindSoftwareList(ctx context.Context, searchText string, after *string, first *int) (*model.FindSoftwareConnection, error) { + return nil, fmt.Errorf("not implemented: FindSoftwareList") +} diff --git a/pkg/assembler/backends/neo4j/src.go b/pkg/assembler/backends/neo4j/src.go index 475c737d2f4..78d31884237 100644 --- a/pkg/assembler/backends/neo4j/src.go +++ b/pkg/assembler/backends/neo4j/src.go @@ -25,6 +25,10 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func (c *neo4jClient) SourcesList(ctx context.Context, sourceSpec model.SourceSpec, after *string, first *int) (*model.SourceConnection, error) { + return nil, fmt.Errorf("not implemented: SourcesList") +} + func (c *neo4jClient) Sources(ctx context.Context, sourceSpec *model.SourceSpec) ([]*model.Source, error) { // fields: [type namespaces namespaces.namespace namespaces.names namespaces.names.name namespaces.names.tag namespaces.names.commit] diff --git a/pkg/assembler/backends/neo4j/vulnEqual.go b/pkg/assembler/backends/neo4j/vulnEqual.go index 0d246b406b5..f55da57a9eb 100644 --- a/pkg/assembler/backends/neo4j/vulnEqual.go +++ b/pkg/assembler/backends/neo4j/vulnEqual.go @@ -22,6 +22,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +func (c *neo4jClient) VulnEqualList(ctx context.Context, vulnEqualSpec model.VulnEqualSpec, after *string, first *int) (*model.VulnEqualConnection, error) { + return nil, fmt.Errorf("not implemented: VulnEqualList") +} + // TODO (pxp928): fix for new vulnerability func (c *neo4jClient) VulnEqual(ctx context.Context, vulnEqualSpec *model.VulnEqualSpec) ([]*model.VulnEqual, error) { diff --git a/pkg/assembler/backends/neo4j/vulnMetadata.go b/pkg/assembler/backends/neo4j/vulnMetadata.go index d7f2094e014..2f6d270dec0 100644 --- a/pkg/assembler/backends/neo4j/vulnMetadata.go +++ b/pkg/assembler/backends/neo4j/vulnMetadata.go @@ -22,6 +22,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +func (c *neo4jClient) VulnerabilityMetadataList(ctx context.Context, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec, after *string, first *int) (*model.VulnerabilityMetadataConnection, error) { + return nil, fmt.Errorf("not implemented: VulnerabilityMetadataList") +} + func (c *neo4jClient) IngestVulnerabilityMetadata(ctx context.Context, vulnerability model.IDorVulnerabilityInput, vulnerabilityMetadata model.VulnerabilityMetadataInputSpec) (string, error) { return "", fmt.Errorf("not implemented - IngestVulnerabilityMetadata") } diff --git a/pkg/assembler/backends/neo4j/vulnerability.go b/pkg/assembler/backends/neo4j/vulnerability.go index fb91c94adf5..160ba6e4b9e 100644 --- a/pkg/assembler/backends/neo4j/vulnerability.go +++ b/pkg/assembler/backends/neo4j/vulnerability.go @@ -22,6 +22,10 @@ import ( "github.com/guacsec/guac/pkg/assembler/graphql/model" ) +func (c *neo4jClient) VulnerabilityList(ctx context.Context, vulnSpec model.VulnerabilitySpec, after *string, first *int) (*model.VulnerabilityConnection, error) { + return nil, fmt.Errorf("not implemented: VulnerabilityList") +} + // TODO (pxp928): fix for new vulnerability func (c *neo4jClient) Vulnerabilities(ctx context.Context, vulnSpec *model.VulnerabilitySpec) ([]*model.Vulnerability, error) { // fields: [year cveId cveId.id] diff --git a/pkg/assembler/graphql/examples/artifact_builder.gql b/pkg/assembler/graphql/examples/artifact_builder.gql index a6e887056dd..93af0d88e69 100644 --- a/pkg/assembler/graphql/examples/artifact_builder.gql +++ b/pkg/assembler/graphql/examples/artifact_builder.gql @@ -10,6 +10,32 @@ query ArtifactQ1 { } } + +query ArtifactPagination { + artifactsList(artifactSpec: {}, first: 10) { + totalCount + edges { + cursor + node { + ...allArtifactTree + } + } + pageInfo { + startCursor + endCursor + hasNextPage + } + } +} + + +query ArtifactsStartWithDirective { + artifacts(artifactSpec: {}) @filter(keyName: "algorithm", operation: STARTSWITH, value: "sha2") { + algorithm + digest + } +} + query ArtifactQ2 { artifacts( artifactSpec: { diff --git a/pkg/assembler/graphql/generated/artifact.generated.go b/pkg/assembler/graphql/generated/artifact.generated.go index f2da71dcc84..cbd224db1b5 100644 --- a/pkg/assembler/graphql/generated/artifact.generated.go +++ b/pkg/assembler/graphql/generated/artifact.generated.go @@ -68,33 +68,58 @@ type MutationResolver interface { } type QueryResolver interface { Artifacts(ctx context.Context, artifactSpec model.ArtifactSpec) ([]*model.Artifact, error) + ArtifactsList(ctx context.Context, artifactSpec model.ArtifactSpec, after *string, first *int) (*model.ArtifactConnection, error) Builders(ctx context.Context, builderSpec model.BuilderSpec) ([]*model.Builder, error) + BuildersList(ctx context.Context, builderSpec model.BuilderSpec, after *string, first *int) (*model.BuilderConnection, error) CertifyBad(ctx context.Context, certifyBadSpec model.CertifyBadSpec) ([]*model.CertifyBad, error) + CertifyBadList(ctx context.Context, certifyBadSpec model.CertifyBadSpec, after *string, first *int) (*model.CertifyBadConnection, error) CertifyGood(ctx context.Context, certifyGoodSpec model.CertifyGoodSpec) ([]*model.CertifyGood, error) + CertifyGoodList(ctx context.Context, certifyGoodSpec model.CertifyGoodSpec, after *string, first *int) (*model.CertifyGoodConnection, error) CertifyLegal(ctx context.Context, certifyLegalSpec model.CertifyLegalSpec) ([]*model.CertifyLegal, error) + CertifyLegalList(ctx context.Context, certifyLegalSpec model.CertifyLegalSpec, after *string, first *int) (*model.CertifyLegalConnection, error) Scorecards(ctx context.Context, scorecardSpec model.CertifyScorecardSpec) ([]*model.CertifyScorecard, error) + ScorecardsList(ctx context.Context, scorecardSpec model.CertifyScorecardSpec, after *string, first *int) (*model.CertifyScorecardConnection, error) CertifyVEXStatement(ctx context.Context, certifyVEXStatementSpec model.CertifyVEXStatementSpec) ([]*model.CertifyVEXStatement, error) + CertifyVEXStatementList(ctx context.Context, certifyVEXStatementSpec model.CertifyVEXStatementSpec, after *string, first *int) (*model.VEXConnection, error) CertifyVuln(ctx context.Context, certifyVulnSpec model.CertifyVulnSpec) ([]*model.CertifyVuln, error) + CertifyVulnList(ctx context.Context, certifyVulnSpec model.CertifyVulnSpec, after *string, first *int) (*model.CertifyVulnConnection, error) PointOfContact(ctx context.Context, pointOfContactSpec model.PointOfContactSpec) ([]*model.PointOfContact, error) + PointOfContactList(ctx context.Context, pointOfContactSpec model.PointOfContactSpec, after *string, first *int) (*model.PointOfContactConnection, error) HasSbom(ctx context.Context, hasSBOMSpec model.HasSBOMSpec) ([]*model.HasSbom, error) + HasSBOMList(ctx context.Context, hasSBOMSpec model.HasSBOMSpec, after *string, first *int) (*model.HasSBOMConnection, error) HasSlsa(ctx context.Context, hasSLSASpec model.HasSLSASpec) ([]*model.HasSlsa, error) + HasSLSAList(ctx context.Context, hasSLSASpec model.HasSLSASpec, after *string, first *int) (*model.HasSLSAConnection, error) HasSourceAt(ctx context.Context, hasSourceAtSpec model.HasSourceAtSpec) ([]*model.HasSourceAt, error) + HasSourceAtList(ctx context.Context, hasSourceAtSpec model.HasSourceAtSpec, after *string, first *int) (*model.HasSourceAtConnection, error) HashEqual(ctx context.Context, hashEqualSpec model.HashEqualSpec) ([]*model.HashEqual, error) + HashEqualList(ctx context.Context, hashEqualSpec model.HashEqualSpec, after *string, first *int) (*model.HashEqualConnection, error) IsDependency(ctx context.Context, isDependencySpec model.IsDependencySpec) ([]*model.IsDependency, error) + IsDependencyList(ctx context.Context, isDependencySpec model.IsDependencySpec, after *string, first *int) (*model.IsDependencyConnection, error) IsOccurrence(ctx context.Context, isOccurrenceSpec model.IsOccurrenceSpec) ([]*model.IsOccurrence, error) + IsOccurrenceList(ctx context.Context, isOccurrenceSpec model.IsOccurrenceSpec, after *string, first *int) (*model.IsOccurrenceConnection, error) Licenses(ctx context.Context, licenseSpec model.LicenseSpec) ([]*model.License, error) + LicenseList(ctx context.Context, licenseSpec model.LicenseSpec, after *string, first *int) (*model.LicenseConnection, error) HasMetadata(ctx context.Context, hasMetadataSpec model.HasMetadataSpec) ([]*model.HasMetadata, error) + HasMetadataList(ctx context.Context, hasMetadataSpec model.HasMetadataSpec, after *string, first *int) (*model.HasMetadataConnection, error) Packages(ctx context.Context, pkgSpec model.PkgSpec) ([]*model.Package, error) + PackagesList(ctx context.Context, pkgSpec model.PkgSpec, after *string, first *int) (*model.PackageConnection, error) Path(ctx context.Context, subject string, target string, maxPathLength int, usingOnly []model.Edge) ([]model.Node, error) Neighbors(ctx context.Context, node string, usingOnly []model.Edge) ([]model.Node, error) + NeighborsList(ctx context.Context, node string, usingOnly []model.Edge, after *string, first *int) (*model.NeighborConnection, error) Node(ctx context.Context, node string) (model.Node, error) Nodes(ctx context.Context, nodes []string) ([]model.Node, error) PkgEqual(ctx context.Context, pkgEqualSpec model.PkgEqualSpec) ([]*model.PkgEqual, error) + PkgEqualList(ctx context.Context, pkgEqualSpec model.PkgEqualSpec, after *string, first *int) (*model.PkgEqualConnection, error) FindSoftware(ctx context.Context, searchText string) ([]model.PackageSourceOrArtifact, error) + FindSoftwareList(ctx context.Context, searchText string, after *string, first *int) (*model.FindSoftwareConnection, error) Sources(ctx context.Context, sourceSpec model.SourceSpec) ([]*model.Source, error) + SourcesList(ctx context.Context, sourceSpec model.SourceSpec, after *string, first *int) (*model.SourceConnection, error) VulnEqual(ctx context.Context, vulnEqualSpec model.VulnEqualSpec) ([]*model.VulnEqual, error) + VulnEqualList(ctx context.Context, vulnEqualSpec model.VulnEqualSpec, after *string, first *int) (*model.VulnEqualConnection, error) VulnerabilityMetadata(ctx context.Context, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec) ([]*model.VulnerabilityMetadata, error) + VulnerabilityMetadataList(ctx context.Context, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec, after *string, first *int) (*model.VulnerabilityMetadataConnection, error) Vulnerabilities(ctx context.Context, vulnSpec model.VulnerabilitySpec) ([]*model.Vulnerability, error) + VulnerabilityList(ctx context.Context, vulnSpec model.VulnerabilitySpec, after *string, first *int) (*model.VulnerabilityConnection, error) } // endregion ************************** generated!.gotpl ************************** @@ -1439,6 +1464,39 @@ func (ec *executionContext) field_Mutation_ingestVulnerability_args(ctx context. return args, nil } +func (ec *executionContext) field_Query_CertifyBadList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.CertifyBadSpec + if tmp, ok := rawArgs["certifyBadSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("certifyBadSpec")) + arg0, err = ec.unmarshalNCertifyBadSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyBadSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["certifyBadSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_CertifyBad_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1454,6 +1512,39 @@ func (ec *executionContext) field_Query_CertifyBad_args(ctx context.Context, raw return args, nil } +func (ec *executionContext) field_Query_CertifyGoodList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.CertifyGoodSpec + if tmp, ok := rawArgs["certifyGoodSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("certifyGoodSpec")) + arg0, err = ec.unmarshalNCertifyGoodSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyGoodSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["certifyGoodSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_CertifyGood_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1469,6 +1560,39 @@ func (ec *executionContext) field_Query_CertifyGood_args(ctx context.Context, ra return args, nil } +func (ec *executionContext) field_Query_CertifyLegalList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.CertifyLegalSpec + if tmp, ok := rawArgs["certifyLegalSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("certifyLegalSpec")) + arg0, err = ec.unmarshalNCertifyLegalSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyLegalSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["certifyLegalSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_CertifyLegal_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1484,6 +1608,39 @@ func (ec *executionContext) field_Query_CertifyLegal_args(ctx context.Context, r return args, nil } +func (ec *executionContext) field_Query_CertifyVEXStatementList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.CertifyVEXStatementSpec + if tmp, ok := rawArgs["certifyVEXStatementSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("certifyVEXStatementSpec")) + arg0, err = ec.unmarshalNCertifyVEXStatementSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVEXStatementSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["certifyVEXStatementSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_CertifyVEXStatement_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1499,6 +1656,39 @@ func (ec *executionContext) field_Query_CertifyVEXStatement_args(ctx context.Con return args, nil } +func (ec *executionContext) field_Query_CertifyVulnList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.CertifyVulnSpec + if tmp, ok := rawArgs["certifyVulnSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("certifyVulnSpec")) + arg0, err = ec.unmarshalNCertifyVulnSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVulnSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["certifyVulnSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_CertifyVuln_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1514,6 +1704,39 @@ func (ec *executionContext) field_Query_CertifyVuln_args(ctx context.Context, ra return args, nil } +func (ec *executionContext) field_Query_HasMetadataList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.HasMetadataSpec + if tmp, ok := rawArgs["hasMetadataSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasMetadataSpec")) + arg0, err = ec.unmarshalNHasMetadataSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasMetadataSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["hasMetadataSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_HasMetadata_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1529,6 +1752,39 @@ func (ec *executionContext) field_Query_HasMetadata_args(ctx context.Context, ra return args, nil } +func (ec *executionContext) field_Query_HasSBOMList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.HasSBOMSpec + if tmp, ok := rawArgs["hasSBOMSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSBOMSpec")) + arg0, err = ec.unmarshalNHasSBOMSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSBOMSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["hasSBOMSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_HasSBOM_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1544,6 +1800,39 @@ func (ec *executionContext) field_Query_HasSBOM_args(ctx context.Context, rawArg return args, nil } +func (ec *executionContext) field_Query_HasSLSAList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.HasSLSASpec + if tmp, ok := rawArgs["hasSLSASpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSLSASpec")) + arg0, err = ec.unmarshalNHasSLSASpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSLSASpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["hasSLSASpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_HasSLSA_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1559,6 +1848,39 @@ func (ec *executionContext) field_Query_HasSLSA_args(ctx context.Context, rawArg return args, nil } +func (ec *executionContext) field_Query_HasSourceAtList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.HasSourceAtSpec + if tmp, ok := rawArgs["hasSourceAtSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hasSourceAtSpec")) + arg0, err = ec.unmarshalNHasSourceAtSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSourceAtSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["hasSourceAtSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_HasSourceAt_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1574,6 +1896,39 @@ func (ec *executionContext) field_Query_HasSourceAt_args(ctx context.Context, ra return args, nil } +func (ec *executionContext) field_Query_HashEqualList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.HashEqualSpec + if tmp, ok := rawArgs["hashEqualSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("hashEqualSpec")) + arg0, err = ec.unmarshalNHashEqualSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHashEqualSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["hashEqualSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_HashEqual_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1589,7 +1944,7 @@ func (ec *executionContext) field_Query_HashEqual_args(ctx context.Context, rawA return args, nil } -func (ec *executionContext) field_Query_IsDependency_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_IsDependencyList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 model.IsDependencySpec @@ -1601,55 +1956,187 @@ func (ec *executionContext) field_Query_IsDependency_args(ctx context.Context, r } } args["isDependencySpec"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_IsOccurrence_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 model.IsOccurrenceSpec - if tmp, ok := rawArgs["isOccurrenceSpec"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("isOccurrenceSpec")) - arg0, err = ec.unmarshalNIsOccurrenceSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceSpec(ctx, tmp) + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) if err != nil { return nil, err } } - args["isOccurrenceSpec"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_PkgEqual_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 model.PkgEqualSpec - if tmp, ok := rawArgs["pkgEqualSpec"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pkgEqualSpec")) - arg0, err = ec.unmarshalNPkgEqualSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqualSpec(ctx, tmp) + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) if err != nil { return nil, err } } - args["pkgEqualSpec"] = arg0 + args["first"] = arg2 return args, nil } -func (ec *executionContext) field_Query_PointOfContact_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_IsDependency_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 model.PointOfContactSpec - if tmp, ok := rawArgs["pointOfContactSpec"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointOfContactSpec")) - arg0, err = ec.unmarshalNPointOfContactSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContactSpec(ctx, tmp) + var arg0 model.IsDependencySpec + if tmp, ok := rawArgs["isDependencySpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("isDependencySpec")) + arg0, err = ec.unmarshalNIsDependencySpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsDependencySpec(ctx, tmp) if err != nil { return nil, err } } - args["pointOfContactSpec"] = arg0 + args["isDependencySpec"] = arg0 return args, nil } -func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_IsOccurrenceList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.IsOccurrenceSpec + if tmp, ok := rawArgs["isOccurrenceSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("isOccurrenceSpec")) + arg0, err = ec.unmarshalNIsOccurrenceSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["isOccurrenceSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + +func (ec *executionContext) field_Query_IsOccurrence_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.IsOccurrenceSpec + if tmp, ok := rawArgs["isOccurrenceSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("isOccurrenceSpec")) + arg0, err = ec.unmarshalNIsOccurrenceSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["isOccurrenceSpec"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_PkgEqualList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.PkgEqualSpec + if tmp, ok := rawArgs["pkgEqualSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pkgEqualSpec")) + arg0, err = ec.unmarshalNPkgEqualSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqualSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["pkgEqualSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + +func (ec *executionContext) field_Query_PkgEqual_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.PkgEqualSpec + if tmp, ok := rawArgs["pkgEqualSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pkgEqualSpec")) + arg0, err = ec.unmarshalNPkgEqualSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqualSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["pkgEqualSpec"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_PointOfContactList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.PointOfContactSpec + if tmp, ok := rawArgs["pointOfContactSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointOfContactSpec")) + arg0, err = ec.unmarshalNPointOfContactSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContactSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["pointOfContactSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + +func (ec *executionContext) field_Query_PointOfContact_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.PointOfContactSpec + if tmp, ok := rawArgs["pointOfContactSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pointOfContactSpec")) + arg0, err = ec.unmarshalNPointOfContactSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContactSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["pointOfContactSpec"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string @@ -1664,6 +2151,39 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) field_Query_artifactsList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.ArtifactSpec + if tmp, ok := rawArgs["artifactSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactSpec")) + arg0, err = ec.unmarshalNArtifactSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐArtifactSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["artifactSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_artifacts_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1679,6 +2199,39 @@ func (ec *executionContext) field_Query_artifacts_args(ctx context.Context, rawA return args, nil } +func (ec *executionContext) field_Query_buildersList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.BuilderSpec + if tmp, ok := rawArgs["builderSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("builderSpec")) + arg0, err = ec.unmarshalNBuilderSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐBuilderSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["builderSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_builders_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1694,6 +2247,39 @@ func (ec *executionContext) field_Query_builders_args(ctx context.Context, rawAr return args, nil } +func (ec *executionContext) field_Query_findSoftwareList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["searchText"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("searchText")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["searchText"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_findSoftware_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1709,6 +2295,39 @@ func (ec *executionContext) field_Query_findSoftware_args(ctx context.Context, r return args, nil } +func (ec *executionContext) field_Query_licenseList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.LicenseSpec + if tmp, ok := rawArgs["licenseSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("licenseSpec")) + arg0, err = ec.unmarshalNLicenseSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐLicenseSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["licenseSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_licenses_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1724,6 +2343,48 @@ func (ec *executionContext) field_Query_licenses_args(ctx context.Context, rawAr return args, nil } +func (ec *executionContext) field_Query_neighborsList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["node"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("node")) + arg0, err = ec.unmarshalNID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["node"] = arg0 + var arg1 []model.Edge + if tmp, ok := rawArgs["usingOnly"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("usingOnly")) + arg1, err = ec.unmarshalNEdge2ᚕgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐEdgeᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["usingOnly"] = arg1 + var arg2 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg2, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg2 + var arg3 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg3, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg3 + return args, nil +} + func (ec *executionContext) field_Query_neighbors_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1778,6 +2439,39 @@ func (ec *executionContext) field_Query_nodes_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) field_Query_packagesList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.PkgSpec + if tmp, ok := rawArgs["pkgSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pkgSpec")) + arg0, err = ec.unmarshalNPkgSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["pkgSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_packages_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1835,7 +2529,7 @@ func (ec *executionContext) field_Query_path_args(ctx context.Context, rawArgs m return args, nil } -func (ec *executionContext) field_Query_scorecards_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_scorecardsList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 model.CertifyScorecardSpec @@ -1847,8 +2541,74 @@ func (ec *executionContext) field_Query_scorecards_args(ctx context.Context, raw } } args["scorecardSpec"] = arg0 - return args, nil -} + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + +func (ec *executionContext) field_Query_scorecards_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.CertifyScorecardSpec + if tmp, ok := rawArgs["scorecardSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("scorecardSpec")) + arg0, err = ec.unmarshalNCertifyScorecardSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyScorecardSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["scorecardSpec"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query_sourcesList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.SourceSpec + if tmp, ok := rawArgs["sourceSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sourceSpec")) + arg0, err = ec.unmarshalNSourceSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSourceSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["sourceSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} func (ec *executionContext) field_Query_sources_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error @@ -1865,6 +2625,39 @@ func (ec *executionContext) field_Query_sources_args(ctx context.Context, rawArg return args, nil } +func (ec *executionContext) field_Query_vulnEqualList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.VulnEqualSpec + if tmp, ok := rawArgs["vulnEqualSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("vulnEqualSpec")) + arg0, err = ec.unmarshalNVulnEqualSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnEqualSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["vulnEqualSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_vulnEqual_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1895,6 +2688,72 @@ func (ec *executionContext) field_Query_vulnerabilities_args(ctx context.Context return args, nil } +func (ec *executionContext) field_Query_vulnerabilityList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.VulnerabilitySpec + if tmp, ok := rawArgs["vulnSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("vulnSpec")) + arg0, err = ec.unmarshalNVulnerabilitySpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilitySpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["vulnSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + +func (ec *executionContext) field_Query_vulnerabilityMetadataList_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 model.VulnerabilityMetadataSpec + if tmp, ok := rawArgs["vulnerabilityMetadataSpec"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("vulnerabilityMetadataSpec")) + arg0, err = ec.unmarshalNVulnerabilityMetadataSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityMetadataSpec(ctx, tmp) + if err != nil { + return nil, err + } + } + args["vulnerabilityMetadataSpec"] = arg0 + var arg1 *string + if tmp, ok := rawArgs["after"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("after")) + arg1, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["after"] = arg1 + var arg2 *int + if tmp, ok := rawArgs["first"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("first")) + arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["first"] = arg2 + return args, nil +} + func (ec *executionContext) field_Query_vulnerabilityMetadata_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2041,8 +2900,8 @@ func (ec *executionContext) fieldContext_Artifact_digest(ctx context.Context, fi return fc, nil } -func (ec *executionContext) _Mutation_ingestArtifact(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_ingestArtifact(ctx, field) +func (ec *executionContext) _ArtifactConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.ArtifactConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ArtifactConnection_totalCount(ctx, field) if err != nil { return graphql.Null } @@ -2053,9 +2912,9 @@ func (ec *executionContext) _Mutation_ingestArtifact(ctx context.Context, field ret = graphql.Null } }() - resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().IngestArtifact(rctx, fc.Args["artifact"].(*model.IDorArtifactInput)) + return obj.TotalCount, nil }) if resTmp == nil { @@ -2064,37 +2923,26 @@ func (ec *executionContext) _Mutation_ingestArtifact(ctx context.Context, field } return graphql.Null } - res := resTmp.(string) + res := resTmp.(int) fc.Result = res - return ec.marshalNID2string(ctx, field.Selections, res) + return ec.marshalNInt2int(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_ingestArtifact(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ArtifactConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "ArtifactConnection", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + return nil, errors.New("field of type Int does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_ingestArtifact_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_ingestArtifacts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_ingestArtifacts(ctx, field) +func (ec *executionContext) _ArtifactConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.ArtifactConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ArtifactConnection_pageInfo(ctx, field) if err != nil { return graphql.Null } @@ -2105,9 +2953,9 @@ func (ec *executionContext) _Mutation_ingestArtifacts(ctx context.Context, field ret = graphql.Null } }() - resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().IngestArtifacts(rctx, fc.Args["artifacts"].([]*model.IDorArtifactInput)) + return obj.PageInfo, nil }) if resTmp == nil { @@ -2116,37 +2964,81 @@ func (ec *executionContext) _Mutation_ingestArtifacts(ctx context.Context, field } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(*model.PageInfo) fc.Result = res - return ec.marshalNID2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_ingestArtifacts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ArtifactConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "ArtifactConnection", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) }, } + return fc, nil +} + +func (ec *executionContext) _ArtifactConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.ArtifactConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ArtifactConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_ingestArtifacts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.ArtifactEdge) + fc.Result = res + return ec.marshalNArtifactEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐArtifactEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ArtifactConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ArtifactConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_ArtifactEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_ArtifactEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ArtifactEdge", field.Name) + }, } return fc, nil } -func (ec *executionContext) _Mutation_ingestBuilder(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_ingestBuilder(ctx, field) +func (ec *executionContext) _ArtifactEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.ArtifactEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ArtifactEdge_cursor(ctx, field) if err != nil { return graphql.Null } @@ -2157,9 +3049,9 @@ func (ec *executionContext) _Mutation_ingestBuilder(ctx context.Context, field g ret = graphql.Null } }() - resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().IngestBuilder(rctx, fc.Args["builder"].(*model.IDorBuilderInput)) + return obj.Cursor, nil }) if resTmp == nil { @@ -2173,32 +3065,21 @@ func (ec *executionContext) _Mutation_ingestBuilder(ctx context.Context, field g return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_ingestBuilder(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ArtifactEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "ArtifactEdge", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { return nil, errors.New("field of type ID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_ingestBuilder_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_ingestBuilders(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_ingestBuilders(ctx, field) +func (ec *executionContext) _ArtifactEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.ArtifactEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ArtifactEdge_node(ctx, field) if err != nil { return graphql.Null } @@ -2209,9 +3090,9 @@ func (ec *executionContext) _Mutation_ingestBuilders(ctx context.Context, field ret = graphql.Null } }() - resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().IngestBuilders(rctx, fc.Args["builders"].([]*model.IDorBuilderInput)) + return obj.Node, nil }) if resTmp == nil { @@ -2220,37 +3101,34 @@ func (ec *executionContext) _Mutation_ingestBuilders(ctx context.Context, field } return graphql.Null } - res := resTmp.([]string) + res := resTmp.(*model.Artifact) fc.Result = res - return ec.marshalNID2ᚕstringᚄ(ctx, field.Selections, res) + return ec.marshalNArtifact2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐArtifact(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_ingestBuilders(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_ArtifactEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Mutation", + Object: "ArtifactEdge", Field: field, - IsMethod: true, - IsResolver: true, + IsMethod: false, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type ID does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_Artifact_id(ctx, field) + case "algorithm": + return ec.fieldContext_Artifact_algorithm(ctx, field) + case "digest": + return ec.fieldContext_Artifact_digest(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Artifact", field.Name) }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_ingestBuilders_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } return fc, nil } -func (ec *executionContext) _Mutation_ingestCertifyBad(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_ingestCertifyBad(ctx, field) +func (ec *executionContext) _Mutation_ingestArtifact(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_ingestArtifact(ctx, field) if err != nil { return graphql.Null } @@ -2263,7 +3141,7 @@ func (ec *executionContext) _Mutation_ingestCertifyBad(ctx context.Context, fiel }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().IngestCertifyBad(rctx, fc.Args["subject"].(model.PackageSourceOrArtifactInput), fc.Args["pkgMatchType"].(model.MatchFlags), fc.Args["certifyBad"].(model.CertifyBadInputSpec)) + return ec.resolvers.Mutation().IngestArtifact(rctx, fc.Args["artifact"].(*model.IDorArtifactInput)) }) if resTmp == nil { @@ -2277,7 +3155,7 @@ func (ec *executionContext) _Mutation_ingestCertifyBad(ctx context.Context, fiel return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_ingestCertifyBad(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_ingestArtifact(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -2294,14 +3172,222 @@ func (ec *executionContext) fieldContext_Mutation_ingestCertifyBad(ctx context.C } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_ingestCertifyBad_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_ingestArtifact_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_ingestCertifyBads(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_ingestArtifacts(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_ingestArtifacts(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().IngestArtifacts(rctx, fc.Args["artifacts"].([]*model.IDorArtifactInput)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalNID2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_ingestArtifacts(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_ingestArtifacts_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_ingestBuilder(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_ingestBuilder(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().IngestBuilder(rctx, fc.Args["builder"].(*model.IDorBuilderInput)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_ingestBuilder(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_ingestBuilder_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_ingestBuilders(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_ingestBuilders(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().IngestBuilders(rctx, fc.Args["builders"].([]*model.IDorBuilderInput)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalNID2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_ingestBuilders(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_ingestBuilders_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_ingestCertifyBad(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_ingestCertifyBad(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().IngestCertifyBad(rctx, fc.Args["subject"].(model.PackageSourceOrArtifactInput), fc.Args["pkgMatchType"].(model.MatchFlags), fc.Args["certifyBad"].(model.CertifyBadInputSpec)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_ingestCertifyBad(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_ingestCertifyBad_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_ingestCertifyBads(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Mutation_ingestCertifyBads(ctx, field) if err != nil { return graphql.Null @@ -4541,8 +5627,8 @@ func (ec *executionContext) fieldContext_Query_artifacts(ctx context.Context, fi return fc, nil } -func (ec *executionContext) _Query_builders(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_builders(ctx, field) +func (ec *executionContext) _Query_artifactsList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_artifactsList(ctx, field) if err != nil { return graphql.Null } @@ -4555,21 +5641,18 @@ func (ec *executionContext) _Query_builders(ctx context.Context, field graphql.C }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Builders(rctx, fc.Args["builderSpec"].(model.BuilderSpec)) + return ec.resolvers.Query().ArtifactsList(rctx, fc.Args["artifactSpec"].(model.ArtifactSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*model.Builder) + res := resTmp.(*model.ArtifactConnection) fc.Result = res - return ec.marshalNBuilder2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐBuilderᚄ(ctx, field.Selections, res) + return ec.marshalOArtifactConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐArtifactConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_builders(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_artifactsList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -4577,12 +5660,14 @@ func (ec *executionContext) fieldContext_Query_builders(ctx context.Context, fie IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Builder_id(ctx, field) - case "uri": - return ec.fieldContext_Builder_uri(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Builder", field.Name) + case "totalCount": + return ec.fieldContext_ArtifactConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_ArtifactConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_ArtifactConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ArtifactConnection", field.Name) }, } defer func() { @@ -4592,15 +5677,15 @@ func (ec *executionContext) fieldContext_Query_builders(ctx context.Context, fie } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_builders_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_artifactsList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_CertifyBad(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_CertifyBad(ctx, field) +func (ec *executionContext) _Query_builders(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_builders(ctx, field) if err != nil { return graphql.Null } @@ -4613,7 +5698,7 @@ func (ec *executionContext) _Query_CertifyBad(ctx context.Context, field graphql }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().CertifyBad(rctx, fc.Args["certifyBadSpec"].(model.CertifyBadSpec)) + return ec.resolvers.Query().Builders(rctx, fc.Args["builderSpec"].(model.BuilderSpec)) }) if resTmp == nil { @@ -4622,12 +5707,12 @@ func (ec *executionContext) _Query_CertifyBad(ctx context.Context, field graphql } return graphql.Null } - res := resTmp.([]*model.CertifyBad) + res := resTmp.([]*model.Builder) fc.Result = res - return ec.marshalNCertifyBad2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyBadᚄ(ctx, field.Selections, res) + return ec.marshalNBuilder2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐBuilderᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_CertifyBad(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_builders(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -4636,21 +5721,11 @@ func (ec *executionContext) fieldContext_Query_CertifyBad(ctx context.Context, f Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_CertifyBad_id(ctx, field) - case "subject": - return ec.fieldContext_CertifyBad_subject(ctx, field) - case "justification": - return ec.fieldContext_CertifyBad_justification(ctx, field) - case "knownSince": - return ec.fieldContext_CertifyBad_knownSince(ctx, field) - case "origin": - return ec.fieldContext_CertifyBad_origin(ctx, field) - case "collector": - return ec.fieldContext_CertifyBad_collector(ctx, field) - case "documentRef": - return ec.fieldContext_CertifyBad_documentRef(ctx, field) + return ec.fieldContext_Builder_id(ctx, field) + case "uri": + return ec.fieldContext_Builder_uri(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type CertifyBad", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Builder", field.Name) }, } defer func() { @@ -4660,15 +5735,15 @@ func (ec *executionContext) fieldContext_Query_CertifyBad(ctx context.Context, f } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_CertifyBad_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_builders_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_CertifyGood(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_CertifyGood(ctx, field) +func (ec *executionContext) _Query_buildersList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_buildersList(ctx, field) if err != nil { return graphql.Null } @@ -4681,21 +5756,18 @@ func (ec *executionContext) _Query_CertifyGood(ctx context.Context, field graphq }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().CertifyGood(rctx, fc.Args["certifyGoodSpec"].(model.CertifyGoodSpec)) + return ec.resolvers.Query().BuildersList(rctx, fc.Args["builderSpec"].(model.BuilderSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*model.CertifyGood) + res := resTmp.(*model.BuilderConnection) fc.Result = res - return ec.marshalNCertifyGood2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyGoodᚄ(ctx, field.Selections, res) + return ec.marshalOBuilderConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐBuilderConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_CertifyGood(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_buildersList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -4703,22 +5775,14 @@ func (ec *executionContext) fieldContext_Query_CertifyGood(ctx context.Context, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_CertifyGood_id(ctx, field) - case "subject": - return ec.fieldContext_CertifyGood_subject(ctx, field) - case "justification": - return ec.fieldContext_CertifyGood_justification(ctx, field) - case "knownSince": - return ec.fieldContext_CertifyGood_knownSince(ctx, field) - case "origin": - return ec.fieldContext_CertifyGood_origin(ctx, field) - case "collector": - return ec.fieldContext_CertifyGood_collector(ctx, field) - case "documentRef": - return ec.fieldContext_CertifyGood_documentRef(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CertifyGood", field.Name) + case "totalCount": + return ec.fieldContext_BuilderConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_BuilderConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_BuilderConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BuilderConnection", field.Name) }, } defer func() { @@ -4728,15 +5792,15 @@ func (ec *executionContext) fieldContext_Query_CertifyGood(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_CertifyGood_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_buildersList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_CertifyLegal(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_CertifyLegal(ctx, field) +func (ec *executionContext) _Query_CertifyBad(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_CertifyBad(ctx, field) if err != nil { return graphql.Null } @@ -4749,7 +5813,7 @@ func (ec *executionContext) _Query_CertifyLegal(ctx context.Context, field graph }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().CertifyLegal(rctx, fc.Args["certifyLegalSpec"].(model.CertifyLegalSpec)) + return ec.resolvers.Query().CertifyBad(rctx, fc.Args["certifyBadSpec"].(model.CertifyBadSpec)) }) if resTmp == nil { @@ -4758,12 +5822,12 @@ func (ec *executionContext) _Query_CertifyLegal(ctx context.Context, field graph } return graphql.Null } - res := resTmp.([]*model.CertifyLegal) + res := resTmp.([]*model.CertifyBad) fc.Result = res - return ec.marshalNCertifyLegal2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyLegalᚄ(ctx, field.Selections, res) + return ec.marshalNCertifyBad2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyBadᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_CertifyLegal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_CertifyBad(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -4772,31 +5836,21 @@ func (ec *executionContext) fieldContext_Query_CertifyLegal(ctx context.Context, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_CertifyLegal_id(ctx, field) + return ec.fieldContext_CertifyBad_id(ctx, field) case "subject": - return ec.fieldContext_CertifyLegal_subject(ctx, field) - case "declaredLicense": - return ec.fieldContext_CertifyLegal_declaredLicense(ctx, field) - case "declaredLicenses": - return ec.fieldContext_CertifyLegal_declaredLicenses(ctx, field) - case "discoveredLicense": - return ec.fieldContext_CertifyLegal_discoveredLicense(ctx, field) - case "discoveredLicenses": - return ec.fieldContext_CertifyLegal_discoveredLicenses(ctx, field) - case "attribution": - return ec.fieldContext_CertifyLegal_attribution(ctx, field) + return ec.fieldContext_CertifyBad_subject(ctx, field) case "justification": - return ec.fieldContext_CertifyLegal_justification(ctx, field) - case "timeScanned": - return ec.fieldContext_CertifyLegal_timeScanned(ctx, field) + return ec.fieldContext_CertifyBad_justification(ctx, field) + case "knownSince": + return ec.fieldContext_CertifyBad_knownSince(ctx, field) case "origin": - return ec.fieldContext_CertifyLegal_origin(ctx, field) + return ec.fieldContext_CertifyBad_origin(ctx, field) case "collector": - return ec.fieldContext_CertifyLegal_collector(ctx, field) + return ec.fieldContext_CertifyBad_collector(ctx, field) case "documentRef": - return ec.fieldContext_CertifyLegal_documentRef(ctx, field) + return ec.fieldContext_CertifyBad_documentRef(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type CertifyLegal", field.Name) + return nil, fmt.Errorf("no field named %q was found under type CertifyBad", field.Name) }, } defer func() { @@ -4806,15 +5860,15 @@ func (ec *executionContext) fieldContext_Query_CertifyLegal(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_CertifyLegal_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_CertifyBad_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_scorecards(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_scorecards(ctx, field) +func (ec *executionContext) _Query_CertifyBadList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_CertifyBadList(ctx, field) if err != nil { return graphql.Null } @@ -4827,21 +5881,18 @@ func (ec *executionContext) _Query_scorecards(ctx context.Context, field graphql }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Scorecards(rctx, fc.Args["scorecardSpec"].(model.CertifyScorecardSpec)) + return ec.resolvers.Query().CertifyBadList(rctx, fc.Args["certifyBadSpec"].(model.CertifyBadSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*model.CertifyScorecard) + res := resTmp.(*model.CertifyBadConnection) fc.Result = res - return ec.marshalNCertifyScorecard2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyScorecardᚄ(ctx, field.Selections, res) + return ec.marshalOCertifyBadConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyBadConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_scorecards(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_CertifyBadList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -4849,14 +5900,14 @@ func (ec *executionContext) fieldContext_Query_scorecards(ctx context.Context, f IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_CertifyScorecard_id(ctx, field) - case "source": - return ec.fieldContext_CertifyScorecard_source(ctx, field) - case "scorecard": - return ec.fieldContext_CertifyScorecard_scorecard(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CertifyScorecard", field.Name) + case "totalCount": + return ec.fieldContext_CertifyBadConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_CertifyBadConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_CertifyBadConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyBadConnection", field.Name) }, } defer func() { @@ -4866,15 +5917,15 @@ func (ec *executionContext) fieldContext_Query_scorecards(ctx context.Context, f } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_scorecards_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_CertifyBadList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_CertifyVEXStatement(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_CertifyVEXStatement(ctx, field) +func (ec *executionContext) _Query_CertifyGood(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_CertifyGood(ctx, field) if err != nil { return graphql.Null } @@ -4887,7 +5938,7 @@ func (ec *executionContext) _Query_CertifyVEXStatement(ctx context.Context, fiel }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().CertifyVEXStatement(rctx, fc.Args["certifyVEXStatementSpec"].(model.CertifyVEXStatementSpec)) + return ec.resolvers.Query().CertifyGood(rctx, fc.Args["certifyGoodSpec"].(model.CertifyGoodSpec)) }) if resTmp == nil { @@ -4896,12 +5947,12 @@ func (ec *executionContext) _Query_CertifyVEXStatement(ctx context.Context, fiel } return graphql.Null } - res := resTmp.([]*model.CertifyVEXStatement) + res := resTmp.([]*model.CertifyGood) fc.Result = res - return ec.marshalNCertifyVEXStatement2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVEXStatementᚄ(ctx, field.Selections, res) + return ec.marshalNCertifyGood2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyGoodᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_CertifyVEXStatement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_CertifyGood(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -4910,29 +5961,21 @@ func (ec *executionContext) fieldContext_Query_CertifyVEXStatement(ctx context.C Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_CertifyVEXStatement_id(ctx, field) + return ec.fieldContext_CertifyGood_id(ctx, field) case "subject": - return ec.fieldContext_CertifyVEXStatement_subject(ctx, field) - case "vulnerability": - return ec.fieldContext_CertifyVEXStatement_vulnerability(ctx, field) - case "status": - return ec.fieldContext_CertifyVEXStatement_status(ctx, field) - case "vexJustification": - return ec.fieldContext_CertifyVEXStatement_vexJustification(ctx, field) - case "statement": - return ec.fieldContext_CertifyVEXStatement_statement(ctx, field) - case "statusNotes": - return ec.fieldContext_CertifyVEXStatement_statusNotes(ctx, field) + return ec.fieldContext_CertifyGood_subject(ctx, field) + case "justification": + return ec.fieldContext_CertifyGood_justification(ctx, field) case "knownSince": - return ec.fieldContext_CertifyVEXStatement_knownSince(ctx, field) + return ec.fieldContext_CertifyGood_knownSince(ctx, field) case "origin": - return ec.fieldContext_CertifyVEXStatement_origin(ctx, field) + return ec.fieldContext_CertifyGood_origin(ctx, field) case "collector": - return ec.fieldContext_CertifyVEXStatement_collector(ctx, field) + return ec.fieldContext_CertifyGood_collector(ctx, field) case "documentRef": - return ec.fieldContext_CertifyVEXStatement_documentRef(ctx, field) + return ec.fieldContext_CertifyGood_documentRef(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type CertifyVEXStatement", field.Name) + return nil, fmt.Errorf("no field named %q was found under type CertifyGood", field.Name) }, } defer func() { @@ -4942,15 +5985,15 @@ func (ec *executionContext) fieldContext_Query_CertifyVEXStatement(ctx context.C } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_CertifyVEXStatement_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_CertifyGood_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_CertifyVuln(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_CertifyVuln(ctx, field) +func (ec *executionContext) _Query_CertifyGoodList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_CertifyGoodList(ctx, field) if err != nil { return graphql.Null } @@ -4963,21 +6006,18 @@ func (ec *executionContext) _Query_CertifyVuln(ctx context.Context, field graphq }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().CertifyVuln(rctx, fc.Args["certifyVulnSpec"].(model.CertifyVulnSpec)) + return ec.resolvers.Query().CertifyGoodList(rctx, fc.Args["certifyGoodSpec"].(model.CertifyGoodSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*model.CertifyVuln) + res := resTmp.(*model.CertifyGoodConnection) fc.Result = res - return ec.marshalNCertifyVuln2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVulnᚄ(ctx, field.Selections, res) + return ec.marshalOCertifyGoodConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyGoodConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_CertifyVuln(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_CertifyGoodList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -4985,16 +6025,14 @@ func (ec *executionContext) fieldContext_Query_CertifyVuln(ctx context.Context, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_CertifyVuln_id(ctx, field) - case "package": - return ec.fieldContext_CertifyVuln_package(ctx, field) - case "vulnerability": - return ec.fieldContext_CertifyVuln_vulnerability(ctx, field) - case "metadata": - return ec.fieldContext_CertifyVuln_metadata(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type CertifyVuln", field.Name) + case "totalCount": + return ec.fieldContext_CertifyGoodConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_CertifyGoodConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_CertifyGoodConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyGoodConnection", field.Name) }, } defer func() { @@ -5004,15 +6042,15 @@ func (ec *executionContext) fieldContext_Query_CertifyVuln(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_CertifyVuln_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_CertifyGoodList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_PointOfContact(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_PointOfContact(ctx, field) +func (ec *executionContext) _Query_CertifyLegal(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_CertifyLegal(ctx, field) if err != nil { return graphql.Null } @@ -5025,7 +6063,7 @@ func (ec *executionContext) _Query_PointOfContact(ctx context.Context, field gra }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().PointOfContact(rctx, fc.Args["pointOfContactSpec"].(model.PointOfContactSpec)) + return ec.resolvers.Query().CertifyLegal(rctx, fc.Args["certifyLegalSpec"].(model.CertifyLegalSpec)) }) if resTmp == nil { @@ -5034,12 +6072,12 @@ func (ec *executionContext) _Query_PointOfContact(ctx context.Context, field gra } return graphql.Null } - res := resTmp.([]*model.PointOfContact) + res := resTmp.([]*model.CertifyLegal) fc.Result = res - return ec.marshalNPointOfContact2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContactᚄ(ctx, field.Selections, res) + return ec.marshalNCertifyLegal2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyLegalᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_PointOfContact(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_CertifyLegal(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -5048,25 +6086,31 @@ func (ec *executionContext) fieldContext_Query_PointOfContact(ctx context.Contex Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_PointOfContact_id(ctx, field) + return ec.fieldContext_CertifyLegal_id(ctx, field) case "subject": - return ec.fieldContext_PointOfContact_subject(ctx, field) - case "email": - return ec.fieldContext_PointOfContact_email(ctx, field) - case "info": - return ec.fieldContext_PointOfContact_info(ctx, field) - case "since": - return ec.fieldContext_PointOfContact_since(ctx, field) + return ec.fieldContext_CertifyLegal_subject(ctx, field) + case "declaredLicense": + return ec.fieldContext_CertifyLegal_declaredLicense(ctx, field) + case "declaredLicenses": + return ec.fieldContext_CertifyLegal_declaredLicenses(ctx, field) + case "discoveredLicense": + return ec.fieldContext_CertifyLegal_discoveredLicense(ctx, field) + case "discoveredLicenses": + return ec.fieldContext_CertifyLegal_discoveredLicenses(ctx, field) + case "attribution": + return ec.fieldContext_CertifyLegal_attribution(ctx, field) case "justification": - return ec.fieldContext_PointOfContact_justification(ctx, field) + return ec.fieldContext_CertifyLegal_justification(ctx, field) + case "timeScanned": + return ec.fieldContext_CertifyLegal_timeScanned(ctx, field) case "origin": - return ec.fieldContext_PointOfContact_origin(ctx, field) + return ec.fieldContext_CertifyLegal_origin(ctx, field) case "collector": - return ec.fieldContext_PointOfContact_collector(ctx, field) + return ec.fieldContext_CertifyLegal_collector(ctx, field) case "documentRef": - return ec.fieldContext_PointOfContact_documentRef(ctx, field) + return ec.fieldContext_CertifyLegal_documentRef(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PointOfContact", field.Name) + return nil, fmt.Errorf("no field named %q was found under type CertifyLegal", field.Name) }, } defer func() { @@ -5076,15 +6120,15 @@ func (ec *executionContext) fieldContext_Query_PointOfContact(ctx context.Contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_PointOfContact_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_CertifyLegal_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_HasSBOM(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_HasSBOM(ctx, field) +func (ec *executionContext) _Query_CertifyLegalList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_CertifyLegalList(ctx, field) if err != nil { return graphql.Null } @@ -5097,21 +6141,18 @@ func (ec *executionContext) _Query_HasSBOM(ctx context.Context, field graphql.Co }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().HasSbom(rctx, fc.Args["hasSBOMSpec"].(model.HasSBOMSpec)) + return ec.resolvers.Query().CertifyLegalList(rctx, fc.Args["certifyLegalSpec"].(model.CertifyLegalSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*model.HasSbom) + res := resTmp.(*model.CertifyLegalConnection) fc.Result = res - return ec.marshalNHasSBOM2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSbomᚄ(ctx, field.Selections, res) + return ec.marshalOCertifyLegalConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyLegalConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_HasSBOM(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_CertifyLegalList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -5119,34 +6160,14 @@ func (ec *executionContext) fieldContext_Query_HasSBOM(ctx context.Context, fiel IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_HasSBOM_id(ctx, field) - case "subject": - return ec.fieldContext_HasSBOM_subject(ctx, field) - case "uri": - return ec.fieldContext_HasSBOM_uri(ctx, field) - case "algorithm": - return ec.fieldContext_HasSBOM_algorithm(ctx, field) - case "digest": - return ec.fieldContext_HasSBOM_digest(ctx, field) - case "downloadLocation": - return ec.fieldContext_HasSBOM_downloadLocation(ctx, field) - case "knownSince": - return ec.fieldContext_HasSBOM_knownSince(ctx, field) - case "origin": - return ec.fieldContext_HasSBOM_origin(ctx, field) - case "collector": - return ec.fieldContext_HasSBOM_collector(ctx, field) - case "documentRef": - return ec.fieldContext_HasSBOM_documentRef(ctx, field) - case "includedSoftware": - return ec.fieldContext_HasSBOM_includedSoftware(ctx, field) - case "includedDependencies": - return ec.fieldContext_HasSBOM_includedDependencies(ctx, field) - case "includedOccurrences": - return ec.fieldContext_HasSBOM_includedOccurrences(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HasSBOM", field.Name) + case "totalCount": + return ec.fieldContext_CertifyLegalConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_CertifyLegalConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_CertifyLegalConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyLegalConnection", field.Name) }, } defer func() { @@ -5156,15 +6177,15 @@ func (ec *executionContext) fieldContext_Query_HasSBOM(ctx context.Context, fiel } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_HasSBOM_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_CertifyLegalList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_HasSLSA(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_HasSLSA(ctx, field) +func (ec *executionContext) _Query_scorecards(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_scorecards(ctx, field) if err != nil { return graphql.Null } @@ -5177,7 +6198,7 @@ func (ec *executionContext) _Query_HasSLSA(ctx context.Context, field graphql.Co }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().HasSlsa(rctx, fc.Args["hasSLSASpec"].(model.HasSLSASpec)) + return ec.resolvers.Query().Scorecards(rctx, fc.Args["scorecardSpec"].(model.CertifyScorecardSpec)) }) if resTmp == nil { @@ -5186,12 +6207,12 @@ func (ec *executionContext) _Query_HasSLSA(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.([]*model.HasSlsa) + res := resTmp.([]*model.CertifyScorecard) fc.Result = res - return ec.marshalNHasSLSA2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSlsaᚄ(ctx, field.Selections, res) + return ec.marshalNCertifyScorecard2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyScorecardᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_HasSLSA(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_scorecards(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -5200,13 +6221,13 @@ func (ec *executionContext) fieldContext_Query_HasSLSA(ctx context.Context, fiel Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_HasSLSA_id(ctx, field) - case "subject": - return ec.fieldContext_HasSLSA_subject(ctx, field) - case "slsa": - return ec.fieldContext_HasSLSA_slsa(ctx, field) + return ec.fieldContext_CertifyScorecard_id(ctx, field) + case "source": + return ec.fieldContext_CertifyScorecard_source(ctx, field) + case "scorecard": + return ec.fieldContext_CertifyScorecard_scorecard(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HasSLSA", field.Name) + return nil, fmt.Errorf("no field named %q was found under type CertifyScorecard", field.Name) }, } defer func() { @@ -5216,15 +6237,15 @@ func (ec *executionContext) fieldContext_Query_HasSLSA(ctx context.Context, fiel } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_HasSLSA_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_scorecards_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_HasSourceAt(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_HasSourceAt(ctx, field) +func (ec *executionContext) _Query_scorecardsList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_scorecardsList(ctx, field) if err != nil { return graphql.Null } @@ -5237,21 +6258,18 @@ func (ec *executionContext) _Query_HasSourceAt(ctx context.Context, field graphq }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().HasSourceAt(rctx, fc.Args["hasSourceAtSpec"].(model.HasSourceAtSpec)) + return ec.resolvers.Query().ScorecardsList(rctx, fc.Args["scorecardSpec"].(model.CertifyScorecardSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*model.HasSourceAt) + res := resTmp.(*model.CertifyScorecardConnection) fc.Result = res - return ec.marshalNHasSourceAt2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSourceAtᚄ(ctx, field.Selections, res) + return ec.marshalOCertifyScorecardConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyScorecardConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_HasSourceAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_scorecardsList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -5259,24 +6277,14 @@ func (ec *executionContext) fieldContext_Query_HasSourceAt(ctx context.Context, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_HasSourceAt_id(ctx, field) - case "package": - return ec.fieldContext_HasSourceAt_package(ctx, field) - case "source": - return ec.fieldContext_HasSourceAt_source(ctx, field) - case "knownSince": - return ec.fieldContext_HasSourceAt_knownSince(ctx, field) - case "justification": - return ec.fieldContext_HasSourceAt_justification(ctx, field) - case "origin": - return ec.fieldContext_HasSourceAt_origin(ctx, field) - case "collector": - return ec.fieldContext_HasSourceAt_collector(ctx, field) - case "documentRef": - return ec.fieldContext_HasSourceAt_documentRef(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type HasSourceAt", field.Name) + case "totalCount": + return ec.fieldContext_CertifyScorecardConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_CertifyScorecardConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_CertifyScorecardConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyScorecardConnection", field.Name) }, } defer func() { @@ -5286,15 +6294,15 @@ func (ec *executionContext) fieldContext_Query_HasSourceAt(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_HasSourceAt_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_scorecardsList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_HashEqual(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_HashEqual(ctx, field) +func (ec *executionContext) _Query_CertifyVEXStatement(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_CertifyVEXStatement(ctx, field) if err != nil { return graphql.Null } @@ -5307,7 +6315,7 @@ func (ec *executionContext) _Query_HashEqual(ctx context.Context, field graphql. }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().HashEqual(rctx, fc.Args["hashEqualSpec"].(model.HashEqualSpec)) + return ec.resolvers.Query().CertifyVEXStatement(rctx, fc.Args["certifyVEXStatementSpec"].(model.CertifyVEXStatementSpec)) }) if resTmp == nil { @@ -5316,12 +6324,12 @@ func (ec *executionContext) _Query_HashEqual(ctx context.Context, field graphql. } return graphql.Null } - res := resTmp.([]*model.HashEqual) + res := resTmp.([]*model.CertifyVEXStatement) fc.Result = res - return ec.marshalNHashEqual2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHashEqualᚄ(ctx, field.Selections, res) + return ec.marshalNCertifyVEXStatement2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVEXStatementᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_HashEqual(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_CertifyVEXStatement(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -5330,19 +6338,29 @@ func (ec *executionContext) fieldContext_Query_HashEqual(ctx context.Context, fi Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_HashEqual_id(ctx, field) - case "artifacts": - return ec.fieldContext_HashEqual_artifacts(ctx, field) - case "justification": - return ec.fieldContext_HashEqual_justification(ctx, field) + return ec.fieldContext_CertifyVEXStatement_id(ctx, field) + case "subject": + return ec.fieldContext_CertifyVEXStatement_subject(ctx, field) + case "vulnerability": + return ec.fieldContext_CertifyVEXStatement_vulnerability(ctx, field) + case "status": + return ec.fieldContext_CertifyVEXStatement_status(ctx, field) + case "vexJustification": + return ec.fieldContext_CertifyVEXStatement_vexJustification(ctx, field) + case "statement": + return ec.fieldContext_CertifyVEXStatement_statement(ctx, field) + case "statusNotes": + return ec.fieldContext_CertifyVEXStatement_statusNotes(ctx, field) + case "knownSince": + return ec.fieldContext_CertifyVEXStatement_knownSince(ctx, field) case "origin": - return ec.fieldContext_HashEqual_origin(ctx, field) + return ec.fieldContext_CertifyVEXStatement_origin(ctx, field) case "collector": - return ec.fieldContext_HashEqual_collector(ctx, field) + return ec.fieldContext_CertifyVEXStatement_collector(ctx, field) case "documentRef": - return ec.fieldContext_HashEqual_documentRef(ctx, field) + return ec.fieldContext_CertifyVEXStatement_documentRef(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HashEqual", field.Name) + return nil, fmt.Errorf("no field named %q was found under type CertifyVEXStatement", field.Name) }, } defer func() { @@ -5352,15 +6370,15 @@ func (ec *executionContext) fieldContext_Query_HashEqual(ctx context.Context, fi } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_HashEqual_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_CertifyVEXStatement_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_IsDependency(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_IsDependency(ctx, field) +func (ec *executionContext) _Query_CertifyVEXStatementList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_CertifyVEXStatementList(ctx, field) if err != nil { return graphql.Null } @@ -5373,21 +6391,18 @@ func (ec *executionContext) _Query_IsDependency(ctx context.Context, field graph }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().IsDependency(rctx, fc.Args["isDependencySpec"].(model.IsDependencySpec)) + return ec.resolvers.Query().CertifyVEXStatementList(rctx, fc.Args["certifyVEXStatementSpec"].(model.CertifyVEXStatementSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*model.IsDependency) + res := resTmp.(*model.VEXConnection) fc.Result = res - return ec.marshalNIsDependency2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsDependencyᚄ(ctx, field.Selections, res) + return ec.marshalOVEXConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVEXConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_IsDependency(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_CertifyVEXStatementList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -5395,26 +6410,14 @@ func (ec *executionContext) fieldContext_Query_IsDependency(ctx context.Context, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_IsDependency_id(ctx, field) - case "package": - return ec.fieldContext_IsDependency_package(ctx, field) - case "dependencyPackage": - return ec.fieldContext_IsDependency_dependencyPackage(ctx, field) - case "versionRange": - return ec.fieldContext_IsDependency_versionRange(ctx, field) - case "dependencyType": - return ec.fieldContext_IsDependency_dependencyType(ctx, field) - case "justification": - return ec.fieldContext_IsDependency_justification(ctx, field) - case "origin": - return ec.fieldContext_IsDependency_origin(ctx, field) - case "collector": - return ec.fieldContext_IsDependency_collector(ctx, field) - case "documentRef": - return ec.fieldContext_IsDependency_documentRef(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type IsDependency", field.Name) + case "totalCount": + return ec.fieldContext_VEXConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_VEXConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_VEXConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VEXConnection", field.Name) }, } defer func() { @@ -5424,15 +6427,15 @@ func (ec *executionContext) fieldContext_Query_IsDependency(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_IsDependency_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_CertifyVEXStatementList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_IsOccurrence(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_IsOccurrence(ctx, field) +func (ec *executionContext) _Query_CertifyVuln(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_CertifyVuln(ctx, field) if err != nil { return graphql.Null } @@ -5445,7 +6448,7 @@ func (ec *executionContext) _Query_IsOccurrence(ctx context.Context, field graph }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().IsOccurrence(rctx, fc.Args["isOccurrenceSpec"].(model.IsOccurrenceSpec)) + return ec.resolvers.Query().CertifyVuln(rctx, fc.Args["certifyVulnSpec"].(model.CertifyVulnSpec)) }) if resTmp == nil { @@ -5454,12 +6457,12 @@ func (ec *executionContext) _Query_IsOccurrence(ctx context.Context, field graph } return graphql.Null } - res := resTmp.([]*model.IsOccurrence) + res := resTmp.([]*model.CertifyVuln) fc.Result = res - return ec.marshalNIsOccurrence2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceᚄ(ctx, field.Selections, res) + return ec.marshalNCertifyVuln2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVulnᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_IsOccurrence(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_CertifyVuln(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -5468,21 +6471,15 @@ func (ec *executionContext) fieldContext_Query_IsOccurrence(ctx context.Context, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_IsOccurrence_id(ctx, field) - case "subject": - return ec.fieldContext_IsOccurrence_subject(ctx, field) - case "artifact": - return ec.fieldContext_IsOccurrence_artifact(ctx, field) - case "justification": - return ec.fieldContext_IsOccurrence_justification(ctx, field) - case "origin": - return ec.fieldContext_IsOccurrence_origin(ctx, field) - case "collector": - return ec.fieldContext_IsOccurrence_collector(ctx, field) - case "documentRef": - return ec.fieldContext_IsOccurrence_documentRef(ctx, field) + return ec.fieldContext_CertifyVuln_id(ctx, field) + case "package": + return ec.fieldContext_CertifyVuln_package(ctx, field) + case "vulnerability": + return ec.fieldContext_CertifyVuln_vulnerability(ctx, field) + case "metadata": + return ec.fieldContext_CertifyVuln_metadata(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type IsOccurrence", field.Name) + return nil, fmt.Errorf("no field named %q was found under type CertifyVuln", field.Name) }, } defer func() { @@ -5492,15 +6489,15 @@ func (ec *executionContext) fieldContext_Query_IsOccurrence(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_IsOccurrence_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_CertifyVuln_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_licenses(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_licenses(ctx, field) +func (ec *executionContext) _Query_CertifyVulnList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_CertifyVulnList(ctx, field) if err != nil { return graphql.Null } @@ -5513,21 +6510,18 @@ func (ec *executionContext) _Query_licenses(ctx context.Context, field graphql.C }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Licenses(rctx, fc.Args["licenseSpec"].(model.LicenseSpec)) + return ec.resolvers.Query().CertifyVulnList(rctx, fc.Args["certifyVulnSpec"].(model.CertifyVulnSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*model.License) + res := resTmp.(*model.CertifyVulnConnection) fc.Result = res - return ec.marshalNLicense2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐLicenseᚄ(ctx, field.Selections, res) + return ec.marshalOCertifyVulnConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVulnConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_licenses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_CertifyVulnList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -5535,16 +6529,14 @@ func (ec *executionContext) fieldContext_Query_licenses(ctx context.Context, fie IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_License_id(ctx, field) - case "name": - return ec.fieldContext_License_name(ctx, field) - case "inline": - return ec.fieldContext_License_inline(ctx, field) - case "listVersion": - return ec.fieldContext_License_listVersion(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type License", field.Name) + case "totalCount": + return ec.fieldContext_CertifyVulnConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_CertifyVulnConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_CertifyVulnConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyVulnConnection", field.Name) }, } defer func() { @@ -5554,15 +6546,15 @@ func (ec *executionContext) fieldContext_Query_licenses(ctx context.Context, fie } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_licenses_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_CertifyVulnList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_HasMetadata(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_HasMetadata(ctx, field) +func (ec *executionContext) _Query_PointOfContact(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_PointOfContact(ctx, field) if err != nil { return graphql.Null } @@ -5575,7 +6567,7 @@ func (ec *executionContext) _Query_HasMetadata(ctx context.Context, field graphq }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().HasMetadata(rctx, fc.Args["hasMetadataSpec"].(model.HasMetadataSpec)) + return ec.resolvers.Query().PointOfContact(rctx, fc.Args["pointOfContactSpec"].(model.PointOfContactSpec)) }) if resTmp == nil { @@ -5584,12 +6576,12 @@ func (ec *executionContext) _Query_HasMetadata(ctx context.Context, field graphq } return graphql.Null } - res := resTmp.([]*model.HasMetadata) + res := resTmp.([]*model.PointOfContact) fc.Result = res - return ec.marshalNHasMetadata2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasMetadataᚄ(ctx, field.Selections, res) + return ec.marshalNPointOfContact2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContactᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_HasMetadata(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_PointOfContact(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -5598,25 +6590,25 @@ func (ec *executionContext) fieldContext_Query_HasMetadata(ctx context.Context, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_HasMetadata_id(ctx, field) + return ec.fieldContext_PointOfContact_id(ctx, field) case "subject": - return ec.fieldContext_HasMetadata_subject(ctx, field) - case "key": - return ec.fieldContext_HasMetadata_key(ctx, field) - case "value": - return ec.fieldContext_HasMetadata_value(ctx, field) - case "timestamp": - return ec.fieldContext_HasMetadata_timestamp(ctx, field) + return ec.fieldContext_PointOfContact_subject(ctx, field) + case "email": + return ec.fieldContext_PointOfContact_email(ctx, field) + case "info": + return ec.fieldContext_PointOfContact_info(ctx, field) + case "since": + return ec.fieldContext_PointOfContact_since(ctx, field) case "justification": - return ec.fieldContext_HasMetadata_justification(ctx, field) + return ec.fieldContext_PointOfContact_justification(ctx, field) case "origin": - return ec.fieldContext_HasMetadata_origin(ctx, field) + return ec.fieldContext_PointOfContact_origin(ctx, field) case "collector": - return ec.fieldContext_HasMetadata_collector(ctx, field) + return ec.fieldContext_PointOfContact_collector(ctx, field) case "documentRef": - return ec.fieldContext_HasMetadata_documentRef(ctx, field) + return ec.fieldContext_PointOfContact_documentRef(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type HasMetadata", field.Name) + return nil, fmt.Errorf("no field named %q was found under type PointOfContact", field.Name) }, } defer func() { @@ -5626,15 +6618,15 @@ func (ec *executionContext) fieldContext_Query_HasMetadata(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_HasMetadata_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_PointOfContact_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_packages(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_packages(ctx, field) +func (ec *executionContext) _Query_PointOfContactList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_PointOfContactList(ctx, field) if err != nil { return graphql.Null } @@ -5647,21 +6639,18 @@ func (ec *executionContext) _Query_packages(ctx context.Context, field graphql.C }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Packages(rctx, fc.Args["pkgSpec"].(model.PkgSpec)) + return ec.resolvers.Query().PointOfContactList(rctx, fc.Args["pointOfContactSpec"].(model.PointOfContactSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*model.Package) + res := resTmp.(*model.PointOfContactConnection) fc.Result = res - return ec.marshalNPackage2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageᚄ(ctx, field.Selections, res) + return ec.marshalOPointOfContactConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContactConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_packages(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_PointOfContactList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -5669,14 +6658,14 @@ func (ec *executionContext) fieldContext_Query_packages(ctx context.Context, fie IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Package_id(ctx, field) - case "type": - return ec.fieldContext_Package_type(ctx, field) - case "namespaces": - return ec.fieldContext_Package_namespaces(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Package", field.Name) + case "totalCount": + return ec.fieldContext_PointOfContactConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_PointOfContactConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_PointOfContactConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PointOfContactConnection", field.Name) }, } defer func() { @@ -5686,15 +6675,15 @@ func (ec *executionContext) fieldContext_Query_packages(ctx context.Context, fie } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_packages_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_PointOfContactList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_path(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_path(ctx, field) +func (ec *executionContext) _Query_HasSBOM(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_HasSBOM(ctx, field) if err != nil { return graphql.Null } @@ -5707,7 +6696,7 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Path(rctx, fc.Args["subject"].(string), fc.Args["target"].(string), fc.Args["maxPathLength"].(int), fc.Args["usingOnly"].([]model.Edge)) + return ec.resolvers.Query().HasSbom(rctx, fc.Args["hasSBOMSpec"].(model.HasSBOMSpec)) }) if resTmp == nil { @@ -5716,71 +6705,104 @@ func (ec *executionContext) _Query_path(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.([]model.Node) + res := resTmp.([]*model.HasSbom) fc.Result = res - return ec.marshalNNode2ᚕgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNodeᚄ(ctx, field.Selections, res) + return ec.marshalNHasSBOM2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSbomᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_HasSBOM(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Node does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_path_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_neighbors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_neighbors(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() + switch field.Name { + case "id": + return ec.fieldContext_HasSBOM_id(ctx, field) + case "subject": + return ec.fieldContext_HasSBOM_subject(ctx, field) + case "uri": + return ec.fieldContext_HasSBOM_uri(ctx, field) + case "algorithm": + return ec.fieldContext_HasSBOM_algorithm(ctx, field) + case "digest": + return ec.fieldContext_HasSBOM_digest(ctx, field) + case "downloadLocation": + return ec.fieldContext_HasSBOM_downloadLocation(ctx, field) + case "knownSince": + return ec.fieldContext_HasSBOM_knownSince(ctx, field) + case "origin": + return ec.fieldContext_HasSBOM_origin(ctx, field) + case "collector": + return ec.fieldContext_HasSBOM_collector(ctx, field) + case "documentRef": + return ec.fieldContext_HasSBOM_documentRef(ctx, field) + case "includedSoftware": + return ec.fieldContext_HasSBOM_includedSoftware(ctx, field) + case "includedDependencies": + return ec.fieldContext_HasSBOM_includedDependencies(ctx, field) + case "includedOccurrences": + return ec.fieldContext_HasSBOM_includedOccurrences(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasSBOM", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_HasSBOM_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_HasSBOMList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_HasSBOMList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Neighbors(rctx, fc.Args["node"].(string), fc.Args["usingOnly"].([]model.Edge)) + return ec.resolvers.Query().HasSBOMList(rctx, fc.Args["hasSBOMSpec"].(model.HasSBOMSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]model.Node) + res := resTmp.(*model.HasSBOMConnection) fc.Result = res - return ec.marshalNNode2ᚕgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNodeᚄ(ctx, field.Selections, res) + return ec.marshalOHasSBOMConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSBOMConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_neighbors(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_HasSBOMList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Node does not have child fields") + switch field.Name { + case "totalCount": + return ec.fieldContext_HasSBOMConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_HasSBOMConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_HasSBOMConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasSBOMConnection", field.Name) }, } defer func() { @@ -5790,15 +6812,15 @@ func (ec *executionContext) fieldContext_Query_neighbors(ctx context.Context, fi } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_neighbors_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_HasSBOMList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_node(ctx, field) +func (ec *executionContext) _Query_HasSLSA(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_HasSLSA(ctx, field) if err != nil { return graphql.Null } @@ -5811,7 +6833,7 @@ func (ec *executionContext) _Query_node(ctx context.Context, field graphql.Colle }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Node(rctx, fc.Args["node"].(string)) + return ec.resolvers.Query().HasSlsa(rctx, fc.Args["hasSLSASpec"].(model.HasSLSASpec)) }) if resTmp == nil { @@ -5820,19 +6842,27 @@ func (ec *executionContext) _Query_node(ctx context.Context, field graphql.Colle } return graphql.Null } - res := resTmp.(model.Node) + res := resTmp.([]*model.HasSlsa) fc.Result = res - return ec.marshalNNode2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNode(ctx, field.Selections, res) + return ec.marshalNHasSLSA2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSlsaᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_HasSLSA(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Node does not have child fields") + switch field.Name { + case "id": + return ec.fieldContext_HasSLSA_id(ctx, field) + case "subject": + return ec.fieldContext_HasSLSA_subject(ctx, field) + case "slsa": + return ec.fieldContext_HasSLSA_slsa(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasSLSA", field.Name) }, } defer func() { @@ -5842,15 +6872,15 @@ func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field g } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_HasSLSA_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_nodes(ctx, field) +func (ec *executionContext) _Query_HasSLSAList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_HasSLSAList(ctx, field) if err != nil { return graphql.Null } @@ -5863,28 +6893,33 @@ func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.Coll }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Nodes(rctx, fc.Args["nodes"].([]string)) + return ec.resolvers.Query().HasSLSAList(rctx, fc.Args["hasSLSASpec"].(model.HasSLSASpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]model.Node) + res := resTmp.(*model.HasSLSAConnection) fc.Result = res - return ec.marshalNNode2ᚕgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNodeᚄ(ctx, field.Selections, res) + return ec.marshalOHasSLSAConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSLSAConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_HasSLSAList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Node does not have child fields") + switch field.Name { + case "totalCount": + return ec.fieldContext_HasSLSAConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_HasSLSAConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_HasSLSAConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasSLSAConnection", field.Name) }, } defer func() { @@ -5894,15 +6929,15 @@ func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_HasSLSAList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_PkgEqual(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_PkgEqual(ctx, field) +func (ec *executionContext) _Query_HasSourceAt(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_HasSourceAt(ctx, field) if err != nil { return graphql.Null } @@ -5915,7 +6950,7 @@ func (ec *executionContext) _Query_PkgEqual(ctx context.Context, field graphql.C }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().PkgEqual(rctx, fc.Args["pkgEqualSpec"].(model.PkgEqualSpec)) + return ec.resolvers.Query().HasSourceAt(rctx, fc.Args["hasSourceAtSpec"].(model.HasSourceAtSpec)) }) if resTmp == nil { @@ -5924,12 +6959,12 @@ func (ec *executionContext) _Query_PkgEqual(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]*model.PkgEqual) + res := resTmp.([]*model.HasSourceAt) fc.Result = res - return ec.marshalNPkgEqual2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqualᚄ(ctx, field.Selections, res) + return ec.marshalNHasSourceAt2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSourceAtᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_PkgEqual(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_HasSourceAt(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -5938,19 +6973,23 @@ func (ec *executionContext) fieldContext_Query_PkgEqual(ctx context.Context, fie Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_PkgEqual_id(ctx, field) - case "packages": - return ec.fieldContext_PkgEqual_packages(ctx, field) + return ec.fieldContext_HasSourceAt_id(ctx, field) + case "package": + return ec.fieldContext_HasSourceAt_package(ctx, field) + case "source": + return ec.fieldContext_HasSourceAt_source(ctx, field) + case "knownSince": + return ec.fieldContext_HasSourceAt_knownSince(ctx, field) case "justification": - return ec.fieldContext_PkgEqual_justification(ctx, field) + return ec.fieldContext_HasSourceAt_justification(ctx, field) case "origin": - return ec.fieldContext_PkgEqual_origin(ctx, field) + return ec.fieldContext_HasSourceAt_origin(ctx, field) case "collector": - return ec.fieldContext_PkgEqual_collector(ctx, field) + return ec.fieldContext_HasSourceAt_collector(ctx, field) case "documentRef": - return ec.fieldContext_PkgEqual_documentRef(ctx, field) + return ec.fieldContext_HasSourceAt_documentRef(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type PkgEqual", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HasSourceAt", field.Name) }, } defer func() { @@ -5960,15 +6999,15 @@ func (ec *executionContext) fieldContext_Query_PkgEqual(ctx context.Context, fie } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_PkgEqual_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_HasSourceAt_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_findSoftware(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_findSoftware(ctx, field) +func (ec *executionContext) _Query_HasSourceAtList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_HasSourceAtList(ctx, field) if err != nil { return graphql.Null } @@ -5981,28 +7020,33 @@ func (ec *executionContext) _Query_findSoftware(ctx context.Context, field graph }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().FindSoftware(rctx, fc.Args["searchText"].(string)) + return ec.resolvers.Query().HasSourceAtList(rctx, fc.Args["hasSourceAtSpec"].(model.HasSourceAtSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]model.PackageSourceOrArtifact) + res := resTmp.(*model.HasSourceAtConnection) fc.Result = res - return ec.marshalNPackageSourceOrArtifact2ᚕgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageSourceOrArtifactᚄ(ctx, field.Selections, res) + return ec.marshalOHasSourceAtConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSourceAtConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_findSoftware(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_HasSourceAtList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type PackageSourceOrArtifact does not have child fields") + switch field.Name { + case "totalCount": + return ec.fieldContext_HasSourceAtConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_HasSourceAtConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_HasSourceAtConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasSourceAtConnection", field.Name) }, } defer func() { @@ -6012,15 +7056,15 @@ func (ec *executionContext) fieldContext_Query_findSoftware(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_findSoftware_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_HasSourceAtList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_sources(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_sources(ctx, field) +func (ec *executionContext) _Query_HashEqual(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_HashEqual(ctx, field) if err != nil { return graphql.Null } @@ -6033,7 +7077,7 @@ func (ec *executionContext) _Query_sources(ctx context.Context, field graphql.Co }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Sources(rctx, fc.Args["sourceSpec"].(model.SourceSpec)) + return ec.resolvers.Query().HashEqual(rctx, fc.Args["hashEqualSpec"].(model.HashEqualSpec)) }) if resTmp == nil { @@ -6042,12 +7086,12 @@ func (ec *executionContext) _Query_sources(ctx context.Context, field graphql.Co } return graphql.Null } - res := resTmp.([]*model.Source) + res := resTmp.([]*model.HashEqual) fc.Result = res - return ec.marshalNSource2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSourceᚄ(ctx, field.Selections, res) + return ec.marshalNHashEqual2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHashEqualᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_sources(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_HashEqual(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -6056,13 +7100,19 @@ func (ec *executionContext) fieldContext_Query_sources(ctx context.Context, fiel Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_Source_id(ctx, field) - case "type": - return ec.fieldContext_Source_type(ctx, field) - case "namespaces": - return ec.fieldContext_Source_namespaces(ctx, field) + return ec.fieldContext_HashEqual_id(ctx, field) + case "artifacts": + return ec.fieldContext_HashEqual_artifacts(ctx, field) + case "justification": + return ec.fieldContext_HashEqual_justification(ctx, field) + case "origin": + return ec.fieldContext_HashEqual_origin(ctx, field) + case "collector": + return ec.fieldContext_HashEqual_collector(ctx, field) + case "documentRef": + return ec.fieldContext_HashEqual_documentRef(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Source", field.Name) + return nil, fmt.Errorf("no field named %q was found under type HashEqual", field.Name) }, } defer func() { @@ -6072,15 +7122,15 @@ func (ec *executionContext) fieldContext_Query_sources(ctx context.Context, fiel } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_sources_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_HashEqual_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_vulnEqual(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_vulnEqual(ctx, field) +func (ec *executionContext) _Query_HashEqualList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_HashEqualList(ctx, field) if err != nil { return graphql.Null } @@ -6093,21 +7143,18 @@ func (ec *executionContext) _Query_vulnEqual(ctx context.Context, field graphql. }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().VulnEqual(rctx, fc.Args["vulnEqualSpec"].(model.VulnEqualSpec)) + return ec.resolvers.Query().HashEqualList(rctx, fc.Args["hashEqualSpec"].(model.HashEqualSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*model.VulnEqual) + res := resTmp.(*model.HashEqualConnection) fc.Result = res - return ec.marshalNVulnEqual2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnEqualᚄ(ctx, field.Selections, res) + return ec.marshalOHashEqualConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHashEqualConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_vulnEqual(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_HashEqualList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -6115,20 +7162,14 @@ func (ec *executionContext) fieldContext_Query_vulnEqual(ctx context.Context, fi IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_VulnEqual_id(ctx, field) - case "vulnerabilities": - return ec.fieldContext_VulnEqual_vulnerabilities(ctx, field) - case "justification": - return ec.fieldContext_VulnEqual_justification(ctx, field) - case "origin": - return ec.fieldContext_VulnEqual_origin(ctx, field) - case "collector": - return ec.fieldContext_VulnEqual_collector(ctx, field) - case "documentRef": - return ec.fieldContext_VulnEqual_documentRef(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type VulnEqual", field.Name) + case "totalCount": + return ec.fieldContext_HashEqualConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_HashEqualConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_HashEqualConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HashEqualConnection", field.Name) }, } defer func() { @@ -6138,15 +7179,15 @@ func (ec *executionContext) fieldContext_Query_vulnEqual(ctx context.Context, fi } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_vulnEqual_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_HashEqualList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_vulnerabilityMetadata(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_vulnerabilityMetadata(ctx, field) +func (ec *executionContext) _Query_IsDependency(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_IsDependency(ctx, field) if err != nil { return graphql.Null } @@ -6159,7 +7200,7 @@ func (ec *executionContext) _Query_vulnerabilityMetadata(ctx context.Context, fi }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().VulnerabilityMetadata(rctx, fc.Args["vulnerabilityMetadataSpec"].(model.VulnerabilityMetadataSpec)) + return ec.resolvers.Query().IsDependency(rctx, fc.Args["isDependencySpec"].(model.IsDependencySpec)) }) if resTmp == nil { @@ -6168,12 +7209,12 @@ func (ec *executionContext) _Query_vulnerabilityMetadata(ctx context.Context, fi } return graphql.Null } - res := resTmp.([]*model.VulnerabilityMetadata) + res := resTmp.([]*model.IsDependency) fc.Result = res - return ec.marshalNVulnerabilityMetadata2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityMetadataᚄ(ctx, field.Selections, res) + return ec.marshalNIsDependency2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsDependencyᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_vulnerabilityMetadata(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_IsDependency(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -6182,23 +7223,25 @@ func (ec *executionContext) fieldContext_Query_vulnerabilityMetadata(ctx context Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": - return ec.fieldContext_VulnerabilityMetadata_id(ctx, field) - case "vulnerability": - return ec.fieldContext_VulnerabilityMetadata_vulnerability(ctx, field) - case "scoreType": - return ec.fieldContext_VulnerabilityMetadata_scoreType(ctx, field) - case "scoreValue": - return ec.fieldContext_VulnerabilityMetadata_scoreValue(ctx, field) - case "timestamp": - return ec.fieldContext_VulnerabilityMetadata_timestamp(ctx, field) + return ec.fieldContext_IsDependency_id(ctx, field) + case "package": + return ec.fieldContext_IsDependency_package(ctx, field) + case "dependencyPackage": + return ec.fieldContext_IsDependency_dependencyPackage(ctx, field) + case "versionRange": + return ec.fieldContext_IsDependency_versionRange(ctx, field) + case "dependencyType": + return ec.fieldContext_IsDependency_dependencyType(ctx, field) + case "justification": + return ec.fieldContext_IsDependency_justification(ctx, field) case "origin": - return ec.fieldContext_VulnerabilityMetadata_origin(ctx, field) + return ec.fieldContext_IsDependency_origin(ctx, field) case "collector": - return ec.fieldContext_VulnerabilityMetadata_collector(ctx, field) + return ec.fieldContext_IsDependency_collector(ctx, field) case "documentRef": - return ec.fieldContext_VulnerabilityMetadata_documentRef(ctx, field) + return ec.fieldContext_IsDependency_documentRef(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type VulnerabilityMetadata", field.Name) + return nil, fmt.Errorf("no field named %q was found under type IsDependency", field.Name) }, } defer func() { @@ -6208,15 +7251,15 @@ func (ec *executionContext) fieldContext_Query_vulnerabilityMetadata(ctx context } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_vulnerabilityMetadata_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_IsDependency_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query_vulnerabilities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query_vulnerabilities(ctx, field) +func (ec *executionContext) _Query_IsDependencyList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_IsDependencyList(ctx, field) if err != nil { return graphql.Null } @@ -6229,21 +7272,18 @@ func (ec *executionContext) _Query_vulnerabilities(ctx context.Context, field gr }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Vulnerabilities(rctx, fc.Args["vulnSpec"].(model.VulnerabilitySpec)) + return ec.resolvers.Query().IsDependencyList(rctx, fc.Args["isDependencySpec"].(model.IsDependencySpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.([]*model.Vulnerability) + res := resTmp.(*model.IsDependencyConnection) fc.Result = res - return ec.marshalNVulnerability2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityᚄ(ctx, field.Selections, res) + return ec.marshalOIsDependencyConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsDependencyConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query_vulnerabilities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_IsDependencyList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, @@ -6251,14 +7291,14 @@ func (ec *executionContext) fieldContext_Query_vulnerabilities(ctx context.Conte IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "id": - return ec.fieldContext_Vulnerability_id(ctx, field) - case "type": - return ec.fieldContext_Vulnerability_type(ctx, field) - case "vulnerabilityIDs": - return ec.fieldContext_Vulnerability_vulnerabilityIDs(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Vulnerability", field.Name) + case "totalCount": + return ec.fieldContext_IsDependencyConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_IsDependencyConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_IsDependencyConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type IsDependencyConnection", field.Name) }, } defer func() { @@ -6268,15 +7308,15 @@ func (ec *executionContext) fieldContext_Query_vulnerabilities(ctx context.Conte } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_vulnerabilities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_IsDependencyList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___type(ctx, field) +func (ec *executionContext) _Query_IsOccurrence(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_IsOccurrence(ctx, field) if err != nil { return graphql.Null } @@ -6289,47 +7329,44 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + return ec.resolvers.Query().IsOccurrence(rctx, fc.Args["isOccurrenceSpec"].(model.IsOccurrenceSpec)) }) if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]*model.IsOccurrence) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalNIsOccurrence2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceᚄ(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_IsOccurrence(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) - case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) + case "id": + return ec.fieldContext_IsOccurrence_id(ctx, field) + case "subject": + return ec.fieldContext_IsOccurrence_subject(ctx, field) + case "artifact": + return ec.fieldContext_IsOccurrence_artifact(ctx, field) + case "justification": + return ec.fieldContext_IsOccurrence_justification(ctx, field) + case "origin": + return ec.fieldContext_IsOccurrence_origin(ctx, field) + case "collector": + return ec.fieldContext_IsOccurrence_collector(ctx, field) + case "documentRef": + return ec.fieldContext_IsOccurrence_documentRef(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type IsOccurrence", field.Name) }, } defer func() { @@ -6339,15 +7376,15 @@ func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_IsOccurrence_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Query___schema(ctx, field) +func (ec *executionContext) _Query_IsOccurrenceList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_IsOccurrenceList(ctx, field) if err != nil { return graphql.Null } @@ -6360,151 +7397,1625 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C }() resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() + return ec.resolvers.Query().IsOccurrenceList(rctx, fc.Args["isOccurrenceSpec"].(model.IsOccurrenceSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Schema) + res := resTmp.(*model.IsOccurrenceConnection) fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) + return ec.marshalOIsOccurrenceConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceConnection(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_IsOccurrenceList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Query", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + case "totalCount": + return ec.fieldContext_IsOccurrenceConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_IsOccurrenceConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_IsOccurrenceConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type IsOccurrenceConnection", field.Name) }, } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_IsOccurrenceList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } return fc, nil } -// endregion **************************** field.gotpl ***************************** - -// region **************************** input.gotpl ***************************** - -func (ec *executionContext) unmarshalInputArtifactInputSpec(ctx context.Context, obj interface{}) (model.ArtifactInputSpec, error) { - var it model.ArtifactInputSpec - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v +func (ec *executionContext) _Query_licenses(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_licenses(ctx, field) + if err != nil { + return graphql.Null } - - fieldsInOrder := [...]string{"algorithm", "digest"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null } - switch k { - case "algorithm": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithm")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Algorithm = data - case "digest": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("digest")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Digest = data + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Licenses(rctx, fc.Args["licenseSpec"].(model.LicenseSpec)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") } + return graphql.Null } - - return it, nil + res := resTmp.([]*model.License) + fc.Result = res + return ec.marshalNLicense2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐLicenseᚄ(ctx, field.Selections, res) } -func (ec *executionContext) unmarshalInputArtifactSpec(ctx context.Context, obj interface{}) (model.ArtifactSpec, error) { - var it model.ArtifactSpec - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"id", "algorithm", "digest"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "id": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) - data, err := ec.unmarshalOID2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ID = data - case "algorithm": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithm")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Algorithm = data - case "digest": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("digest")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err +func (ec *executionContext) fieldContext_Query_licenses(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_License_id(ctx, field) + case "name": + return ec.fieldContext_License_name(ctx, field) + case "inline": + return ec.fieldContext_License_inline(ctx, field) + case "listVersion": + return ec.fieldContext_License_listVersion(ctx, field) } - it.Digest = data + return nil, fmt.Errorf("no field named %q was found under type License", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_licenses_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err } - - return it, nil + return fc, nil } -func (ec *executionContext) unmarshalInputIDorArtifactInput(ctx context.Context, obj interface{}) (model.IDorArtifactInput, error) { - var it model.IDorArtifactInput - asMap := map[string]interface{}{} - for k, v := range obj.(map[string]interface{}) { - asMap[k] = v +func (ec *executionContext) _Query_licenseList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_licenseList(ctx, field) + if err != nil { + return graphql.Null } - - fieldsInOrder := [...]string{"artifactID", "artifactInput"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "artifactID": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactID")) - data, err := ec.unmarshalOID2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ArtifactID = data - case "artifactInput": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactInput")) - data, err := ec.unmarshalOArtifactInputSpec2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐArtifactInputSpec(ctx, v) - if err != nil { - return it, err - } - it.ArtifactInput = data + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().LicenseList(rctx, fc.Args["licenseSpec"].(model.LicenseSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.LicenseConnection) + fc.Result = res + return ec.marshalOLicenseConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐLicenseConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_licenseList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_LicenseConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_LicenseConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_LicenseConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type LicenseConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_licenseList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_HasMetadata(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_HasMetadata(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().HasMetadata(rctx, fc.Args["hasMetadataSpec"].(model.HasMetadataSpec)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.HasMetadata) + fc.Result = res + return ec.marshalNHasMetadata2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasMetadataᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_HasMetadata(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_HasMetadata_id(ctx, field) + case "subject": + return ec.fieldContext_HasMetadata_subject(ctx, field) + case "key": + return ec.fieldContext_HasMetadata_key(ctx, field) + case "value": + return ec.fieldContext_HasMetadata_value(ctx, field) + case "timestamp": + return ec.fieldContext_HasMetadata_timestamp(ctx, field) + case "justification": + return ec.fieldContext_HasMetadata_justification(ctx, field) + case "origin": + return ec.fieldContext_HasMetadata_origin(ctx, field) + case "collector": + return ec.fieldContext_HasMetadata_collector(ctx, field) + case "documentRef": + return ec.fieldContext_HasMetadata_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasMetadata", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_HasMetadata_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_HasMetadataList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_HasMetadataList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().HasMetadataList(rctx, fc.Args["hasMetadataSpec"].(model.HasMetadataSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.HasMetadataConnection) + fc.Result = res + return ec.marshalOHasMetadataConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasMetadataConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_HasMetadataList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_HasMetadataConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_HasMetadataConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_HasMetadataConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasMetadataConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_HasMetadataList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_packages(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_packages(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Packages(rctx, fc.Args["pkgSpec"].(model.PkgSpec)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.Package) + fc.Result = res + return ec.marshalNPackage2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_packages(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Package_id(ctx, field) + case "type": + return ec.fieldContext_Package_type(ctx, field) + case "namespaces": + return ec.fieldContext_Package_namespaces(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Package", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_packages_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_packagesList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_packagesList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().PackagesList(rctx, fc.Args["pkgSpec"].(model.PkgSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.PackageConnection) + fc.Result = res + return ec.marshalOPackageConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_packagesList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_PackageConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_PackageConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_PackageConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PackageConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_packagesList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_path(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_path(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Path(rctx, fc.Args["subject"].(string), fc.Args["target"].(string), fc.Args["maxPathLength"].(int), fc.Args["usingOnly"].([]model.Edge)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]model.Node) + fc.Result = res + return ec.marshalNNode2ᚕgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNodeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_path(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Node does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_path_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_neighbors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_neighbors(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Neighbors(rctx, fc.Args["node"].(string), fc.Args["usingOnly"].([]model.Edge)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]model.Node) + fc.Result = res + return ec.marshalNNode2ᚕgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNodeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_neighbors(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Node does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_neighbors_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_neighborsList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_neighborsList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().NeighborsList(rctx, fc.Args["node"].(string), fc.Args["usingOnly"].([]model.Edge), fc.Args["after"].(*string), fc.Args["first"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.NeighborConnection) + fc.Result = res + return ec.marshalONeighborConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNeighborConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_neighborsList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_NeighborConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_NeighborConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_NeighborConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type NeighborConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_neighborsList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Node(rctx, fc.Args["node"].(string)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(model.Node) + fc.Result = res + return ec.marshalNNode2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNode(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Node does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_node_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_nodes(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_nodes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Nodes(rctx, fc.Args["nodes"].([]string)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]model.Node) + fc.Result = res + return ec.marshalNNode2ᚕgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNodeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_nodes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Node does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_nodes_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_PkgEqual(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_PkgEqual(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().PkgEqual(rctx, fc.Args["pkgEqualSpec"].(model.PkgEqualSpec)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.PkgEqual) + fc.Result = res + return ec.marshalNPkgEqual2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqualᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_PkgEqual(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_PkgEqual_id(ctx, field) + case "packages": + return ec.fieldContext_PkgEqual_packages(ctx, field) + case "justification": + return ec.fieldContext_PkgEqual_justification(ctx, field) + case "origin": + return ec.fieldContext_PkgEqual_origin(ctx, field) + case "collector": + return ec.fieldContext_PkgEqual_collector(ctx, field) + case "documentRef": + return ec.fieldContext_PkgEqual_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PkgEqual", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_PkgEqual_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_PkgEqualList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_PkgEqualList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().PkgEqualList(rctx, fc.Args["pkgEqualSpec"].(model.PkgEqualSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.PkgEqualConnection) + fc.Result = res + return ec.marshalOPkgEqualConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqualConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_PkgEqualList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_PkgEqualConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_PkgEqualConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_PkgEqualConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PkgEqualConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_PkgEqualList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_findSoftware(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_findSoftware(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().FindSoftware(rctx, fc.Args["searchText"].(string)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]model.PackageSourceOrArtifact) + fc.Result = res + return ec.marshalNPackageSourceOrArtifact2ᚕgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageSourceOrArtifactᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_findSoftware(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type PackageSourceOrArtifact does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_findSoftware_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_findSoftwareList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_findSoftwareList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().FindSoftwareList(rctx, fc.Args["searchText"].(string), fc.Args["after"].(*string), fc.Args["first"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.FindSoftwareConnection) + fc.Result = res + return ec.marshalOFindSoftwareConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐFindSoftwareConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_findSoftwareList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_FindSoftwareConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_FindSoftwareConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_FindSoftwareConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type FindSoftwareConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_findSoftwareList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_sources(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_sources(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Sources(rctx, fc.Args["sourceSpec"].(model.SourceSpec)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.Source) + fc.Result = res + return ec.marshalNSource2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSourceᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_sources(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Source_id(ctx, field) + case "type": + return ec.fieldContext_Source_type(ctx, field) + case "namespaces": + return ec.fieldContext_Source_namespaces(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Source", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_sources_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_sourcesList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_sourcesList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().SourcesList(rctx, fc.Args["sourceSpec"].(model.SourceSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.SourceConnection) + fc.Result = res + return ec.marshalOSourceConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSourceConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_sourcesList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_SourceConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_SourceConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_SourceConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SourceConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_sourcesList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_vulnEqual(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_vulnEqual(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().VulnEqual(rctx, fc.Args["vulnEqualSpec"].(model.VulnEqualSpec)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.VulnEqual) + fc.Result = res + return ec.marshalNVulnEqual2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnEqualᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_vulnEqual(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_VulnEqual_id(ctx, field) + case "vulnerabilities": + return ec.fieldContext_VulnEqual_vulnerabilities(ctx, field) + case "justification": + return ec.fieldContext_VulnEqual_justification(ctx, field) + case "origin": + return ec.fieldContext_VulnEqual_origin(ctx, field) + case "collector": + return ec.fieldContext_VulnEqual_collector(ctx, field) + case "documentRef": + return ec.fieldContext_VulnEqual_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VulnEqual", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_vulnEqual_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_vulnEqualList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_vulnEqualList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().VulnEqualList(rctx, fc.Args["vulnEqualSpec"].(model.VulnEqualSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.VulnEqualConnection) + fc.Result = res + return ec.marshalOVulnEqualConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnEqualConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_vulnEqualList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_VulnEqualConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_VulnEqualConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_VulnEqualConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VulnEqualConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_vulnEqualList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_vulnerabilityMetadata(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_vulnerabilityMetadata(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().VulnerabilityMetadata(rctx, fc.Args["vulnerabilityMetadataSpec"].(model.VulnerabilityMetadataSpec)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.VulnerabilityMetadata) + fc.Result = res + return ec.marshalNVulnerabilityMetadata2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityMetadataᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_vulnerabilityMetadata(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_VulnerabilityMetadata_id(ctx, field) + case "vulnerability": + return ec.fieldContext_VulnerabilityMetadata_vulnerability(ctx, field) + case "scoreType": + return ec.fieldContext_VulnerabilityMetadata_scoreType(ctx, field) + case "scoreValue": + return ec.fieldContext_VulnerabilityMetadata_scoreValue(ctx, field) + case "timestamp": + return ec.fieldContext_VulnerabilityMetadata_timestamp(ctx, field) + case "origin": + return ec.fieldContext_VulnerabilityMetadata_origin(ctx, field) + case "collector": + return ec.fieldContext_VulnerabilityMetadata_collector(ctx, field) + case "documentRef": + return ec.fieldContext_VulnerabilityMetadata_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VulnerabilityMetadata", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_vulnerabilityMetadata_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_vulnerabilityMetadataList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_vulnerabilityMetadataList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().VulnerabilityMetadataList(rctx, fc.Args["vulnerabilityMetadataSpec"].(model.VulnerabilityMetadataSpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.VulnerabilityMetadataConnection) + fc.Result = res + return ec.marshalOVulnerabilityMetadataConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityMetadataConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_vulnerabilityMetadataList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_VulnerabilityMetadataConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_VulnerabilityMetadataConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_VulnerabilityMetadataConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VulnerabilityMetadataConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_vulnerabilityMetadataList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_vulnerabilities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_vulnerabilities(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Vulnerabilities(rctx, fc.Args["vulnSpec"].(model.VulnerabilitySpec)) + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.Vulnerability) + fc.Result = res + return ec.marshalNVulnerability2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_vulnerabilities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Vulnerability_id(ctx, field) + case "type": + return ec.fieldContext_Vulnerability_type(ctx, field) + case "vulnerabilityIDs": + return ec.fieldContext_Vulnerability_vulnerabilityIDs(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Vulnerability", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_vulnerabilities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_vulnerabilityList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_vulnerabilityList(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().VulnerabilityList(rctx, fc.Args["vulnSpec"].(model.VulnerabilitySpec), fc.Args["after"].(*string), fc.Args["first"].(*int)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.VulnerabilityConnection) + fc.Result = res + return ec.marshalOVulnerabilityConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityConnection(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_vulnerabilityList(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "totalCount": + return ec.fieldContext_VulnerabilityConnection_totalCount(ctx, field) + case "pageInfo": + return ec.fieldContext_VulnerabilityConnection_pageInfo(ctx, field) + case "edges": + return ec.fieldContext_VulnerabilityConnection_edges(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VulnerabilityConnection", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_vulnerabilityList_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputArtifactInputSpec(ctx context.Context, obj interface{}) (model.ArtifactInputSpec, error) { + var it model.ArtifactInputSpec + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"algorithm", "digest"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "algorithm": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithm")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Algorithm = data + case "digest": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("digest")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.Digest = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputArtifactSpec(ctx context.Context, obj interface{}) (model.ArtifactSpec, error) { + var it model.ArtifactSpec + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"id", "algorithm", "digest"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "id": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ID = data + case "algorithm": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("algorithm")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Algorithm = data + case "digest": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("digest")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.Digest = data + } + } + + return it, nil +} + +func (ec *executionContext) unmarshalInputIDorArtifactInput(ctx context.Context, obj interface{}) (model.IDorArtifactInput, error) { + var it model.IDorArtifactInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"artifactID", "artifactInput"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "artifactID": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactID")) + data, err := ec.unmarshalOID2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ArtifactID = data + case "artifactInput": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("artifactInput")) + data, err := ec.unmarshalOArtifactInputSpec2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐArtifactInputSpec(ctx, v) + if err != nil { + return it, err + } + it.ArtifactInput = data } } @@ -6568,6 +9079,99 @@ func (ec *executionContext) _Artifact(ctx context.Context, sel ast.SelectionSet, return out } +var artifactConnectionImplementors = []string{"ArtifactConnection"} + +func (ec *executionContext) _ArtifactConnection(ctx context.Context, sel ast.SelectionSet, obj *model.ArtifactConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, artifactConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ArtifactConnection") + case "totalCount": + out.Values[i] = ec._ArtifactConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._ArtifactConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._ArtifactConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var artifactEdgeImplementors = []string{"ArtifactEdge"} + +func (ec *executionContext) _ArtifactEdge(ctx context.Context, sel ast.SelectionSet, obj *model.ArtifactEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, artifactEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ArtifactEdge") + case "cursor": + out.Values[i] = ec._ArtifactEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._ArtifactEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { @@ -6769,189 +9373,558 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } - case "ingestDependency": + case "ingestDependency": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_ingestDependency(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "ingestDependencies": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_ingestDependencies(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "ingestOccurrence": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_ingestOccurrence(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "ingestOccurrences": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_ingestOccurrences(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "ingestLicense": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_ingestLicense(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "ingestLicenses": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_ingestLicenses(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "ingestHasMetadata": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_ingestHasMetadata(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "ingestBulkHasMetadata": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_ingestBulkHasMetadata(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "ingestPackage": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_ingestPackage(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "ingestPackages": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_ingestPackages(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "ingestPkgEqual": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_ingestPkgEqual(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "ingestPkgEquals": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_ingestPkgEquals(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "ingestSource": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestDependency(ctx, field) + return ec._Mutation_ingestSource(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "ingestDependencies": + case "ingestSources": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestDependencies(ctx, field) + return ec._Mutation_ingestSources(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "ingestOccurrence": + case "ingestVulnEqual": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestOccurrence(ctx, field) + return ec._Mutation_ingestVulnEqual(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "ingestOccurrences": + case "ingestVulnEquals": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestOccurrences(ctx, field) + return ec._Mutation_ingestVulnEquals(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "ingestLicense": + case "ingestVulnerabilityMetadata": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestLicense(ctx, field) + return ec._Mutation_ingestVulnerabilityMetadata(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "ingestLicenses": + case "ingestBulkVulnerabilityMetadata": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestLicenses(ctx, field) + return ec._Mutation_ingestBulkVulnerabilityMetadata(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "ingestHasMetadata": + case "ingestVulnerability": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestHasMetadata(ctx, field) + return ec._Mutation_ingestVulnerability(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "ingestBulkHasMetadata": + case "ingestVulnerabilities": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestBulkHasMetadata(ctx, field) + return ec._Mutation_ingestVulnerabilities(ctx, field) }) if out.Values[i] == graphql.Null { out.Invalids++ } - case "ingestPackage": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestPackage(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var queryImplementors = []string{"Query"} + +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ + Object: "Query", + }) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ + Object: field.Name, + Field: field, + }) + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Query") + case "artifacts": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_artifacts(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "artifactsList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_artifactsList(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "builders": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_builders(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "buildersList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_buildersList(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "CertifyBad": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_CertifyBad(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "CertifyBadList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_CertifyBadList(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "CertifyGood": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_CertifyGood(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "CertifyGoodList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_CertifyGoodList(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "CertifyLegal": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_CertifyLegal(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "CertifyLegalList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_CertifyLegalList(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - case "ingestPackages": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestPackages(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "scorecards": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_scorecards(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res } - case "ingestPkgEqual": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestPkgEqual(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - case "ingestPkgEquals": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestPkgEquals(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "scorecardsList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_scorecardsList(ctx, field) + return res } - case "ingestSource": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestSource(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - case "ingestSources": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestSources(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "CertifyVEXStatement": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_CertifyVEXStatement(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res } - case "ingestVulnEqual": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestVulnEqual(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - case "ingestVulnEquals": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestVulnEquals(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "CertifyVEXStatementList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_CertifyVEXStatementList(ctx, field) + return res } - case "ingestVulnerabilityMetadata": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestVulnerabilityMetadata(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - case "ingestBulkVulnerabilityMetadata": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestBulkVulnerabilityMetadata(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "CertifyVuln": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_CertifyVuln(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res } - case "ingestVulnerability": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestVulnerability(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - case "ingestVulnerabilities": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_ingestVulnerabilities(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "CertifyVulnList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_CertifyVulnList(ctx, field) + return res } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - atomic.AddInt32(&ec.deferred, int32(len(deferred))) + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } - for label, dfs := range deferred { - ec.processDeferredGroup(graphql.DeferredGroup{ - Label: label, - Path: graphql.GetPath(ctx), - FieldSet: dfs, - Context: ctx, - }) - } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "PointOfContact": + field := field - return out -} + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_PointOfContact(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } -var queryImplementors = []string{"Query"} + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } -func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Query", - }) + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "PointOfContactList": + field := field - out := graphql.NewFieldSet(fields) - deferred := make(map[string]*graphql.FieldSet) - for i, field := range fields { - innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ - Object: field.Name, - Field: field, - }) + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_PointOfContactList(ctx, field) + return res + } - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Query") - case "artifacts": + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "HasSBOM": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -6960,7 +9933,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_artifacts(ctx, field) + res = ec._Query_HasSBOM(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -6973,7 +9946,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "builders": + case "HasSBOMList": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -6982,10 +9955,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_builders(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_HasSBOMList(ctx, field) return res } @@ -6995,7 +9965,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "CertifyBad": + case "HasSLSA": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7004,7 +9974,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_CertifyBad(ctx, field) + res = ec._Query_HasSLSA(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -7017,7 +9987,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "CertifyGood": + case "HasSLSAList": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7026,10 +9996,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_CertifyGood(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_HasSLSAList(ctx, field) return res } @@ -7039,7 +10006,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "CertifyLegal": + case "HasSourceAt": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7048,7 +10015,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_CertifyLegal(ctx, field) + res = ec._Query_HasSourceAt(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -7061,7 +10028,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "scorecards": + case "HasSourceAtList": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7070,10 +10037,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_scorecards(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_HasSourceAtList(ctx, field) return res } @@ -7083,7 +10047,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "CertifyVEXStatement": + case "HashEqual": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7092,7 +10056,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_CertifyVEXStatement(ctx, field) + res = ec._Query_HashEqual(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -7105,7 +10069,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "CertifyVuln": + case "HashEqualList": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7114,10 +10078,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_CertifyVuln(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_HashEqualList(ctx, field) return res } @@ -7127,7 +10088,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "PointOfContact": + case "IsDependency": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7136,7 +10097,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_PointOfContact(ctx, field) + res = ec._Query_IsDependency(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -7149,7 +10110,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "HasSBOM": + case "IsDependencyList": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7158,10 +10119,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_HasSBOM(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_IsDependencyList(ctx, field) return res } @@ -7171,7 +10129,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "HasSLSA": + case "IsOccurrence": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7180,7 +10138,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_HasSLSA(ctx, field) + res = ec._Query_IsOccurrence(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -7193,7 +10151,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "HasSourceAt": + case "IsOccurrenceList": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7202,10 +10160,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_HasSourceAt(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_IsOccurrenceList(ctx, field) return res } @@ -7215,7 +10170,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "HashEqual": + case "licenses": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7224,7 +10179,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_HashEqual(ctx, field) + res = ec._Query_licenses(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -7237,7 +10192,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "IsDependency": + case "licenseList": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7246,10 +10201,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_IsDependency(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_licenseList(ctx, field) return res } @@ -7259,7 +10211,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "IsOccurrence": + case "HasMetadata": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7268,7 +10220,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_IsOccurrence(ctx, field) + res = ec._Query_HasMetadata(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -7281,7 +10233,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "licenses": + case "HasMetadataList": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7290,10 +10242,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_licenses(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_HasMetadataList(ctx, field) return res } @@ -7303,7 +10252,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "HasMetadata": + case "packages": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7312,7 +10261,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_HasMetadata(ctx, field) + res = ec._Query_packages(ctx, field) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -7325,7 +10274,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "packages": + case "packagesList": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -7334,10 +10283,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_packages(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } + res = ec._Query_packagesList(ctx, field) return res } @@ -7390,6 +10336,25 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "neighborsList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_neighborsList(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "node": field := field @@ -7456,6 +10421,25 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "PkgEqualList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_PkgEqualList(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "findSoftware": field := field @@ -7478,6 +10462,25 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "findSoftwareList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_findSoftwareList(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "sources": field := field @@ -7500,6 +10503,25 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "sourcesList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_sourcesList(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "vulnEqual": field := field @@ -7522,6 +10544,25 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "vulnEqualList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_vulnEqualList(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "vulnerabilityMetadata": field := field @@ -7544,6 +10585,25 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "vulnerabilityMetadataList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_vulnerabilityMetadataList(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "vulnerabilities": field := field @@ -7566,6 +10626,25 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "vulnerabilityList": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_vulnerabilityList(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "__type": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { @@ -7656,6 +10735,60 @@ func (ec *executionContext) marshalNArtifact2ᚖgithubᚗcomᚋguacsecᚋguacᚋ return ec._Artifact(ctx, sel, v) } +func (ec *executionContext) marshalNArtifactEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐArtifactEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.ArtifactEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNArtifactEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐArtifactEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNArtifactEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐArtifactEdge(ctx context.Context, sel ast.SelectionSet, v *model.ArtifactEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._ArtifactEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNArtifactSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐArtifactSpec(ctx context.Context, v interface{}) (model.ArtifactSpec, error) { res, err := ec.unmarshalInputArtifactSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -7710,6 +10843,13 @@ func (ec *executionContext) unmarshalNIDorArtifactInput2ᚖgithubᚗcomᚋguacse return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOArtifactConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐArtifactConnection(ctx context.Context, sel ast.SelectionSet, v *model.ArtifactConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._ArtifactConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOArtifactInputSpec2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐArtifactInputSpec(ctx context.Context, v interface{}) (*model.ArtifactInputSpec, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/builder.generated.go b/pkg/assembler/graphql/generated/builder.generated.go index b320e9a91da..eda69dae2df 100644 --- a/pkg/assembler/graphql/generated/builder.generated.go +++ b/pkg/assembler/graphql/generated/builder.generated.go @@ -5,6 +5,7 @@ package generated import ( "context" "errors" + "fmt" "strconv" "sync" "sync/atomic" @@ -110,6 +111,231 @@ func (ec *executionContext) fieldContext_Builder_uri(ctx context.Context, field return fc, nil } +func (ec *executionContext) _BuilderConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.BuilderConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BuilderConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_BuilderConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuilderConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _BuilderConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.BuilderConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BuilderConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_BuilderConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuilderConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _BuilderConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.BuilderConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BuilderConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.BuilderEdge) + fc.Result = res + return ec.marshalNBuilderEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐBuilderEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_BuilderConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuilderConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_BuilderEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_BuilderEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type BuilderEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _BuilderEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.BuilderEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BuilderEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_BuilderEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuilderEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _BuilderEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.BuilderEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_BuilderEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.Builder) + fc.Result = res + return ec.marshalNBuilder2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐBuilder(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_BuilderEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "BuilderEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Builder_id(ctx, field) + case "uri": + return ec.fieldContext_Builder_uri(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Builder", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -261,6 +487,99 @@ func (ec *executionContext) _Builder(ctx context.Context, sel ast.SelectionSet, return out } +var builderConnectionImplementors = []string{"BuilderConnection"} + +func (ec *executionContext) _BuilderConnection(ctx context.Context, sel ast.SelectionSet, obj *model.BuilderConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, builderConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("BuilderConnection") + case "totalCount": + out.Values[i] = ec._BuilderConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._BuilderConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._BuilderConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var builderEdgeImplementors = []string{"BuilderEdge"} + +func (ec *executionContext) _BuilderEdge(ctx context.Context, sel ast.SelectionSet, obj *model.BuilderEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, builderEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("BuilderEdge") + case "cursor": + out.Values[i] = ec._BuilderEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._BuilderEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -319,6 +638,60 @@ func (ec *executionContext) marshalNBuilder2ᚖgithubᚗcomᚋguacsecᚋguacᚋp return ec._Builder(ctx, sel, v) } +func (ec *executionContext) marshalNBuilderEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐBuilderEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.BuilderEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNBuilderEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐBuilderEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNBuilderEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐBuilderEdge(ctx context.Context, sel ast.SelectionSet, v *model.BuilderEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._BuilderEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNBuilderSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐBuilderSpec(ctx context.Context, v interface{}) (model.BuilderSpec, error) { res, err := ec.unmarshalInputBuilderSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -351,6 +724,13 @@ func (ec *executionContext) unmarshalNIDorBuilderInput2ᚖgithubᚗcomᚋguacsec return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOBuilderConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐBuilderConnection(ctx context.Context, sel ast.SelectionSet, v *model.BuilderConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._BuilderConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOBuilderInputSpec2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐBuilderInputSpec(ctx context.Context, v interface{}) (*model.BuilderInputSpec, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/certifyBad.generated.go b/pkg/assembler/graphql/generated/certifyBad.generated.go index 883fab60cbc..140352cbf18 100644 --- a/pkg/assembler/graphql/generated/certifyBad.generated.go +++ b/pkg/assembler/graphql/generated/certifyBad.generated.go @@ -317,6 +317,241 @@ func (ec *executionContext) fieldContext_CertifyBad_documentRef(ctx context.Cont return fc, nil } +func (ec *executionContext) _CertifyBadConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.CertifyBadConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyBadConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyBadConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyBadConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyBadConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.CertifyBadConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyBadConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyBadConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyBadConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyBadConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.CertifyBadConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyBadConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.CertifyBadEdge) + fc.Result = res + return ec.marshalNCertifyBadEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyBadEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyBadConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyBadConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_CertifyBadEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_CertifyBadEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyBadEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyBadEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.CertifyBadEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyBadEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyBadEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyBadEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyBadEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.CertifyBadEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyBadEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.CertifyBad) + fc.Result = res + return ec.marshalNCertifyBad2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyBad(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyBadEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyBadEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_CertifyBad_id(ctx, field) + case "subject": + return ec.fieldContext_CertifyBad_subject(ctx, field) + case "justification": + return ec.fieldContext_CertifyBad_justification(ctx, field) + case "knownSince": + return ec.fieldContext_CertifyBad_knownSince(ctx, field) + case "origin": + return ec.fieldContext_CertifyBad_origin(ctx, field) + case "collector": + return ec.fieldContext_CertifyBad_collector(ctx, field) + case "documentRef": + return ec.fieldContext_CertifyBad_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyBad", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -702,6 +937,99 @@ func (ec *executionContext) _CertifyBad(ctx context.Context, sel ast.SelectionSe return out } +var certifyBadConnectionImplementors = []string{"CertifyBadConnection"} + +func (ec *executionContext) _CertifyBadConnection(ctx context.Context, sel ast.SelectionSet, obj *model.CertifyBadConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, certifyBadConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CertifyBadConnection") + case "totalCount": + out.Values[i] = ec._CertifyBadConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._CertifyBadConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._CertifyBadConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var certifyBadEdgeImplementors = []string{"CertifyBadEdge"} + +func (ec *executionContext) _CertifyBadEdge(ctx context.Context, sel ast.SelectionSet, obj *model.CertifyBadEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, certifyBadEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CertifyBadEdge") + case "cursor": + out.Values[i] = ec._CertifyBadEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._CertifyBadEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -760,6 +1088,60 @@ func (ec *executionContext) marshalNCertifyBad2ᚖgithubᚗcomᚋguacsecᚋguac return ec._CertifyBad(ctx, sel, v) } +func (ec *executionContext) marshalNCertifyBadEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyBadEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.CertifyBadEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNCertifyBadEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyBadEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNCertifyBadEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyBadEdge(ctx context.Context, sel ast.SelectionSet, v *model.CertifyBadEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CertifyBadEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCertifyBadInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyBadInputSpec(ctx context.Context, v interface{}) (model.CertifyBadInputSpec, error) { res, err := ec.unmarshalInputCertifyBadInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -871,6 +1253,13 @@ func (ec *executionContext) marshalNPkgMatchType2githubᚗcomᚋguacsecᚋguac return v } +func (ec *executionContext) marshalOCertifyBadConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyBadConnection(ctx context.Context, sel ast.SelectionSet, v *model.CertifyBadConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._CertifyBadConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOPackageSourceOrArtifactSpec2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageSourceOrArtifactSpec(ctx context.Context, v interface{}) (*model.PackageSourceOrArtifactSpec, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/certifyGood.generated.go b/pkg/assembler/graphql/generated/certifyGood.generated.go index d2b54e98f0e..b658b89b40c 100644 --- a/pkg/assembler/graphql/generated/certifyGood.generated.go +++ b/pkg/assembler/graphql/generated/certifyGood.generated.go @@ -5,6 +5,7 @@ package generated import ( "context" "errors" + "fmt" "strconv" "sync" "sync/atomic" @@ -316,6 +317,241 @@ func (ec *executionContext) fieldContext_CertifyGood_documentRef(ctx context.Con return fc, nil } +func (ec *executionContext) _CertifyGoodConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.CertifyGoodConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyGoodConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyGoodConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyGoodConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyGoodConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.CertifyGoodConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyGoodConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyGoodConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyGoodConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyGoodConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.CertifyGoodConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyGoodConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.CertifyGoodEdge) + fc.Result = res + return ec.marshalNCertifyGoodEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyGoodEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyGoodConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyGoodConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_CertifyGoodEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_CertifyGoodEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyGoodEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyGoodEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.CertifyGoodEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyGoodEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyGoodEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyGoodEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyGoodEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.CertifyGoodEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyGoodEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.CertifyGood) + fc.Result = res + return ec.marshalNCertifyGood2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyGood(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyGoodEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyGoodEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_CertifyGood_id(ctx, field) + case "subject": + return ec.fieldContext_CertifyGood_subject(ctx, field) + case "justification": + return ec.fieldContext_CertifyGood_justification(ctx, field) + case "knownSince": + return ec.fieldContext_CertifyGood_knownSince(ctx, field) + case "origin": + return ec.fieldContext_CertifyGood_origin(ctx, field) + case "collector": + return ec.fieldContext_CertifyGood_collector(ctx, field) + case "documentRef": + return ec.fieldContext_CertifyGood_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyGood", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -521,6 +757,99 @@ func (ec *executionContext) _CertifyGood(ctx context.Context, sel ast.SelectionS return out } +var certifyGoodConnectionImplementors = []string{"CertifyGoodConnection"} + +func (ec *executionContext) _CertifyGoodConnection(ctx context.Context, sel ast.SelectionSet, obj *model.CertifyGoodConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, certifyGoodConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CertifyGoodConnection") + case "totalCount": + out.Values[i] = ec._CertifyGoodConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._CertifyGoodConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._CertifyGoodConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var certifyGoodEdgeImplementors = []string{"CertifyGoodEdge"} + +func (ec *executionContext) _CertifyGoodEdge(ctx context.Context, sel ast.SelectionSet, obj *model.CertifyGoodEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, certifyGoodEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CertifyGoodEdge") + case "cursor": + out.Values[i] = ec._CertifyGoodEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._CertifyGoodEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -579,6 +908,60 @@ func (ec *executionContext) marshalNCertifyGood2ᚖgithubᚗcomᚋguacsecᚋguac return ec._CertifyGood(ctx, sel, v) } +func (ec *executionContext) marshalNCertifyGoodEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyGoodEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.CertifyGoodEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNCertifyGoodEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyGoodEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNCertifyGoodEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyGoodEdge(ctx context.Context, sel ast.SelectionSet, v *model.CertifyGoodEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CertifyGoodEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCertifyGoodInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyGoodInputSpec(ctx context.Context, v interface{}) (model.CertifyGoodInputSpec, error) { res, err := ec.unmarshalInputCertifyGoodInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -611,4 +994,11 @@ func (ec *executionContext) unmarshalNCertifyGoodSpec2githubᚗcomᚋguacsecᚋg return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOCertifyGoodConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyGoodConnection(ctx context.Context, sel ast.SelectionSet, v *model.CertifyGoodConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._CertifyGoodConnection(ctx, sel, v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/certifyLegal.generated.go b/pkg/assembler/graphql/generated/certifyLegal.generated.go index 26f732d63e6..79fcf559d2e 100644 --- a/pkg/assembler/graphql/generated/certifyLegal.generated.go +++ b/pkg/assembler/graphql/generated/certifyLegal.generated.go @@ -542,6 +542,251 @@ func (ec *executionContext) fieldContext_CertifyLegal_documentRef(ctx context.Co return fc, nil } +func (ec *executionContext) _CertifyLegalConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.CertifyLegalConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyLegalConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyLegalConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyLegalConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyLegalConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.CertifyLegalConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyLegalConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyLegalConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyLegalConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyLegalConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.CertifyLegalConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyLegalConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.CertifyLegalEdge) + fc.Result = res + return ec.marshalNCertifyLegalEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyLegalEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyLegalConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyLegalConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_CertifyLegalEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_CertifyLegalEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyLegalEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyLegalEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.CertifyLegalEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyLegalEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyLegalEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyLegalEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyLegalEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.CertifyLegalEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyLegalEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.CertifyLegal) + fc.Result = res + return ec.marshalNCertifyLegal2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyLegal(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyLegalEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyLegalEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_CertifyLegal_id(ctx, field) + case "subject": + return ec.fieldContext_CertifyLegal_subject(ctx, field) + case "declaredLicense": + return ec.fieldContext_CertifyLegal_declaredLicense(ctx, field) + case "declaredLicenses": + return ec.fieldContext_CertifyLegal_declaredLicenses(ctx, field) + case "discoveredLicense": + return ec.fieldContext_CertifyLegal_discoveredLicense(ctx, field) + case "discoveredLicenses": + return ec.fieldContext_CertifyLegal_discoveredLicenses(ctx, field) + case "attribution": + return ec.fieldContext_CertifyLegal_attribution(ctx, field) + case "justification": + return ec.fieldContext_CertifyLegal_justification(ctx, field) + case "timeScanned": + return ec.fieldContext_CertifyLegal_timeScanned(ctx, field) + case "origin": + return ec.fieldContext_CertifyLegal_origin(ctx, field) + case "collector": + return ec.fieldContext_CertifyLegal_collector(ctx, field) + case "documentRef": + return ec.fieldContext_CertifyLegal_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyLegal", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -828,6 +1073,99 @@ func (ec *executionContext) _CertifyLegal(ctx context.Context, sel ast.Selection return out } +var certifyLegalConnectionImplementors = []string{"CertifyLegalConnection"} + +func (ec *executionContext) _CertifyLegalConnection(ctx context.Context, sel ast.SelectionSet, obj *model.CertifyLegalConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, certifyLegalConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CertifyLegalConnection") + case "totalCount": + out.Values[i] = ec._CertifyLegalConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._CertifyLegalConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._CertifyLegalConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var certifyLegalEdgeImplementors = []string{"CertifyLegalEdge"} + +func (ec *executionContext) _CertifyLegalEdge(ctx context.Context, sel ast.SelectionSet, obj *model.CertifyLegalEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, certifyLegalEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CertifyLegalEdge") + case "cursor": + out.Values[i] = ec._CertifyLegalEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._CertifyLegalEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -886,6 +1224,60 @@ func (ec *executionContext) marshalNCertifyLegal2ᚖgithubᚗcomᚋguacsecᚋgua return ec._CertifyLegal(ctx, sel, v) } +func (ec *executionContext) marshalNCertifyLegalEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyLegalEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.CertifyLegalEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNCertifyLegalEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyLegalEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNCertifyLegalEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyLegalEdge(ctx context.Context, sel ast.SelectionSet, v *model.CertifyLegalEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CertifyLegalEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCertifyLegalInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyLegalInputSpec(ctx context.Context, v interface{}) (model.CertifyLegalInputSpec, error) { res, err := ec.unmarshalInputCertifyLegalInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -918,4 +1310,11 @@ func (ec *executionContext) unmarshalNCertifyLegalSpec2githubᚗcomᚋguacsecᚋ return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOCertifyLegalConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyLegalConnection(ctx context.Context, sel ast.SelectionSet, v *model.CertifyLegalConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._CertifyLegalConnection(ctx, sel, v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/certifyScorecard.generated.go b/pkg/assembler/graphql/generated/certifyScorecard.generated.go index a5debe43fdd..98472fbe0ca 100644 --- a/pkg/assembler/graphql/generated/certifyScorecard.generated.go +++ b/pkg/assembler/graphql/generated/certifyScorecard.generated.go @@ -179,6 +179,233 @@ func (ec *executionContext) fieldContext_CertifyScorecard_scorecard(ctx context. return fc, nil } +func (ec *executionContext) _CertifyScorecardConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.CertifyScorecardConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyScorecardConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyScorecardConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyScorecardConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyScorecardConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.CertifyScorecardConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyScorecardConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyScorecardConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyScorecardConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyScorecardConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.CertifyScorecardConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyScorecardConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.CertifyScorecardEdge) + fc.Result = res + return ec.marshalNCertifyScorecardEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyScorecardEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyScorecardConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyScorecardConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_CertifyScorecardEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_CertifyScorecardEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyScorecardEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyScorecardEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.CertifyScorecardEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyScorecardEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyScorecardEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyScorecardEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyScorecardEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.CertifyScorecardEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyScorecardEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.CertifyScorecard) + fc.Result = res + return ec.marshalNCertifyScorecard2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyScorecard(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyScorecardEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyScorecardEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_CertifyScorecard_id(ctx, field) + case "source": + return ec.fieldContext_CertifyScorecard_source(ctx, field) + case "scorecard": + return ec.fieldContext_CertifyScorecard_scorecard(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyScorecard", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _Scorecard_checks(ctx context.Context, field graphql.CollectedField, obj *model.Scorecard) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Scorecard_checks(ctx, field) if err != nil { @@ -894,6 +1121,99 @@ func (ec *executionContext) _CertifyScorecard(ctx context.Context, sel ast.Selec return out } +var certifyScorecardConnectionImplementors = []string{"CertifyScorecardConnection"} + +func (ec *executionContext) _CertifyScorecardConnection(ctx context.Context, sel ast.SelectionSet, obj *model.CertifyScorecardConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, certifyScorecardConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CertifyScorecardConnection") + case "totalCount": + out.Values[i] = ec._CertifyScorecardConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._CertifyScorecardConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._CertifyScorecardConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var certifyScorecardEdgeImplementors = []string{"CertifyScorecardEdge"} + +func (ec *executionContext) _CertifyScorecardEdge(ctx context.Context, sel ast.SelectionSet, obj *model.CertifyScorecardEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, certifyScorecardEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CertifyScorecardEdge") + case "cursor": + out.Values[i] = ec._CertifyScorecardEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._CertifyScorecardEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var scorecardImplementors = []string{"Scorecard"} func (ec *executionContext) _Scorecard(ctx context.Context, sel ast.SelectionSet, obj *model.Scorecard) graphql.Marshaler { @@ -1070,6 +1390,60 @@ func (ec *executionContext) marshalNCertifyScorecard2ᚖgithubᚗcomᚋguacsec return ec._CertifyScorecard(ctx, sel, v) } +func (ec *executionContext) marshalNCertifyScorecardEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyScorecardEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.CertifyScorecardEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNCertifyScorecardEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyScorecardEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNCertifyScorecardEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyScorecardEdge(ctx context.Context, sel ast.SelectionSet, v *model.CertifyScorecardEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CertifyScorecardEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCertifyScorecardSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyScorecardSpec(ctx context.Context, v interface{}) (model.CertifyScorecardSpec, error) { res, err := ec.unmarshalInputCertifyScorecardSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -1208,6 +1582,13 @@ func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel as return res } +func (ec *executionContext) marshalOCertifyScorecardConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyScorecardConnection(ctx context.Context, sel ast.SelectionSet, v *model.CertifyScorecardConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._CertifyScorecardConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOScorecardCheckSpec2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐScorecardCheckSpecᚄ(ctx context.Context, v interface{}) ([]*model.ScorecardCheckSpec, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/certifyVEXStatement.generated.go b/pkg/assembler/graphql/generated/certifyVEXStatement.generated.go index af2463ef75c..0740a627dac 100644 --- a/pkg/assembler/graphql/generated/certifyVEXStatement.generated.go +++ b/pkg/assembler/graphql/generated/certifyVEXStatement.generated.go @@ -489,6 +489,249 @@ func (ec *executionContext) fieldContext_CertifyVEXStatement_documentRef(ctx con return fc, nil } +func (ec *executionContext) _VEXConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.VEXConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VEXConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VEXConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VEXConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VEXConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.VEXConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VEXConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VEXConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VEXConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _VEXConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.VEXConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VEXConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.VEXEdge) + fc.Result = res + return ec.marshalNVEXEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVEXEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VEXConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VEXConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_VEXEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_VEXEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VEXEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _VEXEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.VEXEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VEXEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VEXEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VEXEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VEXEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.VEXEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VEXEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.CertifyVEXStatement) + fc.Result = res + return ec.marshalNCertifyVEXStatement2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVEXStatement(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VEXEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VEXEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_CertifyVEXStatement_id(ctx, field) + case "subject": + return ec.fieldContext_CertifyVEXStatement_subject(ctx, field) + case "vulnerability": + return ec.fieldContext_CertifyVEXStatement_vulnerability(ctx, field) + case "status": + return ec.fieldContext_CertifyVEXStatement_status(ctx, field) + case "vexJustification": + return ec.fieldContext_CertifyVEXStatement_vexJustification(ctx, field) + case "statement": + return ec.fieldContext_CertifyVEXStatement_statement(ctx, field) + case "statusNotes": + return ec.fieldContext_CertifyVEXStatement_statusNotes(ctx, field) + case "knownSince": + return ec.fieldContext_CertifyVEXStatement_knownSince(ctx, field) + case "origin": + return ec.fieldContext_CertifyVEXStatement_origin(ctx, field) + case "collector": + return ec.fieldContext_CertifyVEXStatement_collector(ctx, field) + case "documentRef": + return ec.fieldContext_CertifyVEXStatement_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyVEXStatement", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -888,6 +1131,99 @@ func (ec *executionContext) _CertifyVEXStatement(ctx context.Context, sel ast.Se return out } +var vEXConnectionImplementors = []string{"VEXConnection"} + +func (ec *executionContext) _VEXConnection(ctx context.Context, sel ast.SelectionSet, obj *model.VEXConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, vEXConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VEXConnection") + case "totalCount": + out.Values[i] = ec._VEXConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._VEXConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._VEXConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var vEXEdgeImplementors = []string{"VEXEdge"} + +func (ec *executionContext) _VEXEdge(ctx context.Context, sel ast.SelectionSet, obj *model.VEXEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, vEXEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VEXEdge") + case "cursor": + out.Values[i] = ec._VEXEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._VEXEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -1020,6 +1356,60 @@ func (ec *executionContext) unmarshalNPackageOrArtifactSpec2ᚖgithubᚗcomᚋgu return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalNVEXEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVEXEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.VEXEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNVEXEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVEXEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNVEXEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVEXEdge(ctx context.Context, sel ast.SelectionSet, v *model.VEXEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._VEXEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNVexJustification2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVexJustification(ctx context.Context, v interface{}) (model.VexJustification, error) { var res model.VexJustification err := res.UnmarshalGQL(v) @@ -1095,6 +1485,13 @@ func (ec *executionContext) unmarshalOPackageOrArtifactSpec2ᚖgithubᚗcomᚋgu return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOVEXConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVEXConnection(ctx context.Context, sel ast.SelectionSet, v *model.VEXConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._VEXConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOVexJustification2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVexJustification(ctx context.Context, v interface{}) (*model.VexJustification, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/certifyVuln.generated.go b/pkg/assembler/graphql/generated/certifyVuln.generated.go index d90136dac20..c336d01fab6 100644 --- a/pkg/assembler/graphql/generated/certifyVuln.generated.go +++ b/pkg/assembler/graphql/generated/certifyVuln.generated.go @@ -228,6 +228,235 @@ func (ec *executionContext) fieldContext_CertifyVuln_metadata(ctx context.Contex return fc, nil } +func (ec *executionContext) _CertifyVulnConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.CertifyVulnConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyVulnConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyVulnConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyVulnConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyVulnConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.CertifyVulnConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyVulnConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyVulnConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyVulnConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyVulnConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.CertifyVulnConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyVulnConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.CertifyVulnEdge) + fc.Result = res + return ec.marshalNCertifyVulnEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVulnEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyVulnConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyVulnConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_CertifyVulnEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_CertifyVulnEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyVulnEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyVulnEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.CertifyVulnEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyVulnEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyVulnEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyVulnEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _CertifyVulnEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.CertifyVulnEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CertifyVulnEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.CertifyVuln) + fc.Result = res + return ec.marshalNCertifyVuln2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVuln(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CertifyVulnEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CertifyVulnEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_CertifyVuln_id(ctx, field) + case "package": + return ec.fieldContext_CertifyVuln_package(ctx, field) + case "vulnerability": + return ec.fieldContext_CertifyVuln_vulnerability(ctx, field) + case "metadata": + return ec.fieldContext_CertifyVuln_metadata(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type CertifyVuln", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _ScanMetadata_timeScanned(ctx context.Context, field graphql.CollectedField, obj *model.ScanMetadata) (ret graphql.Marshaler) { fc, err := ec.fieldContext_ScanMetadata_timeScanned(ctx, field) if err != nil { @@ -795,6 +1024,99 @@ func (ec *executionContext) _CertifyVuln(ctx context.Context, sel ast.SelectionS return out } +var certifyVulnConnectionImplementors = []string{"CertifyVulnConnection"} + +func (ec *executionContext) _CertifyVulnConnection(ctx context.Context, sel ast.SelectionSet, obj *model.CertifyVulnConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, certifyVulnConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CertifyVulnConnection") + case "totalCount": + out.Values[i] = ec._CertifyVulnConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._CertifyVulnConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._CertifyVulnConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var certifyVulnEdgeImplementors = []string{"CertifyVulnEdge"} + +func (ec *executionContext) _CertifyVulnEdge(ctx context.Context, sel ast.SelectionSet, obj *model.CertifyVulnEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, certifyVulnEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CertifyVulnEdge") + case "cursor": + out.Values[i] = ec._CertifyVulnEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._CertifyVulnEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var scanMetadataImplementors = []string{"ScanMetadata"} func (ec *executionContext) _ScanMetadata(ctx context.Context, sel ast.SelectionSet, obj *model.ScanMetadata) graphql.Marshaler { @@ -927,6 +1249,60 @@ func (ec *executionContext) marshalNCertifyVuln2ᚖgithubᚗcomᚋguacsecᚋguac return ec._CertifyVuln(ctx, sel, v) } +func (ec *executionContext) marshalNCertifyVulnEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVulnEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.CertifyVulnEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNCertifyVulnEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVulnEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNCertifyVulnEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVulnEdge(ctx context.Context, sel ast.SelectionSet, v *model.CertifyVulnEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._CertifyVulnEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNCertifyVulnSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVulnSpec(ctx context.Context, v interface{}) (model.CertifyVulnSpec, error) { res, err := ec.unmarshalInputCertifyVulnSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -969,4 +1345,11 @@ func (ec *executionContext) unmarshalNScanMetadataInput2ᚖgithubᚗcomᚋguacse return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOCertifyVulnConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐCertifyVulnConnection(ctx context.Context, sel ast.SelectionSet, v *model.CertifyVulnConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._CertifyVulnConnection(ctx, sel, v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/contact.generated.go b/pkg/assembler/graphql/generated/contact.generated.go index f023f5bd3b9..e3e7a21101c 100644 --- a/pkg/assembler/graphql/generated/contact.generated.go +++ b/pkg/assembler/graphql/generated/contact.generated.go @@ -5,6 +5,7 @@ package generated import ( "context" "errors" + "fmt" "strconv" "sync" "sync/atomic" @@ -398,6 +399,245 @@ func (ec *executionContext) fieldContext_PointOfContact_documentRef(ctx context. return fc, nil } +func (ec *executionContext) _PointOfContactConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.PointOfContactConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PointOfContactConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PointOfContactConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PointOfContactConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PointOfContactConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.PointOfContactConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PointOfContactConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PointOfContactConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PointOfContactConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _PointOfContactConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.PointOfContactConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PointOfContactConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.PointOfContactEdge) + fc.Result = res + return ec.marshalNPointOfContactEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContactEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PointOfContactConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PointOfContactConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_PointOfContactEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_PointOfContactEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PointOfContactEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _PointOfContactEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.PointOfContactEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PointOfContactEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PointOfContactEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PointOfContactEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PointOfContactEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.PointOfContactEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PointOfContactEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PointOfContact) + fc.Result = res + return ec.marshalNPointOfContact2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContact(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PointOfContactEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PointOfContactEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_PointOfContact_id(ctx, field) + case "subject": + return ec.fieldContext_PointOfContact_subject(ctx, field) + case "email": + return ec.fieldContext_PointOfContact_email(ctx, field) + case "info": + return ec.fieldContext_PointOfContact_info(ctx, field) + case "since": + return ec.fieldContext_PointOfContact_since(ctx, field) + case "justification": + return ec.fieldContext_PointOfContact_justification(ctx, field) + case "origin": + return ec.fieldContext_PointOfContact_origin(ctx, field) + case "collector": + return ec.fieldContext_PointOfContact_collector(ctx, field) + case "documentRef": + return ec.fieldContext_PointOfContact_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PointOfContact", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -641,6 +881,99 @@ func (ec *executionContext) _PointOfContact(ctx context.Context, sel ast.Selecti return out } +var pointOfContactConnectionImplementors = []string{"PointOfContactConnection"} + +func (ec *executionContext) _PointOfContactConnection(ctx context.Context, sel ast.SelectionSet, obj *model.PointOfContactConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, pointOfContactConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PointOfContactConnection") + case "totalCount": + out.Values[i] = ec._PointOfContactConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._PointOfContactConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._PointOfContactConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var pointOfContactEdgeImplementors = []string{"PointOfContactEdge"} + +func (ec *executionContext) _PointOfContactEdge(ctx context.Context, sel ast.SelectionSet, obj *model.PointOfContactEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, pointOfContactEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PointOfContactEdge") + case "cursor": + out.Values[i] = ec._PointOfContactEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._PointOfContactEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -699,6 +1032,60 @@ func (ec *executionContext) marshalNPointOfContact2ᚖgithubᚗcomᚋguacsecᚋg return ec._PointOfContact(ctx, sel, v) } +func (ec *executionContext) marshalNPointOfContactEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContactEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.PointOfContactEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNPointOfContactEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContactEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNPointOfContactEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContactEdge(ctx context.Context, sel ast.SelectionSet, v *model.PointOfContactEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._PointOfContactEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNPointOfContactInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContactInputSpec(ctx context.Context, v interface{}) (model.PointOfContactInputSpec, error) { res, err := ec.unmarshalInputPointOfContactInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -731,4 +1118,11 @@ func (ec *executionContext) unmarshalNPointOfContactSpec2githubᚗcomᚋguacsec return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOPointOfContactConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPointOfContactConnection(ctx context.Context, sel ast.SelectionSet, v *model.PointOfContactConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._PointOfContactConnection(ctx, sel, v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/hasSBOM.generated.go b/pkg/assembler/graphql/generated/hasSBOM.generated.go index 023bca257ef..33e141d5518 100644 --- a/pkg/assembler/graphql/generated/hasSBOM.generated.go +++ b/pkg/assembler/graphql/generated/hasSBOM.generated.go @@ -599,6 +599,253 @@ func (ec *executionContext) fieldContext_HasSBOM_includedOccurrences(ctx context return fc, nil } +func (ec *executionContext) _HasSBOMConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.HasSBOMConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSBOMConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSBOMConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSBOMConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HasSBOMConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.HasSBOMConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSBOMConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSBOMConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSBOMConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _HasSBOMConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.HasSBOMConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSBOMConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.HasSBOMEdge) + fc.Result = res + return ec.marshalNHasSBOMEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSBOMEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSBOMConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSBOMConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_HasSBOMEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_HasSBOMEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasSBOMEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _HasSBOMEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.HasSBOMEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSBOMEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSBOMEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSBOMEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HasSBOMEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.HasSBOMEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSBOMEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.HasSbom) + fc.Result = res + return ec.marshalNHasSBOM2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSbom(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSBOMEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSBOMEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_HasSBOM_id(ctx, field) + case "subject": + return ec.fieldContext_HasSBOM_subject(ctx, field) + case "uri": + return ec.fieldContext_HasSBOM_uri(ctx, field) + case "algorithm": + return ec.fieldContext_HasSBOM_algorithm(ctx, field) + case "digest": + return ec.fieldContext_HasSBOM_digest(ctx, field) + case "downloadLocation": + return ec.fieldContext_HasSBOM_downloadLocation(ctx, field) + case "knownSince": + return ec.fieldContext_HasSBOM_knownSince(ctx, field) + case "origin": + return ec.fieldContext_HasSBOM_origin(ctx, field) + case "collector": + return ec.fieldContext_HasSBOM_collector(ctx, field) + case "documentRef": + return ec.fieldContext_HasSBOM_documentRef(ctx, field) + case "includedSoftware": + return ec.fieldContext_HasSBOM_includedSoftware(ctx, field) + case "includedDependencies": + return ec.fieldContext_HasSBOM_includedDependencies(ctx, field) + case "includedOccurrences": + return ec.fieldContext_HasSBOM_includedOccurrences(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasSBOM", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -945,6 +1192,99 @@ func (ec *executionContext) _HasSBOM(ctx context.Context, sel ast.SelectionSet, return out } +var hasSBOMConnectionImplementors = []string{"HasSBOMConnection"} + +func (ec *executionContext) _HasSBOMConnection(ctx context.Context, sel ast.SelectionSet, obj *model.HasSBOMConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hasSBOMConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("HasSBOMConnection") + case "totalCount": + out.Values[i] = ec._HasSBOMConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._HasSBOMConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._HasSBOMConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var hasSBOMEdgeImplementors = []string{"HasSBOMEdge"} + +func (ec *executionContext) _HasSBOMEdge(ctx context.Context, sel ast.SelectionSet, obj *model.HasSBOMEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hasSBOMEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("HasSBOMEdge") + case "cursor": + out.Values[i] = ec._HasSBOMEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._HasSBOMEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -1003,6 +1343,60 @@ func (ec *executionContext) marshalNHasSBOM2ᚖgithubᚗcomᚋguacsecᚋguacᚋp return ec._HasSBOM(ctx, sel, v) } +func (ec *executionContext) marshalNHasSBOMEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSBOMEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.HasSBOMEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNHasSBOMEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSBOMEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNHasSBOMEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSBOMEdge(ctx context.Context, sel ast.SelectionSet, v *model.HasSBOMEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._HasSBOMEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNHasSBOMIncludesInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSBOMIncludesInputSpec(ctx context.Context, v interface{}) (model.HasSBOMIncludesInputSpec, error) { res, err := ec.unmarshalInputHasSBOMIncludesInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -1062,4 +1456,11 @@ func (ec *executionContext) unmarshalNHasSBOMSpec2githubᚗcomᚋguacsecᚋguac return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOHasSBOMConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSBOMConnection(ctx context.Context, sel ast.SelectionSet, v *model.HasSBOMConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._HasSBOMConnection(ctx, sel, v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/hasSLSA.generated.go b/pkg/assembler/graphql/generated/hasSLSA.generated.go index 95cc2ee31a8..9010e8efd0b 100644 --- a/pkg/assembler/graphql/generated/hasSLSA.generated.go +++ b/pkg/assembler/graphql/generated/hasSLSA.generated.go @@ -183,6 +183,233 @@ func (ec *executionContext) fieldContext_HasSLSA_slsa(ctx context.Context, field return fc, nil } +func (ec *executionContext) _HasSLSAConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.HasSLSAConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSLSAConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSLSAConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSLSAConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HasSLSAConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.HasSLSAConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSLSAConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSLSAConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSLSAConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _HasSLSAConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.HasSLSAConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSLSAConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.HasSLSAEdge) + fc.Result = res + return ec.marshalNHasSLSAEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSLSAEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSLSAConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSLSAConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_HasSLSAEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_HasSLSAEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasSLSAEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _HasSLSAEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.HasSLSAEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSLSAEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSLSAEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSLSAEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HasSLSAEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.HasSLSAEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSLSAEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.HasSlsa) + fc.Result = res + return ec.marshalNHasSLSA2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSlsa(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSLSAEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSLSAEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_HasSLSA_id(ctx, field) + case "subject": + return ec.fieldContext_HasSLSA_subject(ctx, field) + case "slsa": + return ec.fieldContext_HasSLSA_slsa(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasSLSA", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _SLSA_builtFrom(ctx context.Context, field graphql.CollectedField, obj *model.Slsa) (ret graphql.Marshaler) { fc, err := ec.fieldContext_SLSA_builtFrom(ctx, field) if err != nil { @@ -1002,6 +1229,99 @@ func (ec *executionContext) _HasSLSA(ctx context.Context, sel ast.SelectionSet, return out } +var hasSLSAConnectionImplementors = []string{"HasSLSAConnection"} + +func (ec *executionContext) _HasSLSAConnection(ctx context.Context, sel ast.SelectionSet, obj *model.HasSLSAConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hasSLSAConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("HasSLSAConnection") + case "totalCount": + out.Values[i] = ec._HasSLSAConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._HasSLSAConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._HasSLSAConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var hasSLSAEdgeImplementors = []string{"HasSLSAEdge"} + +func (ec *executionContext) _HasSLSAEdge(ctx context.Context, sel ast.SelectionSet, obj *model.HasSLSAEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hasSLSAEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("HasSLSAEdge") + case "cursor": + out.Values[i] = ec._HasSLSAEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._HasSLSAEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var sLSAImplementors = []string{"SLSA"} func (ec *executionContext) _SLSA(ctx context.Context, sel ast.SelectionSet, obj *model.Slsa) graphql.Marshaler { @@ -1182,6 +1502,60 @@ func (ec *executionContext) marshalNHasSLSA2ᚖgithubᚗcomᚋguacsecᚋguacᚋp return ec._HasSLSA(ctx, sel, v) } +func (ec *executionContext) marshalNHasSLSAEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSLSAEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.HasSLSAEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNHasSLSAEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSLSAEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNHasSLSAEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSLSAEdge(ctx context.Context, sel ast.SelectionSet, v *model.HasSLSAEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._HasSLSAEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNHasSLSASpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSLSASpec(ctx context.Context, v interface{}) (model.HasSLSASpec, error) { res, err := ec.unmarshalInputHasSLSASpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -1305,6 +1679,13 @@ func (ec *executionContext) unmarshalNSLSAPredicateSpec2ᚖgithubᚗcomᚋguacse return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOHasSLSAConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSLSAConnection(ctx context.Context, sel ast.SelectionSet, v *model.HasSLSAConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._HasSLSAConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOSLSAPredicateSpec2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSLSAPredicateSpecᚄ(ctx context.Context, v interface{}) ([]*model.SLSAPredicateSpec, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/hasSourceAt.generated.go b/pkg/assembler/graphql/generated/hasSourceAt.generated.go index d6619d3c5c7..f8f8293378d 100644 --- a/pkg/assembler/graphql/generated/hasSourceAt.generated.go +++ b/pkg/assembler/graphql/generated/hasSourceAt.generated.go @@ -374,6 +374,243 @@ func (ec *executionContext) fieldContext_HasSourceAt_documentRef(ctx context.Con return fc, nil } +func (ec *executionContext) _HasSourceAtConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.HasSourceAtConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSourceAtConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSourceAtConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSourceAtConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HasSourceAtConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.HasSourceAtConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSourceAtConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSourceAtConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSourceAtConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _HasSourceAtConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.HasSourceAtConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSourceAtConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.HasSourceAtEdge) + fc.Result = res + return ec.marshalNHasSourceAtEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSourceAtEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSourceAtConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSourceAtConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_HasSourceAtEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_HasSourceAtEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasSourceAtEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _HasSourceAtEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.HasSourceAtEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSourceAtEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSourceAtEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSourceAtEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HasSourceAtEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.HasSourceAtEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasSourceAtEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.HasSourceAt) + fc.Result = res + return ec.marshalNHasSourceAt2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSourceAt(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasSourceAtEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasSourceAtEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_HasSourceAt_id(ctx, field) + case "package": + return ec.fieldContext_HasSourceAt_package(ctx, field) + case "source": + return ec.fieldContext_HasSourceAt_source(ctx, field) + case "knownSince": + return ec.fieldContext_HasSourceAt_knownSince(ctx, field) + case "justification": + return ec.fieldContext_HasSourceAt_justification(ctx, field) + case "origin": + return ec.fieldContext_HasSourceAt_origin(ctx, field) + case "collector": + return ec.fieldContext_HasSourceAt_collector(ctx, field) + case "documentRef": + return ec.fieldContext_HasSourceAt_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasSourceAt", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -591,6 +828,99 @@ func (ec *executionContext) _HasSourceAt(ctx context.Context, sel ast.SelectionS return out } +var hasSourceAtConnectionImplementors = []string{"HasSourceAtConnection"} + +func (ec *executionContext) _HasSourceAtConnection(ctx context.Context, sel ast.SelectionSet, obj *model.HasSourceAtConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hasSourceAtConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("HasSourceAtConnection") + case "totalCount": + out.Values[i] = ec._HasSourceAtConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._HasSourceAtConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._HasSourceAtConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var hasSourceAtEdgeImplementors = []string{"HasSourceAtEdge"} + +func (ec *executionContext) _HasSourceAtEdge(ctx context.Context, sel ast.SelectionSet, obj *model.HasSourceAtEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hasSourceAtEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("HasSourceAtEdge") + case "cursor": + out.Values[i] = ec._HasSourceAtEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._HasSourceAtEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -649,6 +979,60 @@ func (ec *executionContext) marshalNHasSourceAt2ᚖgithubᚗcomᚋguacsecᚋguac return ec._HasSourceAt(ctx, sel, v) } +func (ec *executionContext) marshalNHasSourceAtEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSourceAtEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.HasSourceAtEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNHasSourceAtEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSourceAtEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNHasSourceAtEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSourceAtEdge(ctx context.Context, sel ast.SelectionSet, v *model.HasSourceAtEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._HasSourceAtEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNHasSourceAtInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSourceAtInputSpec(ctx context.Context, v interface{}) (model.HasSourceAtInputSpec, error) { res, err := ec.unmarshalInputHasSourceAtInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -681,4 +1065,11 @@ func (ec *executionContext) unmarshalNHasSourceAtSpec2githubᚗcomᚋguacsecᚋg return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOHasSourceAtConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasSourceAtConnection(ctx context.Context, sel ast.SelectionSet, v *model.HasSourceAtConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._HasSourceAtConnection(ctx, sel, v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/hashEqual.generated.go b/pkg/assembler/graphql/generated/hashEqual.generated.go index 39ff578094a..1df19420074 100644 --- a/pkg/assembler/graphql/generated/hashEqual.generated.go +++ b/pkg/assembler/graphql/generated/hashEqual.generated.go @@ -283,6 +283,239 @@ func (ec *executionContext) fieldContext_HashEqual_documentRef(ctx context.Conte return fc, nil } +func (ec *executionContext) _HashEqualConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.HashEqualConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HashEqualConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HashEqualConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HashEqualConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HashEqualConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.HashEqualConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HashEqualConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HashEqualConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HashEqualConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _HashEqualConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.HashEqualConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HashEqualConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.HashEqualEdge) + fc.Result = res + return ec.marshalNHashEqualEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHashEqualEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HashEqualConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HashEqualConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_HashEqualEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_HashEqualEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HashEqualEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _HashEqualEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.HashEqualEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HashEqualEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HashEqualEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HashEqualEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HashEqualEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.HashEqualEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HashEqualEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.HashEqual) + fc.Result = res + return ec.marshalNHashEqual2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHashEqual(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HashEqualEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HashEqualEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_HashEqual_id(ctx, field) + case "artifacts": + return ec.fieldContext_HashEqual_artifacts(ctx, field) + case "justification": + return ec.fieldContext_HashEqual_justification(ctx, field) + case "origin": + return ec.fieldContext_HashEqual_origin(ctx, field) + case "collector": + return ec.fieldContext_HashEqual_collector(ctx, field) + case "documentRef": + return ec.fieldContext_HashEqual_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HashEqual", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -469,6 +702,99 @@ func (ec *executionContext) _HashEqual(ctx context.Context, sel ast.SelectionSet return out } +var hashEqualConnectionImplementors = []string{"HashEqualConnection"} + +func (ec *executionContext) _HashEqualConnection(ctx context.Context, sel ast.SelectionSet, obj *model.HashEqualConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hashEqualConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("HashEqualConnection") + case "totalCount": + out.Values[i] = ec._HashEqualConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._HashEqualConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._HashEqualConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var hashEqualEdgeImplementors = []string{"HashEqualEdge"} + +func (ec *executionContext) _HashEqualEdge(ctx context.Context, sel ast.SelectionSet, obj *model.HashEqualEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hashEqualEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("HashEqualEdge") + case "cursor": + out.Values[i] = ec._HashEqualEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._HashEqualEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -527,6 +853,60 @@ func (ec *executionContext) marshalNHashEqual2ᚖgithubᚗcomᚋguacsecᚋguac return ec._HashEqual(ctx, sel, v) } +func (ec *executionContext) marshalNHashEqualEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHashEqualEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.HashEqualEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNHashEqualEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHashEqualEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNHashEqualEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHashEqualEdge(ctx context.Context, sel ast.SelectionSet, v *model.HashEqualEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._HashEqualEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNHashEqualInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHashEqualInputSpec(ctx context.Context, v interface{}) (model.HashEqualInputSpec, error) { res, err := ec.unmarshalInputHashEqualInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -559,4 +939,11 @@ func (ec *executionContext) unmarshalNHashEqualSpec2githubᚗcomᚋguacsecᚋgua return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOHashEqualConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHashEqualConnection(ctx context.Context, sel ast.SelectionSet, v *model.HashEqualConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._HashEqualConnection(ctx, sel, v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/isDependency.generated.go b/pkg/assembler/graphql/generated/isDependency.generated.go index 004df6be875..4c6134cd0ad 100644 --- a/pkg/assembler/graphql/generated/isDependency.generated.go +++ b/pkg/assembler/graphql/generated/isDependency.generated.go @@ -414,6 +414,245 @@ func (ec *executionContext) fieldContext_IsDependency_documentRef(ctx context.Co return fc, nil } +func (ec *executionContext) _IsDependencyConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.IsDependencyConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IsDependencyConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IsDependencyConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IsDependencyConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _IsDependencyConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.IsDependencyConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IsDependencyConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IsDependencyConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IsDependencyConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _IsDependencyConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.IsDependencyConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IsDependencyConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.IsDependencyEdge) + fc.Result = res + return ec.marshalNIsDependencyEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsDependencyEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IsDependencyConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IsDependencyConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_IsDependencyEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_IsDependencyEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type IsDependencyEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _IsDependencyEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.IsDependencyEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IsDependencyEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IsDependencyEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IsDependencyEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _IsDependencyEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.IsDependencyEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IsDependencyEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.IsDependency) + fc.Result = res + return ec.marshalNIsDependency2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsDependency(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IsDependencyEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IsDependencyEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_IsDependency_id(ctx, field) + case "package": + return ec.fieldContext_IsDependency_package(ctx, field) + case "dependencyPackage": + return ec.fieldContext_IsDependency_dependencyPackage(ctx, field) + case "versionRange": + return ec.fieldContext_IsDependency_versionRange(ctx, field) + case "dependencyType": + return ec.fieldContext_IsDependency_dependencyType(ctx, field) + case "justification": + return ec.fieldContext_IsDependency_justification(ctx, field) + case "origin": + return ec.fieldContext_IsDependency_origin(ctx, field) + case "collector": + return ec.fieldContext_IsDependency_collector(ctx, field) + case "documentRef": + return ec.fieldContext_IsDependency_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type IsDependency", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -650,6 +889,99 @@ func (ec *executionContext) _IsDependency(ctx context.Context, sel ast.Selection return out } +var isDependencyConnectionImplementors = []string{"IsDependencyConnection"} + +func (ec *executionContext) _IsDependencyConnection(ctx context.Context, sel ast.SelectionSet, obj *model.IsDependencyConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, isDependencyConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("IsDependencyConnection") + case "totalCount": + out.Values[i] = ec._IsDependencyConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._IsDependencyConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._IsDependencyConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var isDependencyEdgeImplementors = []string{"IsDependencyEdge"} + +func (ec *executionContext) _IsDependencyEdge(ctx context.Context, sel ast.SelectionSet, obj *model.IsDependencyEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, isDependencyEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("IsDependencyEdge") + case "cursor": + out.Values[i] = ec._IsDependencyEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._IsDependencyEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -718,6 +1050,60 @@ func (ec *executionContext) marshalNIsDependency2ᚖgithubᚗcomᚋguacsecᚋgua return ec._IsDependency(ctx, sel, v) } +func (ec *executionContext) marshalNIsDependencyEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsDependencyEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.IsDependencyEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNIsDependencyEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsDependencyEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNIsDependencyEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsDependencyEdge(ctx context.Context, sel ast.SelectionSet, v *model.IsDependencyEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._IsDependencyEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNIsDependencyInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsDependencyInputSpec(ctx context.Context, v interface{}) (model.IsDependencyInputSpec, error) { res, err := ec.unmarshalInputIsDependencyInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -771,6 +1157,13 @@ func (ec *executionContext) marshalODependencyType2ᚖgithubᚗcomᚋguacsecᚋg return v } +func (ec *executionContext) marshalOIsDependencyConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsDependencyConnection(ctx context.Context, sel ast.SelectionSet, v *model.IsDependencyConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._IsDependencyConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOIsDependencySpec2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsDependencySpecᚄ(ctx context.Context, v interface{}) ([]*model.IsDependencySpec, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/isOccurrence.generated.go b/pkg/assembler/graphql/generated/isOccurrence.generated.go index 79223db5ec5..79335e5d710 100644 --- a/pkg/assembler/graphql/generated/isOccurrence.generated.go +++ b/pkg/assembler/graphql/generated/isOccurrence.generated.go @@ -324,6 +324,241 @@ func (ec *executionContext) fieldContext_IsOccurrence_documentRef(ctx context.Co return fc, nil } +func (ec *executionContext) _IsOccurrenceConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.IsOccurrenceConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IsOccurrenceConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IsOccurrenceConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IsOccurrenceConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _IsOccurrenceConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.IsOccurrenceConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IsOccurrenceConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IsOccurrenceConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IsOccurrenceConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _IsOccurrenceConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.IsOccurrenceConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IsOccurrenceConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.IsOccurrenceEdge) + fc.Result = res + return ec.marshalNIsOccurrenceEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IsOccurrenceConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IsOccurrenceConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_IsOccurrenceEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_IsOccurrenceEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type IsOccurrenceEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _IsOccurrenceEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.IsOccurrenceEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IsOccurrenceEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IsOccurrenceEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IsOccurrenceEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _IsOccurrenceEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.IsOccurrenceEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_IsOccurrenceEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.IsOccurrence) + fc.Result = res + return ec.marshalNIsOccurrence2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrence(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_IsOccurrenceEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "IsOccurrenceEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_IsOccurrence_id(ctx, field) + case "subject": + return ec.fieldContext_IsOccurrence_subject(ctx, field) + case "artifact": + return ec.fieldContext_IsOccurrence_artifact(ctx, field) + case "justification": + return ec.fieldContext_IsOccurrence_justification(ctx, field) + case "origin": + return ec.fieldContext_IsOccurrence_origin(ctx, field) + case "collector": + return ec.fieldContext_IsOccurrence_collector(ctx, field) + case "documentRef": + return ec.fieldContext_IsOccurrence_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type IsOccurrence", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -647,6 +882,99 @@ func (ec *executionContext) _IsOccurrence(ctx context.Context, sel ast.Selection return out } +var isOccurrenceConnectionImplementors = []string{"IsOccurrenceConnection"} + +func (ec *executionContext) _IsOccurrenceConnection(ctx context.Context, sel ast.SelectionSet, obj *model.IsOccurrenceConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, isOccurrenceConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("IsOccurrenceConnection") + case "totalCount": + out.Values[i] = ec._IsOccurrenceConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._IsOccurrenceConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._IsOccurrenceConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var isOccurrenceEdgeImplementors = []string{"IsOccurrenceEdge"} + +func (ec *executionContext) _IsOccurrenceEdge(ctx context.Context, sel ast.SelectionSet, obj *model.IsOccurrenceEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, isOccurrenceEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("IsOccurrenceEdge") + case "cursor": + out.Values[i] = ec._IsOccurrenceEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._IsOccurrenceEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -705,6 +1033,60 @@ func (ec *executionContext) marshalNIsOccurrence2ᚖgithubᚗcomᚋguacsecᚋgua return ec._IsOccurrence(ctx, sel, v) } +func (ec *executionContext) marshalNIsOccurrenceEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.IsOccurrenceEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNIsOccurrenceEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNIsOccurrenceEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceEdge(ctx context.Context, sel ast.SelectionSet, v *model.IsOccurrenceEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._IsOccurrenceEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNIsOccurrenceInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceInputSpec(ctx context.Context, v interface{}) (model.IsOccurrenceInputSpec, error) { res, err := ec.unmarshalInputIsOccurrenceInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -762,6 +1144,13 @@ func (ec *executionContext) unmarshalNPackageOrSourceInputs2githubᚗcomᚋguacs return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOIsOccurrenceConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceConnection(ctx context.Context, sel ast.SelectionSet, v *model.IsOccurrenceConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._IsOccurrenceConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOIsOccurrenceSpec2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐIsOccurrenceSpecᚄ(ctx context.Context, v interface{}) ([]*model.IsOccurrenceSpec, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/license.generated.go b/pkg/assembler/graphql/generated/license.generated.go index 73442b49c01..e2f28c88bbe 100644 --- a/pkg/assembler/graphql/generated/license.generated.go +++ b/pkg/assembler/graphql/generated/license.generated.go @@ -5,6 +5,7 @@ package generated import ( "context" "errors" + "fmt" "strconv" "sync" "sync/atomic" @@ -186,6 +187,235 @@ func (ec *executionContext) fieldContext_License_listVersion(ctx context.Context return fc, nil } +func (ec *executionContext) _LicenseConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.LicenseConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LicenseConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LicenseConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LicenseConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _LicenseConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.LicenseConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LicenseConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LicenseConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LicenseConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _LicenseConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.LicenseConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LicenseConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.LicenseEdge) + fc.Result = res + return ec.marshalNLicenseEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐLicenseEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LicenseConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LicenseConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_LicenseEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_LicenseEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type LicenseEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _LicenseEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.LicenseEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LicenseEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LicenseEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LicenseEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _LicenseEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.LicenseEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_LicenseEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.License) + fc.Result = res + return ec.marshalNLicense2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐLicense(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_LicenseEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "LicenseEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_License_id(ctx, field) + case "name": + return ec.fieldContext_License_name(ctx, field) + case "inline": + return ec.fieldContext_License_inline(ctx, field) + case "listVersion": + return ec.fieldContext_License_listVersion(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type License", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -369,6 +599,99 @@ func (ec *executionContext) _License(ctx context.Context, sel ast.SelectionSet, return out } +var licenseConnectionImplementors = []string{"LicenseConnection"} + +func (ec *executionContext) _LicenseConnection(ctx context.Context, sel ast.SelectionSet, obj *model.LicenseConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, licenseConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("LicenseConnection") + case "totalCount": + out.Values[i] = ec._LicenseConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._LicenseConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._LicenseConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var licenseEdgeImplementors = []string{"LicenseEdge"} + +func (ec *executionContext) _LicenseEdge(ctx context.Context, sel ast.SelectionSet, obj *model.LicenseEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, licenseEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("LicenseEdge") + case "cursor": + out.Values[i] = ec._LicenseEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._LicenseEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -466,6 +789,60 @@ func (ec *executionContext) marshalNLicense2ᚖgithubᚗcomᚋguacsecᚋguacᚋp return ec._License(ctx, sel, v) } +func (ec *executionContext) marshalNLicenseEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐLicenseEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.LicenseEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNLicenseEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐLicenseEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNLicenseEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐLicenseEdge(ctx context.Context, sel ast.SelectionSet, v *model.LicenseEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._LicenseEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNLicenseSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐLicenseSpec(ctx context.Context, v interface{}) (model.LicenseSpec, error) { res, err := ec.unmarshalInputLicenseSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -484,6 +861,13 @@ func (ec *executionContext) unmarshalOIDorLicenseInput2ᚖgithubᚗcomᚋguacsec return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOLicenseConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐLicenseConnection(ctx context.Context, sel ast.SelectionSet, v *model.LicenseConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._LicenseConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOLicenseInputSpec2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐLicenseInputSpec(ctx context.Context, v interface{}) (*model.LicenseInputSpec, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/metadata.generated.go b/pkg/assembler/graphql/generated/metadata.generated.go index 13420be0726..ca8407bce47 100644 --- a/pkg/assembler/graphql/generated/metadata.generated.go +++ b/pkg/assembler/graphql/generated/metadata.generated.go @@ -5,6 +5,7 @@ package generated import ( "context" "errors" + "fmt" "strconv" "sync" "sync/atomic" @@ -398,6 +399,245 @@ func (ec *executionContext) fieldContext_HasMetadata_documentRef(ctx context.Con return fc, nil } +func (ec *executionContext) _HasMetadataConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.HasMetadataConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasMetadataConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasMetadataConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasMetadataConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HasMetadataConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.HasMetadataConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasMetadataConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasMetadataConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasMetadataConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _HasMetadataConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.HasMetadataConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasMetadataConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.HasMetadataEdge) + fc.Result = res + return ec.marshalNHasMetadataEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasMetadataEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasMetadataConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasMetadataConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_HasMetadataEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_HasMetadataEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasMetadataEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _HasMetadataEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.HasMetadataEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasMetadataEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasMetadataEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasMetadataEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _HasMetadataEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.HasMetadataEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_HasMetadataEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.HasMetadata) + fc.Result = res + return ec.marshalNHasMetadata2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasMetadata(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_HasMetadataEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "HasMetadataEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_HasMetadata_id(ctx, field) + case "subject": + return ec.fieldContext_HasMetadata_subject(ctx, field) + case "key": + return ec.fieldContext_HasMetadata_key(ctx, field) + case "value": + return ec.fieldContext_HasMetadata_value(ctx, field) + case "timestamp": + return ec.fieldContext_HasMetadata_timestamp(ctx, field) + case "justification": + return ec.fieldContext_HasMetadata_justification(ctx, field) + case "origin": + return ec.fieldContext_HasMetadata_origin(ctx, field) + case "collector": + return ec.fieldContext_HasMetadata_collector(ctx, field) + case "documentRef": + return ec.fieldContext_HasMetadata_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type HasMetadata", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -641,6 +881,99 @@ func (ec *executionContext) _HasMetadata(ctx context.Context, sel ast.SelectionS return out } +var hasMetadataConnectionImplementors = []string{"HasMetadataConnection"} + +func (ec *executionContext) _HasMetadataConnection(ctx context.Context, sel ast.SelectionSet, obj *model.HasMetadataConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hasMetadataConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("HasMetadataConnection") + case "totalCount": + out.Values[i] = ec._HasMetadataConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._HasMetadataConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._HasMetadataConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var hasMetadataEdgeImplementors = []string{"HasMetadataEdge"} + +func (ec *executionContext) _HasMetadataEdge(ctx context.Context, sel ast.SelectionSet, obj *model.HasMetadataEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, hasMetadataEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("HasMetadataEdge") + case "cursor": + out.Values[i] = ec._HasMetadataEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._HasMetadataEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -699,6 +1032,60 @@ func (ec *executionContext) marshalNHasMetadata2ᚖgithubᚗcomᚋguacsecᚋguac return ec._HasMetadata(ctx, sel, v) } +func (ec *executionContext) marshalNHasMetadataEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasMetadataEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.HasMetadataEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNHasMetadataEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasMetadataEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNHasMetadataEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasMetadataEdge(ctx context.Context, sel ast.SelectionSet, v *model.HasMetadataEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._HasMetadataEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNHasMetadataInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasMetadataInputSpec(ctx context.Context, v interface{}) (model.HasMetadataInputSpec, error) { res, err := ec.unmarshalInputHasMetadataInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -731,4 +1118,11 @@ func (ec *executionContext) unmarshalNHasMetadataSpec2githubᚗcomᚋguacsecᚋg return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOHasMetadataConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐHasMetadataConnection(ctx context.Context, sel ast.SelectionSet, v *model.HasMetadataConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._HasMetadataConnection(ctx, sel, v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/package.generated.go b/pkg/assembler/graphql/generated/package.generated.go index 57091efcd53..10d28469624 100644 --- a/pkg/assembler/graphql/generated/package.generated.go +++ b/pkg/assembler/graphql/generated/package.generated.go @@ -164,6 +164,233 @@ func (ec *executionContext) fieldContext_Package_namespaces(ctx context.Context, return fc, nil } +func (ec *executionContext) _PackageConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.PackageConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PackageConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PackageConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PackageConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PackageConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.PackageConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PackageConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PackageConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PackageConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _PackageConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.PackageConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PackageConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.PackageEdge) + fc.Result = res + return ec.marshalNPackageEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PackageConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PackageConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_PackageEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_PackageEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PackageEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _PackageEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.PackageEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PackageEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PackageEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PackageEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PackageEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.PackageEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PackageEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.Package) + fc.Result = res + return ec.marshalNPackage2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackage(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PackageEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PackageEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Package_id(ctx, field) + case "type": + return ec.fieldContext_Package_type(ctx, field) + case "namespaces": + return ec.fieldContext_Package_namespaces(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Package", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _PackageIDs_packageTypeID(ctx context.Context, field graphql.CollectedField, obj *model.PackageIDs) (ret graphql.Marshaler) { fc, err := ec.fieldContext_PackageIDs_packageTypeID(ctx, field) if err != nil { @@ -1260,6 +1487,99 @@ func (ec *executionContext) _Package(ctx context.Context, sel ast.SelectionSet, return out } +var packageConnectionImplementors = []string{"PackageConnection"} + +func (ec *executionContext) _PackageConnection(ctx context.Context, sel ast.SelectionSet, obj *model.PackageConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, packageConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PackageConnection") + case "totalCount": + out.Values[i] = ec._PackageConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._PackageConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._PackageConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var packageEdgeImplementors = []string{"PackageEdge"} + +func (ec *executionContext) _PackageEdge(ctx context.Context, sel ast.SelectionSet, obj *model.PackageEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, packageEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PackageEdge") + case "cursor": + out.Values[i] = ec._PackageEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._PackageEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var packageIDsImplementors = []string{"PackageIDs"} func (ec *executionContext) _PackageIDs(ctx context.Context, sel ast.SelectionSet, obj *model.PackageIDs) graphql.Marshaler { @@ -1600,6 +1920,60 @@ func (ec *executionContext) marshalNPackage2ᚖgithubᚗcomᚋguacsecᚋguacᚋp return ec._Package(ctx, sel, v) } +func (ec *executionContext) marshalNPackageEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.PackageEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNPackageEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNPackageEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageEdge(ctx context.Context, sel ast.SelectionSet, v *model.PackageEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._PackageEdge(ctx, sel, v) +} + func (ec *executionContext) marshalNPackageIDs2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageIDs(ctx context.Context, sel ast.SelectionSet, v model.PackageIDs) graphql.Marshaler { return ec._PackageIDs(ctx, sel, &v) } @@ -1917,6 +2291,13 @@ func (ec *executionContext) unmarshalOIDorPkgInput2ᚖgithubᚗcomᚋguacsecᚋg return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOPackageConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageConnection(ctx context.Context, sel ast.SelectionSet, v *model.PackageConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._PackageConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOPackageQualifierInputSpec2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageQualifierInputSpecᚄ(ctx context.Context, v interface{}) ([]*model.PackageQualifierInputSpec, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/pagination.generated.go b/pkg/assembler/graphql/generated/pagination.generated.go new file mode 100644 index 00000000000..ecbbba13582 --- /dev/null +++ b/pkg/assembler/graphql/generated/pagination.generated.go @@ -0,0 +1,216 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package generated + +import ( + "context" + "errors" + "strconv" + "sync/atomic" + + "github.com/99designs/gqlgen/graphql" + "github.com/guacsec/guac/pkg/assembler/graphql/model" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +// endregion ***************************** args.gotpl ***************************** + +// region ************************** directives.gotpl ************************** + +// endregion ************************** directives.gotpl ************************** + +// region **************************** field.gotpl ***************************** + +func (ec *executionContext) _PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_hasNextPage(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.HasNextPage, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PageInfo_hasNextPage(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PageInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PageInfo_startCursor(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_startCursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.StartCursor, nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOID2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PageInfo_startCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PageInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PageInfo_endCursor(ctx context.Context, field graphql.CollectedField, obj *model.PageInfo) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PageInfo_endCursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EndCursor, nil + }) + + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOID2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PageInfo_endCursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PageInfo", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var pageInfoImplementors = []string{"PageInfo"} + +func (ec *executionContext) _PageInfo(ctx context.Context, sel ast.SelectionSet, obj *model.PageInfo) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, pageInfoImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PageInfo") + case "hasNextPage": + out.Values[i] = ec._PageInfo_hasNextPage(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "startCursor": + out.Values[i] = ec._PageInfo_startCursor(ctx, field, obj) + case "endCursor": + out.Values[i] = ec._PageInfo_endCursor(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx context.Context, sel ast.SelectionSet, v *model.PageInfo) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._PageInfo(ctx, sel, v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/path.generated.go b/pkg/assembler/graphql/generated/path.generated.go index d0606164674..48ed5af2415 100644 --- a/pkg/assembler/graphql/generated/path.generated.go +++ b/pkg/assembler/graphql/generated/path.generated.go @@ -4,8 +4,11 @@ package generated import ( "context" + "errors" "fmt" + "strconv" "sync" + "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/guacsec/guac/pkg/assembler/graphql/model" @@ -26,6 +29,225 @@ import ( // region **************************** field.gotpl ***************************** +func (ec *executionContext) _NeighborConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.NeighborConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_NeighborConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_NeighborConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "NeighborConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _NeighborConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.NeighborConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_NeighborConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_NeighborConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "NeighborConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _NeighborConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.NeighborConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_NeighborConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.NeighborEdge) + fc.Result = res + return ec.marshalNNeighborEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNeighborEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_NeighborConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "NeighborConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_NeighborEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_NeighborEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type NeighborEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _NeighborEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.NeighborEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_NeighborEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_NeighborEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "NeighborEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _NeighborEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.NeighborEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_NeighborEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(model.Node) + fc.Result = res + return ec.marshalNNode2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNode(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_NeighborEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "NeighborEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Node does not have child fields") + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -208,6 +430,99 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj // region **************************** object.gotpl **************************** +var neighborConnectionImplementors = []string{"NeighborConnection"} + +func (ec *executionContext) _NeighborConnection(ctx context.Context, sel ast.SelectionSet, obj *model.NeighborConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, neighborConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("NeighborConnection") + case "totalCount": + out.Values[i] = ec._NeighborConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._NeighborConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._NeighborConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var neighborEdgeImplementors = []string{"NeighborEdge"} + +func (ec *executionContext) _NeighborEdge(ctx context.Context, sel ast.SelectionSet, obj *model.NeighborEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, neighborEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("NeighborEdge") + case "cursor": + out.Values[i] = ec._NeighborEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._NeighborEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -283,6 +598,60 @@ func (ec *executionContext) marshalNEdge2ᚕgithubᚗcomᚋguacsecᚋguacᚋpkg return ret } +func (ec *executionContext) marshalNNeighborEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNeighborEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.NeighborEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNNeighborEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNeighborEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNNeighborEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNeighborEdge(ctx context.Context, sel ast.SelectionSet, v *model.NeighborEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._NeighborEdge(ctx, sel, v) +} + func (ec *executionContext) marshalNNode2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNode(ctx context.Context, sel ast.SelectionSet, v model.Node) graphql.Marshaler { if v == nil { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { @@ -337,4 +706,11 @@ func (ec *executionContext) marshalNNode2ᚕgithubᚗcomᚋguacsecᚋguacᚋpkg return ret } +func (ec *executionContext) marshalONeighborConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐNeighborConnection(ctx context.Context, sel ast.SelectionSet, v *model.NeighborConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._NeighborConnection(ctx, sel, v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/pkgEqual.generated.go b/pkg/assembler/graphql/generated/pkgEqual.generated.go index 543e7acb29b..ab5eaac8056 100644 --- a/pkg/assembler/graphql/generated/pkgEqual.generated.go +++ b/pkg/assembler/graphql/generated/pkgEqual.generated.go @@ -283,6 +283,239 @@ func (ec *executionContext) fieldContext_PkgEqual_documentRef(ctx context.Contex return fc, nil } +func (ec *executionContext) _PkgEqualConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.PkgEqualConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PkgEqualConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PkgEqualConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PkgEqualConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PkgEqualConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.PkgEqualConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PkgEqualConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PkgEqualConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PkgEqualConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _PkgEqualConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.PkgEqualConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PkgEqualConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.PkgEqualEdge) + fc.Result = res + return ec.marshalNPkgEqualEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqualEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PkgEqualConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PkgEqualConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_PkgEqualEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_PkgEqualEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PkgEqualEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _PkgEqualEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.PkgEqualEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PkgEqualEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PkgEqualEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PkgEqualEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _PkgEqualEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.PkgEqualEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_PkgEqualEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PkgEqual) + fc.Result = res + return ec.marshalNPkgEqual2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqual(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_PkgEqualEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "PkgEqualEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_PkgEqual_id(ctx, field) + case "packages": + return ec.fieldContext_PkgEqual_packages(ctx, field) + case "justification": + return ec.fieldContext_PkgEqual_justification(ctx, field) + case "origin": + return ec.fieldContext_PkgEqual_origin(ctx, field) + case "collector": + return ec.fieldContext_PkgEqual_collector(ctx, field) + case "documentRef": + return ec.fieldContext_PkgEqual_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PkgEqual", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -469,6 +702,99 @@ func (ec *executionContext) _PkgEqual(ctx context.Context, sel ast.SelectionSet, return out } +var pkgEqualConnectionImplementors = []string{"PkgEqualConnection"} + +func (ec *executionContext) _PkgEqualConnection(ctx context.Context, sel ast.SelectionSet, obj *model.PkgEqualConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, pkgEqualConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PkgEqualConnection") + case "totalCount": + out.Values[i] = ec._PkgEqualConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._PkgEqualConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._PkgEqualConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var pkgEqualEdgeImplementors = []string{"PkgEqualEdge"} + +func (ec *executionContext) _PkgEqualEdge(ctx context.Context, sel ast.SelectionSet, obj *model.PkgEqualEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, pkgEqualEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("PkgEqualEdge") + case "cursor": + out.Values[i] = ec._PkgEqualEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._PkgEqualEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -527,6 +853,60 @@ func (ec *executionContext) marshalNPkgEqual2ᚖgithubᚗcomᚋguacsecᚋguacᚋ return ec._PkgEqual(ctx, sel, v) } +func (ec *executionContext) marshalNPkgEqualEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqualEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.PkgEqualEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNPkgEqualEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqualEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNPkgEqualEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqualEdge(ctx context.Context, sel ast.SelectionSet, v *model.PkgEqualEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._PkgEqualEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNPkgEqualInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqualInputSpec(ctx context.Context, v interface{}) (model.PkgEqualInputSpec, error) { res, err := ec.unmarshalInputPkgEqualInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -559,4 +939,11 @@ func (ec *executionContext) unmarshalNPkgEqualSpec2githubᚗcomᚋguacsecᚋguac return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOPkgEqualConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPkgEqualConnection(ctx context.Context, sel ast.SelectionSet, v *model.PkgEqualConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._PkgEqualConnection(ctx, sel, v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/prelude.generated.go b/pkg/assembler/graphql/generated/prelude.generated.go index caf2bdf5542..04d337c0ec1 100644 --- a/pkg/assembler/graphql/generated/prelude.generated.go +++ b/pkg/assembler/graphql/generated/prelude.generated.go @@ -2503,6 +2503,22 @@ func (ec *executionContext) marshalOID2ᚖstring(ctx context.Context, sel ast.Se return res } +func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v interface{}) (*int, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalInt(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.SelectionSet, v *int) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalInt(*v) + return res +} + func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/root_.generated.go b/pkg/assembler/graphql/generated/root_.generated.go index cbb879f523b..266edadfe2e 100644 --- a/pkg/assembler/graphql/generated/root_.generated.go +++ b/pkg/assembler/graphql/generated/root_.generated.go @@ -49,11 +49,33 @@ type ComplexityRoot struct { ID func(childComplexity int) int } + ArtifactConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + ArtifactEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + Builder struct { ID func(childComplexity int) int URI func(childComplexity int) int } + BuilderConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + BuilderEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + CertifyBad struct { Collector func(childComplexity int) int DocumentRef func(childComplexity int) int @@ -64,6 +86,17 @@ type ComplexityRoot struct { Subject func(childComplexity int) int } + CertifyBadConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + CertifyBadEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + CertifyGood struct { Collector func(childComplexity int) int DocumentRef func(childComplexity int) int @@ -74,6 +107,17 @@ type ComplexityRoot struct { Subject func(childComplexity int) int } + CertifyGoodConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + CertifyGoodEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + CertifyLegal struct { Attribution func(childComplexity int) int Collector func(childComplexity int) int @@ -89,12 +133,34 @@ type ComplexityRoot struct { TimeScanned func(childComplexity int) int } + CertifyLegalConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + CertifyLegalEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + CertifyScorecard struct { ID func(childComplexity int) int Scorecard func(childComplexity int) int Source func(childComplexity int) int } + CertifyScorecardConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + CertifyScorecardEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + CertifyVEXStatement struct { Collector func(childComplexity int) int DocumentRef func(childComplexity int) int @@ -116,6 +182,23 @@ type ComplexityRoot struct { Vulnerability func(childComplexity int) int } + CertifyVulnConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + CertifyVulnEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + + FindSoftwareConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + HasMetadata struct { Collector func(childComplexity int) int DocumentRef func(childComplexity int) int @@ -128,6 +211,17 @@ type ComplexityRoot struct { Value func(childComplexity int) int } + HasMetadataConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + HasMetadataEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + HasSBOM struct { Algorithm func(childComplexity int) int Collector func(childComplexity int) int @@ -144,12 +238,34 @@ type ComplexityRoot struct { URI func(childComplexity int) int } + HasSBOMConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + HasSBOMEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + HasSLSA struct { ID func(childComplexity int) int Slsa func(childComplexity int) int Subject func(childComplexity int) int } + HasSLSAConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + HasSLSAEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + HasSourceAt struct { Collector func(childComplexity int) int DocumentRef func(childComplexity int) int @@ -161,6 +277,17 @@ type ComplexityRoot struct { Source func(childComplexity int) int } + HasSourceAtConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + HasSourceAtEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + HashEqual struct { Artifacts func(childComplexity int) int Collector func(childComplexity int) int @@ -170,6 +297,17 @@ type ComplexityRoot struct { Origin func(childComplexity int) int } + HashEqualConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + HashEqualEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + IsDependency struct { Collector func(childComplexity int) int DependencyPackage func(childComplexity int) int @@ -182,6 +320,17 @@ type ComplexityRoot struct { VersionRange func(childComplexity int) int } + IsDependencyConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + IsDependencyEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + IsOccurrence struct { Artifact func(childComplexity int) int Collector func(childComplexity int) int @@ -192,6 +341,17 @@ type ComplexityRoot struct { Subject func(childComplexity int) int } + IsOccurrenceConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + IsOccurrenceEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + License struct { ID func(childComplexity int) int Inline func(childComplexity int) int @@ -199,6 +359,17 @@ type ComplexityRoot struct { Name func(childComplexity int) int } + LicenseConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + LicenseEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + Mutation struct { IngestArtifact func(childComplexity int, artifact *model.IDorArtifactInput) int IngestArtifacts func(childComplexity int, artifacts []*model.IDorArtifactInput) int @@ -248,12 +419,34 @@ type ComplexityRoot struct { IngestVulnerabilityMetadata func(childComplexity int, vulnerability model.IDorVulnerabilityInput, vulnerabilityMetadata model.VulnerabilityMetadataInputSpec) int } + NeighborConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + NeighborEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + Package struct { ID func(childComplexity int) int Namespaces func(childComplexity int) int Type func(childComplexity int) int } + PackageConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + PackageEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + PackageIDs struct { PackageNameID func(childComplexity int) int PackageNamespaceID func(childComplexity int) int @@ -286,6 +479,12 @@ type ComplexityRoot struct { Version func(childComplexity int) int } + PageInfo struct { + EndCursor func(childComplexity int) int + HasNextPage func(childComplexity int) int + StartCursor func(childComplexity int) int + } + PkgEqual struct { Collector func(childComplexity int) int DocumentRef func(childComplexity int) int @@ -295,6 +494,17 @@ type ComplexityRoot struct { Packages func(childComplexity int) int } + PkgEqualConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + PkgEqualEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + PointOfContact struct { Collector func(childComplexity int) int DocumentRef func(childComplexity int) int @@ -307,35 +517,71 @@ type ComplexityRoot struct { Subject func(childComplexity int) int } + PointOfContactConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + PointOfContactEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + Query struct { - Artifacts func(childComplexity int, artifactSpec model.ArtifactSpec) int - Builders func(childComplexity int, builderSpec model.BuilderSpec) int - CertifyBad func(childComplexity int, certifyBadSpec model.CertifyBadSpec) int - CertifyGood func(childComplexity int, certifyGoodSpec model.CertifyGoodSpec) int - CertifyLegal func(childComplexity int, certifyLegalSpec model.CertifyLegalSpec) int - CertifyVEXStatement func(childComplexity int, certifyVEXStatementSpec model.CertifyVEXStatementSpec) int - CertifyVuln func(childComplexity int, certifyVulnSpec model.CertifyVulnSpec) int - FindSoftware func(childComplexity int, searchText string) int - HasMetadata func(childComplexity int, hasMetadataSpec model.HasMetadataSpec) int - HasSbom func(childComplexity int, hasSBOMSpec model.HasSBOMSpec) int - HasSlsa func(childComplexity int, hasSLSASpec model.HasSLSASpec) int - HasSourceAt func(childComplexity int, hasSourceAtSpec model.HasSourceAtSpec) int - HashEqual func(childComplexity int, hashEqualSpec model.HashEqualSpec) int - IsDependency func(childComplexity int, isDependencySpec model.IsDependencySpec) int - IsOccurrence func(childComplexity int, isOccurrenceSpec model.IsOccurrenceSpec) int - Licenses func(childComplexity int, licenseSpec model.LicenseSpec) int - Neighbors func(childComplexity int, node string, usingOnly []model.Edge) int - Node func(childComplexity int, node string) int - Nodes func(childComplexity int, nodes []string) int - Packages func(childComplexity int, pkgSpec model.PkgSpec) int - Path func(childComplexity int, subject string, target string, maxPathLength int, usingOnly []model.Edge) int - PkgEqual func(childComplexity int, pkgEqualSpec model.PkgEqualSpec) int - PointOfContact func(childComplexity int, pointOfContactSpec model.PointOfContactSpec) int - Scorecards func(childComplexity int, scorecardSpec model.CertifyScorecardSpec) int - Sources func(childComplexity int, sourceSpec model.SourceSpec) int - VulnEqual func(childComplexity int, vulnEqualSpec model.VulnEqualSpec) int - Vulnerabilities func(childComplexity int, vulnSpec model.VulnerabilitySpec) int - VulnerabilityMetadata func(childComplexity int, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec) int + Artifacts func(childComplexity int, artifactSpec model.ArtifactSpec) int + ArtifactsList func(childComplexity int, artifactSpec model.ArtifactSpec, after *string, first *int) int + Builders func(childComplexity int, builderSpec model.BuilderSpec) int + BuildersList func(childComplexity int, builderSpec model.BuilderSpec, after *string, first *int) int + CertifyBad func(childComplexity int, certifyBadSpec model.CertifyBadSpec) int + CertifyBadList func(childComplexity int, certifyBadSpec model.CertifyBadSpec, after *string, first *int) int + CertifyGood func(childComplexity int, certifyGoodSpec model.CertifyGoodSpec) int + CertifyGoodList func(childComplexity int, certifyGoodSpec model.CertifyGoodSpec, after *string, first *int) int + CertifyLegal func(childComplexity int, certifyLegalSpec model.CertifyLegalSpec) int + CertifyLegalList func(childComplexity int, certifyLegalSpec model.CertifyLegalSpec, after *string, first *int) int + CertifyVEXStatement func(childComplexity int, certifyVEXStatementSpec model.CertifyVEXStatementSpec) int + CertifyVEXStatementList func(childComplexity int, certifyVEXStatementSpec model.CertifyVEXStatementSpec, after *string, first *int) int + CertifyVuln func(childComplexity int, certifyVulnSpec model.CertifyVulnSpec) int + CertifyVulnList func(childComplexity int, certifyVulnSpec model.CertifyVulnSpec, after *string, first *int) int + FindSoftware func(childComplexity int, searchText string) int + FindSoftwareList func(childComplexity int, searchText string, after *string, first *int) int + HasMetadata func(childComplexity int, hasMetadataSpec model.HasMetadataSpec) int + HasMetadataList func(childComplexity int, hasMetadataSpec model.HasMetadataSpec, after *string, first *int) int + HasSBOMList func(childComplexity int, hasSBOMSpec model.HasSBOMSpec, after *string, first *int) int + HasSLSAList func(childComplexity int, hasSLSASpec model.HasSLSASpec, after *string, first *int) int + HasSbom func(childComplexity int, hasSBOMSpec model.HasSBOMSpec) int + HasSlsa func(childComplexity int, hasSLSASpec model.HasSLSASpec) int + HasSourceAt func(childComplexity int, hasSourceAtSpec model.HasSourceAtSpec) int + HasSourceAtList func(childComplexity int, hasSourceAtSpec model.HasSourceAtSpec, after *string, first *int) int + HashEqual func(childComplexity int, hashEqualSpec model.HashEqualSpec) int + HashEqualList func(childComplexity int, hashEqualSpec model.HashEqualSpec, after *string, first *int) int + IsDependency func(childComplexity int, isDependencySpec model.IsDependencySpec) int + IsDependencyList func(childComplexity int, isDependencySpec model.IsDependencySpec, after *string, first *int) int + IsOccurrence func(childComplexity int, isOccurrenceSpec model.IsOccurrenceSpec) int + IsOccurrenceList func(childComplexity int, isOccurrenceSpec model.IsOccurrenceSpec, after *string, first *int) int + LicenseList func(childComplexity int, licenseSpec model.LicenseSpec, after *string, first *int) int + Licenses func(childComplexity int, licenseSpec model.LicenseSpec) int + Neighbors func(childComplexity int, node string, usingOnly []model.Edge) int + NeighborsList func(childComplexity int, node string, usingOnly []model.Edge, after *string, first *int) int + Node func(childComplexity int, node string) int + Nodes func(childComplexity int, nodes []string) int + Packages func(childComplexity int, pkgSpec model.PkgSpec) int + PackagesList func(childComplexity int, pkgSpec model.PkgSpec, after *string, first *int) int + Path func(childComplexity int, subject string, target string, maxPathLength int, usingOnly []model.Edge) int + PkgEqual func(childComplexity int, pkgEqualSpec model.PkgEqualSpec) int + PkgEqualList func(childComplexity int, pkgEqualSpec model.PkgEqualSpec, after *string, first *int) int + PointOfContact func(childComplexity int, pointOfContactSpec model.PointOfContactSpec) int + PointOfContactList func(childComplexity int, pointOfContactSpec model.PointOfContactSpec, after *string, first *int) int + Scorecards func(childComplexity int, scorecardSpec model.CertifyScorecardSpec) int + ScorecardsList func(childComplexity int, scorecardSpec model.CertifyScorecardSpec, after *string, first *int) int + Sources func(childComplexity int, sourceSpec model.SourceSpec) int + SourcesList func(childComplexity int, sourceSpec model.SourceSpec, after *string, first *int) int + VulnEqual func(childComplexity int, vulnEqualSpec model.VulnEqualSpec) int + VulnEqualList func(childComplexity int, vulnEqualSpec model.VulnEqualSpec, after *string, first *int) int + Vulnerabilities func(childComplexity int, vulnSpec model.VulnerabilitySpec) int + VulnerabilityList func(childComplexity int, vulnSpec model.VulnerabilitySpec, after *string, first *int) int + VulnerabilityMetadata func(childComplexity int, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec) int + VulnerabilityMetadataList func(childComplexity int, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec, after *string, first *int) int } SLSA struct { @@ -383,12 +629,28 @@ type ComplexityRoot struct { Score func(childComplexity int) int } + SoftwareEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + Source struct { ID func(childComplexity int) int Namespaces func(childComplexity int) int Type func(childComplexity int) int } + SourceConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + SourceEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + SourceIDs struct { SourceNameID func(childComplexity int) int SourceNamespaceID func(childComplexity int) int @@ -408,6 +670,17 @@ type ComplexityRoot struct { Namespace func(childComplexity int) int } + VEXConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + VEXEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + VulnEqual struct { Collector func(childComplexity int) int DocumentRef func(childComplexity int) int @@ -417,12 +690,34 @@ type ComplexityRoot struct { Vulnerabilities func(childComplexity int) int } + VulnEqualConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + VulnEqualEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + Vulnerability struct { ID func(childComplexity int) int Type func(childComplexity int) int VulnerabilityIDs func(childComplexity int) int } + VulnerabilityConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + VulnerabilityEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + VulnerabilityID struct { ID func(childComplexity int) int VulnerabilityID func(childComplexity int) int @@ -443,6 +738,17 @@ type ComplexityRoot struct { Timestamp func(childComplexity int) int Vulnerability func(childComplexity int) int } + + VulnerabilityMetadataConnection struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + + VulnerabilityMetadataEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } } type executableSchema struct { @@ -485,6 +791,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Artifact.ID(childComplexity), true + case "ArtifactConnection.edges": + if e.complexity.ArtifactConnection.Edges == nil { + break + } + + return e.complexity.ArtifactConnection.Edges(childComplexity), true + + case "ArtifactConnection.pageInfo": + if e.complexity.ArtifactConnection.PageInfo == nil { + break + } + + return e.complexity.ArtifactConnection.PageInfo(childComplexity), true + + case "ArtifactConnection.totalCount": + if e.complexity.ArtifactConnection.TotalCount == nil { + break + } + + return e.complexity.ArtifactConnection.TotalCount(childComplexity), true + + case "ArtifactEdge.cursor": + if e.complexity.ArtifactEdge.Cursor == nil { + break + } + + return e.complexity.ArtifactEdge.Cursor(childComplexity), true + + case "ArtifactEdge.node": + if e.complexity.ArtifactEdge.Node == nil { + break + } + + return e.complexity.ArtifactEdge.Node(childComplexity), true + case "Builder.id": if e.complexity.Builder.ID == nil { break @@ -499,6 +840,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Builder.URI(childComplexity), true + case "BuilderConnection.edges": + if e.complexity.BuilderConnection.Edges == nil { + break + } + + return e.complexity.BuilderConnection.Edges(childComplexity), true + + case "BuilderConnection.pageInfo": + if e.complexity.BuilderConnection.PageInfo == nil { + break + } + + return e.complexity.BuilderConnection.PageInfo(childComplexity), true + + case "BuilderConnection.totalCount": + if e.complexity.BuilderConnection.TotalCount == nil { + break + } + + return e.complexity.BuilderConnection.TotalCount(childComplexity), true + + case "BuilderEdge.cursor": + if e.complexity.BuilderEdge.Cursor == nil { + break + } + + return e.complexity.BuilderEdge.Cursor(childComplexity), true + + case "BuilderEdge.node": + if e.complexity.BuilderEdge.Node == nil { + break + } + + return e.complexity.BuilderEdge.Node(childComplexity), true + case "CertifyBad.collector": if e.complexity.CertifyBad.Collector == nil { break @@ -548,6 +924,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CertifyBad.Subject(childComplexity), true + case "CertifyBadConnection.edges": + if e.complexity.CertifyBadConnection.Edges == nil { + break + } + + return e.complexity.CertifyBadConnection.Edges(childComplexity), true + + case "CertifyBadConnection.pageInfo": + if e.complexity.CertifyBadConnection.PageInfo == nil { + break + } + + return e.complexity.CertifyBadConnection.PageInfo(childComplexity), true + + case "CertifyBadConnection.totalCount": + if e.complexity.CertifyBadConnection.TotalCount == nil { + break + } + + return e.complexity.CertifyBadConnection.TotalCount(childComplexity), true + + case "CertifyBadEdge.cursor": + if e.complexity.CertifyBadEdge.Cursor == nil { + break + } + + return e.complexity.CertifyBadEdge.Cursor(childComplexity), true + + case "CertifyBadEdge.node": + if e.complexity.CertifyBadEdge.Node == nil { + break + } + + return e.complexity.CertifyBadEdge.Node(childComplexity), true + case "CertifyGood.collector": if e.complexity.CertifyGood.Collector == nil { break @@ -597,6 +1008,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CertifyGood.Subject(childComplexity), true + case "CertifyGoodConnection.edges": + if e.complexity.CertifyGoodConnection.Edges == nil { + break + } + + return e.complexity.CertifyGoodConnection.Edges(childComplexity), true + + case "CertifyGoodConnection.pageInfo": + if e.complexity.CertifyGoodConnection.PageInfo == nil { + break + } + + return e.complexity.CertifyGoodConnection.PageInfo(childComplexity), true + + case "CertifyGoodConnection.totalCount": + if e.complexity.CertifyGoodConnection.TotalCount == nil { + break + } + + return e.complexity.CertifyGoodConnection.TotalCount(childComplexity), true + + case "CertifyGoodEdge.cursor": + if e.complexity.CertifyGoodEdge.Cursor == nil { + break + } + + return e.complexity.CertifyGoodEdge.Cursor(childComplexity), true + + case "CertifyGoodEdge.node": + if e.complexity.CertifyGoodEdge.Node == nil { + break + } + + return e.complexity.CertifyGoodEdge.Node(childComplexity), true + case "CertifyLegal.attribution": if e.complexity.CertifyLegal.Attribution == nil { break @@ -681,6 +1127,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CertifyLegal.TimeScanned(childComplexity), true + case "CertifyLegalConnection.edges": + if e.complexity.CertifyLegalConnection.Edges == nil { + break + } + + return e.complexity.CertifyLegalConnection.Edges(childComplexity), true + + case "CertifyLegalConnection.pageInfo": + if e.complexity.CertifyLegalConnection.PageInfo == nil { + break + } + + return e.complexity.CertifyLegalConnection.PageInfo(childComplexity), true + + case "CertifyLegalConnection.totalCount": + if e.complexity.CertifyLegalConnection.TotalCount == nil { + break + } + + return e.complexity.CertifyLegalConnection.TotalCount(childComplexity), true + + case "CertifyLegalEdge.cursor": + if e.complexity.CertifyLegalEdge.Cursor == nil { + break + } + + return e.complexity.CertifyLegalEdge.Cursor(childComplexity), true + + case "CertifyLegalEdge.node": + if e.complexity.CertifyLegalEdge.Node == nil { + break + } + + return e.complexity.CertifyLegalEdge.Node(childComplexity), true + case "CertifyScorecard.id": if e.complexity.CertifyScorecard.ID == nil { break @@ -702,6 +1183,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CertifyScorecard.Source(childComplexity), true + case "CertifyScorecardConnection.edges": + if e.complexity.CertifyScorecardConnection.Edges == nil { + break + } + + return e.complexity.CertifyScorecardConnection.Edges(childComplexity), true + + case "CertifyScorecardConnection.pageInfo": + if e.complexity.CertifyScorecardConnection.PageInfo == nil { + break + } + + return e.complexity.CertifyScorecardConnection.PageInfo(childComplexity), true + + case "CertifyScorecardConnection.totalCount": + if e.complexity.CertifyScorecardConnection.TotalCount == nil { + break + } + + return e.complexity.CertifyScorecardConnection.TotalCount(childComplexity), true + + case "CertifyScorecardEdge.cursor": + if e.complexity.CertifyScorecardEdge.Cursor == nil { + break + } + + return e.complexity.CertifyScorecardEdge.Cursor(childComplexity), true + + case "CertifyScorecardEdge.node": + if e.complexity.CertifyScorecardEdge.Node == nil { + break + } + + return e.complexity.CertifyScorecardEdge.Node(childComplexity), true + case "CertifyVEXStatement.collector": if e.complexity.CertifyVEXStatement.Collector == nil { break @@ -807,6 +1323,62 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.CertifyVuln.Vulnerability(childComplexity), true + case "CertifyVulnConnection.edges": + if e.complexity.CertifyVulnConnection.Edges == nil { + break + } + + return e.complexity.CertifyVulnConnection.Edges(childComplexity), true + + case "CertifyVulnConnection.pageInfo": + if e.complexity.CertifyVulnConnection.PageInfo == nil { + break + } + + return e.complexity.CertifyVulnConnection.PageInfo(childComplexity), true + + case "CertifyVulnConnection.totalCount": + if e.complexity.CertifyVulnConnection.TotalCount == nil { + break + } + + return e.complexity.CertifyVulnConnection.TotalCount(childComplexity), true + + case "CertifyVulnEdge.cursor": + if e.complexity.CertifyVulnEdge.Cursor == nil { + break + } + + return e.complexity.CertifyVulnEdge.Cursor(childComplexity), true + + case "CertifyVulnEdge.node": + if e.complexity.CertifyVulnEdge.Node == nil { + break + } + + return e.complexity.CertifyVulnEdge.Node(childComplexity), true + + case "FindSoftwareConnection.edges": + if e.complexity.FindSoftwareConnection.Edges == nil { + break + } + + return e.complexity.FindSoftwareConnection.Edges(childComplexity), true + + case "FindSoftwareConnection.pageInfo": + if e.complexity.FindSoftwareConnection.PageInfo == nil { + break + } + + return e.complexity.FindSoftwareConnection.PageInfo(childComplexity), true + + case "FindSoftwareConnection.totalCount": + if e.complexity.FindSoftwareConnection.TotalCount == nil { + break + } + + return e.complexity.FindSoftwareConnection.TotalCount(childComplexity), true + case "HasMetadata.collector": if e.complexity.HasMetadata.Collector == nil { break @@ -870,6 +1442,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.HasMetadata.Value(childComplexity), true + case "HasMetadataConnection.edges": + if e.complexity.HasMetadataConnection.Edges == nil { + break + } + + return e.complexity.HasMetadataConnection.Edges(childComplexity), true + + case "HasMetadataConnection.pageInfo": + if e.complexity.HasMetadataConnection.PageInfo == nil { + break + } + + return e.complexity.HasMetadataConnection.PageInfo(childComplexity), true + + case "HasMetadataConnection.totalCount": + if e.complexity.HasMetadataConnection.TotalCount == nil { + break + } + + return e.complexity.HasMetadataConnection.TotalCount(childComplexity), true + + case "HasMetadataEdge.cursor": + if e.complexity.HasMetadataEdge.Cursor == nil { + break + } + + return e.complexity.HasMetadataEdge.Cursor(childComplexity), true + + case "HasMetadataEdge.node": + if e.complexity.HasMetadataEdge.Node == nil { + break + } + + return e.complexity.HasMetadataEdge.Node(childComplexity), true + case "HasSBOM.algorithm": if e.complexity.HasSBOM.Algorithm == nil { break @@ -961,6 +1568,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.HasSBOM.URI(childComplexity), true + case "HasSBOMConnection.edges": + if e.complexity.HasSBOMConnection.Edges == nil { + break + } + + return e.complexity.HasSBOMConnection.Edges(childComplexity), true + + case "HasSBOMConnection.pageInfo": + if e.complexity.HasSBOMConnection.PageInfo == nil { + break + } + + return e.complexity.HasSBOMConnection.PageInfo(childComplexity), true + + case "HasSBOMConnection.totalCount": + if e.complexity.HasSBOMConnection.TotalCount == nil { + break + } + + return e.complexity.HasSBOMConnection.TotalCount(childComplexity), true + + case "HasSBOMEdge.cursor": + if e.complexity.HasSBOMEdge.Cursor == nil { + break + } + + return e.complexity.HasSBOMEdge.Cursor(childComplexity), true + + case "HasSBOMEdge.node": + if e.complexity.HasSBOMEdge.Node == nil { + break + } + + return e.complexity.HasSBOMEdge.Node(childComplexity), true + case "HasSLSA.id": if e.complexity.HasSLSA.ID == nil { break @@ -982,6 +1624,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.HasSLSA.Subject(childComplexity), true + case "HasSLSAConnection.edges": + if e.complexity.HasSLSAConnection.Edges == nil { + break + } + + return e.complexity.HasSLSAConnection.Edges(childComplexity), true + + case "HasSLSAConnection.pageInfo": + if e.complexity.HasSLSAConnection.PageInfo == nil { + break + } + + return e.complexity.HasSLSAConnection.PageInfo(childComplexity), true + + case "HasSLSAConnection.totalCount": + if e.complexity.HasSLSAConnection.TotalCount == nil { + break + } + + return e.complexity.HasSLSAConnection.TotalCount(childComplexity), true + + case "HasSLSAEdge.cursor": + if e.complexity.HasSLSAEdge.Cursor == nil { + break + } + + return e.complexity.HasSLSAEdge.Cursor(childComplexity), true + + case "HasSLSAEdge.node": + if e.complexity.HasSLSAEdge.Node == nil { + break + } + + return e.complexity.HasSLSAEdge.Node(childComplexity), true + case "HasSourceAt.collector": if e.complexity.HasSourceAt.Collector == nil { break @@ -1038,6 +1715,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.HasSourceAt.Source(childComplexity), true + case "HasSourceAtConnection.edges": + if e.complexity.HasSourceAtConnection.Edges == nil { + break + } + + return e.complexity.HasSourceAtConnection.Edges(childComplexity), true + + case "HasSourceAtConnection.pageInfo": + if e.complexity.HasSourceAtConnection.PageInfo == nil { + break + } + + return e.complexity.HasSourceAtConnection.PageInfo(childComplexity), true + + case "HasSourceAtConnection.totalCount": + if e.complexity.HasSourceAtConnection.TotalCount == nil { + break + } + + return e.complexity.HasSourceAtConnection.TotalCount(childComplexity), true + + case "HasSourceAtEdge.cursor": + if e.complexity.HasSourceAtEdge.Cursor == nil { + break + } + + return e.complexity.HasSourceAtEdge.Cursor(childComplexity), true + + case "HasSourceAtEdge.node": + if e.complexity.HasSourceAtEdge.Node == nil { + break + } + + return e.complexity.HasSourceAtEdge.Node(childComplexity), true + case "HashEqual.artifacts": if e.complexity.HashEqual.Artifacts == nil { break @@ -1080,6 +1792,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.HashEqual.Origin(childComplexity), true + case "HashEqualConnection.edges": + if e.complexity.HashEqualConnection.Edges == nil { + break + } + + return e.complexity.HashEqualConnection.Edges(childComplexity), true + + case "HashEqualConnection.pageInfo": + if e.complexity.HashEqualConnection.PageInfo == nil { + break + } + + return e.complexity.HashEqualConnection.PageInfo(childComplexity), true + + case "HashEqualConnection.totalCount": + if e.complexity.HashEqualConnection.TotalCount == nil { + break + } + + return e.complexity.HashEqualConnection.TotalCount(childComplexity), true + + case "HashEqualEdge.cursor": + if e.complexity.HashEqualEdge.Cursor == nil { + break + } + + return e.complexity.HashEqualEdge.Cursor(childComplexity), true + + case "HashEqualEdge.node": + if e.complexity.HashEqualEdge.Node == nil { + break + } + + return e.complexity.HashEqualEdge.Node(childComplexity), true + case "IsDependency.collector": if e.complexity.IsDependency.Collector == nil { break @@ -1143,6 +1890,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.IsDependency.VersionRange(childComplexity), true + case "IsDependencyConnection.edges": + if e.complexity.IsDependencyConnection.Edges == nil { + break + } + + return e.complexity.IsDependencyConnection.Edges(childComplexity), true + + case "IsDependencyConnection.pageInfo": + if e.complexity.IsDependencyConnection.PageInfo == nil { + break + } + + return e.complexity.IsDependencyConnection.PageInfo(childComplexity), true + + case "IsDependencyConnection.totalCount": + if e.complexity.IsDependencyConnection.TotalCount == nil { + break + } + + return e.complexity.IsDependencyConnection.TotalCount(childComplexity), true + + case "IsDependencyEdge.cursor": + if e.complexity.IsDependencyEdge.Cursor == nil { + break + } + + return e.complexity.IsDependencyEdge.Cursor(childComplexity), true + + case "IsDependencyEdge.node": + if e.complexity.IsDependencyEdge.Node == nil { + break + } + + return e.complexity.IsDependencyEdge.Node(childComplexity), true + case "IsOccurrence.artifact": if e.complexity.IsOccurrence.Artifact == nil { break @@ -1176,21 +1958,56 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in break } - return e.complexity.IsOccurrence.Justification(childComplexity), true + return e.complexity.IsOccurrence.Justification(childComplexity), true + + case "IsOccurrence.origin": + if e.complexity.IsOccurrence.Origin == nil { + break + } + + return e.complexity.IsOccurrence.Origin(childComplexity), true + + case "IsOccurrence.subject": + if e.complexity.IsOccurrence.Subject == nil { + break + } + + return e.complexity.IsOccurrence.Subject(childComplexity), true + + case "IsOccurrenceConnection.edges": + if e.complexity.IsOccurrenceConnection.Edges == nil { + break + } + + return e.complexity.IsOccurrenceConnection.Edges(childComplexity), true + + case "IsOccurrenceConnection.pageInfo": + if e.complexity.IsOccurrenceConnection.PageInfo == nil { + break + } + + return e.complexity.IsOccurrenceConnection.PageInfo(childComplexity), true + + case "IsOccurrenceConnection.totalCount": + if e.complexity.IsOccurrenceConnection.TotalCount == nil { + break + } + + return e.complexity.IsOccurrenceConnection.TotalCount(childComplexity), true - case "IsOccurrence.origin": - if e.complexity.IsOccurrence.Origin == nil { + case "IsOccurrenceEdge.cursor": + if e.complexity.IsOccurrenceEdge.Cursor == nil { break } - return e.complexity.IsOccurrence.Origin(childComplexity), true + return e.complexity.IsOccurrenceEdge.Cursor(childComplexity), true - case "IsOccurrence.subject": - if e.complexity.IsOccurrence.Subject == nil { + case "IsOccurrenceEdge.node": + if e.complexity.IsOccurrenceEdge.Node == nil { break } - return e.complexity.IsOccurrence.Subject(childComplexity), true + return e.complexity.IsOccurrenceEdge.Node(childComplexity), true case "License.id": if e.complexity.License.ID == nil { @@ -1220,6 +2037,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.License.Name(childComplexity), true + case "LicenseConnection.edges": + if e.complexity.LicenseConnection.Edges == nil { + break + } + + return e.complexity.LicenseConnection.Edges(childComplexity), true + + case "LicenseConnection.pageInfo": + if e.complexity.LicenseConnection.PageInfo == nil { + break + } + + return e.complexity.LicenseConnection.PageInfo(childComplexity), true + + case "LicenseConnection.totalCount": + if e.complexity.LicenseConnection.TotalCount == nil { + break + } + + return e.complexity.LicenseConnection.TotalCount(childComplexity), true + + case "LicenseEdge.cursor": + if e.complexity.LicenseEdge.Cursor == nil { + break + } + + return e.complexity.LicenseEdge.Cursor(childComplexity), true + + case "LicenseEdge.node": + if e.complexity.LicenseEdge.Node == nil { + break + } + + return e.complexity.LicenseEdge.Node(childComplexity), true + case "Mutation.ingestArtifact": if e.complexity.Mutation.IngestArtifact == nil { break @@ -1772,6 +2624,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.IngestVulnerabilityMetadata(childComplexity, args["vulnerability"].(model.IDorVulnerabilityInput), args["vulnerabilityMetadata"].(model.VulnerabilityMetadataInputSpec)), true + case "NeighborConnection.edges": + if e.complexity.NeighborConnection.Edges == nil { + break + } + + return e.complexity.NeighborConnection.Edges(childComplexity), true + + case "NeighborConnection.pageInfo": + if e.complexity.NeighborConnection.PageInfo == nil { + break + } + + return e.complexity.NeighborConnection.PageInfo(childComplexity), true + + case "NeighborConnection.totalCount": + if e.complexity.NeighborConnection.TotalCount == nil { + break + } + + return e.complexity.NeighborConnection.TotalCount(childComplexity), true + + case "NeighborEdge.cursor": + if e.complexity.NeighborEdge.Cursor == nil { + break + } + + return e.complexity.NeighborEdge.Cursor(childComplexity), true + + case "NeighborEdge.node": + if e.complexity.NeighborEdge.Node == nil { + break + } + + return e.complexity.NeighborEdge.Node(childComplexity), true + case "Package.id": if e.complexity.Package.ID == nil { break @@ -1793,6 +2680,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Package.Type(childComplexity), true + case "PackageConnection.edges": + if e.complexity.PackageConnection.Edges == nil { + break + } + + return e.complexity.PackageConnection.Edges(childComplexity), true + + case "PackageConnection.pageInfo": + if e.complexity.PackageConnection.PageInfo == nil { + break + } + + return e.complexity.PackageConnection.PageInfo(childComplexity), true + + case "PackageConnection.totalCount": + if e.complexity.PackageConnection.TotalCount == nil { + break + } + + return e.complexity.PackageConnection.TotalCount(childComplexity), true + + case "PackageEdge.cursor": + if e.complexity.PackageEdge.Cursor == nil { + break + } + + return e.complexity.PackageEdge.Cursor(childComplexity), true + + case "PackageEdge.node": + if e.complexity.PackageEdge.Node == nil { + break + } + + return e.complexity.PackageEdge.Node(childComplexity), true + case "PackageIDs.packageNameID": if e.complexity.PackageIDs.PackageNameID == nil { break @@ -1912,6 +2834,27 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.PackageVersion.Version(childComplexity), true + case "PageInfo.endCursor": + if e.complexity.PageInfo.EndCursor == nil { + break + } + + return e.complexity.PageInfo.EndCursor(childComplexity), true + + case "PageInfo.hasNextPage": + if e.complexity.PageInfo.HasNextPage == nil { + break + } + + return e.complexity.PageInfo.HasNextPage(childComplexity), true + + case "PageInfo.startCursor": + if e.complexity.PageInfo.StartCursor == nil { + break + } + + return e.complexity.PageInfo.StartCursor(childComplexity), true + case "PkgEqual.collector": if e.complexity.PkgEqual.Collector == nil { break @@ -1954,6 +2897,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.PkgEqual.Packages(childComplexity), true + case "PkgEqualConnection.edges": + if e.complexity.PkgEqualConnection.Edges == nil { + break + } + + return e.complexity.PkgEqualConnection.Edges(childComplexity), true + + case "PkgEqualConnection.pageInfo": + if e.complexity.PkgEqualConnection.PageInfo == nil { + break + } + + return e.complexity.PkgEqualConnection.PageInfo(childComplexity), true + + case "PkgEqualConnection.totalCount": + if e.complexity.PkgEqualConnection.TotalCount == nil { + break + } + + return e.complexity.PkgEqualConnection.TotalCount(childComplexity), true + + case "PkgEqualEdge.cursor": + if e.complexity.PkgEqualEdge.Cursor == nil { + break + } + + return e.complexity.PkgEqualEdge.Cursor(childComplexity), true + + case "PkgEqualEdge.node": + if e.complexity.PkgEqualEdge.Node == nil { + break + } + + return e.complexity.PkgEqualEdge.Node(childComplexity), true + case "PointOfContact.collector": if e.complexity.PointOfContact.Collector == nil { break @@ -2017,6 +2995,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.PointOfContact.Subject(childComplexity), true + case "PointOfContactConnection.edges": + if e.complexity.PointOfContactConnection.Edges == nil { + break + } + + return e.complexity.PointOfContactConnection.Edges(childComplexity), true + + case "PointOfContactConnection.pageInfo": + if e.complexity.PointOfContactConnection.PageInfo == nil { + break + } + + return e.complexity.PointOfContactConnection.PageInfo(childComplexity), true + + case "PointOfContactConnection.totalCount": + if e.complexity.PointOfContactConnection.TotalCount == nil { + break + } + + return e.complexity.PointOfContactConnection.TotalCount(childComplexity), true + + case "PointOfContactEdge.cursor": + if e.complexity.PointOfContactEdge.Cursor == nil { + break + } + + return e.complexity.PointOfContactEdge.Cursor(childComplexity), true + + case "PointOfContactEdge.node": + if e.complexity.PointOfContactEdge.Node == nil { + break + } + + return e.complexity.PointOfContactEdge.Node(childComplexity), true + case "Query.artifacts": if e.complexity.Query.Artifacts == nil { break @@ -2029,6 +3042,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Artifacts(childComplexity, args["artifactSpec"].(model.ArtifactSpec)), true + case "Query.artifactsList": + if e.complexity.Query.ArtifactsList == nil { + break + } + + args, err := ec.field_Query_artifactsList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.ArtifactsList(childComplexity, args["artifactSpec"].(model.ArtifactSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.builders": if e.complexity.Query.Builders == nil { break @@ -2041,6 +3066,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Builders(childComplexity, args["builderSpec"].(model.BuilderSpec)), true + case "Query.buildersList": + if e.complexity.Query.BuildersList == nil { + break + } + + args, err := ec.field_Query_buildersList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.BuildersList(childComplexity, args["builderSpec"].(model.BuilderSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.CertifyBad": if e.complexity.Query.CertifyBad == nil { break @@ -2053,6 +3090,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.CertifyBad(childComplexity, args["certifyBadSpec"].(model.CertifyBadSpec)), true + case "Query.CertifyBadList": + if e.complexity.Query.CertifyBadList == nil { + break + } + + args, err := ec.field_Query_CertifyBadList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.CertifyBadList(childComplexity, args["certifyBadSpec"].(model.CertifyBadSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.CertifyGood": if e.complexity.Query.CertifyGood == nil { break @@ -2065,6 +3114,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.CertifyGood(childComplexity, args["certifyGoodSpec"].(model.CertifyGoodSpec)), true + case "Query.CertifyGoodList": + if e.complexity.Query.CertifyGoodList == nil { + break + } + + args, err := ec.field_Query_CertifyGoodList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.CertifyGoodList(childComplexity, args["certifyGoodSpec"].(model.CertifyGoodSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.CertifyLegal": if e.complexity.Query.CertifyLegal == nil { break @@ -2077,6 +3138,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.CertifyLegal(childComplexity, args["certifyLegalSpec"].(model.CertifyLegalSpec)), true + case "Query.CertifyLegalList": + if e.complexity.Query.CertifyLegalList == nil { + break + } + + args, err := ec.field_Query_CertifyLegalList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.CertifyLegalList(childComplexity, args["certifyLegalSpec"].(model.CertifyLegalSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.CertifyVEXStatement": if e.complexity.Query.CertifyVEXStatement == nil { break @@ -2089,6 +3162,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.CertifyVEXStatement(childComplexity, args["certifyVEXStatementSpec"].(model.CertifyVEXStatementSpec)), true + case "Query.CertifyVEXStatementList": + if e.complexity.Query.CertifyVEXStatementList == nil { + break + } + + args, err := ec.field_Query_CertifyVEXStatementList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.CertifyVEXStatementList(childComplexity, args["certifyVEXStatementSpec"].(model.CertifyVEXStatementSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.CertifyVuln": if e.complexity.Query.CertifyVuln == nil { break @@ -2101,6 +3186,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.CertifyVuln(childComplexity, args["certifyVulnSpec"].(model.CertifyVulnSpec)), true + case "Query.CertifyVulnList": + if e.complexity.Query.CertifyVulnList == nil { + break + } + + args, err := ec.field_Query_CertifyVulnList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.CertifyVulnList(childComplexity, args["certifyVulnSpec"].(model.CertifyVulnSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.findSoftware": if e.complexity.Query.FindSoftware == nil { break @@ -2113,6 +3210,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.FindSoftware(childComplexity, args["searchText"].(string)), true + case "Query.findSoftwareList": + if e.complexity.Query.FindSoftwareList == nil { + break + } + + args, err := ec.field_Query_findSoftwareList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.FindSoftwareList(childComplexity, args["searchText"].(string), args["after"].(*string), args["first"].(*int)), true + case "Query.HasMetadata": if e.complexity.Query.HasMetadata == nil { break @@ -2125,6 +3234,42 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.HasMetadata(childComplexity, args["hasMetadataSpec"].(model.HasMetadataSpec)), true + case "Query.HasMetadataList": + if e.complexity.Query.HasMetadataList == nil { + break + } + + args, err := ec.field_Query_HasMetadataList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.HasMetadataList(childComplexity, args["hasMetadataSpec"].(model.HasMetadataSpec), args["after"].(*string), args["first"].(*int)), true + + case "Query.HasSBOMList": + if e.complexity.Query.HasSBOMList == nil { + break + } + + args, err := ec.field_Query_HasSBOMList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.HasSBOMList(childComplexity, args["hasSBOMSpec"].(model.HasSBOMSpec), args["after"].(*string), args["first"].(*int)), true + + case "Query.HasSLSAList": + if e.complexity.Query.HasSLSAList == nil { + break + } + + args, err := ec.field_Query_HasSLSAList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.HasSLSAList(childComplexity, args["hasSLSASpec"].(model.HasSLSASpec), args["after"].(*string), args["first"].(*int)), true + case "Query.HasSBOM": if e.complexity.Query.HasSbom == nil { break @@ -2161,41 +3306,101 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.HasSourceAt(childComplexity, args["hasSourceAtSpec"].(model.HasSourceAtSpec)), true + case "Query.HasSourceAtList": + if e.complexity.Query.HasSourceAtList == nil { + break + } + + args, err := ec.field_Query_HasSourceAtList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.HasSourceAtList(childComplexity, args["hasSourceAtSpec"].(model.HasSourceAtSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.HashEqual": if e.complexity.Query.HashEqual == nil { break } - args, err := ec.field_Query_HashEqual_args(context.TODO(), rawArgs) + args, err := ec.field_Query_HashEqual_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.HashEqual(childComplexity, args["hashEqualSpec"].(model.HashEqualSpec)), true + + case "Query.HashEqualList": + if e.complexity.Query.HashEqualList == nil { + break + } + + args, err := ec.field_Query_HashEqualList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.HashEqualList(childComplexity, args["hashEqualSpec"].(model.HashEqualSpec), args["after"].(*string), args["first"].(*int)), true + + case "Query.IsDependency": + if e.complexity.Query.IsDependency == nil { + break + } + + args, err := ec.field_Query_IsDependency_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.IsDependency(childComplexity, args["isDependencySpec"].(model.IsDependencySpec)), true + + case "Query.IsDependencyList": + if e.complexity.Query.IsDependencyList == nil { + break + } + + args, err := ec.field_Query_IsDependencyList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.IsDependencyList(childComplexity, args["isDependencySpec"].(model.IsDependencySpec), args["after"].(*string), args["first"].(*int)), true + + case "Query.IsOccurrence": + if e.complexity.Query.IsOccurrence == nil { + break + } + + args, err := ec.field_Query_IsOccurrence_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.HashEqual(childComplexity, args["hashEqualSpec"].(model.HashEqualSpec)), true + return e.complexity.Query.IsOccurrence(childComplexity, args["isOccurrenceSpec"].(model.IsOccurrenceSpec)), true - case "Query.IsDependency": - if e.complexity.Query.IsDependency == nil { + case "Query.IsOccurrenceList": + if e.complexity.Query.IsOccurrenceList == nil { break } - args, err := ec.field_Query_IsDependency_args(context.TODO(), rawArgs) + args, err := ec.field_Query_IsOccurrenceList_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.IsDependency(childComplexity, args["isDependencySpec"].(model.IsDependencySpec)), true + return e.complexity.Query.IsOccurrenceList(childComplexity, args["isOccurrenceSpec"].(model.IsOccurrenceSpec), args["after"].(*string), args["first"].(*int)), true - case "Query.IsOccurrence": - if e.complexity.Query.IsOccurrence == nil { + case "Query.licenseList": + if e.complexity.Query.LicenseList == nil { break } - args, err := ec.field_Query_IsOccurrence_args(context.TODO(), rawArgs) + args, err := ec.field_Query_licenseList_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.IsOccurrence(childComplexity, args["isOccurrenceSpec"].(model.IsOccurrenceSpec)), true + return e.complexity.Query.LicenseList(childComplexity, args["licenseSpec"].(model.LicenseSpec), args["after"].(*string), args["first"].(*int)), true case "Query.licenses": if e.complexity.Query.Licenses == nil { @@ -2221,6 +3426,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Neighbors(childComplexity, args["node"].(string), args["usingOnly"].([]model.Edge)), true + case "Query.neighborsList": + if e.complexity.Query.NeighborsList == nil { + break + } + + args, err := ec.field_Query_neighborsList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.NeighborsList(childComplexity, args["node"].(string), args["usingOnly"].([]model.Edge), args["after"].(*string), args["first"].(*int)), true + case "Query.node": if e.complexity.Query.Node == nil { break @@ -2257,6 +3474,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Packages(childComplexity, args["pkgSpec"].(model.PkgSpec)), true + case "Query.packagesList": + if e.complexity.Query.PackagesList == nil { + break + } + + args, err := ec.field_Query_packagesList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.PackagesList(childComplexity, args["pkgSpec"].(model.PkgSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.path": if e.complexity.Query.Path == nil { break @@ -2281,6 +3510,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.PkgEqual(childComplexity, args["pkgEqualSpec"].(model.PkgEqualSpec)), true + case "Query.PkgEqualList": + if e.complexity.Query.PkgEqualList == nil { + break + } + + args, err := ec.field_Query_PkgEqualList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.PkgEqualList(childComplexity, args["pkgEqualSpec"].(model.PkgEqualSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.PointOfContact": if e.complexity.Query.PointOfContact == nil { break @@ -2293,6 +3534,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.PointOfContact(childComplexity, args["pointOfContactSpec"].(model.PointOfContactSpec)), true + case "Query.PointOfContactList": + if e.complexity.Query.PointOfContactList == nil { + break + } + + args, err := ec.field_Query_PointOfContactList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.PointOfContactList(childComplexity, args["pointOfContactSpec"].(model.PointOfContactSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.scorecards": if e.complexity.Query.Scorecards == nil { break @@ -2305,6 +3558,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Scorecards(childComplexity, args["scorecardSpec"].(model.CertifyScorecardSpec)), true + case "Query.scorecardsList": + if e.complexity.Query.ScorecardsList == nil { + break + } + + args, err := ec.field_Query_scorecardsList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.ScorecardsList(childComplexity, args["scorecardSpec"].(model.CertifyScorecardSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.sources": if e.complexity.Query.Sources == nil { break @@ -2317,6 +3582,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Sources(childComplexity, args["sourceSpec"].(model.SourceSpec)), true + case "Query.sourcesList": + if e.complexity.Query.SourcesList == nil { + break + } + + args, err := ec.field_Query_sourcesList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.SourcesList(childComplexity, args["sourceSpec"].(model.SourceSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.vulnEqual": if e.complexity.Query.VulnEqual == nil { break @@ -2329,6 +3606,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.VulnEqual(childComplexity, args["vulnEqualSpec"].(model.VulnEqualSpec)), true + case "Query.vulnEqualList": + if e.complexity.Query.VulnEqualList == nil { + break + } + + args, err := ec.field_Query_vulnEqualList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.VulnEqualList(childComplexity, args["vulnEqualSpec"].(model.VulnEqualSpec), args["after"].(*string), args["first"].(*int)), true + case "Query.vulnerabilities": if e.complexity.Query.Vulnerabilities == nil { break @@ -2341,6 +3630,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Vulnerabilities(childComplexity, args["vulnSpec"].(model.VulnerabilitySpec)), true + case "Query.vulnerabilityList": + if e.complexity.Query.VulnerabilityList == nil { + break + } + + args, err := ec.field_Query_vulnerabilityList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.VulnerabilityList(childComplexity, args["vulnSpec"].(model.VulnerabilitySpec), args["after"].(*string), args["first"].(*int)), true + case "Query.vulnerabilityMetadata": if e.complexity.Query.VulnerabilityMetadata == nil { break @@ -2353,6 +3654,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.VulnerabilityMetadata(childComplexity, args["vulnerabilityMetadataSpec"].(model.VulnerabilityMetadataSpec)), true + case "Query.vulnerabilityMetadataList": + if e.complexity.Query.VulnerabilityMetadataList == nil { + break + } + + args, err := ec.field_Query_vulnerabilityMetadataList_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.VulnerabilityMetadataList(childComplexity, args["vulnerabilityMetadataSpec"].(model.VulnerabilityMetadataSpec), args["after"].(*string), args["first"].(*int)), true + case "SLSA.buildType": if e.complexity.SLSA.BuildType == nil { break @@ -2563,6 +3876,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ScorecardCheck.Score(childComplexity), true + case "SoftwareEdge.cursor": + if e.complexity.SoftwareEdge.Cursor == nil { + break + } + + return e.complexity.SoftwareEdge.Cursor(childComplexity), true + + case "SoftwareEdge.node": + if e.complexity.SoftwareEdge.Node == nil { + break + } + + return e.complexity.SoftwareEdge.Node(childComplexity), true + case "Source.id": if e.complexity.Source.ID == nil { break @@ -2584,6 +3911,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Source.Type(childComplexity), true + case "SourceConnection.edges": + if e.complexity.SourceConnection.Edges == nil { + break + } + + return e.complexity.SourceConnection.Edges(childComplexity), true + + case "SourceConnection.pageInfo": + if e.complexity.SourceConnection.PageInfo == nil { + break + } + + return e.complexity.SourceConnection.PageInfo(childComplexity), true + + case "SourceConnection.totalCount": + if e.complexity.SourceConnection.TotalCount == nil { + break + } + + return e.complexity.SourceConnection.TotalCount(childComplexity), true + + case "SourceEdge.cursor": + if e.complexity.SourceEdge.Cursor == nil { + break + } + + return e.complexity.SourceEdge.Cursor(childComplexity), true + + case "SourceEdge.node": + if e.complexity.SourceEdge.Node == nil { + break + } + + return e.complexity.SourceEdge.Node(childComplexity), true + case "SourceIDs.sourceNameID": if e.complexity.SourceIDs.SourceNameID == nil { break @@ -2654,6 +4016,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.SourceNamespace.Namespace(childComplexity), true + case "VEXConnection.edges": + if e.complexity.VEXConnection.Edges == nil { + break + } + + return e.complexity.VEXConnection.Edges(childComplexity), true + + case "VEXConnection.pageInfo": + if e.complexity.VEXConnection.PageInfo == nil { + break + } + + return e.complexity.VEXConnection.PageInfo(childComplexity), true + + case "VEXConnection.totalCount": + if e.complexity.VEXConnection.TotalCount == nil { + break + } + + return e.complexity.VEXConnection.TotalCount(childComplexity), true + + case "VEXEdge.cursor": + if e.complexity.VEXEdge.Cursor == nil { + break + } + + return e.complexity.VEXEdge.Cursor(childComplexity), true + + case "VEXEdge.node": + if e.complexity.VEXEdge.Node == nil { + break + } + + return e.complexity.VEXEdge.Node(childComplexity), true + case "VulnEqual.collector": if e.complexity.VulnEqual.Collector == nil { break @@ -2696,6 +4093,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.VulnEqual.Vulnerabilities(childComplexity), true + case "VulnEqualConnection.edges": + if e.complexity.VulnEqualConnection.Edges == nil { + break + } + + return e.complexity.VulnEqualConnection.Edges(childComplexity), true + + case "VulnEqualConnection.pageInfo": + if e.complexity.VulnEqualConnection.PageInfo == nil { + break + } + + return e.complexity.VulnEqualConnection.PageInfo(childComplexity), true + + case "VulnEqualConnection.totalCount": + if e.complexity.VulnEqualConnection.TotalCount == nil { + break + } + + return e.complexity.VulnEqualConnection.TotalCount(childComplexity), true + + case "VulnEqualEdge.cursor": + if e.complexity.VulnEqualEdge.Cursor == nil { + break + } + + return e.complexity.VulnEqualEdge.Cursor(childComplexity), true + + case "VulnEqualEdge.node": + if e.complexity.VulnEqualEdge.Node == nil { + break + } + + return e.complexity.VulnEqualEdge.Node(childComplexity), true + case "Vulnerability.id": if e.complexity.Vulnerability.ID == nil { break @@ -2717,6 +4149,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Vulnerability.VulnerabilityIDs(childComplexity), true + case "VulnerabilityConnection.edges": + if e.complexity.VulnerabilityConnection.Edges == nil { + break + } + + return e.complexity.VulnerabilityConnection.Edges(childComplexity), true + + case "VulnerabilityConnection.pageInfo": + if e.complexity.VulnerabilityConnection.PageInfo == nil { + break + } + + return e.complexity.VulnerabilityConnection.PageInfo(childComplexity), true + + case "VulnerabilityConnection.totalCount": + if e.complexity.VulnerabilityConnection.TotalCount == nil { + break + } + + return e.complexity.VulnerabilityConnection.TotalCount(childComplexity), true + + case "VulnerabilityEdge.cursor": + if e.complexity.VulnerabilityEdge.Cursor == nil { + break + } + + return e.complexity.VulnerabilityEdge.Cursor(childComplexity), true + + case "VulnerabilityEdge.node": + if e.complexity.VulnerabilityEdge.Node == nil { + break + } + + return e.complexity.VulnerabilityEdge.Node(childComplexity), true + case "VulnerabilityID.id": if e.complexity.VulnerabilityID.ID == nil { break @@ -2801,6 +4268,41 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.VulnerabilityMetadata.Vulnerability(childComplexity), true + case "VulnerabilityMetadataConnection.edges": + if e.complexity.VulnerabilityMetadataConnection.Edges == nil { + break + } + + return e.complexity.VulnerabilityMetadataConnection.Edges(childComplexity), true + + case "VulnerabilityMetadataConnection.pageInfo": + if e.complexity.VulnerabilityMetadataConnection.PageInfo == nil { + break + } + + return e.complexity.VulnerabilityMetadataConnection.PageInfo(childComplexity), true + + case "VulnerabilityMetadataConnection.totalCount": + if e.complexity.VulnerabilityMetadataConnection.TotalCount == nil { + break + } + + return e.complexity.VulnerabilityMetadataConnection.TotalCount(childComplexity), true + + case "VulnerabilityMetadataEdge.cursor": + if e.complexity.VulnerabilityMetadataEdge.Cursor == nil { + break + } + + return e.complexity.VulnerabilityMetadataEdge.Cursor(childComplexity), true + + case "VulnerabilityMetadataEdge.node": + if e.complexity.VulnerabilityMetadataEdge.Node == nil { + break + } + + return e.complexity.VulnerabilityMetadataEdge.Node(childComplexity), true + } return 0, false } @@ -3042,9 +4544,38 @@ input IDorArtifactInput { artifactInput: ArtifactInputSpec } +""" +ArtifactConnection returns the paginated results for artifact. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the ArtifactEdge which contains the current cursor +and the artifact node itself +""" +type ArtifactConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [ArtifactEdge!]! +} + +""" +ArtifactEdge contains the cursor for the resulting node and +the artifact node itself. +""" +type ArtifactEdge { + cursor: ID! + node: Artifact! +} + extend type Query { "Returns all artifacts matching a filter." artifacts(artifactSpec: ArtifactSpec!): [Artifact!]! + "Returns a paginated results via ArtifactConnection" + artifactsList(artifactSpec: ArtifactSpec!, after: ID, first: Int): ArtifactConnection } extend type Mutation { @@ -3106,9 +4637,38 @@ input IDorBuilderInput { builderInput: BuilderInputSpec } +""" +BuilderConnection returns the paginated results for builder. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the BuilderEdge which contains the current cursor +and the Builder node itself +""" +type BuilderConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [BuilderEdge!]! +} + +""" +BuilderEdge contains the cursor for the resulting node and +the Builder node itself. +""" +type BuilderEdge { + cursor: ID! + node: Builder! +} + extend type Query { "Returns all builders matching a filter." builders(builderSpec: BuilderSpec!): [Builder!]! + "Returns a paginated results via BuilderConnection" + buildersList(builderSpec: BuilderSpec!, after: ID, first: Int): BuilderConnection } extend type Mutation { @@ -3255,9 +4815,38 @@ input MatchFlags { pkg: PkgMatchType! } +""" +CertifyBadConnection returns the paginated results for CertifyBad. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the CertifyBadEdge which contains the current cursor +and the CertifyBad node itself +""" +type CertifyBadConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [CertifyBadEdge!]! +} + +""" +CertifyBadEdge contains the cursor for the resulting node and +the CertifyBad node itself. +""" +type CertifyBadEdge { + cursor: ID! + node: CertifyBad! +} + extend type Query { "Returns all CertifyBad attestations matching a filter." CertifyBad(certifyBadSpec: CertifyBadSpec!): [CertifyBad!]! + "Returns a paginated results via CertifyBadConnection" + CertifyBadList(certifyBadSpec: CertifyBadSpec!, after: ID, first: Int): CertifyBadConnection } extend type Mutation { @@ -3358,9 +4947,38 @@ input CertifyGoodInputSpec { documentRef: String! } +""" +CertifyGoodConnection returns the paginated results for CertifyGood. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the CertifyGoodEdge which contains the current cursor +and the CertifyGood node itself +""" +type CertifyGoodConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [CertifyGoodEdge!]! +} + +""" +CertifyGoodEdge contains the cursor for the resulting node and +the CertifyGood node itself. +""" +type CertifyGoodEdge { + cursor: ID! + node: CertifyGood! +} + extend type Query { "Returns all CertifyGood attestations matching a filter." CertifyGood(certifyGoodSpec: CertifyGoodSpec!): [CertifyGood!]! + "Returns a paginated results via CertifyGoodConnection" + CertifyGoodList(certifyGoodSpec: CertifyGoodSpec!, after: ID, first: Int): CertifyGoodConnection } extend type Mutation { @@ -3465,20 +5083,49 @@ input CertifyLegalSpec { CertifyLegalInputSpec represents the input for certifying legal information in mutations. """ -input CertifyLegalInputSpec { - declaredLicense: String! - discoveredLicense: String! - attribution: String! - justification: String! - timeScanned: Time! - origin: String! - collector: String! - documentRef: String! +input CertifyLegalInputSpec { + declaredLicense: String! + discoveredLicense: String! + attribution: String! + justification: String! + timeScanned: Time! + origin: String! + collector: String! + documentRef: String! +} + +""" +CertifyLegalConnection returns the paginated results for CertifyLegal. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the CertifyLegalEdge which contains the current cursor +and the CertifyLegal node itself +""" +type CertifyLegalConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [CertifyLegalEdge!]! +} + +""" +CertifyLegalEdge contains the cursor for the resulting node and +the CertifyLegal node itself. +""" +type CertifyLegalEdge { + cursor: ID! + node: CertifyLegal! } extend type Query { "Returns all legal certifications matching the input filter." CertifyLegal(certifyLegalSpec: CertifyLegalSpec!): [CertifyLegal!]! + "Returns a paginated results via CertifyLegalConnection" + CertifyLegalList(certifyLegalSpec: CertifyLegalSpec!, after: ID, first: Int): CertifyLegalConnection } extend type Mutation { @@ -3613,9 +5260,38 @@ input ScorecardCheckInputSpec { score: Int! } +""" +CertifyScorecardConnection returns the paginated results for CertifyScorecard. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the CertifyScorecardEdge which contains the current cursor +and the CertifyScorecard node itself +""" +type CertifyScorecardConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [CertifyScorecardEdge!]! +} + +""" +CertifyScorecardEdge contains the cursor for the resulting node and +the CertifyScorecard node itself. +""" +type CertifyScorecardEdge { + cursor: ID! + node: CertifyScorecard! +} + extend type Query { "Returns all Scorecard certifications matching the filter." scorecards(scorecardSpec: CertifyScorecardSpec!): [CertifyScorecard!]! + "Returns a paginated results via CertifyScorecardConnection" + scorecardsList(scorecardSpec: CertifyScorecardSpec!, after: ID, first: Int): CertifyScorecardConnection } extend type Mutation { @@ -3761,11 +5437,40 @@ input VexStatementInputSpec { documentRef: String! } +""" +VEXConnection returns the paginated results for CertifyVEXStatement. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the VEXEdge which contains the current cursor +and the CertifyVEXStatement node itself +""" +type VEXConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [VEXEdge!]! +} + +""" +VEXEdge contains the cursor for the resulting node and +the CertifyVEXStatement node itself. +""" +type VEXEdge { + cursor: ID! + node: CertifyVEXStatement! +} + extend type Query { "Returns all VEX certifications matching the input filter." CertifyVEXStatement( certifyVEXStatementSpec: CertifyVEXStatementSpec! ): [CertifyVEXStatement!]! + "Returns a paginated results via CertifyVexConnection" + CertifyVEXStatementList(certifyVEXStatementSpec: CertifyVEXStatementSpec!, after: ID, first: Int): VEXConnection } extend type Mutation { @@ -3882,9 +5587,38 @@ input ScanMetadataInput { documentRef: String! } +""" +CertifyVulnConnection returns the paginated results for CertifyVuln. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the CertifyVulnEdge which contains the current cursor +and the CertifyVuln node itself +""" +type CertifyVulnConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [CertifyVulnEdge!]! +} + +""" +CertifyVulnEdge contains the cursor for the resulting node and +the CertifyVuln node itself. +""" +type CertifyVulnEdge { + cursor: ID! + node: CertifyVuln! +} + extend type Query { "Returns all vulnerability certifications matching the input filter." CertifyVuln(certifyVulnSpec: CertifyVulnSpec!): [CertifyVuln!]! + "Returns a paginated results via CertifyVulnConnection" + CertifyVulnList(certifyVulnSpec: CertifyVulnSpec!, after: ID, first: Int): CertifyVulnConnection } extend type Mutation { @@ -4000,9 +5734,38 @@ input PointOfContactInputSpec { documentRef: String! } +""" +PointOfContactConnection returns the paginated results for PointOfContact. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the PointOfContactEdge which contains the current cursor +and the PointOfContact node itself +""" +type PointOfContactConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [PointOfContactEdge!]! +} + +""" +PointOfContactEdge contains the cursor for the resulting node and +the PointOfContact node itself. +""" +type PointOfContactEdge { + cursor: ID! + node: PointOfContact! +} + extend type Query { "Returns all PointOfContact attestations matching a filter." PointOfContact(pointOfContactSpec: PointOfContactSpec!): [PointOfContact!]! + "Returns a paginated results via PointOfContactConnection" + PointOfContactList(pointOfContactSpec: PointOfContactSpec!, after: ID, first: Int): PointOfContactConnection } extend type Mutation { @@ -4115,9 +5878,38 @@ input HasSBOMInputSpec { documentRef: String! } +""" +HasSBOMConnection returns the paginated results for HasSBOM. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the HasSBOMEdge which contains the current cursor +and the HasSBOM node itself +""" +type HasSBOMConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [HasSBOMEdge!]! +} + +""" +HasSBOMEdge contains the cursor for the resulting node and +the HasSBOMEdge node itself. +""" +type HasSBOMEdge { + cursor: ID! + node: HasSBOM! +} + extend type Query { "Returns all SBOM certifications." HasSBOM(hasSBOMSpec: HasSBOMSpec!): [HasSBOM!]! + "Returns a paginated results via HasSBOMConnection" + HasSBOMList(hasSBOMSpec: HasSBOMSpec!, after: ID, first: Int): HasSBOMConnection } extend type Mutation { @@ -4268,9 +6060,38 @@ input SLSAPredicateInputSpec { value: String! } +""" +HasSLSAConnection returns the paginated results for HasSLSA. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the HasSLSAEdge which contains the current cursor +and the HasSLSA node itself +""" +type HasSLSAConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [HasSLSAEdge!]! +} + +""" +HasSLSAEdge contains the cursor for the resulting node and +the HasSLSA node itself. +""" +type HasSLSAEdge { + cursor: ID! + node: HasSLSA! +} + extend type Query { "Returns all SLSA attestations matching the filter." HasSLSA(hasSLSASpec: HasSLSASpec!): [HasSLSA!]! + "Returns a paginated results via HasSLSAConnection" + HasSLSAList(hasSLSASpec: HasSLSASpec!, after: ID, first: Int): HasSLSAConnection } extend type Mutation { @@ -4349,9 +6170,38 @@ input HasSourceAtInputSpec { documentRef: String! } +""" +HasSourceAtConnection returns the paginated results for HasSourceAt. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the HasSourceAtEdge which contains the current cursor +and the HasSourceAt node itself +""" +type HasSourceAtConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [HasSourceAtEdge!]! +} + +""" +HasSourceAtEdge contains the cursor for the resulting node and +the HasSourceAt node itself. +""" +type HasSourceAtEdge { + cursor: ID! + node: HasSourceAt! +} + extend type Query { "Returns all source mappings that match the filter." HasSourceAt(hasSourceAtSpec: HasSourceAtSpec!): [HasSourceAt!]! + "Returns a paginated results via HasSourceAtConnection" + HasSourceAtList(hasSourceAtSpec: HasSourceAtSpec!, after: ID, first: Int): HasSourceAtConnection } extend type Mutation { @@ -4429,9 +6279,38 @@ input HashEqualInputSpec { documentRef: String! } +""" +HashEqualConnection returns the paginated results for HashEqual. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the HashEqualEdge which contains the current cursor +and the HashEqual node itself +""" +type HashEqualConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [HashEqualEdge!]! +} + +""" +HashEqualEdge contains the cursor for the resulting node and +the HashEqual node itself. +""" +type HashEqualEdge { + cursor: ID! + node: HashEqual! +} + extend type Query { "Returns all artifact equality statements matching a filter." HashEqual(hashEqualSpec: HashEqualSpec!): [HashEqual!]! + "Returns a paginated results via HashEqualConnection" + HashEqualList(hashEqualSpec: HashEqualSpec!, after: ID, first: Int): HashEqualConnection } extend type Mutation { @@ -4530,9 +6409,38 @@ input IsDependencyInputSpec { documentRef: String! } +""" +IsDependencyConnection returns the paginated results for IsDependency. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the IsDependencyEdge which contains the current cursor +and the IsDependency node itself +""" +type IsDependencyConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [IsDependencyEdge!]! +} + +""" +IsDependencyEdge contains the cursor for the resulting node and +the IsDependency node itself. +""" +type IsDependencyEdge { + cursor: ID! + node: IsDependency! +} + extend type Query { "Returns all package dependencies that match the filter." IsDependency(isDependencySpec: IsDependencySpec!): [IsDependency!]! + "Returns a paginated results via IsDependencyConnection" + IsDependencyList(isDependencySpec: IsDependencySpec!, after: ID, first: Int): IsDependencyConnection } extend type Mutation { @@ -4646,9 +6554,38 @@ input IsOccurrenceInputSpec { documentRef: String! } +""" +IsOccurrenceConnection returns the paginated results for IsOccurrence. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the IsOccurrenceEdge which contains the current cursor +and the IsOccurrence node itself +""" +type IsOccurrenceConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [IsOccurrenceEdge!]! +} + +""" +IsOccurrenceEdge contains the cursor for the resulting node and +the IsOccurrence node itself. +""" +type IsOccurrenceEdge { + cursor: ID! + node: IsOccurrence! +} + extend type Query { "Returns all artifacts-source/package mappings that match a filter." IsOccurrence(isOccurrenceSpec: IsOccurrenceSpec!): [IsOccurrence!]! + "Returns a paginated results via IsOccurrenceConnection" + IsOccurrenceList(isOccurrenceSpec: IsOccurrenceSpec!, after: ID, first: Int): IsOccurrenceConnection } extend type Mutation { @@ -4751,9 +6688,38 @@ input IDorLicenseInput { licenseInput: LicenseInputSpec } +""" +LicenseConnection returns the paginated results for License. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the LicenseEdge which contains the current cursor +and the License node itself +""" +type LicenseConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [LicenseEdge!]! +} + +""" +LicenseEdge contains the cursor for the resulting node and +the License node itself. +""" +type LicenseEdge { + cursor: ID! + node: License! +} + extend type Query { "Returns all licenses matching a filter." licenses(licenseSpec: LicenseSpec!): [License!]! + "Returns a paginated results via LicenseConnection" + licenseList(licenseSpec: LicenseSpec!, after: ID, first: Int): LicenseConnection } extend type Mutation { @@ -4856,9 +6822,38 @@ input HasMetadataInputSpec { documentRef: String! } +""" +HasMetadataConnection returns the paginated results for HasMetadata. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the HasMetadataEdge which contains the current cursor +and the HasMetadata node itself +""" +type HasMetadataConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [HasMetadataEdge!]! +} + +""" +HasMetadataEdge contains the cursor for the resulting node and +the HasMetadata node itself. +""" +type HasMetadataEdge { + cursor: ID! + node: HasMetadata! +} + extend type Query { "Returns all HasMetdata attestations matching a filter." HasMetadata(hasMetadataSpec: HasMetadataSpec!): [HasMetadata!]! + "Returns a paginated results via HasMetadataConnection" + HasMetadataList(hasMetadataSpec: HasMetadataSpec!, after: ID, first: Int): HasMetadataConnection } extend type Mutation { @@ -5082,9 +7077,38 @@ input IDorPkgInput { packageInput: PkgInputSpec } +""" +PackageConnection returns the paginated results for Package. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the PackageEdge which contains the current cursor +and the Package node itself +""" +type PackageConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [PackageEdge!]! +} + +""" +PackageEdge contains the cursor for the resulting node and +the Package node itself. +""" +type PackageEdge { + cursor: ID! + node: Package! +} + extend type Query { "Returns all packages matching a filter." packages(pkgSpec: PkgSpec!): [Package!]! + "Returns a paginated results via PackageConnection" + packagesList(pkgSpec: PkgSpec!, after: ID, first: Int): PackageConnection } extend type Mutation { @@ -5093,6 +7117,42 @@ extend type Mutation { "Bulk ingests packages and returns the list of corresponding package hierarchies containing only the IDs. The returned array of IDs must be in the same order as the inputs." ingestPackages(pkgs: [IDorPkgInput!]!): [PackageIDs!]! } +`, BuiltIn: false}, + {Name: "../schema/pagination.graphql", Input: `# +# Copyright 2024 The GUAC Authors. +# +# 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. + +# NOTE: This is experimental and might change in the future! + +# Defines a GraphQL schema for the pagination + +""" +PageInfo serves the client information about the paginated query results. + +hasNextPage is true when there are results to be returned. + +hasPreviousPage is true when there is a previous page to return to. + +startCursor is the ID where the query started from. + +endCursor is where the query ended. +""" +type PageInfo { + hasNextPage: Boolean! + startCursor: ID + endCursor: ID +} `, BuiltIn: false}, {Name: "../schema/path.graphql", Input: `# # Copyright 2023 The GUAC Authors. @@ -5248,6 +7308,35 @@ enum Edge { VULN_METADATA_VULNERABILITY } + +""" +NeighborConnection returns the paginated results for Neighbor. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the NeighborEdge which contains the current cursor +and the node itself +""" +type NeighborConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [NeighborEdge!]! +} + +""" +NeighborEdge contains the cursor for the resulting node and +the node itself. +""" +type NeighborEdge { + cursor: ID! + node: Node! +} + + extend type Query { """ path query returns a path between subject and target, of a maximum length. @@ -5274,6 +7363,8 @@ extend type Query { contain the corresponding GUAC evidence trees (GUAC verbs). """ neighbors(node: ID!, usingOnly: [Edge!]!): [Node!]! + "Returns a paginated results via NeighborConnection" + neighborsList(node: ID!, usingOnly: [Edge!]!, after: ID, first: Int): NeighborConnection """ node returns a single node, regardless of type. @@ -5348,9 +7439,38 @@ input PkgEqualInputSpec { documentRef: String! } +""" +PkgEqualConnection returns the paginated results for PkgEqual. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the PkgEqualEdge which contains the current cursor +and the PkgEqual node itself +""" +type PkgEqualConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [PkgEqualEdge!]! +} + +""" +PkgEqualEdge contains the cursor for the resulting node and +the PkgEqual node itself. +""" +type PkgEqualEdge { + cursor: ID! + node: PkgEqual! +} + extend type Query { "Returns all package equality statements matching a filter." PkgEqual(pkgEqualSpec: PkgEqualSpec!): [PkgEqual!]! + "Returns a paginated results via PkgEqualConnection" + PkgEqualList(pkgEqualSpec: PkgEqualSpec!, after: ID, first: Int): PkgEqualConnection } extend type Mutation { @@ -5383,6 +7503,34 @@ extend type Mutation { # See the License for the specific language governing permissions and # limitations under the License. + +""" +FindSoftwareConnection returns the paginated results for FindSoftware. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the SoftwareEdge which contains the current cursor +and the PackageSourceOrArtifact node itself +""" +type FindSoftwareConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [SoftwareEdge!]! +} + +""" +SoftwareEdge contains the cursor for the resulting node and +the PackageSourceOrArtifact node itself. +""" +type SoftwareEdge { + cursor: ID! + node: PackageSourceOrArtifact! +} + extend type Query { """ findSoftware takes in a searchText string and looks for software @@ -5404,6 +7552,8 @@ extend type Query { implement this API. """ findSoftware(searchText: String!): [PackageSourceOrArtifact!]! + "Returns a paginated results via CertifyBadConnection" + findSoftwareList(searchText: String!, after: ID, first: Int): FindSoftwareConnection } `, BuiltIn: false}, {Name: "../schema/source.graphql", Input: `# @@ -5532,9 +7682,38 @@ input IDorSourceInput { sourceInput: SourceInputSpec } +""" +SourceConnection returns the paginated results for Source. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the SourceEdge which contains the current cursor +and the Source node itself +""" +type SourceConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [SourceEdge!]! +} + +""" +SourceEdge contains the cursor for the resulting node and +the Source node itself. +""" +type SourceEdge { + cursor: ID! + node: Source! +} + extend type Query { "Returns all sources matching a filter." sources(sourceSpec: SourceSpec!): [Source!]! + "Returns a paginated results via SourceConnection" + sourcesList(sourceSpec: SourceSpec!, after: ID, first: Int): SourceConnection } extend type Mutation { @@ -5603,9 +7782,38 @@ input VulnEqualInputSpec { documentRef: String! } +""" +VulnEqualConnection returns the paginated results for VulnEqual. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the VulnEqualEdge which contains the current cursor +and the VulnEqual node itself +""" +type VulnEqualConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [VulnEqualEdge!]! +} + +""" +VulnEqualEdge contains the cursor for the resulting node and +the VulnEqual node itself. +""" +type VulnEqualEdge { + cursor: ID! + node: VulnEqual! +} + extend type Query { "Returns all equal vulnerability mappings that match a filter." vulnEqual(vulnEqualSpec: VulnEqualSpec!): [VulnEqual!]! + "Returns a paginated results via VulnEqualConnection" + vulnEqualList(vulnEqualSpec: VulnEqualSpec!, after: ID, first: Int): VulnEqualConnection } extend type Mutation { @@ -5737,9 +7945,38 @@ input VulnerabilityMetadataInputSpec { documentRef: String! } +""" +VulnerabilityMetadataConnection returns the paginated results for VulnerabilityMetadata. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the VulnerabilityMetadataEdge which contains the current cursor +and the VulnerabilityMetadata node itself +""" +type VulnerabilityMetadataConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [VulnerabilityMetadataEdge!]! +} + +""" +VulnerabilityMetadataEdge contains the cursor for the resulting node and +the VulnerabilityMetadata node itself. +""" +type VulnerabilityMetadataEdge { + cursor: ID! + node: VulnerabilityMetadata! +} + extend type Query { "Returns all vulnerabilityMetadata attestations matching a filter." vulnerabilityMetadata(vulnerabilityMetadataSpec: VulnerabilityMetadataSpec!): [VulnerabilityMetadata!]! + "Returns a paginated results via VulnerabilityMetadataConnection" + vulnerabilityMetadataList(vulnerabilityMetadataSpec: VulnerabilityMetadataSpec!, after: ID, first: Int): VulnerabilityMetadataConnection } extend type Mutation { @@ -5866,9 +8103,38 @@ input IDorVulnerabilityInput { vulnerabilityInput: VulnerabilityInputSpec } +""" +VulnerabilityConnection returns the paginated results for Vulnerability. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the VulnerabilityEdge which contains the current cursor +and the Vulnerability node itself +""" +type VulnerabilityConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [VulnerabilityEdge!]! +} + +""" +VulnerabilityEdge contains the cursor for the resulting node and +the Vulnerability node itself. +""" +type VulnerabilityEdge { + cursor: ID! + node: Vulnerability! +} + extend type Query { "Returns all vulnerabilities matching a filter." vulnerabilities(vulnSpec: VulnerabilitySpec!): [Vulnerability!]! + "Returns a paginated results via VulnerabilityConnection" + vulnerabilityList(vulnSpec: VulnerabilitySpec!, after: ID, first: Int): VulnerabilityConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/generated/search.generated.go b/pkg/assembler/graphql/generated/search.generated.go new file mode 100644 index 00000000000..ba2de3d40ab --- /dev/null +++ b/pkg/assembler/graphql/generated/search.generated.go @@ -0,0 +1,421 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package generated + +import ( + "context" + "errors" + "fmt" + "strconv" + "sync" + "sync/atomic" + + "github.com/99designs/gqlgen/graphql" + "github.com/guacsec/guac/pkg/assembler/graphql/model" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +// endregion ***************************** args.gotpl ***************************** + +// region ************************** directives.gotpl ************************** + +// endregion ************************** directives.gotpl ************************** + +// region **************************** field.gotpl ***************************** + +func (ec *executionContext) _FindSoftwareConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.FindSoftwareConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FindSoftwareConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FindSoftwareConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FindSoftwareConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _FindSoftwareConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.FindSoftwareConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FindSoftwareConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FindSoftwareConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FindSoftwareConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _FindSoftwareConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.FindSoftwareConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_FindSoftwareConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.SoftwareEdge) + fc.Result = res + return ec.marshalNSoftwareEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSoftwareEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_FindSoftwareConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "FindSoftwareConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_SoftwareEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_SoftwareEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SoftwareEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _SoftwareEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.SoftwareEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SoftwareEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SoftwareEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SoftwareEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SoftwareEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.SoftwareEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SoftwareEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(model.PackageSourceOrArtifact) + fc.Result = res + return ec.marshalNPackageSourceOrArtifact2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPackageSourceOrArtifact(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SoftwareEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SoftwareEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type PackageSourceOrArtifact does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var findSoftwareConnectionImplementors = []string{"FindSoftwareConnection"} + +func (ec *executionContext) _FindSoftwareConnection(ctx context.Context, sel ast.SelectionSet, obj *model.FindSoftwareConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, findSoftwareConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("FindSoftwareConnection") + case "totalCount": + out.Values[i] = ec._FindSoftwareConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._FindSoftwareConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._FindSoftwareConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var softwareEdgeImplementors = []string{"SoftwareEdge"} + +func (ec *executionContext) _SoftwareEdge(ctx context.Context, sel ast.SelectionSet, obj *model.SoftwareEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, softwareEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("SoftwareEdge") + case "cursor": + out.Values[i] = ec._SoftwareEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._SoftwareEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) marshalNSoftwareEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSoftwareEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.SoftwareEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNSoftwareEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSoftwareEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNSoftwareEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSoftwareEdge(ctx context.Context, sel ast.SelectionSet, v *model.SoftwareEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._SoftwareEdge(ctx, sel, v) +} + +func (ec *executionContext) marshalOFindSoftwareConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐFindSoftwareConnection(ctx context.Context, sel ast.SelectionSet, v *model.FindSoftwareConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._FindSoftwareConnection(ctx, sel, v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/source.generated.go b/pkg/assembler/graphql/generated/source.generated.go index 01af4504474..714ad61e209 100644 --- a/pkg/assembler/graphql/generated/source.generated.go +++ b/pkg/assembler/graphql/generated/source.generated.go @@ -160,6 +160,233 @@ func (ec *executionContext) fieldContext_Source_namespaces(ctx context.Context, return fc, nil } +func (ec *executionContext) _SourceConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.SourceConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SourceConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SourceConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SourceConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SourceConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.SourceConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SourceConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SourceConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SourceConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _SourceConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.SourceConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SourceConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.SourceEdge) + fc.Result = res + return ec.marshalNSourceEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSourceEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SourceConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SourceConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_SourceEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_SourceEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type SourceEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _SourceEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.SourceEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SourceEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SourceEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SourceEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _SourceEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.SourceEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_SourceEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.Source) + fc.Result = res + return ec.marshalNSource2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSource(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_SourceEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "SourceEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Source_id(ctx, field) + case "type": + return ec.fieldContext_Source_type(ctx, field) + case "namespaces": + return ec.fieldContext_Source_namespaces(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Source", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _SourceIDs_sourceTypeID(ctx context.Context, field graphql.CollectedField, obj *model.SourceIDs) (ret graphql.Marshaler) { fc, err := ec.fieldContext_SourceIDs_sourceTypeID(ctx, field) if err != nil { @@ -807,6 +1034,99 @@ func (ec *executionContext) _Source(ctx context.Context, sel ast.SelectionSet, o return out } +var sourceConnectionImplementors = []string{"SourceConnection"} + +func (ec *executionContext) _SourceConnection(ctx context.Context, sel ast.SelectionSet, obj *model.SourceConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, sourceConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("SourceConnection") + case "totalCount": + out.Values[i] = ec._SourceConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._SourceConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._SourceConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var sourceEdgeImplementors = []string{"SourceEdge"} + +func (ec *executionContext) _SourceEdge(ctx context.Context, sel ast.SelectionSet, obj *model.SourceEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, sourceEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("SourceEdge") + case "cursor": + out.Values[i] = ec._SourceEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._SourceEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var sourceIDsImplementors = []string{"SourceIDs"} func (ec *executionContext) _SourceIDs(ctx context.Context, sel ast.SelectionSet, obj *model.SourceIDs) graphql.Marshaler { @@ -1038,6 +1358,60 @@ func (ec *executionContext) marshalNSource2ᚖgithubᚗcomᚋguacsecᚋguacᚋpk return ec._Source(ctx, sel, v) } +func (ec *executionContext) marshalNSourceEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSourceEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.SourceEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNSourceEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSourceEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNSourceEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSourceEdge(ctx context.Context, sel ast.SelectionSet, v *model.SourceEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._SourceEdge(ctx, sel, v) +} + func (ec *executionContext) marshalNSourceIDs2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSourceIDs(ctx context.Context, sel ast.SelectionSet, v model.SourceIDs) graphql.Marshaler { return ec._SourceIDs(ctx, sel, &v) } @@ -1237,6 +1611,13 @@ func (ec *executionContext) unmarshalOIDorSourceInput2ᚖgithubᚗcomᚋguacsec return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOSourceConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSourceConnection(ctx context.Context, sel ast.SelectionSet, v *model.SourceConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._SourceConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOSourceInputSpec2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐSourceInputSpec(ctx context.Context, v interface{}) (*model.SourceInputSpec, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/vulnEqual.generated.go b/pkg/assembler/graphql/generated/vulnEqual.generated.go index 5a4312d97c5..0e1103723c4 100644 --- a/pkg/assembler/graphql/generated/vulnEqual.generated.go +++ b/pkg/assembler/graphql/generated/vulnEqual.generated.go @@ -283,6 +283,239 @@ func (ec *executionContext) fieldContext_VulnEqual_documentRef(ctx context.Conte return fc, nil } +func (ec *executionContext) _VulnEqualConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.VulnEqualConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnEqualConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnEqualConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnEqualConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VulnEqualConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.VulnEqualConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnEqualConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnEqualConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnEqualConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _VulnEqualConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.VulnEqualConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnEqualConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.VulnEqualEdge) + fc.Result = res + return ec.marshalNVulnEqualEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnEqualEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnEqualConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnEqualConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_VulnEqualEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_VulnEqualEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VulnEqualEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _VulnEqualEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.VulnEqualEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnEqualEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnEqualEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnEqualEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VulnEqualEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.VulnEqualEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnEqualEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.VulnEqual) + fc.Result = res + return ec.marshalNVulnEqual2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnEqual(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnEqualEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnEqualEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_VulnEqual_id(ctx, field) + case "vulnerabilities": + return ec.fieldContext_VulnEqual_vulnerabilities(ctx, field) + case "justification": + return ec.fieldContext_VulnEqual_justification(ctx, field) + case "origin": + return ec.fieldContext_VulnEqual_origin(ctx, field) + case "collector": + return ec.fieldContext_VulnEqual_collector(ctx, field) + case "documentRef": + return ec.fieldContext_VulnEqual_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VulnEqual", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -469,6 +702,99 @@ func (ec *executionContext) _VulnEqual(ctx context.Context, sel ast.SelectionSet return out } +var vulnEqualConnectionImplementors = []string{"VulnEqualConnection"} + +func (ec *executionContext) _VulnEqualConnection(ctx context.Context, sel ast.SelectionSet, obj *model.VulnEqualConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, vulnEqualConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VulnEqualConnection") + case "totalCount": + out.Values[i] = ec._VulnEqualConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._VulnEqualConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._VulnEqualConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var vulnEqualEdgeImplementors = []string{"VulnEqualEdge"} + +func (ec *executionContext) _VulnEqualEdge(ctx context.Context, sel ast.SelectionSet, obj *model.VulnEqualEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, vulnEqualEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VulnEqualEdge") + case "cursor": + out.Values[i] = ec._VulnEqualEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._VulnEqualEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -527,6 +853,60 @@ func (ec *executionContext) marshalNVulnEqual2ᚖgithubᚗcomᚋguacsecᚋguac return ec._VulnEqual(ctx, sel, v) } +func (ec *executionContext) marshalNVulnEqualEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnEqualEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.VulnEqualEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNVulnEqualEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnEqualEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNVulnEqualEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnEqualEdge(ctx context.Context, sel ast.SelectionSet, v *model.VulnEqualEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._VulnEqualEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNVulnEqualInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnEqualInputSpec(ctx context.Context, v interface{}) (model.VulnEqualInputSpec, error) { res, err := ec.unmarshalInputVulnEqualInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -559,4 +939,11 @@ func (ec *executionContext) unmarshalNVulnEqualSpec2githubᚗcomᚋguacsecᚋgua return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOVulnEqualConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnEqualConnection(ctx context.Context, sel ast.SelectionSet, v *model.VulnEqualConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._VulnEqualConnection(ctx, sel, v) +} + // endregion ***************************** type.gotpl ***************************** diff --git a/pkg/assembler/graphql/generated/vulnMetadata.generated.go b/pkg/assembler/graphql/generated/vulnMetadata.generated.go index bdfbc8dbeac..c4da6984117 100644 --- a/pkg/assembler/graphql/generated/vulnMetadata.generated.go +++ b/pkg/assembler/graphql/generated/vulnMetadata.generated.go @@ -366,6 +366,243 @@ func (ec *executionContext) fieldContext_VulnerabilityMetadata_documentRef(ctx c return fc, nil } +func (ec *executionContext) _VulnerabilityMetadataConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.VulnerabilityMetadataConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnerabilityMetadataConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnerabilityMetadataConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnerabilityMetadataConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VulnerabilityMetadataConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.VulnerabilityMetadataConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnerabilityMetadataConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnerabilityMetadataConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnerabilityMetadataConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _VulnerabilityMetadataConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.VulnerabilityMetadataConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnerabilityMetadataConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.VulnerabilityMetadataEdge) + fc.Result = res + return ec.marshalNVulnerabilityMetadataEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityMetadataEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnerabilityMetadataConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnerabilityMetadataConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_VulnerabilityMetadataEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_VulnerabilityMetadataEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VulnerabilityMetadataEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _VulnerabilityMetadataEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.VulnerabilityMetadataEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnerabilityMetadataEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnerabilityMetadataEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnerabilityMetadataEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VulnerabilityMetadataEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.VulnerabilityMetadataEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnerabilityMetadataEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.VulnerabilityMetadata) + fc.Result = res + return ec.marshalNVulnerabilityMetadata2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityMetadata(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnerabilityMetadataEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnerabilityMetadataEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_VulnerabilityMetadata_id(ctx, field) + case "vulnerability": + return ec.fieldContext_VulnerabilityMetadata_vulnerability(ctx, field) + case "scoreType": + return ec.fieldContext_VulnerabilityMetadata_scoreType(ctx, field) + case "scoreValue": + return ec.fieldContext_VulnerabilityMetadata_scoreValue(ctx, field) + case "timestamp": + return ec.fieldContext_VulnerabilityMetadata_timestamp(ctx, field) + case "origin": + return ec.fieldContext_VulnerabilityMetadata_origin(ctx, field) + case "collector": + return ec.fieldContext_VulnerabilityMetadata_collector(ctx, field) + case "documentRef": + return ec.fieldContext_VulnerabilityMetadata_documentRef(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VulnerabilityMetadata", field.Name) + }, + } + return fc, nil +} + // endregion **************************** field.gotpl ***************************** // region **************************** input.gotpl ***************************** @@ -597,6 +834,99 @@ func (ec *executionContext) _VulnerabilityMetadata(ctx context.Context, sel ast. return out } +var vulnerabilityMetadataConnectionImplementors = []string{"VulnerabilityMetadataConnection"} + +func (ec *executionContext) _VulnerabilityMetadataConnection(ctx context.Context, sel ast.SelectionSet, obj *model.VulnerabilityMetadataConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, vulnerabilityMetadataConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VulnerabilityMetadataConnection") + case "totalCount": + out.Values[i] = ec._VulnerabilityMetadataConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._VulnerabilityMetadataConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._VulnerabilityMetadataConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var vulnerabilityMetadataEdgeImplementors = []string{"VulnerabilityMetadataEdge"} + +func (ec *executionContext) _VulnerabilityMetadataEdge(ctx context.Context, sel ast.SelectionSet, obj *model.VulnerabilityMetadataEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, vulnerabilityMetadataEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VulnerabilityMetadataEdge") + case "cursor": + out.Values[i] = ec._VulnerabilityMetadataEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._VulnerabilityMetadataEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + // endregion **************************** object.gotpl **************************** // region ***************************** type.gotpl ***************************** @@ -655,6 +985,60 @@ func (ec *executionContext) marshalNVulnerabilityMetadata2ᚖgithubᚗcomᚋguac return ec._VulnerabilityMetadata(ctx, sel, v) } +func (ec *executionContext) marshalNVulnerabilityMetadataEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityMetadataEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.VulnerabilityMetadataEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNVulnerabilityMetadataEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityMetadataEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNVulnerabilityMetadataEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityMetadataEdge(ctx context.Context, sel ast.SelectionSet, v *model.VulnerabilityMetadataEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._VulnerabilityMetadataEdge(ctx, sel, v) +} + func (ec *executionContext) unmarshalNVulnerabilityMetadataInputSpec2githubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityMetadataInputSpec(ctx context.Context, v interface{}) (model.VulnerabilityMetadataInputSpec, error) { res, err := ec.unmarshalInputVulnerabilityMetadataInputSpec(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -713,6 +1097,13 @@ func (ec *executionContext) marshalOComparator2ᚖgithubᚗcomᚋguacsecᚋguac return v } +func (ec *executionContext) marshalOVulnerabilityMetadataConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityMetadataConnection(ctx context.Context, sel ast.SelectionSet, v *model.VulnerabilityMetadataConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._VulnerabilityMetadataConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOVulnerabilityScoreType2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityScoreType(ctx context.Context, v interface{}) (*model.VulnerabilityScoreType, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/generated/vulnerability.generated.go b/pkg/assembler/graphql/generated/vulnerability.generated.go index 4f475b384ee..c8d1823da34 100644 --- a/pkg/assembler/graphql/generated/vulnerability.generated.go +++ b/pkg/assembler/graphql/generated/vulnerability.generated.go @@ -158,6 +158,233 @@ func (ec *executionContext) fieldContext_Vulnerability_vulnerabilityIDs(ctx cont return fc, nil } +func (ec *executionContext) _VulnerabilityConnection_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.VulnerabilityConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnerabilityConnection_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnerabilityConnection_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnerabilityConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VulnerabilityConnection_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.VulnerabilityConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnerabilityConnection_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnerabilityConnection_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnerabilityConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _VulnerabilityConnection_edges(ctx context.Context, field graphql.CollectedField, obj *model.VulnerabilityConnection) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnerabilityConnection_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.VulnerabilityEdge) + fc.Result = res + return ec.marshalNVulnerabilityEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnerabilityConnection_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnerabilityConnection", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_VulnerabilityEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_VulnerabilityEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type VulnerabilityEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _VulnerabilityEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.VulnerabilityEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnerabilityEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNID2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnerabilityEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnerabilityEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _VulnerabilityEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.VulnerabilityEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_VulnerabilityEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.Vulnerability) + fc.Result = res + return ec.marshalNVulnerability2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerability(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_VulnerabilityEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "VulnerabilityEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "id": + return ec.fieldContext_Vulnerability_id(ctx, field) + case "type": + return ec.fieldContext_Vulnerability_type(ctx, field) + case "vulnerabilityIDs": + return ec.fieldContext_Vulnerability_vulnerabilityIDs(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Vulnerability", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _VulnerabilityID_id(ctx context.Context, field graphql.CollectedField, obj *model.VulnerabilityID) (ret graphql.Marshaler) { fc, err := ec.fieldContext_VulnerabilityID_id(ctx, field) if err != nil { @@ -506,6 +733,99 @@ func (ec *executionContext) _Vulnerability(ctx context.Context, sel ast.Selectio return out } +var vulnerabilityConnectionImplementors = []string{"VulnerabilityConnection"} + +func (ec *executionContext) _VulnerabilityConnection(ctx context.Context, sel ast.SelectionSet, obj *model.VulnerabilityConnection) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, vulnerabilityConnectionImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VulnerabilityConnection") + case "totalCount": + out.Values[i] = ec._VulnerabilityConnection_totalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "pageInfo": + out.Values[i] = ec._VulnerabilityConnection_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "edges": + out.Values[i] = ec._VulnerabilityConnection_edges(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var vulnerabilityEdgeImplementors = []string{"VulnerabilityEdge"} + +func (ec *executionContext) _VulnerabilityEdge(ctx context.Context, sel ast.SelectionSet, obj *model.VulnerabilityEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, vulnerabilityEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("VulnerabilityEdge") + case "cursor": + out.Values[i] = ec._VulnerabilityEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._VulnerabilityEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var vulnerabilityIDImplementors = []string{"VulnerabilityID"} func (ec *executionContext) _VulnerabilityID(ctx context.Context, sel ast.SelectionSet, obj *model.VulnerabilityID) graphql.Marshaler { @@ -679,6 +999,60 @@ func (ec *executionContext) marshalNVulnerability2ᚖgithubᚗcomᚋguacsecᚋgu return ec._Vulnerability(ctx, sel, v) } +func (ec *executionContext) marshalNVulnerabilityEdge2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.VulnerabilityEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNVulnerabilityEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNVulnerabilityEdge2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityEdge(ctx context.Context, sel ast.SelectionSet, v *model.VulnerabilityEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._VulnerabilityEdge(ctx, sel, v) +} + func (ec *executionContext) marshalNVulnerabilityID2ᚕᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityIDᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.VulnerabilityID) graphql.Marshaler { ret := make(graphql.Array, len(v)) var wg sync.WaitGroup @@ -796,6 +1170,13 @@ func (ec *executionContext) unmarshalNVulnerabilitySpec2githubᚗcomᚋguacsec return res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOVulnerabilityConnection2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityConnection(ctx context.Context, sel ast.SelectionSet, v *model.VulnerabilityConnection) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._VulnerabilityConnection(ctx, sel, v) +} + func (ec *executionContext) unmarshalOVulnerabilityInputSpec2ᚖgithubᚗcomᚋguacsecᚋguacᚋpkgᚋassemblerᚋgraphqlᚋmodelᚐVulnerabilityInputSpec(ctx context.Context, v interface{}) (*model.VulnerabilityInputSpec, error) { if v == nil { return nil, nil diff --git a/pkg/assembler/graphql/model/nodes.go b/pkg/assembler/graphql/model/nodes.go index fb827b10cc8..6f3d58751e1 100644 --- a/pkg/assembler/graphql/model/nodes.go +++ b/pkg/assembler/graphql/model/nodes.go @@ -52,6 +52,29 @@ func (Artifact) IsPackageOrArtifact() {} func (Artifact) IsNode() {} +// ArtifactConnection returns the paginated results for artifact. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the ArtifactEdge which contains the current cursor +// and the artifact node itself +type ArtifactConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*ArtifactEdge `json:"edges"` +} + +// ArtifactEdge contains the cursor for the resulting node and +// the artifact node itself. +type ArtifactEdge struct { + Cursor string `json:"cursor"` + Node *Artifact `json:"node"` +} + // ArtifactInputSpec specifies an artifact for mutations. // // The checksum fields are canonicalized to be lowercase. @@ -79,6 +102,29 @@ type Builder struct { func (Builder) IsNode() {} +// BuilderConnection returns the paginated results for builder. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the BuilderEdge which contains the current cursor +// and the Builder node itself +type BuilderConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*BuilderEdge `json:"edges"` +} + +// BuilderEdge contains the cursor for the resulting node and +// the Builder node itself. +type BuilderEdge struct { + Cursor string `json:"cursor"` + Node *Builder `json:"node"` +} + // BuilderInputSpec specifies a builder for mutations. type BuilderInputSpec struct { URI string `json:"uri"` @@ -119,6 +165,29 @@ type CertifyBad struct { func (CertifyBad) IsNode() {} +// CertifyBadConnection returns the paginated results for CertifyBad. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the CertifyBadEdge which contains the current cursor +// and the CertifyBad node itself +type CertifyBadConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*CertifyBadEdge `json:"edges"` +} + +// CertifyBadEdge contains the cursor for the resulting node and +// the CertifyBad node itself. +type CertifyBadEdge struct { + Cursor string `json:"cursor"` + Node *CertifyBad `json:"node"` +} + // CertifyBadInputSpec represents the mutation input to ingest a CertifyBad // evidence. type CertifyBadInputSpec struct { @@ -180,6 +249,29 @@ type CertifyGood struct { func (CertifyGood) IsNode() {} +// CertifyGoodConnection returns the paginated results for CertifyGood. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the CertifyGoodEdge which contains the current cursor +// and the CertifyGood node itself +type CertifyGoodConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*CertifyGoodEdge `json:"edges"` +} + +// CertifyGoodEdge contains the cursor for the resulting node and +// the CertifyGood node itself. +type CertifyGoodEdge struct { + Cursor string `json:"cursor"` + Node *CertifyGood `json:"node"` +} + // CertifyGoodInputSpec represents the mutation input to ingest a CertifyGood evidence. type CertifyGoodInputSpec struct { Justification string `json:"justification"` @@ -253,6 +345,29 @@ type CertifyLegal struct { func (CertifyLegal) IsNode() {} +// CertifyLegalConnection returns the paginated results for CertifyLegal. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the CertifyLegalEdge which contains the current cursor +// and the CertifyLegal node itself +type CertifyLegalConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*CertifyLegalEdge `json:"edges"` +} + +// CertifyLegalEdge contains the cursor for the resulting node and +// the CertifyLegal node itself. +type CertifyLegalEdge struct { + Cursor string `json:"cursor"` + Node *CertifyLegal `json:"node"` +} + // CertifyLegalInputSpec represents the input for certifying legal information in // mutations. type CertifyLegalInputSpec struct { @@ -298,6 +413,29 @@ type CertifyScorecard struct { func (CertifyScorecard) IsNode() {} +// CertifyScorecardConnection returns the paginated results for CertifyScorecard. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the CertifyScorecardEdge which contains the current cursor +// and the CertifyScorecard node itself +type CertifyScorecardConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*CertifyScorecardEdge `json:"edges"` +} + +// CertifyScorecardEdge contains the cursor for the resulting node and +// the CertifyScorecard node itself. +type CertifyScorecardEdge struct { + Cursor string `json:"cursor"` + Node *CertifyScorecard `json:"node"` +} + // CertifyScorecardSpec allows filtering the list of Scorecards to return. type CertifyScorecardSpec struct { ID *string `json:"id,omitempty"` @@ -377,6 +515,29 @@ type CertifyVuln struct { func (CertifyVuln) IsNode() {} +// CertifyVulnConnection returns the paginated results for CertifyVuln. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the CertifyVulnEdge which contains the current cursor +// and the CertifyVuln node itself +type CertifyVulnConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*CertifyVulnEdge `json:"edges"` +} + +// CertifyVulnEdge contains the cursor for the resulting node and +// the CertifyVuln node itself. +type CertifyVulnEdge struct { + Cursor string `json:"cursor"` + Node *CertifyVuln `json:"node"` +} + // CertifyVulnSpec allows filtering the list of vulnerability certifications to // return in a query. // @@ -399,6 +560,22 @@ type CertifyVulnSpec struct { DocumentRef *string `json:"documentRef,omitempty"` } +// FindSoftwareConnection returns the paginated results for FindSoftware. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the SoftwareEdge which contains the current cursor +// and the PackageSourceOrArtifact node itself +type FindSoftwareConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*SoftwareEdge `json:"edges"` +} + // HasMetadata is an attestation that a package, source, or artifact has a certain // attested property (key) with value (value). For example, a source may have // metadata "SourceRepo2FAEnabled=true". @@ -435,6 +612,29 @@ type HasMetadata struct { func (HasMetadata) IsNode() {} +// HasMetadataConnection returns the paginated results for HasMetadata. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the HasMetadataEdge which contains the current cursor +// and the HasMetadata node itself +type HasMetadataConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*HasMetadataEdge `json:"edges"` +} + +// HasMetadataEdge contains the cursor for the resulting node and +// the HasMetadata node itself. +type HasMetadataEdge struct { + Cursor string `json:"cursor"` + Node *HasMetadata `json:"node"` +} + // HasMetadataInputSpec represents the mutation input to ingest a CertifyGood evidence. type HasMetadataInputSpec struct { Key string `json:"key"` @@ -499,6 +699,29 @@ type HasSbom struct { func (HasSbom) IsNode() {} +// HasSBOMConnection returns the paginated results for HasSBOM. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the HasSBOMEdge which contains the current cursor +// and the HasSBOM node itself +type HasSBOMConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*HasSBOMEdge `json:"edges"` +} + +// HasSBOMEdge contains the cursor for the resulting node and +// the HasSBOMEdge node itself. +type HasSBOMEdge struct { + Cursor string `json:"cursor"` + Node *HasSbom `json:"node"` +} + type HasSBOMIncludesInputSpec struct { Packages []string `json:"packages"` Artifacts []string `json:"artifacts"` @@ -551,6 +774,29 @@ type HasSlsa struct { func (HasSlsa) IsNode() {} +// HasSLSAConnection returns the paginated results for HasSLSA. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the HasSLSAEdge which contains the current cursor +// and the HasSLSA node itself +type HasSLSAConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*HasSLSAEdge `json:"edges"` +} + +// HasSLSAEdge contains the cursor for the resulting node and +// the HasSLSA node itself. +type HasSLSAEdge struct { + Cursor string `json:"cursor"` + Node *HasSlsa `json:"node"` +} + // HasSLSASpec allows filtering the list of HasSLSA to return. type HasSLSASpec struct { ID *string `json:"id,omitempty"` @@ -588,6 +834,29 @@ type HasSourceAt struct { func (HasSourceAt) IsNode() {} +// HasSourceAtConnection returns the paginated results for HasSourceAt. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the HasSourceAtEdge which contains the current cursor +// and the HasSourceAt node itself +type HasSourceAtConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*HasSourceAtEdge `json:"edges"` +} + +// HasSourceAtEdge contains the cursor for the resulting node and +// the HasSourceAt node itself. +type HasSourceAtEdge struct { + Cursor string `json:"cursor"` + Node *HasSourceAt `json:"node"` +} + // HasSourceAtInputSpec is the same as HasSourceAt but for mutation input. type HasSourceAtInputSpec struct { KnownSince time.Time `json:"knownSince"` @@ -626,6 +895,29 @@ type HashEqual struct { func (HashEqual) IsNode() {} +// HashEqualConnection returns the paginated results for HashEqual. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the HashEqualEdge which contains the current cursor +// and the HashEqual node itself +type HashEqualConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*HashEqualEdge `json:"edges"` +} + +// HashEqualEdge contains the cursor for the resulting node and +// the HashEqual node itself. +type HashEqualEdge struct { + Cursor string `json:"cursor"` + Node *HashEqual `json:"node"` +} + // HashEqualInputSpec represents the input to certify that packages are similar. type HashEqualInputSpec struct { Justification string `json:"justification"` @@ -737,6 +1029,29 @@ type IsDependency struct { func (IsDependency) IsNode() {} +// IsDependencyConnection returns the paginated results for IsDependency. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the IsDependencyEdge which contains the current cursor +// and the IsDependency node itself +type IsDependencyConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*IsDependencyEdge `json:"edges"` +} + +// IsDependencyEdge contains the cursor for the resulting node and +// the IsDependency node itself. +type IsDependencyEdge struct { + Cursor string `json:"cursor"` + Node *IsDependency `json:"node"` +} + // IsDependencyInputSpec is the input to record a new dependency. type IsDependencyInputSpec struct { // versionRange should be specified for depedentPackages that point to PackageName @@ -787,6 +1102,29 @@ type IsOccurrence struct { func (IsOccurrence) IsNode() {} +// IsOccurrenceConnection returns the paginated results for IsOccurrence. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the IsOccurrenceEdge which contains the current cursor +// and the IsOccurrence node itself +type IsOccurrenceConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*IsOccurrenceEdge `json:"edges"` +} + +// IsOccurrenceEdge contains the cursor for the resulting node and +// the IsOccurrence node itself. +type IsOccurrenceEdge struct { + Cursor string `json:"cursor"` + Node *IsOccurrence `json:"node"` +} + // IsOccurrenceInputSpec represents the input to record an artifact's origin. type IsOccurrenceInputSpec struct { Justification string `json:"justification"` @@ -841,6 +1179,29 @@ type License struct { func (License) IsNode() {} +// LicenseConnection returns the paginated results for License. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the LicenseEdge which contains the current cursor +// and the License node itself +type LicenseConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*LicenseEdge `json:"edges"` +} + +// LicenseEdge contains the cursor for the resulting node and +// the License node itself. +type LicenseEdge struct { + Cursor string `json:"cursor"` + Node *License `json:"node"` +} + // LicenseInputSpec specifies an license for mutations. One of inline or // listVersion should be empty or missing. type LicenseInputSpec struct { @@ -865,6 +1226,29 @@ type MatchFlags struct { type Mutation struct { } +// NeighborConnection returns the paginated results for Neighbor. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the NeighborEdge which contains the current cursor +// and the node itself +type NeighborConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*NeighborEdge `json:"edges"` +} + +// NeighborEdge contains the cursor for the resulting node and +// the node itself. +type NeighborEdge struct { + Cursor string `json:"cursor"` + Node Node `json:"node"` +} + // Package represents the root of the package trie/tree. // // We map package information to a trie, closely matching the pURL specification @@ -893,6 +1277,29 @@ func (Package) IsPackageOrSource() {} func (Package) IsNode() {} +// PackageConnection returns the paginated results for Package. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the PackageEdge which contains the current cursor +// and the Package node itself +type PackageConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*PackageEdge `json:"edges"` +} + +// PackageEdge contains the cursor for the resulting node and +// the Package node itself. +type PackageEdge struct { + Cursor string `json:"cursor"` + Node *Package `json:"node"` +} + // The IDs of the ingested package type PackageIDs struct { PackageTypeID string `json:"packageTypeID"` @@ -1066,6 +1473,21 @@ type PackageVersion struct { Subpath string `json:"subpath"` } +// PageInfo serves the client information about the paginated query results. +// +// hasNextPage is true when there are results to be returned. +// +// hasPreviousPage is true when there is a previous page to return to. +// +// startCursor is the ID where the query started from. +// +// endCursor is where the query ended. +type PageInfo struct { + HasNextPage bool `json:"hasNextPage"` + StartCursor *string `json:"startCursor,omitempty"` + EndCursor *string `json:"endCursor,omitempty"` +} + // PkgEqual is an attestation that a set of packages are similar. type PkgEqual struct { ID string `json:"id"` @@ -1083,6 +1505,29 @@ type PkgEqual struct { func (PkgEqual) IsNode() {} +// PkgEqualConnection returns the paginated results for PkgEqual. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the PkgEqualEdge which contains the current cursor +// and the PkgEqual node itself +type PkgEqualConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*PkgEqualEdge `json:"edges"` +} + +// PkgEqualEdge contains the cursor for the resulting node and +// the PkgEqual node itself. +type PkgEqualEdge struct { + Cursor string `json:"cursor"` + Node *PkgEqual `json:"node"` +} + // PkgEqualInputSpec represents the input to certify that packages are similar. type PkgEqualInputSpec struct { Justification string `json:"justification"` @@ -1187,6 +1632,29 @@ type PointOfContact struct { func (PointOfContact) IsNode() {} +// PointOfContactConnection returns the paginated results for PointOfContact. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the PointOfContactEdge which contains the current cursor +// and the PointOfContact node itself +type PointOfContactConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*PointOfContactEdge `json:"edges"` +} + +// PointOfContactEdge contains the cursor for the resulting node and +// the PointOfContact node itself. +type PointOfContactEdge struct { + Cursor string `json:"cursor"` + Node *PointOfContact `json:"node"` +} + // PointOfContactInputSpec represents the mutation input to ingest a PointOfContact evidence. type PointOfContactInputSpec struct { Email string `json:"email"` @@ -1415,6 +1883,13 @@ type ScorecardInputSpec struct { DocumentRef string `json:"documentRef"` } +// SoftwareEdge contains the cursor for the resulting node and +// the PackageSourceOrArtifact node itself. +type SoftwareEdge struct { + Cursor string `json:"cursor"` + Node PackageSourceOrArtifact `json:"node"` +} + // Source represents the root of the source trie/tree. // // We map source information to a trie, as a derivative of the pURL specification: @@ -1438,6 +1913,29 @@ func (Source) IsPackageOrSource() {} func (Source) IsNode() {} +// SourceConnection returns the paginated results for Source. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the SourceEdge which contains the current cursor +// and the Source node itself +type SourceConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*SourceEdge `json:"edges"` +} + +// SourceEdge contains the cursor for the resulting node and +// the Source node itself. +type SourceEdge struct { + Cursor string `json:"cursor"` + Node *Source `json:"node"` +} + // The IDs of the ingested source type SourceIDs struct { SourceTypeID string `json:"sourceTypeID"` @@ -1502,6 +2000,29 @@ type SourceSpec struct { Commit *string `json:"commit,omitempty"` } +// VEXConnection returns the paginated results for CertifyVEXStatement. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the VEXEdge which contains the current cursor +// and the CertifyVEXStatement node itself +type VEXConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*VEXEdge `json:"edges"` +} + +// VEXEdge contains the cursor for the resulting node and +// the CertifyVEXStatement node itself. +type VEXEdge struct { + Cursor string `json:"cursor"` + Node *CertifyVEXStatement `json:"node"` +} + // VexStatementInputSpec represents the input to ingest VEX statements. type VexStatementInputSpec struct { Status VexStatus `json:"status"` @@ -1533,6 +2054,29 @@ type VulnEqual struct { func (VulnEqual) IsNode() {} +// VulnEqualConnection returns the paginated results for VulnEqual. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the VulnEqualEdge which contains the current cursor +// and the VulnEqual node itself +type VulnEqualConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*VulnEqualEdge `json:"edges"` +} + +// VulnEqualEdge contains the cursor for the resulting node and +// the VulnEqual node itself. +type VulnEqualEdge struct { + Cursor string `json:"cursor"` + Node *VulnEqual `json:"node"` +} + // VulnEqualInputSpec represents the input to link vulnerabilities to each other. type VulnEqualInputSpec struct { Justification string `json:"justification"` @@ -1585,6 +2129,29 @@ type Vulnerability struct { func (Vulnerability) IsNode() {} +// VulnerabilityConnection returns the paginated results for Vulnerability. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the VulnerabilityEdge which contains the current cursor +// and the Vulnerability node itself +type VulnerabilityConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*VulnerabilityEdge `json:"edges"` +} + +// VulnerabilityEdge contains the cursor for the resulting node and +// the Vulnerability node itself. +type VulnerabilityEdge struct { + Cursor string `json:"cursor"` + Node *Vulnerability `json:"node"` +} + // VulnerabilityID is a specific vulnerability ID associated with the type of the vulnerability. // // This will be enforced to be all lowercase. @@ -1651,6 +2218,29 @@ type VulnerabilityMetadata struct { func (VulnerabilityMetadata) IsNode() {} +// VulnerabilityMetadataConnection returns the paginated results for VulnerabilityMetadata. +// +// totalCount is the total number of results returned. +// +// pageInfo provides information to the client if there is +// a next page of results and the starting and +// ending cursor for the current set. +// +// edges contains the VulnerabilityMetadataEdge which contains the current cursor +// and the VulnerabilityMetadata node itself +type VulnerabilityMetadataConnection struct { + TotalCount int `json:"totalCount"` + PageInfo *PageInfo `json:"pageInfo"` + Edges []*VulnerabilityMetadataEdge `json:"edges"` +} + +// VulnerabilityMetadataEdge contains the cursor for the resulting node and +// the VulnerabilityMetadata node itself. +type VulnerabilityMetadataEdge struct { + Cursor string `json:"cursor"` + Node *VulnerabilityMetadata `json:"node"` +} + // VulnerabilityMetadataInputSpec represents the mutation input to ingest a vulnerability metadata. type VulnerabilityMetadataInputSpec struct { ScoreType VulnerabilityScoreType `json:"scoreType"` diff --git a/pkg/assembler/graphql/resolvers/artifact.resolvers.go b/pkg/assembler/graphql/resolvers/artifact.resolvers.go index f19b633015a..951155acde9 100644 --- a/pkg/assembler/graphql/resolvers/artifact.resolvers.go +++ b/pkg/assembler/graphql/resolvers/artifact.resolvers.go @@ -26,6 +26,11 @@ func (r *queryResolver) Artifacts(ctx context.Context, artifactSpec model.Artifa return r.Backend.Artifacts(ctx, &artifactSpec) } +// ArtifactsList is the resolver for the artifactsList field. +func (r *queryResolver) ArtifactsList(ctx context.Context, artifactSpec model.ArtifactSpec, after *string, first *int) (*model.ArtifactConnection, error) { + return r.Backend.ArtifactsList(ctx, artifactSpec, after, first) +} + // Mutation returns generated.MutationResolver implementation. func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } diff --git a/pkg/assembler/graphql/resolvers/builder.resolvers.go b/pkg/assembler/graphql/resolvers/builder.resolvers.go index d3da8657776..863f7397bcd 100644 --- a/pkg/assembler/graphql/resolvers/builder.resolvers.go +++ b/pkg/assembler/graphql/resolvers/builder.resolvers.go @@ -24,3 +24,8 @@ func (r *mutationResolver) IngestBuilders(ctx context.Context, builders []*model func (r *queryResolver) Builders(ctx context.Context, builderSpec model.BuilderSpec) ([]*model.Builder, error) { return r.Backend.Builders(ctx, &builderSpec) } + +// BuildersList is the resolver for the buildersList field. +func (r *queryResolver) BuildersList(ctx context.Context, builderSpec model.BuilderSpec, after *string, first *int) (*model.BuilderConnection, error) { + return r.Backend.BuildersList(ctx, builderSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/certifyBad.resolvers.go b/pkg/assembler/graphql/resolvers/certifyBad.resolvers.go index 860018a55d3..dffcf1b6390 100644 --- a/pkg/assembler/graphql/resolvers/certifyBad.resolvers.go +++ b/pkg/assembler/graphql/resolvers/certifyBad.resolvers.go @@ -66,3 +66,11 @@ func (r *queryResolver) CertifyBad(ctx context.Context, certifyBadSpec model.Cer } return r.Backend.CertifyBad(ctx, &certifyBadSpec) } + +// CertifyBadList is the resolver for the CertifyBadList field. +func (r *queryResolver) CertifyBadList(ctx context.Context, certifyBadSpec model.CertifyBadSpec, after *string, first *int) (*model.CertifyBadConnection, error) { + if err := validatePackageSourceOrArtifactQueryFilter(certifyBadSpec.Subject); err != nil { + return nil, gqlerror.Errorf("CertifyBad :: %s", err) + } + return r.Backend.CertifyBadList(ctx, certifyBadSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/certifyGood.resolvers.go b/pkg/assembler/graphql/resolvers/certifyGood.resolvers.go index 93dc519cc6d..dfdcc93e03b 100644 --- a/pkg/assembler/graphql/resolvers/certifyGood.resolvers.go +++ b/pkg/assembler/graphql/resolvers/certifyGood.resolvers.go @@ -66,3 +66,11 @@ func (r *queryResolver) CertifyGood(ctx context.Context, certifyGoodSpec model.C } return r.Backend.CertifyGood(ctx, &certifyGoodSpec) } + +// CertifyGoodList is the resolver for the CertifyGoodList field. +func (r *queryResolver) CertifyGoodList(ctx context.Context, certifyGoodSpec model.CertifyGoodSpec, after *string, first *int) (*model.CertifyGoodConnection, error) { + if err := validatePackageSourceOrArtifactQueryFilter(certifyGoodSpec.Subject); err != nil { + return nil, gqlerror.Errorf("CertifyGood :: %s", err) + } + return r.Backend.CertifyGoodList(ctx, certifyGoodSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/certifyLegal.resolvers.go b/pkg/assembler/graphql/resolvers/certifyLegal.resolvers.go index c60ed51cd6a..164621ce20f 100644 --- a/pkg/assembler/graphql/resolvers/certifyLegal.resolvers.go +++ b/pkg/assembler/graphql/resolvers/certifyLegal.resolvers.go @@ -55,3 +55,12 @@ func (r *queryResolver) CertifyLegal(ctx context.Context, certifyLegalSpec model return r.Backend.CertifyLegal(ctx, &certifyLegalSpec) } + +// CertifyLegalList is the resolver for the CertifyLegalList field. +func (r *queryResolver) CertifyLegalList(ctx context.Context, certifyLegalSpec model.CertifyLegalSpec, after *string, first *int) (*model.CertifyLegalConnection, error) { + if err := validatePackageOrSourceQueryFilter(certifyLegalSpec.Subject); err != nil { + return nil, gqlerror.Errorf("CertifyLegal :: %v", err) + } + + return r.Backend.CertifyLegalList(ctx, certifyLegalSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/certifyScorecard.resolvers.go b/pkg/assembler/graphql/resolvers/certifyScorecard.resolvers.go index 13ca9c02e33..5180426b332 100644 --- a/pkg/assembler/graphql/resolvers/certifyScorecard.resolvers.go +++ b/pkg/assembler/graphql/resolvers/certifyScorecard.resolvers.go @@ -30,3 +30,8 @@ func (r *mutationResolver) IngestScorecards(ctx context.Context, sources []*mode func (r *queryResolver) Scorecards(ctx context.Context, scorecardSpec model.CertifyScorecardSpec) ([]*model.CertifyScorecard, error) { return r.Backend.Scorecards(ctx, &scorecardSpec) } + +// ScorecardsList is the resolver for the scorecardsList field. +func (r *queryResolver) ScorecardsList(ctx context.Context, scorecardSpec model.CertifyScorecardSpec, after *string, first *int) (*model.CertifyScorecardConnection, error) { + return r.Backend.ScorecardsList(ctx, scorecardSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers.go b/pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers.go index 9ac8808e32f..6e3f9de0346 100644 --- a/pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers.go +++ b/pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers.go @@ -139,3 +139,48 @@ func (r *queryResolver) CertifyVEXStatement(ctx context.Context, certifyVEXState return r.Backend.CertifyVEXStatement(ctx, &certifyVEXStatementSpec) } } + +// CertifyVEXStatementList is the resolver for the CertifyVEXStatementList field. +func (r *queryResolver) CertifyVEXStatementList(ctx context.Context, certifyVEXStatementSpec model.CertifyVEXStatementSpec, after *string, first *int) (*model.VEXConnection, error) { + if err := validatePackageOrArtifactQueryFilter(certifyVEXStatementSpec.Subject); err != nil { + return nil, gqlerror.Errorf("CertifyVEXStatement :: %s", err) + } + + // vulnerability input (type and vulnerability ID) will be enforced to be lowercase + + if certifyVEXStatementSpec.Vulnerability != nil { + var typeLowerCase *string = nil + var vulnIDLowerCase *string = nil + if certifyVEXStatementSpec.Vulnerability.Type != nil { + lower := strings.ToLower(*certifyVEXStatementSpec.Vulnerability.Type) + typeLowerCase = &lower + } + if certifyVEXStatementSpec.Vulnerability.VulnerabilityID != nil { + lower := strings.ToLower(*certifyVEXStatementSpec.Vulnerability.VulnerabilityID) + vulnIDLowerCase = &lower + } + + lowercaseVulnFilter := &model.VulnerabilitySpec{ + ID: certifyVEXStatementSpec.Vulnerability.ID, + Type: typeLowerCase, + VulnerabilityID: vulnIDLowerCase, + NoVuln: certifyVEXStatementSpec.Vulnerability.NoVuln, + } + + lowercaseCertifyVexFilter := model.CertifyVEXStatementSpec{ + ID: certifyVEXStatementSpec.ID, + Subject: certifyVEXStatementSpec.Subject, + Vulnerability: lowercaseVulnFilter, + Status: certifyVEXStatementSpec.Status, + VexJustification: certifyVEXStatementSpec.VexJustification, + Statement: certifyVEXStatementSpec.Statement, + StatusNotes: certifyVEXStatementSpec.StatusNotes, + KnownSince: certifyVEXStatementSpec.KnownSince, + Origin: certifyVEXStatementSpec.Origin, + Collector: certifyVEXStatementSpec.Collector, + } + return r.Backend.CertifyVEXStatementList(ctx, lowercaseCertifyVexFilter, after, first) + } else { + return r.Backend.CertifyVEXStatementList(ctx, certifyVEXStatementSpec, after, first) + } +} diff --git a/pkg/assembler/graphql/resolvers/certifyVuln.resolvers.go b/pkg/assembler/graphql/resolvers/certifyVuln.resolvers.go index 44a8c3fe576..f348f06211e 100644 --- a/pkg/assembler/graphql/resolvers/certifyVuln.resolvers.go +++ b/pkg/assembler/graphql/resolvers/certifyVuln.resolvers.go @@ -115,3 +115,51 @@ func (r *queryResolver) CertifyVuln(ctx context.Context, certifyVulnSpec model.C return r.Backend.CertifyVuln(ctx, &certifyVulnSpec) } } + +// CertifyVulnList is the resolver for the CertifyVulnList field. +func (r *queryResolver) CertifyVulnList(ctx context.Context, certifyVulnSpec model.CertifyVulnSpec, after *string, first *int) (*model.CertifyVulnConnection, error) { + // vulnerability input (type and vulnerability ID) will be enforced to be lowercase + + if certifyVulnSpec.Vulnerability != nil { + + var typeLowerCase *string = nil + var vulnIDLowerCase *string = nil + if certifyVulnSpec.Vulnerability.Type != nil { + lower := strings.ToLower(*certifyVulnSpec.Vulnerability.Type) + typeLowerCase = &lower + } + if certifyVulnSpec.Vulnerability.VulnerabilityID != nil { + lower := strings.ToLower(*certifyVulnSpec.Vulnerability.VulnerabilityID) + vulnIDLowerCase = &lower + } + + if certifyVulnSpec.Vulnerability.NoVuln != nil && !*certifyVulnSpec.Vulnerability.NoVuln { + if certifyVulnSpec.Vulnerability.Type != nil && *typeLowerCase == "novuln" { + return nil, gqlerror.Errorf("novuln boolean set to false, cannot specify vulnerability type to be novuln") + } + } + + lowercaseVulnFilter := model.VulnerabilitySpec{ + ID: certifyVulnSpec.Vulnerability.ID, + Type: typeLowerCase, + VulnerabilityID: vulnIDLowerCase, + NoVuln: certifyVulnSpec.Vulnerability.NoVuln, + } + + lowercaseCertifyVulnFilter := model.CertifyVulnSpec{ + ID: certifyVulnSpec.ID, + Package: certifyVulnSpec.Package, + Vulnerability: &lowercaseVulnFilter, + TimeScanned: certifyVulnSpec.TimeScanned, + DbURI: certifyVulnSpec.DbURI, + DbVersion: certifyVulnSpec.DbVersion, + ScannerURI: certifyVulnSpec.ScannerURI, + ScannerVersion: certifyVulnSpec.ScannerVersion, + Origin: certifyVulnSpec.Origin, + Collector: certifyVulnSpec.Collector, + } + return r.Backend.CertifyVulnList(ctx, lowercaseCertifyVulnFilter, after, first) + } else { + return r.Backend.CertifyVulnList(ctx, certifyVulnSpec, after, first) + } +} diff --git a/pkg/assembler/graphql/resolvers/contact.resolvers.go b/pkg/assembler/graphql/resolvers/contact.resolvers.go index 5ad0103143b..4b9007354cb 100644 --- a/pkg/assembler/graphql/resolvers/contact.resolvers.go +++ b/pkg/assembler/graphql/resolvers/contact.resolvers.go @@ -55,3 +55,11 @@ func (r *queryResolver) PointOfContact(ctx context.Context, pointOfContactSpec m } return r.Backend.PointOfContact(ctx, &pointOfContactSpec) } + +// PointOfContactList is the resolver for the PointOfContactList field. +func (r *queryResolver) PointOfContactList(ctx context.Context, pointOfContactSpec model.PointOfContactSpec, after *string, first *int) (*model.PointOfContactConnection, error) { + if err := validatePackageSourceOrArtifactQueryFilter(pointOfContactSpec.Subject); err != nil { + return nil, gqlerror.Errorf("PointOfContact :: %s", err) + } + return r.Backend.PointOfContactList(ctx, pointOfContactSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/hasSBOM.resolvers.go b/pkg/assembler/graphql/resolvers/hasSBOM.resolvers.go index 6db0c7a5294..f4fa5dae738 100644 --- a/pkg/assembler/graphql/resolvers/hasSBOM.resolvers.go +++ b/pkg/assembler/graphql/resolvers/hasSBOM.resolvers.go @@ -64,3 +64,11 @@ func (r *queryResolver) HasSbom(ctx context.Context, hasSBOMSpec model.HasSBOMSp } return r.Backend.HasSBOM(ctx, &hasSBOMSpec) } + +// HasSBOMList is the resolver for the HasSBOMList field. +func (r *queryResolver) HasSBOMList(ctx context.Context, hasSBOMSpec model.HasSBOMSpec, after *string, first *int) (*model.HasSBOMConnection, error) { + if err := validatePackageOrArtifactQueryFilter(hasSBOMSpec.Subject); err != nil { + return nil, gqlerror.Errorf("%v :: %s", "HasSBOM", err) + } + return r.Backend.HasSBOMList(ctx, hasSBOMSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/hasSLSA.resolvers.go b/pkg/assembler/graphql/resolvers/hasSLSA.resolvers.go index 2f43b98ebee..c51ec153bc0 100644 --- a/pkg/assembler/graphql/resolvers/hasSLSA.resolvers.go +++ b/pkg/assembler/graphql/resolvers/hasSLSA.resolvers.go @@ -41,3 +41,8 @@ func (r *mutationResolver) IngestSLSAs(ctx context.Context, subjects []*model.ID func (r *queryResolver) HasSlsa(ctx context.Context, hasSLSASpec model.HasSLSASpec) ([]*model.HasSlsa, error) { return r.Backend.HasSlsa(ctx, &hasSLSASpec) } + +// HasSLSAList is the resolver for the HasSLSAList field. +func (r *queryResolver) HasSLSAList(ctx context.Context, hasSLSASpec model.HasSLSASpec, after *string, first *int) (*model.HasSLSAConnection, error) { + return r.Backend.HasSLSAList(ctx, hasSLSASpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/hasSourceAt.resolvers.go b/pkg/assembler/graphql/resolvers/hasSourceAt.resolvers.go index 133e3f25fce..7a4c01561b4 100644 --- a/pkg/assembler/graphql/resolvers/hasSourceAt.resolvers.go +++ b/pkg/assembler/graphql/resolvers/hasSourceAt.resolvers.go @@ -32,3 +32,8 @@ func (r *mutationResolver) IngestHasSourceAts(ctx context.Context, pkgs []*model func (r *queryResolver) HasSourceAt(ctx context.Context, hasSourceAtSpec model.HasSourceAtSpec) ([]*model.HasSourceAt, error) { return r.Backend.HasSourceAt(ctx, &hasSourceAtSpec) } + +// HasSourceAtList is the resolver for the HasSourceAtList field. +func (r *queryResolver) HasSourceAtList(ctx context.Context, hasSourceAtSpec model.HasSourceAtSpec, after *string, first *int) (*model.HasSourceAtConnection, error) { + return r.Backend.HasSourceAtList(ctx, hasSourceAtSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/hashEqual.resolvers.go b/pkg/assembler/graphql/resolvers/hashEqual.resolvers.go index 34ecec830b5..496988c407a 100644 --- a/pkg/assembler/graphql/resolvers/hashEqual.resolvers.go +++ b/pkg/assembler/graphql/resolvers/hashEqual.resolvers.go @@ -36,3 +36,11 @@ func (r *queryResolver) HashEqual(ctx context.Context, hashEqualSpec model.HashE } return r.Backend.HashEqual(ctx, &hashEqualSpec) } + +// HashEqualList is the resolver for the HashEqualList field. +func (r *queryResolver) HashEqualList(ctx context.Context, hashEqualSpec model.HashEqualSpec, after *string, first *int) (*model.HashEqualConnection, error) { + if hashEqualSpec.Artifacts != nil && len(hashEqualSpec.Artifacts) > 2 { + return nil, gqlerror.Errorf("HashEqual :: Provided spec has too many Artifacts") + } + return r.Backend.HashEqualList(ctx, hashEqualSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/isDependency.resolvers.go b/pkg/assembler/graphql/resolvers/isDependency.resolvers.go index cc0c3120633..0fc8bf9f4bb 100644 --- a/pkg/assembler/graphql/resolvers/isDependency.resolvers.go +++ b/pkg/assembler/graphql/resolvers/isDependency.resolvers.go @@ -49,3 +49,13 @@ func (r *queryResolver) IsDependency(ctx context.Context, isDependencySpec model return r.Backend.IsDependency(ctx, &isDependencySpec) } + +// IsDependencyList is the resolver for the IsDependencyList field. +func (r *queryResolver) IsDependencyList(ctx context.Context, isDependencySpec model.IsDependencySpec, after *string, first *int) (*model.IsDependencyConnection, error) { + funcName := "IsDependency" + if isDependencySpec.DependencyType != nil && !isDependencySpec.DependencyType.IsValid() { + return nil, gqlerror.Errorf("%s :: dependency type was not valid", funcName) + } + + return r.Backend.IsDependencyList(ctx, isDependencySpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/isOccurrence.resolvers.go b/pkg/assembler/graphql/resolvers/isOccurrence.resolvers.go index 0b65238cce1..748df565c61 100644 --- a/pkg/assembler/graphql/resolvers/isOccurrence.resolvers.go +++ b/pkg/assembler/graphql/resolvers/isOccurrence.resolvers.go @@ -57,3 +57,11 @@ func (r *queryResolver) IsOccurrence(ctx context.Context, isOccurrenceSpec model } return r.Backend.IsOccurrence(ctx, &isOccurrenceSpec) } + +// IsOccurrenceList is the resolver for the IsOccurrenceList field. +func (r *queryResolver) IsOccurrenceList(ctx context.Context, isOccurrenceSpec model.IsOccurrenceSpec, after *string, first *int) (*model.IsOccurrenceConnection, error) { + if err := validatePackageOrSourceQueryFilter(isOccurrenceSpec.Subject); err != nil { + return nil, gqlerror.Errorf("IsOccurrence :: %s", err) + } + return r.Backend.IsOccurrenceList(ctx, isOccurrenceSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/license.resolvers.go b/pkg/assembler/graphql/resolvers/license.resolvers.go index 8093a7c6218..d8174363f5b 100644 --- a/pkg/assembler/graphql/resolvers/license.resolvers.go +++ b/pkg/assembler/graphql/resolvers/license.resolvers.go @@ -36,3 +36,8 @@ func (r *mutationResolver) IngestLicenses(ctx context.Context, licenses []*model func (r *queryResolver) Licenses(ctx context.Context, licenseSpec model.LicenseSpec) ([]*model.License, error) { return r.Backend.Licenses(ctx, &licenseSpec) } + +// LicenseList is the resolver for the licenseList field. +func (r *queryResolver) LicenseList(ctx context.Context, licenseSpec model.LicenseSpec, after *string, first *int) (*model.LicenseConnection, error) { + return r.Backend.LicenseList(ctx, licenseSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/metadata.resolvers.go b/pkg/assembler/graphql/resolvers/metadata.resolvers.go index 95a389396f6..cc01627259b 100644 --- a/pkg/assembler/graphql/resolvers/metadata.resolvers.go +++ b/pkg/assembler/graphql/resolvers/metadata.resolvers.go @@ -56,3 +56,11 @@ func (r *queryResolver) HasMetadata(ctx context.Context, hasMetadataSpec model.H } return r.Backend.HasMetadata(ctx, &hasMetadataSpec) } + +// HasMetadataList is the resolver for the HasMetadataList field. +func (r *queryResolver) HasMetadataList(ctx context.Context, hasMetadataSpec model.HasMetadataSpec, after *string, first *int) (*model.HasMetadataConnection, error) { + if err := validatePackageSourceOrArtifactQueryFilter(hasMetadataSpec.Subject); err != nil { + return nil, gqlerror.Errorf("HasMetadata :: %s", err) + } + return r.Backend.HasMetadataList(ctx, hasMetadataSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/package.resolvers.go b/pkg/assembler/graphql/resolvers/package.resolvers.go index b9745a9cd05..6089665adbc 100644 --- a/pkg/assembler/graphql/resolvers/package.resolvers.go +++ b/pkg/assembler/graphql/resolvers/package.resolvers.go @@ -34,6 +34,11 @@ func (r *queryResolver) Packages(ctx context.Context, pkgSpec model.PkgSpec) ([] return r.Backend.Packages(ctx, &pkgSpec) } +// PackagesList is the resolver for the packagesList field. +func (r *queryResolver) PackagesList(ctx context.Context, pkgSpec model.PkgSpec, after *string, first *int) (*model.PackageConnection, error) { + return r.Backend.PackagesList(ctx, pkgSpec, after, first) +} + // Package returns generated.PackageResolver implementation. func (r *Resolver) Package() generated.PackageResolver { return &packageResolver{r} } diff --git a/pkg/assembler/graphql/resolvers/path.resolvers.go b/pkg/assembler/graphql/resolvers/path.resolvers.go index bd6d232238f..08247f57ede 100644 --- a/pkg/assembler/graphql/resolvers/path.resolvers.go +++ b/pkg/assembler/graphql/resolvers/path.resolvers.go @@ -25,6 +25,11 @@ func (r *queryResolver) Neighbors(ctx context.Context, node string, usingOnly [] return r.Backend.Neighbors(ctx, node, usingOnly) } +// NeighborsList is the resolver for the neighborsList field. +func (r *queryResolver) NeighborsList(ctx context.Context, node string, usingOnly []model.Edge, after *string, first *int) (*model.NeighborConnection, error) { + return r.Backend.NeighborsList(ctx, node, usingOnly, after, first) +} + // Node is the resolver for the node field. func (r *queryResolver) Node(ctx context.Context, node string) (model.Node, error) { return r.Backend.Node(ctx, node) diff --git a/pkg/assembler/graphql/resolvers/pkgEqual.resolvers.go b/pkg/assembler/graphql/resolvers/pkgEqual.resolvers.go index 84230e19386..02c2086c33f 100644 --- a/pkg/assembler/graphql/resolvers/pkgEqual.resolvers.go +++ b/pkg/assembler/graphql/resolvers/pkgEqual.resolvers.go @@ -36,3 +36,11 @@ func (r *queryResolver) PkgEqual(ctx context.Context, pkgEqualSpec model.PkgEqua } return r.Backend.PkgEqual(ctx, &pkgEqualSpec) } + +// PkgEqualList is the resolver for the PkgEqualList field. +func (r *queryResolver) PkgEqualList(ctx context.Context, pkgEqualSpec model.PkgEqualSpec, after *string, first *int) (*model.PkgEqualConnection, error) { + if len(pkgEqualSpec.Packages) > 2 { + return nil, gqlerror.Errorf("PkgEqual :: too many packages in query, max 2, got: %v", len(pkgEqualSpec.Packages)) + } + return r.Backend.PkgEqualList(ctx, pkgEqualSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/search.resolvers.go b/pkg/assembler/graphql/resolvers/search.resolvers.go index e7c2cff422b..7a5942769a3 100644 --- a/pkg/assembler/graphql/resolvers/search.resolvers.go +++ b/pkg/assembler/graphql/resolvers/search.resolvers.go @@ -14,3 +14,8 @@ import ( func (r *queryResolver) FindSoftware(ctx context.Context, searchText string) ([]model.PackageSourceOrArtifact, error) { return r.Backend.FindSoftware(ctx, searchText) } + +// FindSoftwareList is the resolver for the findSoftwareList field. +func (r *queryResolver) FindSoftwareList(ctx context.Context, searchText string, after *string, first *int) (*model.FindSoftwareConnection, error) { + return r.Backend.FindSoftwareList(ctx, searchText, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/source.resolvers.go b/pkg/assembler/graphql/resolvers/source.resolvers.go index 6a74499962e..32f6bf9dfce 100644 --- a/pkg/assembler/graphql/resolvers/source.resolvers.go +++ b/pkg/assembler/graphql/resolvers/source.resolvers.go @@ -31,3 +31,14 @@ func (r *queryResolver) Sources(ctx context.Context, sourceSpec model.SourceSpec return r.Backend.Sources(ctx, &sourceSpec) } + +// SourcesList is the resolver for the sourcesList field. +func (r *queryResolver) SourcesList(ctx context.Context, sourceSpec model.SourceSpec, after *string, first *int) (*model.SourceConnection, error) { + if sourceSpec.Commit != nil && sourceSpec.Tag != nil { + if *sourceSpec.Commit != "" && *sourceSpec.Tag != "" { + return nil, gqlerror.Errorf("Sources :: Passing both commit and tag selectors is an error") + } + } + + return r.Backend.SourcesList(ctx, sourceSpec, after, first) +} diff --git a/pkg/assembler/graphql/resolvers/vulnEqual.resolvers.go b/pkg/assembler/graphql/resolvers/vulnEqual.resolvers.go index d4350fa65a9..1a2ef18aabe 100644 --- a/pkg/assembler/graphql/resolvers/vulnEqual.resolvers.go +++ b/pkg/assembler/graphql/resolvers/vulnEqual.resolvers.go @@ -165,3 +165,47 @@ func (r *queryResolver) VulnEqual(ctx context.Context, vulnEqualSpec model.VulnE return r.Backend.VulnEqual(ctx, &vulnEqualSpec) } } + +// VulnEqualList is the resolver for the vulnEqualList field. +func (r *queryResolver) VulnEqualList(ctx context.Context, vulnEqualSpec model.VulnEqualSpec, after *string, first *int) (*model.VulnEqualConnection, error) { + // vulnerability input (type and vulnerability ID) will be enforced to be lowercase + + if vulnEqualSpec.Vulnerabilities != nil && len(vulnEqualSpec.Vulnerabilities) > 2 { + return nil, gqlerror.Errorf("VulnEqual :: cannot specify more than 2 vulnerabilities in VulnEqual") + } + + if len(vulnEqualSpec.Vulnerabilities) > 0 { + var lowercaseVulnFilterList []*model.VulnerabilitySpec + for _, v := range vulnEqualSpec.Vulnerabilities { + var typeLowerCase *string = nil + var vulnIDLowerCase *string = nil + if v.Type != nil { + lower := strings.ToLower(*v.Type) + typeLowerCase = &lower + } + if v.VulnerabilityID != nil { + lower := strings.ToLower(*v.VulnerabilityID) + vulnIDLowerCase = &lower + } + + lowercaseVulnFilter := model.VulnerabilitySpec{ + ID: v.ID, + Type: typeLowerCase, + VulnerabilityID: vulnIDLowerCase, + NoVuln: v.NoVuln, + } + lowercaseVulnFilterList = append(lowercaseVulnFilterList, &lowercaseVulnFilter) + } + + lowercaseVulnEqualFilter := model.VulnEqualSpec{ + ID: vulnEqualSpec.ID, + Vulnerabilities: lowercaseVulnFilterList, + Justification: vulnEqualSpec.Justification, + Origin: vulnEqualSpec.Origin, + Collector: vulnEqualSpec.Collector, + } + return r.Backend.VulnEqualList(ctx, lowercaseVulnEqualFilter, after, first) + } else { + return r.Backend.VulnEqualList(ctx, vulnEqualSpec, after, first) + } +} diff --git a/pkg/assembler/graphql/resolvers/vulnMetadata.resolvers.go b/pkg/assembler/graphql/resolvers/vulnMetadata.resolvers.go index b18780a5b45..fa0287a604a 100644 --- a/pkg/assembler/graphql/resolvers/vulnMetadata.resolvers.go +++ b/pkg/assembler/graphql/resolvers/vulnMetadata.resolvers.go @@ -75,7 +75,7 @@ func (r *mutationResolver) IngestBulkVulnerabilityMetadata(ctx context.Context, // VulnerabilityMetadata is the resolver for the vulnerabilityMetadata field. func (r *queryResolver) VulnerabilityMetadata(ctx context.Context, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec) ([]*model.VulnerabilityMetadata, error) { - funcName := "IngestVulnerabilityMetadata" + funcName := "VulnerabilityMetadata" // vulnerability input (type and vulnerability ID) will be enforced to be lowercase if vulnerabilityMetadataSpec.Comparator != nil && vulnerabilityMetadataSpec.ScoreValue == nil { @@ -122,3 +122,53 @@ func (r *queryResolver) VulnerabilityMetadata(ctx context.Context, vulnerability return r.Backend.VulnerabilityMetadata(ctx, &vulnerabilityMetadataSpec) } } + +// VulnerabilityMetadataList is the resolver for the vulnerabilityMetadataList field. +func (r *queryResolver) VulnerabilityMetadataList(ctx context.Context, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec, after *string, first *int) (*model.VulnerabilityMetadataConnection, error) { + funcName := "VulnerabilityMetadataList" + // vulnerability input (type and vulnerability ID) will be enforced to be lowercase + + if vulnerabilityMetadataSpec.Comparator != nil && vulnerabilityMetadataSpec.ScoreValue == nil { + return nil, gqlerror.Errorf("%v :: comparator cannot be set without a score value specified", funcName) + } + + if vulnerabilityMetadataSpec.Vulnerability != nil { + + var typeLowerCase *string = nil + var vulnIDLowerCase *string = nil + if vulnerabilityMetadataSpec.Vulnerability.Type != nil { + lower := strings.ToLower(*vulnerabilityMetadataSpec.Vulnerability.Type) + typeLowerCase = &lower + } + if vulnerabilityMetadataSpec.Vulnerability.VulnerabilityID != nil { + lower := strings.ToLower(*vulnerabilityMetadataSpec.Vulnerability.VulnerabilityID) + vulnIDLowerCase = &lower + } + + err := validateVulnerabilitySpec(*vulnerabilityMetadataSpec.Vulnerability) + if err != nil { + return nil, gqlerror.Errorf("%v :: %s", funcName, err) + } + + lowercaseVulnFilter := model.VulnerabilitySpec{ + ID: vulnerabilityMetadataSpec.Vulnerability.ID, + Type: typeLowerCase, + VulnerabilityID: vulnIDLowerCase, + NoVuln: vulnerabilityMetadataSpec.Vulnerability.NoVuln, + } + + lowercaseVulnerabilityMetadataSpec := model.VulnerabilityMetadataSpec{ + ID: vulnerabilityMetadataSpec.ID, + Vulnerability: &lowercaseVulnFilter, + ScoreType: vulnerabilityMetadataSpec.ScoreType, + ScoreValue: vulnerabilityMetadataSpec.ScoreValue, + Comparator: vulnerabilityMetadataSpec.Comparator, + Timestamp: vulnerabilityMetadataSpec.Timestamp, + Origin: vulnerabilityMetadataSpec.Origin, + Collector: vulnerabilityMetadataSpec.Collector, + } + return r.Backend.VulnerabilityMetadataList(ctx, lowercaseVulnerabilityMetadataSpec, after, first) + } else { + return r.Backend.VulnerabilityMetadataList(ctx, vulnerabilityMetadataSpec, after, first) + } +} diff --git a/pkg/assembler/graphql/resolvers/vulnerability.resolvers.go b/pkg/assembler/graphql/resolvers/vulnerability.resolvers.go index 7003107ae94..1d08dc7ca96 100644 --- a/pkg/assembler/graphql/resolvers/vulnerability.resolvers.go +++ b/pkg/assembler/graphql/resolvers/vulnerability.resolvers.go @@ -83,3 +83,27 @@ func (r *queryResolver) Vulnerabilities(ctx context.Context, vulnSpec model.Vuln return r.Backend.Vulnerabilities(ctx, &model.VulnerabilitySpec{ID: vulnSpec.ID, Type: typeLowerCase, VulnerabilityID: vulnIDLowerCase, NoVuln: vulnSpec.NoVuln}) } + +// VulnerabilityList is the resolver for the vulnerabilityList field. +func (r *queryResolver) VulnerabilityList(ctx context.Context, vulnSpec model.VulnerabilitySpec, after *string, first *int) (*model.VulnerabilityConnection, error) { + // vulnerability input (type and vulnerability ID) will be enforced to be lowercase + + var typeLowerCase *string = nil + var vulnIDLowerCase *string = nil + if vulnSpec.Type != nil { + lower := strings.ToLower(*vulnSpec.Type) + typeLowerCase = &lower + } + if vulnSpec.VulnerabilityID != nil { + lower := strings.ToLower(*vulnSpec.VulnerabilityID) + vulnIDLowerCase = &lower + } + + err := validateVulnerabilitySpec(vulnSpec) + if err != nil { + return nil, gqlerror.Errorf("IngestVulnerabilityMetadata :: %s", err) + } + + return r.Backend.VulnerabilityList(ctx, model.VulnerabilitySpec{ID: vulnSpec.ID, Type: typeLowerCase, + VulnerabilityID: vulnIDLowerCase, NoVuln: vulnSpec.NoVuln}, after, first) +} diff --git a/pkg/assembler/graphql/schema/artifact.graphql b/pkg/assembler/graphql/schema/artifact.graphql index 32c9c86321d..7c7a2a808a8 100644 --- a/pkg/assembler/graphql/schema/artifact.graphql +++ b/pkg/assembler/graphql/schema/artifact.graphql @@ -65,9 +65,38 @@ input IDorArtifactInput { artifactInput: ArtifactInputSpec } +""" +ArtifactConnection returns the paginated results for artifact. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the ArtifactEdge which contains the current cursor +and the artifact node itself +""" +type ArtifactConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [ArtifactEdge!]! +} + +""" +ArtifactEdge contains the cursor for the resulting node and +the artifact node itself. +""" +type ArtifactEdge { + cursor: ID! + node: Artifact! +} + extend type Query { "Returns all artifacts matching a filter." artifacts(artifactSpec: ArtifactSpec!): [Artifact!]! + "Returns a paginated results via ArtifactConnection" + artifactsList(artifactSpec: ArtifactSpec!, after: ID, first: Int): ArtifactConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/builder.graphql b/pkg/assembler/graphql/schema/builder.graphql index dfb352f69a9..3c6234aac78 100644 --- a/pkg/assembler/graphql/schema/builder.graphql +++ b/pkg/assembler/graphql/schema/builder.graphql @@ -50,9 +50,38 @@ input IDorBuilderInput { builderInput: BuilderInputSpec } +""" +BuilderConnection returns the paginated results for builder. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the BuilderEdge which contains the current cursor +and the Builder node itself +""" +type BuilderConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [BuilderEdge!]! +} + +""" +BuilderEdge contains the cursor for the resulting node and +the Builder node itself. +""" +type BuilderEdge { + cursor: ID! + node: Builder! +} + extend type Query { "Returns all builders matching a filter." builders(builderSpec: BuilderSpec!): [Builder!]! + "Returns a paginated results via BuilderConnection" + buildersList(builderSpec: BuilderSpec!, after: ID, first: Int): BuilderConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/certifyBad.graphql b/pkg/assembler/graphql/schema/certifyBad.graphql index 3d585f5bec3..198067f3079 100644 --- a/pkg/assembler/graphql/schema/certifyBad.graphql +++ b/pkg/assembler/graphql/schema/certifyBad.graphql @@ -135,9 +135,38 @@ input MatchFlags { pkg: PkgMatchType! } +""" +CertifyBadConnection returns the paginated results for CertifyBad. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the CertifyBadEdge which contains the current cursor +and the CertifyBad node itself +""" +type CertifyBadConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [CertifyBadEdge!]! +} + +""" +CertifyBadEdge contains the cursor for the resulting node and +the CertifyBad node itself. +""" +type CertifyBadEdge { + cursor: ID! + node: CertifyBad! +} + extend type Query { "Returns all CertifyBad attestations matching a filter." CertifyBad(certifyBadSpec: CertifyBadSpec!): [CertifyBad!]! + "Returns a paginated results via CertifyBadConnection" + CertifyBadList(certifyBadSpec: CertifyBadSpec!, after: ID, first: Int): CertifyBadConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/certifyGood.graphql b/pkg/assembler/graphql/schema/certifyGood.graphql index 7dca7a3c906..8ab7641a176 100644 --- a/pkg/assembler/graphql/schema/certifyGood.graphql +++ b/pkg/assembler/graphql/schema/certifyGood.graphql @@ -81,9 +81,38 @@ input CertifyGoodInputSpec { documentRef: String! } +""" +CertifyGoodConnection returns the paginated results for CertifyGood. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the CertifyGoodEdge which contains the current cursor +and the CertifyGood node itself +""" +type CertifyGoodConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [CertifyGoodEdge!]! +} + +""" +CertifyGoodEdge contains the cursor for the resulting node and +the CertifyGood node itself. +""" +type CertifyGoodEdge { + cursor: ID! + node: CertifyGood! +} + extend type Query { "Returns all CertifyGood attestations matching a filter." CertifyGood(certifyGoodSpec: CertifyGoodSpec!): [CertifyGood!]! + "Returns a paginated results via CertifyGoodConnection" + CertifyGoodList(certifyGoodSpec: CertifyGoodSpec!, after: ID, first: Int): CertifyGoodConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/certifyLegal.graphql b/pkg/assembler/graphql/schema/certifyLegal.graphql index 1d81e7ac62b..94aeeb875a5 100644 --- a/pkg/assembler/graphql/schema/certifyLegal.graphql +++ b/pkg/assembler/graphql/schema/certifyLegal.graphql @@ -96,9 +96,38 @@ input CertifyLegalInputSpec { documentRef: String! } +""" +CertifyLegalConnection returns the paginated results for CertifyLegal. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the CertifyLegalEdge which contains the current cursor +and the CertifyLegal node itself +""" +type CertifyLegalConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [CertifyLegalEdge!]! +} + +""" +CertifyLegalEdge contains the cursor for the resulting node and +the CertifyLegal node itself. +""" +type CertifyLegalEdge { + cursor: ID! + node: CertifyLegal! +} + extend type Query { "Returns all legal certifications matching the input filter." CertifyLegal(certifyLegalSpec: CertifyLegalSpec!): [CertifyLegal!]! + "Returns a paginated results via CertifyLegalConnection" + CertifyLegalList(certifyLegalSpec: CertifyLegalSpec!, after: ID, first: Int): CertifyLegalConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/certifyScorecard.graphql b/pkg/assembler/graphql/schema/certifyScorecard.graphql index 1ac92538237..9b23bd67250 100644 --- a/pkg/assembler/graphql/schema/certifyScorecard.graphql +++ b/pkg/assembler/graphql/schema/certifyScorecard.graphql @@ -123,9 +123,38 @@ input ScorecardCheckInputSpec { score: Int! } +""" +CertifyScorecardConnection returns the paginated results for CertifyScorecard. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the CertifyScorecardEdge which contains the current cursor +and the CertifyScorecard node itself +""" +type CertifyScorecardConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [CertifyScorecardEdge!]! +} + +""" +CertifyScorecardEdge contains the cursor for the resulting node and +the CertifyScorecard node itself. +""" +type CertifyScorecardEdge { + cursor: ID! + node: CertifyScorecard! +} + extend type Query { "Returns all Scorecard certifications matching the filter." scorecards(scorecardSpec: CertifyScorecardSpec!): [CertifyScorecard!]! + "Returns a paginated results via CertifyScorecardConnection" + scorecardsList(scorecardSpec: CertifyScorecardSpec!, after: ID, first: Int): CertifyScorecardConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/certifyVEXStatement.graphql b/pkg/assembler/graphql/schema/certifyVEXStatement.graphql index 725c76e5c84..7dadc7ef889 100644 --- a/pkg/assembler/graphql/schema/certifyVEXStatement.graphql +++ b/pkg/assembler/graphql/schema/certifyVEXStatement.graphql @@ -131,11 +131,40 @@ input VexStatementInputSpec { documentRef: String! } +""" +VEXConnection returns the paginated results for CertifyVEXStatement. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the VEXEdge which contains the current cursor +and the CertifyVEXStatement node itself +""" +type VEXConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [VEXEdge!]! +} + +""" +VEXEdge contains the cursor for the resulting node and +the CertifyVEXStatement node itself. +""" +type VEXEdge { + cursor: ID! + node: CertifyVEXStatement! +} + extend type Query { "Returns all VEX certifications matching the input filter." CertifyVEXStatement( certifyVEXStatementSpec: CertifyVEXStatementSpec! ): [CertifyVEXStatement!]! + "Returns a paginated results via CertifyVexConnection" + CertifyVEXStatementList(certifyVEXStatementSpec: CertifyVEXStatementSpec!, after: ID, first: Int): VEXConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/certifyVuln.graphql b/pkg/assembler/graphql/schema/certifyVuln.graphql index c80104cd7e8..fa9a1fa028e 100644 --- a/pkg/assembler/graphql/schema/certifyVuln.graphql +++ b/pkg/assembler/graphql/schema/certifyVuln.graphql @@ -97,9 +97,38 @@ input ScanMetadataInput { documentRef: String! } +""" +CertifyVulnConnection returns the paginated results for CertifyVuln. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the CertifyVulnEdge which contains the current cursor +and the CertifyVuln node itself +""" +type CertifyVulnConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [CertifyVulnEdge!]! +} + +""" +CertifyVulnEdge contains the cursor for the resulting node and +the CertifyVuln node itself. +""" +type CertifyVulnEdge { + cursor: ID! + node: CertifyVuln! +} + extend type Query { "Returns all vulnerability certifications matching the input filter." CertifyVuln(certifyVulnSpec: CertifyVulnSpec!): [CertifyVuln!]! + "Returns a paginated results via CertifyVulnConnection" + CertifyVulnList(certifyVulnSpec: CertifyVulnSpec!, after: ID, first: Int): CertifyVulnConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/contact.graphql b/pkg/assembler/graphql/schema/contact.graphql index a030f6d129a..afd61982dca 100644 --- a/pkg/assembler/graphql/schema/contact.graphql +++ b/pkg/assembler/graphql/schema/contact.graphql @@ -96,9 +96,38 @@ input PointOfContactInputSpec { documentRef: String! } +""" +PointOfContactConnection returns the paginated results for PointOfContact. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the PointOfContactEdge which contains the current cursor +and the PointOfContact node itself +""" +type PointOfContactConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [PointOfContactEdge!]! +} + +""" +PointOfContactEdge contains the cursor for the resulting node and +the PointOfContact node itself. +""" +type PointOfContactEdge { + cursor: ID! + node: PointOfContact! +} + extend type Query { "Returns all PointOfContact attestations matching a filter." PointOfContact(pointOfContactSpec: PointOfContactSpec!): [PointOfContact!]! + "Returns a paginated results via PointOfContactConnection" + PointOfContactList(pointOfContactSpec: PointOfContactSpec!, after: ID, first: Int): PointOfContactConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/hasSBOM.graphql b/pkg/assembler/graphql/schema/hasSBOM.graphql index d499babdf33..421047cdfb0 100644 --- a/pkg/assembler/graphql/schema/hasSBOM.graphql +++ b/pkg/assembler/graphql/schema/hasSBOM.graphql @@ -88,9 +88,38 @@ input HasSBOMInputSpec { documentRef: String! } +""" +HasSBOMConnection returns the paginated results for HasSBOM. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the HasSBOMEdge which contains the current cursor +and the HasSBOM node itself +""" +type HasSBOMConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [HasSBOMEdge!]! +} + +""" +HasSBOMEdge contains the cursor for the resulting node and +the HasSBOMEdge node itself. +""" +type HasSBOMEdge { + cursor: ID! + node: HasSBOM! +} + extend type Query { "Returns all SBOM certifications." HasSBOM(hasSBOMSpec: HasSBOMSpec!): [HasSBOM!]! + "Returns a paginated results via HasSBOMConnection" + HasSBOMList(hasSBOMSpec: HasSBOMSpec!, after: ID, first: Int): HasSBOMConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/hasSLSA.graphql b/pkg/assembler/graphql/schema/hasSLSA.graphql index db35cd7997f..d5f19cf5223 100644 --- a/pkg/assembler/graphql/schema/hasSLSA.graphql +++ b/pkg/assembler/graphql/schema/hasSLSA.graphql @@ -131,9 +131,38 @@ input SLSAPredicateInputSpec { value: String! } +""" +HasSLSAConnection returns the paginated results for HasSLSA. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the HasSLSAEdge which contains the current cursor +and the HasSLSA node itself +""" +type HasSLSAConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [HasSLSAEdge!]! +} + +""" +HasSLSAEdge contains the cursor for the resulting node and +the HasSLSA node itself. +""" +type HasSLSAEdge { + cursor: ID! + node: HasSLSA! +} + extend type Query { "Returns all SLSA attestations matching the filter." HasSLSA(hasSLSASpec: HasSLSASpec!): [HasSLSA!]! + "Returns a paginated results via HasSLSAConnection" + HasSLSAList(hasSLSASpec: HasSLSASpec!, after: ID, first: Int): HasSLSAConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/hasSourceAt.graphql b/pkg/assembler/graphql/schema/hasSourceAt.graphql index 33513abe60e..73276bffe55 100644 --- a/pkg/assembler/graphql/schema/hasSourceAt.graphql +++ b/pkg/assembler/graphql/schema/hasSourceAt.graphql @@ -57,9 +57,38 @@ input HasSourceAtInputSpec { documentRef: String! } +""" +HasSourceAtConnection returns the paginated results for HasSourceAt. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the HasSourceAtEdge which contains the current cursor +and the HasSourceAt node itself +""" +type HasSourceAtConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [HasSourceAtEdge!]! +} + +""" +HasSourceAtEdge contains the cursor for the resulting node and +the HasSourceAt node itself. +""" +type HasSourceAtEdge { + cursor: ID! + node: HasSourceAt! +} + extend type Query { "Returns all source mappings that match the filter." HasSourceAt(hasSourceAtSpec: HasSourceAtSpec!): [HasSourceAt!]! + "Returns a paginated results via HasSourceAtConnection" + HasSourceAtList(hasSourceAtSpec: HasSourceAtSpec!, after: ID, first: Int): HasSourceAtConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/hashEqual.graphql b/pkg/assembler/graphql/schema/hashEqual.graphql index 03f14a827e8..b674322858b 100644 --- a/pkg/assembler/graphql/schema/hashEqual.graphql +++ b/pkg/assembler/graphql/schema/hashEqual.graphql @@ -56,9 +56,38 @@ input HashEqualInputSpec { documentRef: String! } +""" +HashEqualConnection returns the paginated results for HashEqual. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the HashEqualEdge which contains the current cursor +and the HashEqual node itself +""" +type HashEqualConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [HashEqualEdge!]! +} + +""" +HashEqualEdge contains the cursor for the resulting node and +the HashEqual node itself. +""" +type HashEqualEdge { + cursor: ID! + node: HashEqual! +} + extend type Query { "Returns all artifact equality statements matching a filter." HashEqual(hashEqualSpec: HashEqualSpec!): [HashEqual!]! + "Returns a paginated results via HashEqualConnection" + HashEqualList(hashEqualSpec: HashEqualSpec!, after: ID, first: Int): HashEqualConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/isDependency.graphql b/pkg/assembler/graphql/schema/isDependency.graphql index a875594f390..a8cc2ad118c 100644 --- a/pkg/assembler/graphql/schema/isDependency.graphql +++ b/pkg/assembler/graphql/schema/isDependency.graphql @@ -79,9 +79,38 @@ input IsDependencyInputSpec { documentRef: String! } +""" +IsDependencyConnection returns the paginated results for IsDependency. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the IsDependencyEdge which contains the current cursor +and the IsDependency node itself +""" +type IsDependencyConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [IsDependencyEdge!]! +} + +""" +IsDependencyEdge contains the cursor for the resulting node and +the IsDependency node itself. +""" +type IsDependencyEdge { + cursor: ID! + node: IsDependency! +} + extend type Query { "Returns all package dependencies that match the filter." IsDependency(isDependencySpec: IsDependencySpec!): [IsDependency!]! + "Returns a paginated results via IsDependencyConnection" + IsDependencyList(isDependencySpec: IsDependencySpec!, after: ID, first: Int): IsDependencyConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/isOccurrence.graphql b/pkg/assembler/graphql/schema/isOccurrence.graphql index 9acc5a5db2d..d71287a273d 100644 --- a/pkg/assembler/graphql/schema/isOccurrence.graphql +++ b/pkg/assembler/graphql/schema/isOccurrence.graphql @@ -92,9 +92,38 @@ input IsOccurrenceInputSpec { documentRef: String! } +""" +IsOccurrenceConnection returns the paginated results for IsOccurrence. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the IsOccurrenceEdge which contains the current cursor +and the IsOccurrence node itself +""" +type IsOccurrenceConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [IsOccurrenceEdge!]! +} + +""" +IsOccurrenceEdge contains the cursor for the resulting node and +the IsOccurrence node itself. +""" +type IsOccurrenceEdge { + cursor: ID! + node: IsOccurrence! +} + extend type Query { "Returns all artifacts-source/package mappings that match a filter." IsOccurrence(isOccurrenceSpec: IsOccurrenceSpec!): [IsOccurrence!]! + "Returns a paginated results via IsOccurrenceConnection" + IsOccurrenceList(isOccurrenceSpec: IsOccurrenceSpec!, after: ID, first: Int): IsOccurrenceConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/license.graphql b/pkg/assembler/graphql/schema/license.graphql index b33233d10ae..c2e81cfcf07 100644 --- a/pkg/assembler/graphql/schema/license.graphql +++ b/pkg/assembler/graphql/schema/license.graphql @@ -83,9 +83,38 @@ input IDorLicenseInput { licenseInput: LicenseInputSpec } +""" +LicenseConnection returns the paginated results for License. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the LicenseEdge which contains the current cursor +and the License node itself +""" +type LicenseConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [LicenseEdge!]! +} + +""" +LicenseEdge contains the cursor for the resulting node and +the License node itself. +""" +type LicenseEdge { + cursor: ID! + node: License! +} + extend type Query { "Returns all licenses matching a filter." licenses(licenseSpec: LicenseSpec!): [License!]! + "Returns a paginated results via LicenseConnection" + licenseList(licenseSpec: LicenseSpec!, after: ID, first: Int): LicenseConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/metadata.graphql b/pkg/assembler/graphql/schema/metadata.graphql index 1efc82dfa06..db71c4fb31b 100644 --- a/pkg/assembler/graphql/schema/metadata.graphql +++ b/pkg/assembler/graphql/schema/metadata.graphql @@ -91,9 +91,38 @@ input HasMetadataInputSpec { documentRef: String! } +""" +HasMetadataConnection returns the paginated results for HasMetadata. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the HasMetadataEdge which contains the current cursor +and the HasMetadata node itself +""" +type HasMetadataConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [HasMetadataEdge!]! +} + +""" +HasMetadataEdge contains the cursor for the resulting node and +the HasMetadata node itself. +""" +type HasMetadataEdge { + cursor: ID! + node: HasMetadata! +} + extend type Query { "Returns all HasMetdata attestations matching a filter." HasMetadata(hasMetadataSpec: HasMetadataSpec!): [HasMetadata!]! + "Returns a paginated results via HasMetadataConnection" + HasMetadataList(hasMetadataSpec: HasMetadataSpec!, after: ID, first: Int): HasMetadataConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/package.graphql b/pkg/assembler/graphql/schema/package.graphql index 3c3b260c3a2..73e709d06a5 100644 --- a/pkg/assembler/graphql/schema/package.graphql +++ b/pkg/assembler/graphql/schema/package.graphql @@ -204,9 +204,38 @@ input IDorPkgInput { packageInput: PkgInputSpec } +""" +PackageConnection returns the paginated results for Package. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the PackageEdge which contains the current cursor +and the Package node itself +""" +type PackageConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [PackageEdge!]! +} + +""" +PackageEdge contains the cursor for the resulting node and +the Package node itself. +""" +type PackageEdge { + cursor: ID! + node: Package! +} + extend type Query { "Returns all packages matching a filter." packages(pkgSpec: PkgSpec!): [Package!]! + "Returns a paginated results via PackageConnection" + packagesList(pkgSpec: PkgSpec!, after: ID, first: Int): PackageConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/pagination.graphql b/pkg/assembler/graphql/schema/pagination.graphql new file mode 100644 index 00000000000..029794ef797 --- /dev/null +++ b/pkg/assembler/graphql/schema/pagination.graphql @@ -0,0 +1,35 @@ +# +# Copyright 2024 The GUAC Authors. +# +# 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. + +# NOTE: This is experimental and might change in the future! + +# Defines a GraphQL schema for the pagination + +""" +PageInfo serves the client information about the paginated query results. + +hasNextPage is true when there are results to be returned. + +hasPreviousPage is true when there is a previous page to return to. + +startCursor is the ID where the query started from. + +endCursor is where the query ended. +""" +type PageInfo { + hasNextPage: Boolean! + startCursor: ID + endCursor: ID +} diff --git a/pkg/assembler/graphql/schema/path.graphql b/pkg/assembler/graphql/schema/path.graphql index 7db830bc54a..66d054857b1 100644 --- a/pkg/assembler/graphql/schema/path.graphql +++ b/pkg/assembler/graphql/schema/path.graphql @@ -152,6 +152,35 @@ enum Edge { VULN_METADATA_VULNERABILITY } + +""" +NeighborConnection returns the paginated results for Neighbor. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the NeighborEdge which contains the current cursor +and the node itself +""" +type NeighborConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [NeighborEdge!]! +} + +""" +NeighborEdge contains the cursor for the resulting node and +the node itself. +""" +type NeighborEdge { + cursor: ID! + node: Node! +} + + extend type Query { """ path query returns a path between subject and target, of a maximum length. @@ -178,6 +207,8 @@ extend type Query { contain the corresponding GUAC evidence trees (GUAC verbs). """ neighbors(node: ID!, usingOnly: [Edge!]!): [Node!]! + "Returns a paginated results via NeighborConnection" + neighborsList(node: ID!, usingOnly: [Edge!]!, after: ID, first: Int): NeighborConnection """ node returns a single node, regardless of type. diff --git a/pkg/assembler/graphql/schema/pkgEqual.graphql b/pkg/assembler/graphql/schema/pkgEqual.graphql index 8d4f702be8f..75723b7e94f 100644 --- a/pkg/assembler/graphql/schema/pkgEqual.graphql +++ b/pkg/assembler/graphql/schema/pkgEqual.graphql @@ -56,9 +56,38 @@ input PkgEqualInputSpec { documentRef: String! } +""" +PkgEqualConnection returns the paginated results for PkgEqual. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the PkgEqualEdge which contains the current cursor +and the PkgEqual node itself +""" +type PkgEqualConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [PkgEqualEdge!]! +} + +""" +PkgEqualEdge contains the cursor for the resulting node and +the PkgEqual node itself. +""" +type PkgEqualEdge { + cursor: ID! + node: PkgEqual! +} + extend type Query { "Returns all package equality statements matching a filter." PkgEqual(pkgEqualSpec: PkgEqualSpec!): [PkgEqual!]! + "Returns a paginated results via PkgEqualConnection" + PkgEqualList(pkgEqualSpec: PkgEqualSpec!, after: ID, first: Int): PkgEqualConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/search.graphql b/pkg/assembler/graphql/schema/search.graphql index 16a98c40dde..77a874fa016 100644 --- a/pkg/assembler/graphql/schema/search.graphql +++ b/pkg/assembler/graphql/schema/search.graphql @@ -13,6 +13,34 @@ # See the License for the specific language governing permissions and # limitations under the License. + +""" +FindSoftwareConnection returns the paginated results for FindSoftware. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the SoftwareEdge which contains the current cursor +and the PackageSourceOrArtifact node itself +""" +type FindSoftwareConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [SoftwareEdge!]! +} + +""" +SoftwareEdge contains the cursor for the resulting node and +the PackageSourceOrArtifact node itself. +""" +type SoftwareEdge { + cursor: ID! + node: PackageSourceOrArtifact! +} + extend type Query { """ findSoftware takes in a searchText string and looks for software @@ -34,4 +62,6 @@ extend type Query { implement this API. """ findSoftware(searchText: String!): [PackageSourceOrArtifact!]! + "Returns a paginated results via CertifyBadConnection" + findSoftwareList(searchText: String!, after: ID, first: Int): FindSoftwareConnection } diff --git a/pkg/assembler/graphql/schema/source.graphql b/pkg/assembler/graphql/schema/source.graphql index e35eea814dd..dc8a81e127b 100644 --- a/pkg/assembler/graphql/schema/source.graphql +++ b/pkg/assembler/graphql/schema/source.graphql @@ -124,9 +124,38 @@ input IDorSourceInput { sourceInput: SourceInputSpec } +""" +SourceConnection returns the paginated results for Source. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the SourceEdge which contains the current cursor +and the Source node itself +""" +type SourceConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [SourceEdge!]! +} + +""" +SourceEdge contains the cursor for the resulting node and +the Source node itself. +""" +type SourceEdge { + cursor: ID! + node: Source! +} + extend type Query { "Returns all sources matching a filter." sources(sourceSpec: SourceSpec!): [Source!]! + "Returns a paginated results via SourceConnection" + sourcesList(sourceSpec: SourceSpec!, after: ID, first: Int): SourceConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/vulnEqual.graphql b/pkg/assembler/graphql/schema/vulnEqual.graphql index 5823ec9fe3e..1d8d70a8ff3 100644 --- a/pkg/assembler/graphql/schema/vulnEqual.graphql +++ b/pkg/assembler/graphql/schema/vulnEqual.graphql @@ -57,9 +57,38 @@ input VulnEqualInputSpec { documentRef: String! } +""" +VulnEqualConnection returns the paginated results for VulnEqual. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the VulnEqualEdge which contains the current cursor +and the VulnEqual node itself +""" +type VulnEqualConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [VulnEqualEdge!]! +} + +""" +VulnEqualEdge contains the cursor for the resulting node and +the VulnEqual node itself. +""" +type VulnEqualEdge { + cursor: ID! + node: VulnEqual! +} + extend type Query { "Returns all equal vulnerability mappings that match a filter." vulnEqual(vulnEqualSpec: VulnEqualSpec!): [VulnEqual!]! + "Returns a paginated results via VulnEqualConnection" + vulnEqualList(vulnEqualSpec: VulnEqualSpec!, after: ID, first: Int): VulnEqualConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/vulnMetadata.graphql b/pkg/assembler/graphql/schema/vulnMetadata.graphql index 7531ebab4b3..f5b812718ab 100644 --- a/pkg/assembler/graphql/schema/vulnMetadata.graphql +++ b/pkg/assembler/graphql/schema/vulnMetadata.graphql @@ -112,9 +112,38 @@ input VulnerabilityMetadataInputSpec { documentRef: String! } +""" +VulnerabilityMetadataConnection returns the paginated results for VulnerabilityMetadata. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the VulnerabilityMetadataEdge which contains the current cursor +and the VulnerabilityMetadata node itself +""" +type VulnerabilityMetadataConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [VulnerabilityMetadataEdge!]! +} + +""" +VulnerabilityMetadataEdge contains the cursor for the resulting node and +the VulnerabilityMetadata node itself. +""" +type VulnerabilityMetadataEdge { + cursor: ID! + node: VulnerabilityMetadata! +} + extend type Query { "Returns all vulnerabilityMetadata attestations matching a filter." vulnerabilityMetadata(vulnerabilityMetadataSpec: VulnerabilityMetadataSpec!): [VulnerabilityMetadata!]! + "Returns a paginated results via VulnerabilityMetadataConnection" + vulnerabilityMetadataList(vulnerabilityMetadataSpec: VulnerabilityMetadataSpec!, after: ID, first: Int): VulnerabilityMetadataConnection } extend type Mutation { diff --git a/pkg/assembler/graphql/schema/vulnerability.graphql b/pkg/assembler/graphql/schema/vulnerability.graphql index 69d95c8e8e2..d2003958b43 100644 --- a/pkg/assembler/graphql/schema/vulnerability.graphql +++ b/pkg/assembler/graphql/schema/vulnerability.graphql @@ -115,9 +115,38 @@ input IDorVulnerabilityInput { vulnerabilityInput: VulnerabilityInputSpec } +""" +VulnerabilityConnection returns the paginated results for Vulnerability. + +totalCount is the total number of results returned. + +pageInfo provides information to the client if there is +a next page of results and the starting and +ending cursor for the current set. + +edges contains the VulnerabilityEdge which contains the current cursor +and the Vulnerability node itself +""" +type VulnerabilityConnection { + totalCount: Int! + pageInfo: PageInfo! + edges: [VulnerabilityEdge!]! +} + +""" +VulnerabilityEdge contains the cursor for the resulting node and +the Vulnerability node itself. +""" +type VulnerabilityEdge { + cursor: ID! + node: Vulnerability! +} + extend type Query { "Returns all vulnerabilities matching a filter." vulnerabilities(vulnSpec: VulnerabilitySpec!): [Vulnerability!]! + "Returns a paginated results via VulnerabilityConnection" + vulnerabilityList(vulnSpec: VulnerabilitySpec!, after: ID, first: Int): VulnerabilityConnection } extend type Mutation { From b5e2b39656b545987a4656a8b1495165f429cce3 Mon Sep 17 00:00:00 2001 From: Rakshit Gondwal <98955085+rakshitgondwal@users.noreply.github.com> Date: Thu, 25 Apr 2024 21:50:16 +0530 Subject: [PATCH 11/17] feat: switch golang/mock to uber-go/mock (#1866) Signed-off-by: Rakshit Gondwal --- go.mod | 2 +- go.sum | 9 +- internal/testing/mocks/backend.go | 155 +++++++++--------- internal/testing/mocks/documentparser.go | 15 +- internal/testing/mocks/mockgen.go | 6 +- internal/testing/mocks/scorecard.go | 9 +- .../resolvers/certifyBad.resolvers_test.go | 2 +- .../resolvers/certifyGood.resolvers_test.go | 2 +- .../resolvers/certifyLegal.resolvers_test.go | 2 +- .../certifyScorecard.resolvers_test.go | 2 +- .../certifyVEXStatement.resolvers_test.go | 2 +- .../resolvers/certifyVuln.resolvers_test.go | 2 +- .../resolvers/contact.resolvers_test.go | 2 +- .../resolvers/hasSBOM.resolvers_test.go | 2 +- .../resolvers/hasSLSA.resolvers_test.go | 2 +- .../resolvers/hasSourceAt.resolvers_test.go | 2 +- .../resolvers/hashEqual.resolvers_test.go | 2 +- .../resolvers/isDependency.resolvers_test.go | 2 +- .../resolvers/isOccurrence.resolvers_test.go | 2 +- .../resolvers/license.resolvers_test.go | 2 +- .../resolvers/metadata.resolvers_test.go | 2 +- .../resolvers/package.resolver_test.go | 2 +- .../graphql/resolvers/path.resolvers_test.go | 2 +- .../resolvers/pkgEqual.resolvers_test.go | 2 +- .../resolvers/source.resolvers_test.go | 2 +- .../resolvers/vulnEqual.resolvers_test.go | 2 +- .../resolvers/vulnMetadata.resolvers_test.go | 2 +- .../resolvers/vulnerability.resolvers_test.go | 2 +- pkg/certifier/scorecard/scorecard_test.go | 2 +- .../collector/deps_dev/deps_dev_test.go | 2 +- pkg/ingestor/parser/parser_test.go | 5 +- tools/tools.go | 2 +- 32 files changed, 131 insertions(+), 120 deletions(-) diff --git a/go.mod b/go.mod index c3fe040a31c..68234ef3997 100644 --- a/go.mod +++ b/go.mod @@ -291,7 +291,6 @@ require ( github.com/go-git/go-git/v5 v5.12.0 github.com/gobwas/glob v0.2.3 github.com/gofrs/uuid v4.4.0+incompatible - github.com/golang/mock v1.6.0 github.com/google/go-github/v50 v50.2.0 github.com/google/osv-scanner v1.7.1 github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 @@ -322,6 +321,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/tikv/client-go/v2 v2.0.8-0.20231115083414-7c96dfd783fb github.com/vektah/gqlparser/v2 v2.5.11 + go.uber.org/mock v0.4.0 gocloud.dev v0.37.0 gocloud.dev/pubsub/kafkapubsub v0.37.0 gocloud.dev/pubsub/rabbitpubsub v0.37.0 diff --git a/go.sum b/go.sum index ebaed6cd16e..b897b8ad3d9 100644 --- a/go.sum +++ b/go.sum @@ -801,7 +801,6 @@ github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7v github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= @@ -836,6 +835,8 @@ go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -875,7 +876,6 @@ golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhp golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= @@ -897,7 +897,6 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -920,7 +919,6 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= @@ -943,9 +941,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210608053332-aa57babbf139/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1007,7 +1003,6 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= diff --git a/internal/testing/mocks/backend.go b/internal/testing/mocks/backend.go index 81ab3247173..5fd9df0e43b 100644 --- a/internal/testing/mocks/backend.go +++ b/internal/testing/mocks/backend.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: ../../../pkg/assembler/backends/backends.go +// +// Generated by this command: +// +// mockgen -source=../../../pkg/assembler/backends/backends.go -destination=../../../internal/testing/mocks/backend.go -package mocks +// // Package mocks is a generated GoMock package. package mocks @@ -8,8 +13,8 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" model "github.com/guacsec/guac/pkg/assembler/graphql/model" + gomock "go.uber.org/mock/gomock" ) // MockBackend is a mock of Backend interface. @@ -45,7 +50,7 @@ func (m *MockBackend) Artifacts(ctx context.Context, artifactSpec *model.Artifac } // Artifacts indicates an expected call of Artifacts. -func (mr *MockBackendMockRecorder) Artifacts(ctx, artifactSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) Artifacts(ctx, artifactSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Artifacts", reflect.TypeOf((*MockBackend)(nil).Artifacts), ctx, artifactSpec) } @@ -75,7 +80,7 @@ func (m *MockBackend) Builders(ctx context.Context, builderSpec *model.BuilderSp } // Builders indicates an expected call of Builders. -func (mr *MockBackendMockRecorder) Builders(ctx, builderSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) Builders(ctx, builderSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Builders", reflect.TypeOf((*MockBackend)(nil).Builders), ctx, builderSpec) } @@ -105,7 +110,7 @@ func (m *MockBackend) CertifyBad(ctx context.Context, certifyBadSpec *model.Cert } // CertifyBad indicates an expected call of CertifyBad. -func (mr *MockBackendMockRecorder) CertifyBad(ctx, certifyBadSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) CertifyBad(ctx, certifyBadSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyBad", reflect.TypeOf((*MockBackend)(nil).CertifyBad), ctx, certifyBadSpec) } @@ -135,7 +140,7 @@ func (m *MockBackend) CertifyGood(ctx context.Context, certifyGoodSpec *model.Ce } // CertifyGood indicates an expected call of CertifyGood. -func (mr *MockBackendMockRecorder) CertifyGood(ctx, certifyGoodSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) CertifyGood(ctx, certifyGoodSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyGood", reflect.TypeOf((*MockBackend)(nil).CertifyGood), ctx, certifyGoodSpec) } @@ -165,7 +170,7 @@ func (m *MockBackend) CertifyLegal(ctx context.Context, certifyLegalSpec *model. } // CertifyLegal indicates an expected call of CertifyLegal. -func (mr *MockBackendMockRecorder) CertifyLegal(ctx, certifyLegalSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) CertifyLegal(ctx, certifyLegalSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyLegal", reflect.TypeOf((*MockBackend)(nil).CertifyLegal), ctx, certifyLegalSpec) } @@ -195,7 +200,7 @@ func (m *MockBackend) CertifyVEXStatement(ctx context.Context, certifyVEXStateme } // CertifyVEXStatement indicates an expected call of CertifyVEXStatement. -func (mr *MockBackendMockRecorder) CertifyVEXStatement(ctx, certifyVEXStatementSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) CertifyVEXStatement(ctx, certifyVEXStatementSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyVEXStatement", reflect.TypeOf((*MockBackend)(nil).CertifyVEXStatement), ctx, certifyVEXStatementSpec) } @@ -225,7 +230,7 @@ func (m *MockBackend) CertifyVuln(ctx context.Context, certifyVulnSpec *model.Ce } // CertifyVuln indicates an expected call of CertifyVuln. -func (mr *MockBackendMockRecorder) CertifyVuln(ctx, certifyVulnSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) CertifyVuln(ctx, certifyVulnSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyVuln", reflect.TypeOf((*MockBackend)(nil).CertifyVuln), ctx, certifyVulnSpec) } @@ -255,7 +260,7 @@ func (m *MockBackend) FindSoftware(ctx context.Context, searchText string) ([]mo } // FindSoftware indicates an expected call of FindSoftware. -func (mr *MockBackendMockRecorder) FindSoftware(ctx, searchText interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) FindSoftware(ctx, searchText any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindSoftware", reflect.TypeOf((*MockBackend)(nil).FindSoftware), ctx, searchText) } @@ -285,7 +290,7 @@ func (m *MockBackend) HasMetadata(ctx context.Context, hasMetadataSpec *model.Ha } // HasMetadata indicates an expected call of HasMetadata. -func (mr *MockBackendMockRecorder) HasMetadata(ctx, hasMetadataSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) HasMetadata(ctx, hasMetadataSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasMetadata", reflect.TypeOf((*MockBackend)(nil).HasMetadata), ctx, hasMetadataSpec) } @@ -315,7 +320,7 @@ func (m *MockBackend) HasSBOM(ctx context.Context, hasSBOMSpec *model.HasSBOMSpe } // HasSBOM indicates an expected call of HasSBOM. -func (mr *MockBackendMockRecorder) HasSBOM(ctx, hasSBOMSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) HasSBOM(ctx, hasSBOMSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSBOM", reflect.TypeOf((*MockBackend)(nil).HasSBOM), ctx, hasSBOMSpec) } @@ -360,7 +365,7 @@ func (m *MockBackend) HasSlsa(ctx context.Context, hasSLSASpec *model.HasSLSASpe } // HasSlsa indicates an expected call of HasSlsa. -func (mr *MockBackendMockRecorder) HasSlsa(ctx, hasSLSASpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) HasSlsa(ctx, hasSLSASpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSlsa", reflect.TypeOf((*MockBackend)(nil).HasSlsa), ctx, hasSLSASpec) } @@ -375,7 +380,7 @@ func (m *MockBackend) HasSourceAt(ctx context.Context, hasSourceAtSpec *model.Ha } // HasSourceAt indicates an expected call of HasSourceAt. -func (mr *MockBackendMockRecorder) HasSourceAt(ctx, hasSourceAtSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) HasSourceAt(ctx, hasSourceAtSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSourceAt", reflect.TypeOf((*MockBackend)(nil).HasSourceAt), ctx, hasSourceAtSpec) } @@ -405,7 +410,7 @@ func (m *MockBackend) HashEqual(ctx context.Context, hashEqualSpec *model.HashEq } // HashEqual indicates an expected call of HashEqual. -func (mr *MockBackendMockRecorder) HashEqual(ctx, hashEqualSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) HashEqual(ctx, hashEqualSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HashEqual", reflect.TypeOf((*MockBackend)(nil).HashEqual), ctx, hashEqualSpec) } @@ -435,7 +440,7 @@ func (m *MockBackend) IngestArtifact(ctx context.Context, artifact *model.IDorAr } // IngestArtifact indicates an expected call of IngestArtifact. -func (mr *MockBackendMockRecorder) IngestArtifact(ctx, artifact interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestArtifact(ctx, artifact any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestArtifact", reflect.TypeOf((*MockBackend)(nil).IngestArtifact), ctx, artifact) } @@ -450,7 +455,7 @@ func (m *MockBackend) IngestArtifacts(ctx context.Context, artifacts []*model.ID } // IngestArtifacts indicates an expected call of IngestArtifacts. -func (mr *MockBackendMockRecorder) IngestArtifacts(ctx, artifacts interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestArtifacts(ctx, artifacts any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestArtifacts", reflect.TypeOf((*MockBackend)(nil).IngestArtifacts), ctx, artifacts) } @@ -465,7 +470,7 @@ func (m *MockBackend) IngestBuilder(ctx context.Context, builder *model.IDorBuil } // IngestBuilder indicates an expected call of IngestBuilder. -func (mr *MockBackendMockRecorder) IngestBuilder(ctx, builder interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestBuilder(ctx, builder any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestBuilder", reflect.TypeOf((*MockBackend)(nil).IngestBuilder), ctx, builder) } @@ -480,7 +485,7 @@ func (m *MockBackend) IngestBuilders(ctx context.Context, builders []*model.IDor } // IngestBuilders indicates an expected call of IngestBuilders. -func (mr *MockBackendMockRecorder) IngestBuilders(ctx, builders interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestBuilders(ctx, builders any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestBuilders", reflect.TypeOf((*MockBackend)(nil).IngestBuilders), ctx, builders) } @@ -495,7 +500,7 @@ func (m *MockBackend) IngestBulkHasMetadata(ctx context.Context, subjects model. } // IngestBulkHasMetadata indicates an expected call of IngestBulkHasMetadata. -func (mr *MockBackendMockRecorder) IngestBulkHasMetadata(ctx, subjects, pkgMatchType, hasMetadataList interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestBulkHasMetadata(ctx, subjects, pkgMatchType, hasMetadataList any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestBulkHasMetadata", reflect.TypeOf((*MockBackend)(nil).IngestBulkHasMetadata), ctx, subjects, pkgMatchType, hasMetadataList) } @@ -510,7 +515,7 @@ func (m *MockBackend) IngestBulkVulnerabilityMetadata(ctx context.Context, vulne } // IngestBulkVulnerabilityMetadata indicates an expected call of IngestBulkVulnerabilityMetadata. -func (mr *MockBackendMockRecorder) IngestBulkVulnerabilityMetadata(ctx, vulnerabilities, vulnerabilityMetadataList interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestBulkVulnerabilityMetadata(ctx, vulnerabilities, vulnerabilityMetadataList any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestBulkVulnerabilityMetadata", reflect.TypeOf((*MockBackend)(nil).IngestBulkVulnerabilityMetadata), ctx, vulnerabilities, vulnerabilityMetadataList) } @@ -525,7 +530,7 @@ func (m *MockBackend) IngestCertifyBad(ctx context.Context, subject model.Packag } // IngestCertifyBad indicates an expected call of IngestCertifyBad. -func (mr *MockBackendMockRecorder) IngestCertifyBad(ctx, subject, pkgMatchType, certifyBad interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestCertifyBad(ctx, subject, pkgMatchType, certifyBad any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestCertifyBad", reflect.TypeOf((*MockBackend)(nil).IngestCertifyBad), ctx, subject, pkgMatchType, certifyBad) } @@ -540,7 +545,7 @@ func (m *MockBackend) IngestCertifyBads(ctx context.Context, subjects model.Pack } // IngestCertifyBads indicates an expected call of IngestCertifyBads. -func (mr *MockBackendMockRecorder) IngestCertifyBads(ctx, subjects, pkgMatchType, certifyBads interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestCertifyBads(ctx, subjects, pkgMatchType, certifyBads any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestCertifyBads", reflect.TypeOf((*MockBackend)(nil).IngestCertifyBads), ctx, subjects, pkgMatchType, certifyBads) } @@ -555,7 +560,7 @@ func (m *MockBackend) IngestCertifyGood(ctx context.Context, subject model.Packa } // IngestCertifyGood indicates an expected call of IngestCertifyGood. -func (mr *MockBackendMockRecorder) IngestCertifyGood(ctx, subject, pkgMatchType, certifyGood interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestCertifyGood(ctx, subject, pkgMatchType, certifyGood any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestCertifyGood", reflect.TypeOf((*MockBackend)(nil).IngestCertifyGood), ctx, subject, pkgMatchType, certifyGood) } @@ -570,7 +575,7 @@ func (m *MockBackend) IngestCertifyGoods(ctx context.Context, subjects model.Pac } // IngestCertifyGoods indicates an expected call of IngestCertifyGoods. -func (mr *MockBackendMockRecorder) IngestCertifyGoods(ctx, subjects, pkgMatchType, certifyGoods interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestCertifyGoods(ctx, subjects, pkgMatchType, certifyGoods any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestCertifyGoods", reflect.TypeOf((*MockBackend)(nil).IngestCertifyGoods), ctx, subjects, pkgMatchType, certifyGoods) } @@ -585,7 +590,7 @@ func (m *MockBackend) IngestCertifyLegal(ctx context.Context, subject model.Pack } // IngestCertifyLegal indicates an expected call of IngestCertifyLegal. -func (mr *MockBackendMockRecorder) IngestCertifyLegal(ctx, subject, declaredLicenses, discoveredLicenses, certifyLegal interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestCertifyLegal(ctx, subject, declaredLicenses, discoveredLicenses, certifyLegal any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestCertifyLegal", reflect.TypeOf((*MockBackend)(nil).IngestCertifyLegal), ctx, subject, declaredLicenses, discoveredLicenses, certifyLegal) } @@ -600,7 +605,7 @@ func (m *MockBackend) IngestCertifyLegals(ctx context.Context, subjects model.Pa } // IngestCertifyLegals indicates an expected call of IngestCertifyLegals. -func (mr *MockBackendMockRecorder) IngestCertifyLegals(ctx, subjects, declaredLicensesList, discoveredLicensesList, certifyLegals interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestCertifyLegals(ctx, subjects, declaredLicensesList, discoveredLicensesList, certifyLegals any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestCertifyLegals", reflect.TypeOf((*MockBackend)(nil).IngestCertifyLegals), ctx, subjects, declaredLicensesList, discoveredLicensesList, certifyLegals) } @@ -615,7 +620,7 @@ func (m *MockBackend) IngestCertifyVuln(ctx context.Context, pkg model.IDorPkgIn } // IngestCertifyVuln indicates an expected call of IngestCertifyVuln. -func (mr *MockBackendMockRecorder) IngestCertifyVuln(ctx, pkg, vulnerability, certifyVuln interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestCertifyVuln(ctx, pkg, vulnerability, certifyVuln any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestCertifyVuln", reflect.TypeOf((*MockBackend)(nil).IngestCertifyVuln), ctx, pkg, vulnerability, certifyVuln) } @@ -630,7 +635,7 @@ func (m *MockBackend) IngestCertifyVulns(ctx context.Context, pkgs []*model.IDor } // IngestCertifyVulns indicates an expected call of IngestCertifyVulns. -func (mr *MockBackendMockRecorder) IngestCertifyVulns(ctx, pkgs, vulnerabilities, certifyVulns interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestCertifyVulns(ctx, pkgs, vulnerabilities, certifyVulns any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestCertifyVulns", reflect.TypeOf((*MockBackend)(nil).IngestCertifyVulns), ctx, pkgs, vulnerabilities, certifyVulns) } @@ -645,7 +650,7 @@ func (m *MockBackend) IngestDependencies(ctx context.Context, pkgs, depPkgs []*m } // IngestDependencies indicates an expected call of IngestDependencies. -func (mr *MockBackendMockRecorder) IngestDependencies(ctx, pkgs, depPkgs, depPkgMatchType, dependencies interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestDependencies(ctx, pkgs, depPkgs, depPkgMatchType, dependencies any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestDependencies", reflect.TypeOf((*MockBackend)(nil).IngestDependencies), ctx, pkgs, depPkgs, depPkgMatchType, dependencies) } @@ -660,7 +665,7 @@ func (m *MockBackend) IngestDependency(ctx context.Context, pkg, depPkg model.ID } // IngestDependency indicates an expected call of IngestDependency. -func (mr *MockBackendMockRecorder) IngestDependency(ctx, pkg, depPkg, depPkgMatchType, dependency interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestDependency(ctx, pkg, depPkg, depPkgMatchType, dependency any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestDependency", reflect.TypeOf((*MockBackend)(nil).IngestDependency), ctx, pkg, depPkg, depPkgMatchType, dependency) } @@ -675,7 +680,7 @@ func (m *MockBackend) IngestHasMetadata(ctx context.Context, subject model.Packa } // IngestHasMetadata indicates an expected call of IngestHasMetadata. -func (mr *MockBackendMockRecorder) IngestHasMetadata(ctx, subject, pkgMatchType, hasMetadata interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestHasMetadata(ctx, subject, pkgMatchType, hasMetadata any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestHasMetadata", reflect.TypeOf((*MockBackend)(nil).IngestHasMetadata), ctx, subject, pkgMatchType, hasMetadata) } @@ -690,7 +695,7 @@ func (m *MockBackend) IngestHasSBOMs(ctx context.Context, subjects model.Package } // IngestHasSBOMs indicates an expected call of IngestHasSBOMs. -func (mr *MockBackendMockRecorder) IngestHasSBOMs(ctx, subjects, hasSBOMs, includes interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestHasSBOMs(ctx, subjects, hasSBOMs, includes any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestHasSBOMs", reflect.TypeOf((*MockBackend)(nil).IngestHasSBOMs), ctx, subjects, hasSBOMs, includes) } @@ -705,7 +710,7 @@ func (m *MockBackend) IngestHasSbom(ctx context.Context, subject model.PackageOr } // IngestHasSbom indicates an expected call of IngestHasSbom. -func (mr *MockBackendMockRecorder) IngestHasSbom(ctx, subject, hasSbom, includes interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestHasSbom(ctx, subject, hasSbom, includes any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestHasSbom", reflect.TypeOf((*MockBackend)(nil).IngestHasSbom), ctx, subject, hasSbom, includes) } @@ -720,7 +725,7 @@ func (m *MockBackend) IngestHasSourceAt(ctx context.Context, pkg model.IDorPkgIn } // IngestHasSourceAt indicates an expected call of IngestHasSourceAt. -func (mr *MockBackendMockRecorder) IngestHasSourceAt(ctx, pkg, pkgMatchType, source, hasSourceAt interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestHasSourceAt(ctx, pkg, pkgMatchType, source, hasSourceAt any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestHasSourceAt", reflect.TypeOf((*MockBackend)(nil).IngestHasSourceAt), ctx, pkg, pkgMatchType, source, hasSourceAt) } @@ -735,7 +740,7 @@ func (m *MockBackend) IngestHasSourceAts(ctx context.Context, pkgs []*model.IDor } // IngestHasSourceAts indicates an expected call of IngestHasSourceAts. -func (mr *MockBackendMockRecorder) IngestHasSourceAts(ctx, pkgs, pkgMatchType, sources, hasSourceAts interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestHasSourceAts(ctx, pkgs, pkgMatchType, sources, hasSourceAts any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestHasSourceAts", reflect.TypeOf((*MockBackend)(nil).IngestHasSourceAts), ctx, pkgs, pkgMatchType, sources, hasSourceAts) } @@ -750,7 +755,7 @@ func (m *MockBackend) IngestHashEqual(ctx context.Context, artifact, equalArtifa } // IngestHashEqual indicates an expected call of IngestHashEqual. -func (mr *MockBackendMockRecorder) IngestHashEqual(ctx, artifact, equalArtifact, hashEqual interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestHashEqual(ctx, artifact, equalArtifact, hashEqual any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestHashEqual", reflect.TypeOf((*MockBackend)(nil).IngestHashEqual), ctx, artifact, equalArtifact, hashEqual) } @@ -765,7 +770,7 @@ func (m *MockBackend) IngestHashEquals(ctx context.Context, artifacts, otherArti } // IngestHashEquals indicates an expected call of IngestHashEquals. -func (mr *MockBackendMockRecorder) IngestHashEquals(ctx, artifacts, otherArtifacts, hashEquals interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestHashEquals(ctx, artifacts, otherArtifacts, hashEquals any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestHashEquals", reflect.TypeOf((*MockBackend)(nil).IngestHashEquals), ctx, artifacts, otherArtifacts, hashEquals) } @@ -780,7 +785,7 @@ func (m *MockBackend) IngestLicense(ctx context.Context, license *model.IDorLice } // IngestLicense indicates an expected call of IngestLicense. -func (mr *MockBackendMockRecorder) IngestLicense(ctx, license interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestLicense(ctx, license any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestLicense", reflect.TypeOf((*MockBackend)(nil).IngestLicense), ctx, license) } @@ -795,7 +800,7 @@ func (m *MockBackend) IngestLicenses(ctx context.Context, licenses []*model.IDor } // IngestLicenses indicates an expected call of IngestLicenses. -func (mr *MockBackendMockRecorder) IngestLicenses(ctx, licenses interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestLicenses(ctx, licenses any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestLicenses", reflect.TypeOf((*MockBackend)(nil).IngestLicenses), ctx, licenses) } @@ -810,7 +815,7 @@ func (m *MockBackend) IngestOccurrence(ctx context.Context, subject model.Packag } // IngestOccurrence indicates an expected call of IngestOccurrence. -func (mr *MockBackendMockRecorder) IngestOccurrence(ctx, subject, artifact, occurrence interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestOccurrence(ctx, subject, artifact, occurrence any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestOccurrence", reflect.TypeOf((*MockBackend)(nil).IngestOccurrence), ctx, subject, artifact, occurrence) } @@ -825,7 +830,7 @@ func (m *MockBackend) IngestOccurrences(ctx context.Context, subjects model.Pack } // IngestOccurrences indicates an expected call of IngestOccurrences. -func (mr *MockBackendMockRecorder) IngestOccurrences(ctx, subjects, artifacts, occurrences interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestOccurrences(ctx, subjects, artifacts, occurrences any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestOccurrences", reflect.TypeOf((*MockBackend)(nil).IngestOccurrences), ctx, subjects, artifacts, occurrences) } @@ -840,7 +845,7 @@ func (m *MockBackend) IngestPackage(ctx context.Context, pkg model.IDorPkgInput) } // IngestPackage indicates an expected call of IngestPackage. -func (mr *MockBackendMockRecorder) IngestPackage(ctx, pkg interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestPackage(ctx, pkg any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestPackage", reflect.TypeOf((*MockBackend)(nil).IngestPackage), ctx, pkg) } @@ -855,7 +860,7 @@ func (m *MockBackend) IngestPackages(ctx context.Context, pkgs []*model.IDorPkgI } // IngestPackages indicates an expected call of IngestPackages. -func (mr *MockBackendMockRecorder) IngestPackages(ctx, pkgs interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestPackages(ctx, pkgs any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestPackages", reflect.TypeOf((*MockBackend)(nil).IngestPackages), ctx, pkgs) } @@ -870,7 +875,7 @@ func (m *MockBackend) IngestPkgEqual(ctx context.Context, pkg, depPkg model.IDor } // IngestPkgEqual indicates an expected call of IngestPkgEqual. -func (mr *MockBackendMockRecorder) IngestPkgEqual(ctx, pkg, depPkg, pkgEqual interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestPkgEqual(ctx, pkg, depPkg, pkgEqual any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestPkgEqual", reflect.TypeOf((*MockBackend)(nil).IngestPkgEqual), ctx, pkg, depPkg, pkgEqual) } @@ -885,7 +890,7 @@ func (m *MockBackend) IngestPkgEquals(ctx context.Context, pkgs, otherPackages [ } // IngestPkgEquals indicates an expected call of IngestPkgEquals. -func (mr *MockBackendMockRecorder) IngestPkgEquals(ctx, pkgs, otherPackages, pkgEquals interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestPkgEquals(ctx, pkgs, otherPackages, pkgEquals any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestPkgEquals", reflect.TypeOf((*MockBackend)(nil).IngestPkgEquals), ctx, pkgs, otherPackages, pkgEquals) } @@ -900,7 +905,7 @@ func (m *MockBackend) IngestPointOfContact(ctx context.Context, subject model.Pa } // IngestPointOfContact indicates an expected call of IngestPointOfContact. -func (mr *MockBackendMockRecorder) IngestPointOfContact(ctx, subject, pkgMatchType, pointOfContact interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestPointOfContact(ctx, subject, pkgMatchType, pointOfContact any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestPointOfContact", reflect.TypeOf((*MockBackend)(nil).IngestPointOfContact), ctx, subject, pkgMatchType, pointOfContact) } @@ -915,7 +920,7 @@ func (m *MockBackend) IngestPointOfContacts(ctx context.Context, subjects model. } // IngestPointOfContacts indicates an expected call of IngestPointOfContacts. -func (mr *MockBackendMockRecorder) IngestPointOfContacts(ctx, subjects, pkgMatchType, pointOfContacts interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestPointOfContacts(ctx, subjects, pkgMatchType, pointOfContacts any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestPointOfContacts", reflect.TypeOf((*MockBackend)(nil).IngestPointOfContacts), ctx, subjects, pkgMatchType, pointOfContacts) } @@ -930,7 +935,7 @@ func (m *MockBackend) IngestSLSA(ctx context.Context, subject model.IDorArtifact } // IngestSLSA indicates an expected call of IngestSLSA. -func (mr *MockBackendMockRecorder) IngestSLSA(ctx, subject, builtFrom, builtBy, slsa interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestSLSA(ctx, subject, builtFrom, builtBy, slsa any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestSLSA", reflect.TypeOf((*MockBackend)(nil).IngestSLSA), ctx, subject, builtFrom, builtBy, slsa) } @@ -945,7 +950,7 @@ func (m *MockBackend) IngestSLSAs(ctx context.Context, subjects []*model.IDorArt } // IngestSLSAs indicates an expected call of IngestSLSAs. -func (mr *MockBackendMockRecorder) IngestSLSAs(ctx, subjects, builtFromList, builtByList, slsaList interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestSLSAs(ctx, subjects, builtFromList, builtByList, slsaList any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestSLSAs", reflect.TypeOf((*MockBackend)(nil).IngestSLSAs), ctx, subjects, builtFromList, builtByList, slsaList) } @@ -960,7 +965,7 @@ func (m *MockBackend) IngestScorecard(ctx context.Context, source model.IDorSour } // IngestScorecard indicates an expected call of IngestScorecard. -func (mr *MockBackendMockRecorder) IngestScorecard(ctx, source, scorecard interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestScorecard(ctx, source, scorecard any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestScorecard", reflect.TypeOf((*MockBackend)(nil).IngestScorecard), ctx, source, scorecard) } @@ -975,7 +980,7 @@ func (m *MockBackend) IngestScorecards(ctx context.Context, sources []*model.IDo } // IngestScorecards indicates an expected call of IngestScorecards. -func (mr *MockBackendMockRecorder) IngestScorecards(ctx, sources, scorecards interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestScorecards(ctx, sources, scorecards any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestScorecards", reflect.TypeOf((*MockBackend)(nil).IngestScorecards), ctx, sources, scorecards) } @@ -990,7 +995,7 @@ func (m *MockBackend) IngestSource(ctx context.Context, source model.IDorSourceI } // IngestSource indicates an expected call of IngestSource. -func (mr *MockBackendMockRecorder) IngestSource(ctx, source interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestSource(ctx, source any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestSource", reflect.TypeOf((*MockBackend)(nil).IngestSource), ctx, source) } @@ -1005,7 +1010,7 @@ func (m *MockBackend) IngestSources(ctx context.Context, sources []*model.IDorSo } // IngestSources indicates an expected call of IngestSources. -func (mr *MockBackendMockRecorder) IngestSources(ctx, sources interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestSources(ctx, sources any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestSources", reflect.TypeOf((*MockBackend)(nil).IngestSources), ctx, sources) } @@ -1020,7 +1025,7 @@ func (m *MockBackend) IngestVEXStatement(ctx context.Context, subject model.Pack } // IngestVEXStatement indicates an expected call of IngestVEXStatement. -func (mr *MockBackendMockRecorder) IngestVEXStatement(ctx, subject, vulnerability, vexStatement interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestVEXStatement(ctx, subject, vulnerability, vexStatement any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestVEXStatement", reflect.TypeOf((*MockBackend)(nil).IngestVEXStatement), ctx, subject, vulnerability, vexStatement) } @@ -1035,7 +1040,7 @@ func (m *MockBackend) IngestVEXStatements(ctx context.Context, subjects model.Pa } // IngestVEXStatements indicates an expected call of IngestVEXStatements. -func (mr *MockBackendMockRecorder) IngestVEXStatements(ctx, subjects, vulnerabilities, vexStatements interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestVEXStatements(ctx, subjects, vulnerabilities, vexStatements any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestVEXStatements", reflect.TypeOf((*MockBackend)(nil).IngestVEXStatements), ctx, subjects, vulnerabilities, vexStatements) } @@ -1050,7 +1055,7 @@ func (m *MockBackend) IngestVulnEqual(ctx context.Context, vulnerability, otherV } // IngestVulnEqual indicates an expected call of IngestVulnEqual. -func (mr *MockBackendMockRecorder) IngestVulnEqual(ctx, vulnerability, otherVulnerability, vulnEqual interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestVulnEqual(ctx, vulnerability, otherVulnerability, vulnEqual any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestVulnEqual", reflect.TypeOf((*MockBackend)(nil).IngestVulnEqual), ctx, vulnerability, otherVulnerability, vulnEqual) } @@ -1065,7 +1070,7 @@ func (m *MockBackend) IngestVulnEquals(ctx context.Context, vulnerabilities, oth } // IngestVulnEquals indicates an expected call of IngestVulnEquals. -func (mr *MockBackendMockRecorder) IngestVulnEquals(ctx, vulnerabilities, otherVulnerabilities, vulnEquals interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestVulnEquals(ctx, vulnerabilities, otherVulnerabilities, vulnEquals any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestVulnEquals", reflect.TypeOf((*MockBackend)(nil).IngestVulnEquals), ctx, vulnerabilities, otherVulnerabilities, vulnEquals) } @@ -1080,7 +1085,7 @@ func (m *MockBackend) IngestVulnerabilities(ctx context.Context, vulns []*model. } // IngestVulnerabilities indicates an expected call of IngestVulnerabilities. -func (mr *MockBackendMockRecorder) IngestVulnerabilities(ctx, vulns interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestVulnerabilities(ctx, vulns any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestVulnerabilities", reflect.TypeOf((*MockBackend)(nil).IngestVulnerabilities), ctx, vulns) } @@ -1095,7 +1100,7 @@ func (m *MockBackend) IngestVulnerability(ctx context.Context, vuln model.IDorVu } // IngestVulnerability indicates an expected call of IngestVulnerability. -func (mr *MockBackendMockRecorder) IngestVulnerability(ctx, vuln interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestVulnerability(ctx, vuln any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestVulnerability", reflect.TypeOf((*MockBackend)(nil).IngestVulnerability), ctx, vuln) } @@ -1110,7 +1115,7 @@ func (m *MockBackend) IngestVulnerabilityMetadata(ctx context.Context, vulnerabi } // IngestVulnerabilityMetadata indicates an expected call of IngestVulnerabilityMetadata. -func (mr *MockBackendMockRecorder) IngestVulnerabilityMetadata(ctx, vulnerability, vulnerabilityMetadata interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IngestVulnerabilityMetadata(ctx, vulnerability, vulnerabilityMetadata any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IngestVulnerabilityMetadata", reflect.TypeOf((*MockBackend)(nil).IngestVulnerabilityMetadata), ctx, vulnerability, vulnerabilityMetadata) } @@ -1125,7 +1130,7 @@ func (m *MockBackend) IsDependency(ctx context.Context, isDependencySpec *model. } // IsDependency indicates an expected call of IsDependency. -func (mr *MockBackendMockRecorder) IsDependency(ctx, isDependencySpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IsDependency(ctx, isDependencySpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDependency", reflect.TypeOf((*MockBackend)(nil).IsDependency), ctx, isDependencySpec) } @@ -1155,7 +1160,7 @@ func (m *MockBackend) IsOccurrence(ctx context.Context, isOccurrenceSpec *model. } // IsOccurrence indicates an expected call of IsOccurrence. -func (mr *MockBackendMockRecorder) IsOccurrence(ctx, isOccurrenceSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IsOccurrence(ctx, isOccurrenceSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOccurrence", reflect.TypeOf((*MockBackend)(nil).IsOccurrence), ctx, isOccurrenceSpec) } @@ -1200,7 +1205,7 @@ func (m *MockBackend) Licenses(ctx context.Context, licenseSpec *model.LicenseSp } // Licenses indicates an expected call of Licenses. -func (mr *MockBackendMockRecorder) Licenses(ctx, licenseSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) Licenses(ctx, licenseSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Licenses", reflect.TypeOf((*MockBackend)(nil).Licenses), ctx, licenseSpec) } @@ -1215,7 +1220,7 @@ func (m *MockBackend) Neighbors(ctx context.Context, node string, usingOnly []mo } // Neighbors indicates an expected call of Neighbors. -func (mr *MockBackendMockRecorder) Neighbors(ctx, node, usingOnly interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) Neighbors(ctx, node, usingOnly any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Neighbors", reflect.TypeOf((*MockBackend)(nil).Neighbors), ctx, node, usingOnly) } @@ -1245,7 +1250,7 @@ func (m *MockBackend) Node(ctx context.Context, node string) (model.Node, error) } // Node indicates an expected call of Node. -func (mr *MockBackendMockRecorder) Node(ctx, node interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) Node(ctx, node any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Node", reflect.TypeOf((*MockBackend)(nil).Node), ctx, node) } @@ -1260,7 +1265,7 @@ func (m *MockBackend) Nodes(ctx context.Context, nodes []string) ([]model.Node, } // Nodes indicates an expected call of Nodes. -func (mr *MockBackendMockRecorder) Nodes(ctx, nodes interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) Nodes(ctx, nodes any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Nodes", reflect.TypeOf((*MockBackend)(nil).Nodes), ctx, nodes) } @@ -1275,7 +1280,7 @@ func (m *MockBackend) Packages(ctx context.Context, pkgSpec *model.PkgSpec) ([]* } // Packages indicates an expected call of Packages. -func (mr *MockBackendMockRecorder) Packages(ctx, pkgSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) Packages(ctx, pkgSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Packages", reflect.TypeOf((*MockBackend)(nil).Packages), ctx, pkgSpec) } @@ -1305,7 +1310,7 @@ func (m *MockBackend) Path(ctx context.Context, subject, target string, maxPathL } // Path indicates an expected call of Path. -func (mr *MockBackendMockRecorder) Path(ctx, subject, target, maxPathLength, usingOnly interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) Path(ctx, subject, target, maxPathLength, usingOnly any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Path", reflect.TypeOf((*MockBackend)(nil).Path), ctx, subject, target, maxPathLength, usingOnly) } @@ -1320,7 +1325,7 @@ func (m *MockBackend) PkgEqual(ctx context.Context, pkgEqualSpec *model.PkgEqual } // PkgEqual indicates an expected call of PkgEqual. -func (mr *MockBackendMockRecorder) PkgEqual(ctx, pkgEqualSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) PkgEqual(ctx, pkgEqualSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PkgEqual", reflect.TypeOf((*MockBackend)(nil).PkgEqual), ctx, pkgEqualSpec) } @@ -1350,7 +1355,7 @@ func (m *MockBackend) PointOfContact(ctx context.Context, pointOfContactSpec *mo } // PointOfContact indicates an expected call of PointOfContact. -func (mr *MockBackendMockRecorder) PointOfContact(ctx, pointOfContactSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) PointOfContact(ctx, pointOfContactSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PointOfContact", reflect.TypeOf((*MockBackend)(nil).PointOfContact), ctx, pointOfContactSpec) } @@ -1380,7 +1385,7 @@ func (m *MockBackend) Scorecards(ctx context.Context, certifyScorecardSpec *mode } // Scorecards indicates an expected call of Scorecards. -func (mr *MockBackendMockRecorder) Scorecards(ctx, certifyScorecardSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) Scorecards(ctx, certifyScorecardSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Scorecards", reflect.TypeOf((*MockBackend)(nil).Scorecards), ctx, certifyScorecardSpec) } @@ -1410,7 +1415,7 @@ func (m *MockBackend) Sources(ctx context.Context, sourceSpec *model.SourceSpec) } // Sources indicates an expected call of Sources. -func (mr *MockBackendMockRecorder) Sources(ctx, sourceSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) Sources(ctx, sourceSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Sources", reflect.TypeOf((*MockBackend)(nil).Sources), ctx, sourceSpec) } @@ -1440,7 +1445,7 @@ func (m *MockBackend) VulnEqual(ctx context.Context, vulnEqualSpec *model.VulnEq } // VulnEqual indicates an expected call of VulnEqual. -func (mr *MockBackendMockRecorder) VulnEqual(ctx, vulnEqualSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) VulnEqual(ctx, vulnEqualSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VulnEqual", reflect.TypeOf((*MockBackend)(nil).VulnEqual), ctx, vulnEqualSpec) } @@ -1470,7 +1475,7 @@ func (m *MockBackend) Vulnerabilities(ctx context.Context, vulnSpec *model.Vulne } // Vulnerabilities indicates an expected call of Vulnerabilities. -func (mr *MockBackendMockRecorder) Vulnerabilities(ctx, vulnSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) Vulnerabilities(ctx, vulnSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Vulnerabilities", reflect.TypeOf((*MockBackend)(nil).Vulnerabilities), ctx, vulnSpec) } @@ -1500,7 +1505,7 @@ func (m *MockBackend) VulnerabilityMetadata(ctx context.Context, vulnerabilityMe } // VulnerabilityMetadata indicates an expected call of VulnerabilityMetadata. -func (mr *MockBackendMockRecorder) VulnerabilityMetadata(ctx, vulnerabilityMetadataSpec interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) VulnerabilityMetadata(ctx, vulnerabilityMetadataSpec any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VulnerabilityMetadata", reflect.TypeOf((*MockBackend)(nil).VulnerabilityMetadata), ctx, vulnerabilityMetadataSpec) } diff --git a/internal/testing/mocks/documentparser.go b/internal/testing/mocks/documentparser.go index ddbdb11e190..168988e9929 100644 --- a/internal/testing/mocks/documentparser.go +++ b/internal/testing/mocks/documentparser.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: ../../../pkg/ingestor/parser/common/types.go +// +// Generated by this command: +// +// mockgen -source=../../../pkg/ingestor/parser/common/types.go -destination=../../../internal/testing/mocks/documentparser.go -package mocks +// // Package mocks is a generated GoMock package. package mocks @@ -8,10 +13,10 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" assembler "github.com/guacsec/guac/pkg/assembler" processor "github.com/guacsec/guac/pkg/handler/processor" common "github.com/guacsec/guac/pkg/ingestor/parser/common" + gomock "go.uber.org/mock/gomock" ) // MockDocumentParser is a mock of DocumentParser interface. @@ -47,7 +52,7 @@ func (m *MockDocumentParser) GetIdentifiers(ctx context.Context) (*common.Identi } // GetIdentifiers indicates an expected call of GetIdentifiers. -func (mr *MockDocumentParserMockRecorder) GetIdentifiers(ctx interface{}) *gomock.Call { +func (mr *MockDocumentParserMockRecorder) GetIdentifiers(ctx any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIdentifiers", reflect.TypeOf((*MockDocumentParser)(nil).GetIdentifiers), ctx) } @@ -61,7 +66,7 @@ func (m *MockDocumentParser) GetIdentities(ctx context.Context) []common.TrustIn } // GetIdentities indicates an expected call of GetIdentities. -func (mr *MockDocumentParserMockRecorder) GetIdentities(ctx interface{}) *gomock.Call { +func (mr *MockDocumentParserMockRecorder) GetIdentities(ctx any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetIdentities", reflect.TypeOf((*MockDocumentParser)(nil).GetIdentities), ctx) } @@ -75,7 +80,7 @@ func (m *MockDocumentParser) GetPredicates(ctx context.Context) *assembler.Inges } // GetPredicates indicates an expected call of GetPredicates. -func (mr *MockDocumentParserMockRecorder) GetPredicates(ctx interface{}) *gomock.Call { +func (mr *MockDocumentParserMockRecorder) GetPredicates(ctx any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPredicates", reflect.TypeOf((*MockDocumentParser)(nil).GetPredicates), ctx) } @@ -89,7 +94,7 @@ func (m *MockDocumentParser) Parse(ctx context.Context, doc *processor.Document) } // Parse indicates an expected call of Parse. -func (mr *MockDocumentParserMockRecorder) Parse(ctx, doc interface{}) *gomock.Call { +func (mr *MockDocumentParserMockRecorder) Parse(ctx, doc any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Parse", reflect.TypeOf((*MockDocumentParser)(nil).Parse), ctx, doc) } diff --git a/internal/testing/mocks/mockgen.go b/internal/testing/mocks/mockgen.go index 7a04541e478..e8d233abdfd 100644 --- a/internal/testing/mocks/mockgen.go +++ b/internal/testing/mocks/mockgen.go @@ -15,9 +15,9 @@ package mocks -//go:generate go run github.com/golang/mock/mockgen -source=../../../pkg/certifier/scorecard/types.go -destination=../../../internal/testing/mocks/scorecard.go -package mocks -//go:generate go run github.com/golang/mock/mockgen -source=../../../pkg/ingestor/parser/common/types.go -destination=../../../internal/testing/mocks/documentparser.go -package mocks -//go:generate go run github.com/golang/mock/mockgen -source=../../../pkg/assembler/backends/backends.go -destination=../../../internal/testing/mocks/backend.go -package mocks +//go:generate go run go.uber.org/mock/mockgen -source=../../../pkg/certifier/scorecard/types.go -destination=../../../internal/testing/mocks/scorecard.go -package mocks +//go:generate go run go.uber.org/mock/mockgen -source=../../../pkg/ingestor/parser/common/types.go -destination=../../../internal/testing/mocks/documentparser.go -package mocks +//go:generate go run go.uber.org/mock/mockgen -source=../../../pkg/assembler/backends/backends.go -destination=../../../internal/testing/mocks/backend.go -package mocks // This file is currently empty and used only to allow generating the mocked code via mockgen // by executing `go generate ./...`. diff --git a/internal/testing/mocks/scorecard.go b/internal/testing/mocks/scorecard.go index 5e42b6d6c64..07ae4e9277a 100644 --- a/internal/testing/mocks/scorecard.go +++ b/internal/testing/mocks/scorecard.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: ../../../pkg/certifier/scorecard/types.go +// +// Generated by this command: +// +// mockgen -source=../../../pkg/certifier/scorecard/types.go -destination=../../../internal/testing/mocks/scorecard.go -package mocks +// // Package mocks is a generated GoMock package. package mocks @@ -7,8 +12,8 @@ package mocks import ( reflect "reflect" - gomock "github.com/golang/mock/gomock" pkg "github.com/ossf/scorecard/v4/pkg" + gomock "go.uber.org/mock/gomock" ) // MockScorecard is a mock of Scorecard interface. @@ -44,7 +49,7 @@ func (m *MockScorecard) GetScore(repoName, commitSHA, tag string) (*pkg.Scorecar } // GetScore indicates an expected call of GetScore. -func (mr *MockScorecardMockRecorder) GetScore(repoName, commitSHA, tag interface{}) *gomock.Call { +func (mr *MockScorecardMockRecorder) GetScore(repoName, commitSHA, tag any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetScore", reflect.TypeOf((*MockScorecard)(nil).GetScore), repoName, commitSHA, tag) } diff --git a/pkg/assembler/graphql/resolvers/certifyBad.resolvers_test.go b/pkg/assembler/graphql/resolvers/certifyBad.resolvers_test.go index 4d71033bd4b..8c6f05d3bdf 100644 --- a/pkg/assembler/graphql/resolvers/certifyBad.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/certifyBad.resolvers_test.go @@ -20,12 +20,12 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) var ZeroTime = time.Unix(0, 0) diff --git a/pkg/assembler/graphql/resolvers/certifyGood.resolvers_test.go b/pkg/assembler/graphql/resolvers/certifyGood.resolvers_test.go index fa43f43ec5e..8d04b85373a 100644 --- a/pkg/assembler/graphql/resolvers/certifyGood.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/certifyGood.resolvers_test.go @@ -19,12 +19,12 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestCertifyGood(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/certifyLegal.resolvers_test.go b/pkg/assembler/graphql/resolvers/certifyLegal.resolvers_test.go index ad8c6827f1d..118a3bb8762 100644 --- a/pkg/assembler/graphql/resolvers/certifyLegal.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/certifyLegal.resolvers_test.go @@ -19,12 +19,12 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestCertifyLegal(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/certifyScorecard.resolvers_test.go b/pkg/assembler/graphql/resolvers/certifyScorecard.resolvers_test.go index b8bd0ee51ed..a00b3282970 100644 --- a/pkg/assembler/graphql/resolvers/certifyScorecard.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/certifyScorecard.resolvers_test.go @@ -19,11 +19,11 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestScorecards(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers_test.go b/pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers_test.go index bcaccdb4957..e9f8187f3ef 100644 --- a/pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/certifyVEXStatement.resolvers_test.go @@ -20,12 +20,12 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestVEXStatement(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/certifyVuln.resolvers_test.go b/pkg/assembler/graphql/resolvers/certifyVuln.resolvers_test.go index 4e504768062..0ff59e51014 100644 --- a/pkg/assembler/graphql/resolvers/certifyVuln.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/certifyVuln.resolvers_test.go @@ -20,11 +20,11 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) var t1, _ = time.Parse(time.RFC3339, "2023-01-01T00:00:00Z") diff --git a/pkg/assembler/graphql/resolvers/contact.resolvers_test.go b/pkg/assembler/graphql/resolvers/contact.resolvers_test.go index fa767b1851c..0be25cabdb0 100644 --- a/pkg/assembler/graphql/resolvers/contact.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/contact.resolvers_test.go @@ -20,12 +20,12 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestPointOfContact(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/hasSBOM.resolvers_test.go b/pkg/assembler/graphql/resolvers/hasSBOM.resolvers_test.go index e5ab2a82a29..c37d076f65d 100644 --- a/pkg/assembler/graphql/resolvers/hasSBOM.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/hasSBOM.resolvers_test.go @@ -19,12 +19,12 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestHasSbom(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/hasSLSA.resolvers_test.go b/pkg/assembler/graphql/resolvers/hasSLSA.resolvers_test.go index 2b5f24cdfd7..4a369b5972b 100644 --- a/pkg/assembler/graphql/resolvers/hasSLSA.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/hasSLSA.resolvers_test.go @@ -20,11 +20,11 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestHasSLSA(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/hasSourceAt.resolvers_test.go b/pkg/assembler/graphql/resolvers/hasSourceAt.resolvers_test.go index 91eab5a38f7..ec4db37376b 100644 --- a/pkg/assembler/graphql/resolvers/hasSourceAt.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/hasSourceAt.resolvers_test.go @@ -19,11 +19,11 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestHasSourceAts(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/hashEqual.resolvers_test.go b/pkg/assembler/graphql/resolvers/hashEqual.resolvers_test.go index d46c67144a9..eaae9b808ed 100644 --- a/pkg/assembler/graphql/resolvers/hashEqual.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/hashEqual.resolvers_test.go @@ -19,12 +19,12 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestHashEquals(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/isDependency.resolvers_test.go b/pkg/assembler/graphql/resolvers/isDependency.resolvers_test.go index d9dfd81843c..551c3fb3dfc 100644 --- a/pkg/assembler/graphql/resolvers/isDependency.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/isDependency.resolvers_test.go @@ -20,12 +20,12 @@ import ( "fmt" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" "github.com/vektah/gqlparser/v2/gqlerror" + "go.uber.org/mock/gomock" ) func TestIngestDependency(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/isOccurrence.resolvers_test.go b/pkg/assembler/graphql/resolvers/isOccurrence.resolvers_test.go index 052e4bb6d47..b72161c88a0 100644 --- a/pkg/assembler/graphql/resolvers/isOccurrence.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/isOccurrence.resolvers_test.go @@ -19,12 +19,12 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestOccurrence(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/license.resolvers_test.go b/pkg/assembler/graphql/resolvers/license.resolvers_test.go index 7e558e39897..49efca57ad2 100644 --- a/pkg/assembler/graphql/resolvers/license.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/license.resolvers_test.go @@ -19,11 +19,11 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestLicense(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/metadata.resolvers_test.go b/pkg/assembler/graphql/resolvers/metadata.resolvers_test.go index 92a7485ecf2..bfd31f35f92 100644 --- a/pkg/assembler/graphql/resolvers/metadata.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/metadata.resolvers_test.go @@ -20,12 +20,12 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestMetadata(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/package.resolver_test.go b/pkg/assembler/graphql/resolvers/package.resolver_test.go index be2b4bbee87..e4598cd6fd7 100644 --- a/pkg/assembler/graphql/resolvers/package.resolver_test.go +++ b/pkg/assembler/graphql/resolvers/package.resolver_test.go @@ -4,10 +4,10 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestPackages(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/path.resolvers_test.go b/pkg/assembler/graphql/resolvers/path.resolvers_test.go index 4115ee4bcd4..b600ad5435e 100644 --- a/pkg/assembler/graphql/resolvers/path.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/path.resolvers_test.go @@ -19,10 +19,10 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestPath(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/pkgEqual.resolvers_test.go b/pkg/assembler/graphql/resolvers/pkgEqual.resolvers_test.go index 490996b78a4..3913423bf6f 100644 --- a/pkg/assembler/graphql/resolvers/pkgEqual.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/pkgEqual.resolvers_test.go @@ -19,12 +19,12 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestIngestPkgEquals(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/source.resolvers_test.go b/pkg/assembler/graphql/resolvers/source.resolvers_test.go index 8c0a162e347..6f6d953f1c2 100644 --- a/pkg/assembler/graphql/resolvers/source.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/source.resolvers_test.go @@ -19,11 +19,11 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestSources(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/vulnEqual.resolvers_test.go b/pkg/assembler/graphql/resolvers/vulnEqual.resolvers_test.go index 1fd0f1155a3..2e22042f24e 100644 --- a/pkg/assembler/graphql/resolvers/vulnEqual.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/vulnEqual.resolvers_test.go @@ -19,12 +19,12 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestVulnEqual(t *testing.T) { diff --git a/pkg/assembler/graphql/resolvers/vulnMetadata.resolvers_test.go b/pkg/assembler/graphql/resolvers/vulnMetadata.resolvers_test.go index f78bfdb0dd0..fcd504812b4 100644 --- a/pkg/assembler/graphql/resolvers/vulnMetadata.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/vulnMetadata.resolvers_test.go @@ -19,12 +19,12 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/internal/testing/testdata" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) var greater = model.ComparatorGreater diff --git a/pkg/assembler/graphql/resolvers/vulnerability.resolvers_test.go b/pkg/assembler/graphql/resolvers/vulnerability.resolvers_test.go index b42fbf55ab2..05003a07902 100644 --- a/pkg/assembler/graphql/resolvers/vulnerability.resolvers_test.go +++ b/pkg/assembler/graphql/resolvers/vulnerability.resolvers_test.go @@ -19,11 +19,11 @@ import ( "context" "testing" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/pkg/assembler/graphql/model" "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" + "go.uber.org/mock/gomock" ) func TestVulnerabilities(t *testing.T) { diff --git a/pkg/certifier/scorecard/scorecard_test.go b/pkg/certifier/scorecard/scorecard_test.go index b3434f77d58..4acd05b4989 100644 --- a/pkg/certifier/scorecard/scorecard_test.go +++ b/pkg/certifier/scorecard/scorecard_test.go @@ -22,12 +22,12 @@ import ( "testing" "time" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/internal/testing/mocks" "github.com/guacsec/guac/pkg/certifier" "github.com/guacsec/guac/pkg/certifier/components/source" "github.com/guacsec/guac/pkg/handler/processor" "github.com/ossf/scorecard/v4/pkg" + "go.uber.org/mock/gomock" ) type mockScorecard struct{} diff --git a/pkg/handler/collector/deps_dev/deps_dev_test.go b/pkg/handler/collector/deps_dev/deps_dev_test.go index fd05a6741e4..432db9cf1f9 100644 --- a/pkg/handler/collector/deps_dev/deps_dev_test.go +++ b/pkg/handler/collector/deps_dev/deps_dev_test.go @@ -306,7 +306,7 @@ func TestPerformanceDepsCollector(t *testing.T) { "pkg:golang/github.com/bradleyfalzon/ghinstallation/v2@v2.6.0", "pkg:golang/github.com/go-git/go-git/v5@v5.8.1", "pkg:golang/github.com/go-logr/logr@v1.2.4", - "pkg:golang/github.com/golang/mock@v1.6.0", + "pkg:golang/go.uber.org/mock/mockgen@v0.4.0", "pkg:golang/github.com/google/go-cmp@v0.5.9", "pkg:golang/github.com/google/go-containerregistry@v0.16.1", "pkg:golang/github.com/grafeas/kritis@v0.2.3-0.20210120183821-faeba81c520c", diff --git a/pkg/ingestor/parser/parser_test.go b/pkg/ingestor/parser/parser_test.go index 1297f140b65..819c00fc2ca 100644 --- a/pkg/ingestor/parser/parser_test.go +++ b/pkg/ingestor/parser/parser_test.go @@ -18,17 +18,18 @@ package parser import ( "context" "errors" - "github.com/guacsec/guac/pkg/logging" "reflect" "testing" + "github.com/guacsec/guac/pkg/logging" + "github.com/guacsec/guac/pkg/assembler" "github.com/guacsec/guac/internal/testing/mocks" - "github.com/golang/mock/gomock" "github.com/guacsec/guac/pkg/handler/processor" "github.com/guacsec/guac/pkg/ingestor/parser/common" + "go.uber.org/mock/gomock" ) func TestParserHelper(t *testing.T) { diff --git a/tools/tools.go b/tools/tools.go index 9be6b201fb3..98cd489aaae 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -21,6 +21,6 @@ package tools import ( _ "github.com/99designs/gqlgen" _ "github.com/Khan/genqlient" - _ "github.com/golang/mock/mockgen" _ "github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen" + _ "go.uber.org/mock/mockgen" ) From 56ed85138c7232d177422f36c85791bd2d7c74b6 Mon Sep 17 00:00:00 2001 From: Jeff Mendoza Date: Sat, 27 Apr 2024 07:47:11 -0700 Subject: [PATCH 12/17] Go generate (#1869) Signed-off-by: Jeff Mendoza --- internal/testing/mocks/backend.go | 50 +++++++++++++++---------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/internal/testing/mocks/backend.go b/internal/testing/mocks/backend.go index 5fd9df0e43b..3992560d7ca 100644 --- a/internal/testing/mocks/backend.go +++ b/internal/testing/mocks/backend.go @@ -65,7 +65,7 @@ func (m *MockBackend) ArtifactsList(ctx context.Context, artifactSpec model.Arti } // ArtifactsList indicates an expected call of ArtifactsList. -func (mr *MockBackendMockRecorder) ArtifactsList(ctx, artifactSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) ArtifactsList(ctx, artifactSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ArtifactsList", reflect.TypeOf((*MockBackend)(nil).ArtifactsList), ctx, artifactSpec, after, first) } @@ -95,7 +95,7 @@ func (m *MockBackend) BuildersList(ctx context.Context, builderSpec model.Builde } // BuildersList indicates an expected call of BuildersList. -func (mr *MockBackendMockRecorder) BuildersList(ctx, builderSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) BuildersList(ctx, builderSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BuildersList", reflect.TypeOf((*MockBackend)(nil).BuildersList), ctx, builderSpec, after, first) } @@ -125,7 +125,7 @@ func (m *MockBackend) CertifyBadList(ctx context.Context, certifyBadSpec model.C } // CertifyBadList indicates an expected call of CertifyBadList. -func (mr *MockBackendMockRecorder) CertifyBadList(ctx, certifyBadSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) CertifyBadList(ctx, certifyBadSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyBadList", reflect.TypeOf((*MockBackend)(nil).CertifyBadList), ctx, certifyBadSpec, after, first) } @@ -155,7 +155,7 @@ func (m *MockBackend) CertifyGoodList(ctx context.Context, certifyGoodSpec model } // CertifyGoodList indicates an expected call of CertifyGoodList. -func (mr *MockBackendMockRecorder) CertifyGoodList(ctx, certifyGoodSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) CertifyGoodList(ctx, certifyGoodSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyGoodList", reflect.TypeOf((*MockBackend)(nil).CertifyGoodList), ctx, certifyGoodSpec, after, first) } @@ -185,7 +185,7 @@ func (m *MockBackend) CertifyLegalList(ctx context.Context, certifyLegalSpec mod } // CertifyLegalList indicates an expected call of CertifyLegalList. -func (mr *MockBackendMockRecorder) CertifyLegalList(ctx, certifyLegalSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) CertifyLegalList(ctx, certifyLegalSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyLegalList", reflect.TypeOf((*MockBackend)(nil).CertifyLegalList), ctx, certifyLegalSpec, after, first) } @@ -215,7 +215,7 @@ func (m *MockBackend) CertifyVEXStatementList(ctx context.Context, certifyVEXSta } // CertifyVEXStatementList indicates an expected call of CertifyVEXStatementList. -func (mr *MockBackendMockRecorder) CertifyVEXStatementList(ctx, certifyVEXStatementSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) CertifyVEXStatementList(ctx, certifyVEXStatementSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyVEXStatementList", reflect.TypeOf((*MockBackend)(nil).CertifyVEXStatementList), ctx, certifyVEXStatementSpec, after, first) } @@ -245,7 +245,7 @@ func (m *MockBackend) CertifyVulnList(ctx context.Context, certifyVulnSpec model } // CertifyVulnList indicates an expected call of CertifyVulnList. -func (mr *MockBackendMockRecorder) CertifyVulnList(ctx, certifyVulnSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) CertifyVulnList(ctx, certifyVulnSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CertifyVulnList", reflect.TypeOf((*MockBackend)(nil).CertifyVulnList), ctx, certifyVulnSpec, after, first) } @@ -275,7 +275,7 @@ func (m *MockBackend) FindSoftwareList(ctx context.Context, searchText string, a } // FindSoftwareList indicates an expected call of FindSoftwareList. -func (mr *MockBackendMockRecorder) FindSoftwareList(ctx, searchText, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) FindSoftwareList(ctx, searchText, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindSoftwareList", reflect.TypeOf((*MockBackend)(nil).FindSoftwareList), ctx, searchText, after, first) } @@ -305,7 +305,7 @@ func (m *MockBackend) HasMetadataList(ctx context.Context, hasMetadataSpec model } // HasMetadataList indicates an expected call of HasMetadataList. -func (mr *MockBackendMockRecorder) HasMetadataList(ctx, hasMetadataSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) HasMetadataList(ctx, hasMetadataSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasMetadataList", reflect.TypeOf((*MockBackend)(nil).HasMetadataList), ctx, hasMetadataSpec, after, first) } @@ -335,7 +335,7 @@ func (m *MockBackend) HasSBOMList(ctx context.Context, hasSBOMSpec model.HasSBOM } // HasSBOMList indicates an expected call of HasSBOMList. -func (mr *MockBackendMockRecorder) HasSBOMList(ctx, hasSBOMSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) HasSBOMList(ctx, hasSBOMSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSBOMList", reflect.TypeOf((*MockBackend)(nil).HasSBOMList), ctx, hasSBOMSpec, after, first) } @@ -350,7 +350,7 @@ func (m *MockBackend) HasSLSAList(ctx context.Context, hasSLSASpec model.HasSLSA } // HasSLSAList indicates an expected call of HasSLSAList. -func (mr *MockBackendMockRecorder) HasSLSAList(ctx, hasSLSASpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) HasSLSAList(ctx, hasSLSASpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSLSAList", reflect.TypeOf((*MockBackend)(nil).HasSLSAList), ctx, hasSLSASpec, after, first) } @@ -395,7 +395,7 @@ func (m *MockBackend) HasSourceAtList(ctx context.Context, hasSourceAtSpec model } // HasSourceAtList indicates an expected call of HasSourceAtList. -func (mr *MockBackendMockRecorder) HasSourceAtList(ctx, hasSourceAtSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) HasSourceAtList(ctx, hasSourceAtSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasSourceAtList", reflect.TypeOf((*MockBackend)(nil).HasSourceAtList), ctx, hasSourceAtSpec, after, first) } @@ -425,7 +425,7 @@ func (m *MockBackend) HashEqualList(ctx context.Context, hashEqualSpec model.Has } // HashEqualList indicates an expected call of HashEqualList. -func (mr *MockBackendMockRecorder) HashEqualList(ctx, hashEqualSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) HashEqualList(ctx, hashEqualSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HashEqualList", reflect.TypeOf((*MockBackend)(nil).HashEqualList), ctx, hashEqualSpec, after, first) } @@ -1145,7 +1145,7 @@ func (m *MockBackend) IsDependencyList(ctx context.Context, isDependencySpec mod } // IsDependencyList indicates an expected call of IsDependencyList. -func (mr *MockBackendMockRecorder) IsDependencyList(ctx, isDependencySpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IsDependencyList(ctx, isDependencySpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDependencyList", reflect.TypeOf((*MockBackend)(nil).IsDependencyList), ctx, isDependencySpec, after, first) } @@ -1175,7 +1175,7 @@ func (m *MockBackend) IsOccurrenceList(ctx context.Context, isOccurrenceSpec mod } // IsOccurrenceList indicates an expected call of IsOccurrenceList. -func (mr *MockBackendMockRecorder) IsOccurrenceList(ctx, isOccurrenceSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) IsOccurrenceList(ctx, isOccurrenceSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsOccurrenceList", reflect.TypeOf((*MockBackend)(nil).IsOccurrenceList), ctx, isOccurrenceSpec, after, first) } @@ -1190,7 +1190,7 @@ func (m *MockBackend) LicenseList(ctx context.Context, licenseSpec model.License } // LicenseList indicates an expected call of LicenseList. -func (mr *MockBackendMockRecorder) LicenseList(ctx, licenseSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) LicenseList(ctx, licenseSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LicenseList", reflect.TypeOf((*MockBackend)(nil).LicenseList), ctx, licenseSpec, after, first) } @@ -1235,7 +1235,7 @@ func (m *MockBackend) NeighborsList(ctx context.Context, node string, usingOnly } // NeighborsList indicates an expected call of NeighborsList. -func (mr *MockBackendMockRecorder) NeighborsList(ctx, node, usingOnly, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) NeighborsList(ctx, node, usingOnly, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NeighborsList", reflect.TypeOf((*MockBackend)(nil).NeighborsList), ctx, node, usingOnly, after, first) } @@ -1295,7 +1295,7 @@ func (m *MockBackend) PackagesList(ctx context.Context, pkgSpec model.PkgSpec, a } // PackagesList indicates an expected call of PackagesList. -func (mr *MockBackendMockRecorder) PackagesList(ctx, pkgSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) PackagesList(ctx, pkgSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackagesList", reflect.TypeOf((*MockBackend)(nil).PackagesList), ctx, pkgSpec, after, first) } @@ -1340,7 +1340,7 @@ func (m *MockBackend) PkgEqualList(ctx context.Context, pkgEqualSpec model.PkgEq } // PkgEqualList indicates an expected call of PkgEqualList. -func (mr *MockBackendMockRecorder) PkgEqualList(ctx, pkgEqualSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) PkgEqualList(ctx, pkgEqualSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PkgEqualList", reflect.TypeOf((*MockBackend)(nil).PkgEqualList), ctx, pkgEqualSpec, after, first) } @@ -1370,7 +1370,7 @@ func (m *MockBackend) PointOfContactList(ctx context.Context, pointOfContactSpec } // PointOfContactList indicates an expected call of PointOfContactList. -func (mr *MockBackendMockRecorder) PointOfContactList(ctx, pointOfContactSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) PointOfContactList(ctx, pointOfContactSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PointOfContactList", reflect.TypeOf((*MockBackend)(nil).PointOfContactList), ctx, pointOfContactSpec, after, first) } @@ -1400,7 +1400,7 @@ func (m *MockBackend) ScorecardsList(ctx context.Context, scorecardSpec model.Ce } // ScorecardsList indicates an expected call of ScorecardsList. -func (mr *MockBackendMockRecorder) ScorecardsList(ctx, scorecardSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) ScorecardsList(ctx, scorecardSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ScorecardsList", reflect.TypeOf((*MockBackend)(nil).ScorecardsList), ctx, scorecardSpec, after, first) } @@ -1430,7 +1430,7 @@ func (m *MockBackend) SourcesList(ctx context.Context, sourceSpec model.SourceSp } // SourcesList indicates an expected call of SourcesList. -func (mr *MockBackendMockRecorder) SourcesList(ctx, sourceSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) SourcesList(ctx, sourceSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SourcesList", reflect.TypeOf((*MockBackend)(nil).SourcesList), ctx, sourceSpec, after, first) } @@ -1460,7 +1460,7 @@ func (m *MockBackend) VulnEqualList(ctx context.Context, vulnEqualSpec model.Vul } // VulnEqualList indicates an expected call of VulnEqualList. -func (mr *MockBackendMockRecorder) VulnEqualList(ctx, vulnEqualSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) VulnEqualList(ctx, vulnEqualSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VulnEqualList", reflect.TypeOf((*MockBackend)(nil).VulnEqualList), ctx, vulnEqualSpec, after, first) } @@ -1490,7 +1490,7 @@ func (m *MockBackend) VulnerabilityList(ctx context.Context, vulnSpec model.Vuln } // VulnerabilityList indicates an expected call of VulnerabilityList. -func (mr *MockBackendMockRecorder) VulnerabilityList(ctx, vulnSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) VulnerabilityList(ctx, vulnSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VulnerabilityList", reflect.TypeOf((*MockBackend)(nil).VulnerabilityList), ctx, vulnSpec, after, first) } @@ -1520,7 +1520,7 @@ func (m *MockBackend) VulnerabilityMetadataList(ctx context.Context, vulnerabili } // VulnerabilityMetadataList indicates an expected call of VulnerabilityMetadataList. -func (mr *MockBackendMockRecorder) VulnerabilityMetadataList(ctx, vulnerabilityMetadataSpec, after, first interface{}) *gomock.Call { +func (mr *MockBackendMockRecorder) VulnerabilityMetadataList(ctx, vulnerabilityMetadataSpec, after, first any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VulnerabilityMetadataList", reflect.TypeOf((*MockBackend)(nil).VulnerabilityMetadataList), ctx, vulnerabilityMetadataSpec, after, first) } From 3bb8b21e49128ff988be8f936415e2359c1bc84f Mon Sep 17 00:00:00 2001 From: Marco Deicas Date: Sat, 27 Apr 2024 12:34:12 -0400 Subject: [PATCH 13/17] Add a transitive dependencies endpoint to the REST API (#1867) * client testing support Signed-off-by: Marco Deicas * Add HashEquals and IsOccurrences queries to gql client Signed-off-by: Marco Deicas * Change Paginate to take pointer to PaginationSpec Signed-off-by: Marco Deicas * Add better logging Signed-off-by: Marco Deicas * Implement transitive dependency search Signed-off-by: Marco Deicas --------- Signed-off-by: Marco Deicas --- cmd/guacrest/cmd/server.go | 11 +- internal/testing/graphqlClients/guacdata.go | 441 ++++++++++++ internal/testing/graphqlClients/testsetup.go | 101 +++ pkg/assembler/clients/generated/operations.go | 393 +++++++++++ .../clients/operations/hashEqual.graphql | 6 + .../clients/operations/isOccurrence.graphql | 6 + pkg/assembler/helpers/purl.go | 37 + pkg/guacrest/client/client.go | 56 +- pkg/guacrest/client/models.go | 23 +- pkg/guacrest/generated/models.go | 23 +- pkg/guacrest/generated/server.go | 39 +- pkg/guacrest/generated/spec.go | 36 +- pkg/guacrest/helpers/artifact.go | 47 ++ pkg/guacrest/helpers/artifact_test.go | 54 ++ pkg/guacrest/helpers/errors.go | 25 + pkg/guacrest/helpers/package.go | 71 ++ pkg/guacrest/helpers/package_test.go | 225 +++++++ pkg/guacrest/openapi.yaml | 31 +- pkg/guacrest/pagination/pagination.go | 11 +- pkg/guacrest/pagination/pagination_test.go | 49 +- pkg/guacrest/server/errors.go | 48 ++ pkg/guacrest/server/retrieveDependencies.go | 394 +++++++++++ .../server/retrieveDependencies_test.go | 632 ++++++++++++++++++ pkg/guacrest/server/server.go | 33 +- pkg/logging/logger.go | 8 +- 25 files changed, 2710 insertions(+), 90 deletions(-) create mode 100644 internal/testing/graphqlClients/guacdata.go create mode 100644 internal/testing/graphqlClients/testsetup.go create mode 100644 pkg/guacrest/helpers/artifact.go create mode 100644 pkg/guacrest/helpers/artifact_test.go create mode 100644 pkg/guacrest/helpers/errors.go create mode 100644 pkg/guacrest/helpers/package.go create mode 100644 pkg/guacrest/helpers/package_test.go create mode 100644 pkg/guacrest/server/errors.go create mode 100644 pkg/guacrest/server/retrieveDependencies.go create mode 100644 pkg/guacrest/server/retrieveDependencies_test.go diff --git a/cmd/guacrest/cmd/server.go b/cmd/guacrest/cmd/server.go index 1cc8d866f6b..5a44e14abb5 100644 --- a/cmd/guacrest/cmd/server.go +++ b/cmd/guacrest/cmd/server.go @@ -33,9 +33,6 @@ import ( "github.com/guacsec/guac/pkg/logging" ) -// TODO: add logging middleware -// TODO: add context propagation middleware - func startServer() { ctx := logging.WithLogger(context.Background()) logger := logging.FromContext(ctx) @@ -47,10 +44,12 @@ func startServer() { httpClient := &http.Client{Transport: transport} gqlClient := getGraphqlServerClientOrExit(ctx, httpClient) - handler := server.NewDefaultServer(gqlClient) - handlerWrapper := gen.NewStrictHandler(handler, nil) + + restApiHandler := gen.Handler(gen.NewStrictHandler(server.NewDefaultServer(gqlClient), nil)) + router := chi.NewRouter() - router.Mount("/", gen.Handler(handlerWrapper)) + router.Use(server.AddLoggerToCtxMiddleware, server.LogRequestsMiddleware) + router.Mount("/", restApiHandler) server := http.Server{ Addr: fmt.Sprintf(":%d", flags.restAPIServerPort), Handler: router, diff --git a/internal/testing/graphqlClients/guacdata.go b/internal/testing/graphqlClients/guacdata.go new file mode 100644 index 00000000000..88f9a990d3d --- /dev/null +++ b/internal/testing/graphqlClients/guacdata.go @@ -0,0 +1,441 @@ +// +// Copyright 2024 The GUAC Authors. +// +// 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 clients + +import ( + "context" + "testing" + "time" + + "github.com/Khan/genqlient/graphql" + _ "github.com/guacsec/guac/pkg/assembler/backends/keyvalue" + gql "github.com/guacsec/guac/pkg/assembler/clients/generated" + "github.com/guacsec/guac/pkg/assembler/helpers" +) + +const ( + // nouns + defaultHashAlgorithm = "sha256" + defaultSourceType = "test-type" + defaultSourceNamespace = "test-namespace" + + // IsOccurrence + defaultIsOccurrenceJustification = "test-justification" + defaultIsOccurrenceOrigin = "test-origin" + defaultIsOccurrenceCollector = "test-collector" + + // HasSbom + defaultHasSbomOrigin = "test-origin" + defaultHasSbomCollector = "test-collector" + defaultHasSbomUri = "test-uri" + defaultHasSbomDownloadLocation = "test-download-loc" + defaultHasSbomDigest = "test-digest" + + // IsDependency + defaultIsDependencyDependencyType = gql.DependencyTypeUnknown + defaultIsDependencyJustification = "test-justification" + defaultIsDependencyOrigin = "test-origin" + defaultIsDependencyCollector = "test-collector" + + // HashEquals + defaultHashEqualJustification = "test-justification" + defaultHashEqualOrigin = "test-origin" + defaultHashEqualCollector = "test-collector" + + // HasSlsa + defaultHasSlsaBuildType = "test-builder=type" + defaultHasSlsaVersion = "test-slsa-version" + defaultHasSlsaOrigin = "test-origin" + defaultHasSlsaCollector = "test-collector" + defaultHasSlsaPredicateKey = "test-predicate-key" + defaultHasSlsaPredicateValue = "test-predicate-value" +) + +// Defines the Guac graph, to test clients of the Graphql server. +// +// This type, along with the Ingest function, is similar to the backend IngestPredicates +// type and the corresponding assembler function, but allows for significantly less verbose +// tests by specifying each noun with a single string and making the various InputSpec +// structs optional. Additionally, t.Fatalf is called upon any errors. However, this also means +// that a few inputs aren't supported, such as finer-grained definition of nouns. +// +// All verbs are currently attached to packge version nodes, but a configuration for this +// could be added if needed. +type GuacData struct { + /** the nouns need to be specified here in order to be referenced from a verb **/ + Packages []string // packages are specified by purl + Artifacts []string // artifacts are specified by digest + Sources []string // sources are specified by the name in the SourceName node + Builders []string // builders are specified by URI + + /** verbs **/ + HasSboms []HasSbom + IsOccurrences []IsOccurrence + IsDependencies []IsDependency + HashEquals []HashEqual + HasSlsas []HasSlsa + + // Other graphql verbs still need to be added here +} + +type IsDependency struct { + DependentPkg string // a previously ingested purl + DependencyPkg string // a previously ingested purl + Spec *gql.IsDependencyInputSpec // if nil, a default will be used +} + +type IsOccurrence struct { + Subject string // a previously ingested purl or source + Artifact string // a previously ingested digest + Spec *gql.IsOccurrenceInputSpec // if nil, a default will be used +} + +type HasSbom struct { + Subject string // a previously ingested purl or digest + IncludedSoftware []string // a list of previously ingested purls and digests + IncludedIsDependencies []IsDependency + IncludedIsOccurrences []IsOccurrence + Spec *gql.HasSBOMInputSpec // if nil, a default will be used +} + +type HashEqual struct { + ArtifactA string // a previously ingested digest + ArtifactB string // a previously ingested digest + Spec *gql.HashEqualInputSpec // if nil, a default will be used +} + +type HasSlsa struct { + Subject string // a previously ingested digest + BuiltFrom []string // a list of previously ingested digests + BuiltBy string // a previously ingested builder + Spec *gql.SLSAInputSpec // if nil, a default will be used +} + +// maintains the ids of nouns, to use when ingesting verbs +type nounIds struct { + PackageIds map[string]string // map from purls to IDs of PackageName nodes + ArtifactIds map[string]string // map from digest to IDs of Artifact nodes + SourceIds map[string]string // map from source names to IDs of SourceName nodes + BuilderIds map[string]string // map from URI to IDs of Builder nodes + +} + +func Ingest(ctx context.Context, t *testing.T, gqlClient graphql.Client, data GuacData) nounIds { + packageIds := map[string]string{} + for _, pkg := range data.Packages { + packageIds[pkg] = ingestPackage(ctx, t, gqlClient, pkg) + } + + artifactIds := map[string]string{} + for _, artifact := range data.Artifacts { + artifactIds[artifact] = ingestArtifact(ctx, t, gqlClient, artifact) + } + + sourceIds := map[string]string{} + for _, source := range data.Sources { + sourceIds[source] = ingestSource(ctx, t, gqlClient, source) + } + + builderIds := map[string]string{} + for _, builder := range data.Builders { + builderIds[builder] = ingestBuilder(ctx, t, gqlClient, builder) + } + + i := nounIds{ + PackageIds: packageIds, + ArtifactIds: artifactIds, + SourceIds: sourceIds, + BuilderIds: builderIds, + } + + for _, sbom := range data.HasSboms { + i.ingestHasSbom(ctx, t, gqlClient, sbom) + } + + for _, isDependency := range data.IsDependencies { + i.ingestIsDependency(ctx, t, gqlClient, isDependency) + } + + for _, isOccurrence := range data.IsOccurrences { + i.ingestIsOccurrence(ctx, t, gqlClient, isOccurrence) + } + + for _, hashEqual := range data.HashEquals { + i.ingestHashEqual(ctx, t, gqlClient, hashEqual) + } + + for _, hasSlsa := range data.HasSlsas { + i.ingestHasSlsa(ctx, t, gqlClient, hasSlsa) + } + + return i +} + +func (i nounIds) ingestHasSlsa(ctx context.Context, t *testing.T, gqlClient graphql.Client, hasSlsa HasSlsa) { + slsaSpec := hasSlsa.Spec + if slsaSpec == nil { + slsaSpec = &gql.SLSAInputSpec{ + BuildType: defaultHasSlsaBuildType, + SlsaPredicate: []gql.SLSAPredicateInputSpec{ + {Key: defaultHasSlsaPredicateKey, Value: defaultHasSlsaPredicateValue}, + }, + SlsaVersion: defaultHasSlsaVersion, + Origin: defaultHasSlsaOrigin, + Collector: defaultHasSlsaCollector, + } + } + + subjectId, ok := i.ArtifactIds[hasSlsa.Subject] + if !ok { + t.Fatalf("The digest %s has not been ingested", hasSlsa.Subject) + } + subjectSpec := gql.IDorArtifactInput{ArtifactID: &subjectId} + + builtFromSpecs := []gql.IDorArtifactInput{} + for _, buildMaterial := range hasSlsa.BuiltFrom { + buildMaterialId, ok := i.ArtifactIds[buildMaterial] + if !ok { + t.Fatalf("The digest %s has not been ingested", buildMaterial) + } + builtFromSpec := gql.IDorArtifactInput{ArtifactID: &buildMaterialId} + builtFromSpecs = append(builtFromSpecs, builtFromSpec) + } + + builderId, ok := i.BuilderIds[hasSlsa.BuiltBy] + if !ok { + t.Fatalf("The builder %s has not been ingested", hasSlsa.BuiltBy) + } + builtBySpec := gql.IDorBuilderInput{BuilderID: &builderId} + + _, err := gql.IngestSLSAForArtifact(ctx, gqlClient, subjectSpec, builtFromSpecs, builtBySpec, *slsaSpec) + if err != nil { + t.Fatalf("Error ingesting HasSlsa when setting up test: %s", err) + } +} + +func (i nounIds) ingestHashEqual(ctx context.Context, t *testing.T, gqlClient graphql.Client, hashEqual HashEqual) { + spec := hashEqual.Spec + if spec == nil { + spec = &gql.HashEqualInputSpec{ + Justification: defaultHashEqualJustification, + Origin: defaultHashEqualOrigin, + Collector: defaultHashEqualCollector, + } + } + + artifactAId, ok := i.ArtifactIds[hashEqual.ArtifactA] + if !ok { + t.Fatalf("The digest %s has not been ingested", hashEqual.ArtifactA) + } + artifactBId, ok := i.ArtifactIds[hashEqual.ArtifactB] + if !ok { + t.Fatalf("The digest %s has not been ingested", hashEqual.ArtifactB) + } + + artifactASpec := gql.IDorArtifactInput{ArtifactID: &artifactAId} + artifactBSpec := gql.IDorArtifactInput{ArtifactID: &artifactBId} + _, err := gql.IngestHashEqual(ctx, gqlClient, artifactASpec, artifactBSpec, *spec) + if err != nil { + t.Fatalf("Error ingesting HashEqual when setting up test: %s", err) + } +} + +// Returns the id of the IsDependency node +func (i nounIds) ingestIsDependency(ctx context.Context, t *testing.T, gqlClient graphql.Client, isDependency IsDependency) string { + spec := isDependency.Spec + if spec == nil { + spec = &gql.IsDependencyInputSpec{ + DependencyType: defaultIsDependencyDependencyType, + Justification: defaultIsDependencyJustification, + Origin: defaultIsDependencyOrigin, + Collector: defaultIsDependencyCollector, + } + } + + dependentId, ok := i.PackageIds[isDependency.DependentPkg] + if !ok { + t.Fatalf("The purl %s has not been ingested", isDependency.DependentPkg) + } + dependencyId := i.PackageIds[isDependency.DependencyPkg] + if !ok { + t.Fatalf("The purl %s has not been ingested", isDependency.DependencyPkg) + } + + // The IsDependency is attached to the package version node + flags := gql.MatchFlags{Pkg: gql.PkgMatchTypeSpecificVersion} + dependentSpec := gql.IDorPkgInput{PackageVersionID: &dependentId} + dependencySpec := gql.IDorPkgInput{PackageVersionID: &dependencyId} + + res, err := gql.IngestIsDependency(ctx, gqlClient, dependentSpec, dependencySpec, flags, *spec) + if err != nil { + t.Fatalf("Error ingesting IsDependency when setting up test: %s", err) + } + return res.GetIngestDependency() +} + +// Returns the ID of the IsOccurrence node. +func (i nounIds) ingestIsOccurrence(ctx context.Context, t *testing.T, gqlClient graphql.Client, isOccurrence IsOccurrence) string { + spec := isOccurrence.Spec + if spec == nil { + spec = &gql.IsOccurrenceInputSpec{ + Justification: defaultIsOccurrenceJustification, + Origin: defaultIsOccurrenceOrigin, + Collector: defaultIsOccurrenceCollector, + } + } + + artifactId, ok := i.ArtifactIds[isOccurrence.Artifact] + if !ok { + t.Fatalf("The digest %s has not been ingested", isOccurrence.Artifact) + } + artifactSpec := gql.IDorArtifactInput{ArtifactID: &artifactId} + + // the subject can be either a package or a source + if v, ok := i.PackageIds[isOccurrence.Subject]; ok { + pkgSpec := gql.IDorPkgInput{PackageVersionID: &v} + res, err := gql.IngestIsOccurrencePkg(ctx, gqlClient, pkgSpec, artifactSpec, *spec) + if err != nil { + t.Fatalf("Error ingesting IsOccurrence: %s", err) + } + return res.GetIngestOccurrence() + + } else if v, ok := i.SourceIds[isOccurrence.Subject]; ok { + sourceSpec := gql.IDorSourceInput{SourceNameID: &v} + res, err := gql.IngestIsOccurrenceSrc(ctx, gqlClient, sourceSpec, artifactSpec, *spec) + if err != nil { + t.Fatalf("Error ingesting IsOccurrence: %s", err) + } + return res.GetIngestOccurrence() + } + + t.Fatalf("The purl or source %s has not been ingested", isOccurrence.Subject) + return "" +} + +func (i nounIds) ingestHasSbom(ctx context.Context, t *testing.T, gqlClient graphql.Client, hasSbom HasSbom) { + isDependencyIds := []string{} + for _, dependency := range hasSbom.IncludedIsDependencies { + id := i.ingestIsDependency(ctx, t, gqlClient, dependency) + isDependencyIds = append(isDependencyIds, id) + } + + isOccurrenceIds := []string{} + for _, occurrence := range hasSbom.IncludedIsOccurrences { + id := i.ingestIsOccurrence(ctx, t, gqlClient, occurrence) + isOccurrenceIds = append(isOccurrenceIds, id) + } + + includedPackageIds := []string{} + includedArtifactIds := []string{} + for _, software := range hasSbom.IncludedSoftware { + if id, ok := i.PackageIds[software]; ok { + includedPackageIds = append(includedPackageIds, id) + } else if id, ok := i.ArtifactIds[software]; ok { + includedArtifactIds = append(includedArtifactIds, id) + } else { + t.Fatalf("The purl or digest %s has not been ingested", software) + } + } + + sbomSpec := hasSbom.Spec + if hasSbom.Spec == nil { + sbomSpec = &gql.HasSBOMInputSpec{ + Uri: defaultHasSbomUri, + Algorithm: defaultHashAlgorithm, + Digest: defaultHasSbomDigest, + DownloadLocation: defaultHasSbomDownloadLocation, + Origin: defaultHasSbomOrigin, + Collector: defaultHasSbomCollector, + KnownSince: time.Now(), + } + } + includesSpec := gql.HasSBOMIncludesInputSpec{ + Packages: includedPackageIds, + Artifacts: includedArtifactIds, + Dependencies: isDependencyIds, + Occurrences: isOccurrenceIds, + } + + // the subject can be either a package or an artifact + if v, ok := i.PackageIds[hasSbom.Subject]; ok { + pkgSpec := gql.IDorPkgInput{PackageVersionID: &v} + _, err := gql.IngestHasSBOMPkg(ctx, gqlClient, pkgSpec, *sbomSpec, includesSpec) + if err != nil { + t.Fatalf("Error ingesting sbom when setting up test: %s", err) + } + } else if v, ok := i.ArtifactIds[hasSbom.Subject]; ok { + artifactSpec := gql.IDorArtifactInput{ArtifactID: &v} + _, err := gql.IngestHasSBOMArtifact(ctx, gqlClient, artifactSpec, *sbomSpec, includesSpec) + if err != nil { + t.Fatalf("Error ingesting sbom when setting up test: %s", err) + } + } else { + t.Fatalf("The purl or digest %s has not been ingested", hasSbom.Subject) + } +} + +// Returns the ID of the version node in the package trie +func ingestPackage(ctx context.Context, t *testing.T, gqlClient graphql.Client, purl string) string { + spec, err := helpers.PurlToPkg(purl) + if err != nil { + t.Fatalf("Could not create a package input spec from a purl: %s", err) + } + idOrInputSpec := gql.IDorPkgInput{PackageInput: spec} + res, err := gql.IngestPackage(ctx, gqlClient, idOrInputSpec) + if err != nil { + t.Fatalf("Error ingesting package when setting up test: %s", err) + } + return res.IngestPackage.PackageVersionID +} + +func ingestArtifact(ctx context.Context, t *testing.T, gqlClient graphql.Client, digest string) string { + spec := gql.ArtifactInputSpec{ + Algorithm: defaultHashAlgorithm, + Digest: digest, + } + idOrInputSpec := gql.IDorArtifactInput{ArtifactInput: &spec} + res, err := gql.IngestArtifact(ctx, gqlClient, idOrInputSpec) + if err != nil { + t.Fatalf("Error ingesting artifact when setting up test: %s", err) + } + return res.GetIngestArtifact() +} + +// Returns the ID of the SourceName node in the trie. +func ingestSource(ctx context.Context, t *testing.T, gqlClient graphql.Client, name string) string { + spec := gql.SourceInputSpec{ + Type: defaultSourceType, + Namespace: defaultSourceNamespace, + } + idorInputSpec := gql.IDorSourceInput{SourceInput: &spec} + res, err := gql.IngestSource(ctx, gqlClient, idorInputSpec) + if err != nil { + t.Fatalf("Error ingesting source when setting up test: %s", err) + } + return res.GetIngestSource().SourceNameID +} + +func ingestBuilder(ctx context.Context, t *testing.T, gqlClient graphql.Client, uri string) string { + spec := gql.BuilderInputSpec{ + Uri: defaultSourceType, + } + idorInputSpec := gql.IDorBuilderInput{BuilderInput: &spec} + res, err := gql.IngestBuilder(ctx, gqlClient, idorInputSpec) + if err != nil { + t.Fatalf("Error ingesting builder when setting up test: %s", err) + } + return res.GetIngestBuilder() +} diff --git a/internal/testing/graphqlClients/testsetup.go b/internal/testing/graphqlClients/testsetup.go new file mode 100644 index 00000000000..a22be0fc5d8 --- /dev/null +++ b/internal/testing/graphqlClients/testsetup.go @@ -0,0 +1,101 @@ +// +// Copyright 2024 The GUAC Authors. +// +// 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 clients helps set up the graphql backend for testing graphql clients +package clients + +import ( + "context" + "fmt" + "net" + "net/http" + "sync" + "testing" + + "github.com/99designs/gqlgen/graphql/handler" + "github.com/Khan/genqlient/graphql" + "github.com/guacsec/guac/pkg/assembler/backends" + _ "github.com/guacsec/guac/pkg/assembler/backends/keyvalue" + assembler "github.com/guacsec/guac/pkg/assembler/graphql/generated" + "github.com/guacsec/guac/pkg/assembler/graphql/resolvers" +) + +// SetupTest starts the graphql server and returns a client for it. The parameter +// t is used to register a function to close the server and to fail the test upon +// any errors. +func SetupTest(t *testing.T) graphql.Client { + gqlHandler := getGraphqlHandler(t) + port := startGraphqlServer(t, gqlHandler) + serverAddr := fmt.Sprintf("http://localhost:%s", port) + client := graphql.NewClient(serverAddr, nil) + return client +} + +// startGraphqlServer starts up up the graphql server, registers a function to close it when the test completes, +// and returns the port it is listening on. +func startGraphqlServer(t *testing.T, gqlHandler *handler.Server) string { + srv := http.Server{Handler: gqlHandler} + + // Create the listener explicitely in order to find the port it listens on + listener, err := net.Listen("tcp", "") + if err != nil { + t.Fatalf("Error initializing listener for graphql server: %v", err) + return "" + } + _, port, err := net.SplitHostPort(listener.Addr().String()) + if err != nil { + t.Fatalf("Error getting post from server address: %v", err) + return "" + } + + wg := sync.WaitGroup{} + wg.Add(1) + go func() { + t.Logf("Starting graphql server on: %v", listener.Addr()) + wg.Done() + // this thread could still be preempted here, but I don't think we can do better? + err := srv.Serve(listener) + if err != http.ErrServerClosed { + t.Logf("Graphql server finished with error: %v", srv.Serve(listener)) + } + }() + wg.Wait() + + closeFunc := func() { + err := srv.Close() + if err != nil { + t.Logf("Error closing graphql server listener") + } else { + t.Logf("Graphql server shut down") + } + } + t.Cleanup(closeFunc) + + return port +} + +// Gets the handler for the graphql server with the inmem backend resolver. +func getGraphqlHandler(t *testing.T) *handler.Server { + ctx := context.Background() + backend, err := backends.Get("keyvalue", ctx, struct{}{}) + if err != nil { + t.Fatalf("Error getting the keyvalue backend") + } + resolver := resolvers.Resolver{Backend: backend} + + config := assembler.Config{Resolvers: &resolver} + config.Directives.Filter = resolvers.Filter + return handler.NewDefaultServer(assembler.NewExecutableSchema(config)) +} diff --git a/pkg/assembler/clients/generated/operations.go b/pkg/assembler/clients/generated/operations.go index 38c98bc8bfa..bd5ec02990c 100644 --- a/pkg/assembler/clients/generated/operations.go +++ b/pkg/assembler/clients/generated/operations.go @@ -8177,6 +8177,128 @@ func (v *HashEqualInputSpec) GetCollector() string { return v.Collector } // GetDocumentRef returns HashEqualInputSpec.DocumentRef, and is useful for accessing the field via an interface. func (v *HashEqualInputSpec) GetDocumentRef() string { return v.DocumentRef } +// HashEqualSpec allows filtering the list of artifact equality statements to +// return in a query. +// +// Specifying just one artifact allows to query for all similar artifacts (if any +// exists). +type HashEqualSpec struct { + Id *string `json:"id"` + Artifacts []*ArtifactSpec `json:"artifacts"` + Justification *string `json:"justification"` + Origin *string `json:"origin"` + Collector *string `json:"collector"` + DocumentRef *string `json:"documentRef"` +} + +// GetId returns HashEqualSpec.Id, and is useful for accessing the field via an interface. +func (v *HashEqualSpec) GetId() *string { return v.Id } + +// GetArtifacts returns HashEqualSpec.Artifacts, and is useful for accessing the field via an interface. +func (v *HashEqualSpec) GetArtifacts() []*ArtifactSpec { return v.Artifacts } + +// GetJustification returns HashEqualSpec.Justification, and is useful for accessing the field via an interface. +func (v *HashEqualSpec) GetJustification() *string { return v.Justification } + +// GetOrigin returns HashEqualSpec.Origin, and is useful for accessing the field via an interface. +func (v *HashEqualSpec) GetOrigin() *string { return v.Origin } + +// GetCollector returns HashEqualSpec.Collector, and is useful for accessing the field via an interface. +func (v *HashEqualSpec) GetCollector() *string { return v.Collector } + +// GetDocumentRef returns HashEqualSpec.DocumentRef, and is useful for accessing the field via an interface. +func (v *HashEqualSpec) GetDocumentRef() *string { return v.DocumentRef } + +// HashEqualsHashEqual includes the requested fields of the GraphQL type HashEqual. +// The GraphQL type's documentation follows. +// +// HashEqual is an attestation that a set of artifacts are identical. +type HashEqualsHashEqual struct { + AllHashEqualTree `json:"-"` +} + +// GetId returns HashEqualsHashEqual.Id, and is useful for accessing the field via an interface. +func (v *HashEqualsHashEqual) GetId() string { return v.AllHashEqualTree.Id } + +// GetJustification returns HashEqualsHashEqual.Justification, and is useful for accessing the field via an interface. +func (v *HashEqualsHashEqual) GetJustification() string { return v.AllHashEqualTree.Justification } + +// GetArtifacts returns HashEqualsHashEqual.Artifacts, and is useful for accessing the field via an interface. +func (v *HashEqualsHashEqual) GetArtifacts() []AllHashEqualTreeArtifactsArtifact { + return v.AllHashEqualTree.Artifacts +} + +// GetOrigin returns HashEqualsHashEqual.Origin, and is useful for accessing the field via an interface. +func (v *HashEqualsHashEqual) GetOrigin() string { return v.AllHashEqualTree.Origin } + +// GetCollector returns HashEqualsHashEqual.Collector, and is useful for accessing the field via an interface. +func (v *HashEqualsHashEqual) GetCollector() string { return v.AllHashEqualTree.Collector } + +func (v *HashEqualsHashEqual) UnmarshalJSON(b []byte) error { + + if string(b) == "null" { + return nil + } + + var firstPass struct { + *HashEqualsHashEqual + graphql.NoUnmarshalJSON + } + firstPass.HashEqualsHashEqual = v + + err := json.Unmarshal(b, &firstPass) + if err != nil { + return err + } + + err = json.Unmarshal( + b, &v.AllHashEqualTree) + if err != nil { + return err + } + return nil +} + +type __premarshalHashEqualsHashEqual struct { + Id string `json:"id"` + + Justification string `json:"justification"` + + Artifacts []AllHashEqualTreeArtifactsArtifact `json:"artifacts"` + + Origin string `json:"origin"` + + Collector string `json:"collector"` +} + +func (v *HashEqualsHashEqual) MarshalJSON() ([]byte, error) { + premarshaled, err := v.__premarshalJSON() + if err != nil { + return nil, err + } + return json.Marshal(premarshaled) +} + +func (v *HashEqualsHashEqual) __premarshalJSON() (*__premarshalHashEqualsHashEqual, error) { + var retval __premarshalHashEqualsHashEqual + + retval.Id = v.AllHashEqualTree.Id + retval.Justification = v.AllHashEqualTree.Justification + retval.Artifacts = v.AllHashEqualTree.Artifacts + retval.Origin = v.AllHashEqualTree.Origin + retval.Collector = v.AllHashEqualTree.Collector + return &retval, nil +} + +// HashEqualsResponse is returned by HashEquals on success. +type HashEqualsResponse struct { + // Returns all artifact equality statements matching a filter. + HashEqual []HashEqualsHashEqual `json:"HashEqual"` +} + +// GetHashEqual returns HashEqualsResponse.HashEqual, and is useful for accessing the field via an interface. +func (v *HashEqualsResponse) GetHashEqual() []HashEqualsHashEqual { return v.HashEqual } + // IDorArtifactInput allows for specifying either the artifact ID or the ArtifactInputSpec. // // Either the ID or the ArtifactInputSpec must be specified. Both cannot be nil. @@ -9236,6 +9358,119 @@ func (v *IsOccurrenceSpec) GetCollector() *string { return v.Collector } // GetDocumentRef returns IsOccurrenceSpec.DocumentRef, and is useful for accessing the field via an interface. func (v *IsOccurrenceSpec) GetDocumentRef() *string { return v.DocumentRef } +// IsOccurrencesIsOccurrence includes the requested fields of the GraphQL type IsOccurrence. +// The GraphQL type's documentation follows. +// +// IsOccurrence is an attestation to link an artifact to a package or source. +// +// Attestation must occur at the PackageVersion or at the SourceName. +type IsOccurrencesIsOccurrence struct { + AllIsOccurrencesTree `json:"-"` +} + +// GetId returns IsOccurrencesIsOccurrence.Id, and is useful for accessing the field via an interface. +func (v *IsOccurrencesIsOccurrence) GetId() string { return v.AllIsOccurrencesTree.Id } + +// GetSubject returns IsOccurrencesIsOccurrence.Subject, and is useful for accessing the field via an interface. +func (v *IsOccurrencesIsOccurrence) GetSubject() AllIsOccurrencesTreeSubjectPackageOrSource { + return v.AllIsOccurrencesTree.Subject +} + +// GetArtifact returns IsOccurrencesIsOccurrence.Artifact, and is useful for accessing the field via an interface. +func (v *IsOccurrencesIsOccurrence) GetArtifact() AllIsOccurrencesTreeArtifact { + return v.AllIsOccurrencesTree.Artifact +} + +// GetJustification returns IsOccurrencesIsOccurrence.Justification, and is useful for accessing the field via an interface. +func (v *IsOccurrencesIsOccurrence) GetJustification() string { + return v.AllIsOccurrencesTree.Justification +} + +// GetOrigin returns IsOccurrencesIsOccurrence.Origin, and is useful for accessing the field via an interface. +func (v *IsOccurrencesIsOccurrence) GetOrigin() string { return v.AllIsOccurrencesTree.Origin } + +// GetCollector returns IsOccurrencesIsOccurrence.Collector, and is useful for accessing the field via an interface. +func (v *IsOccurrencesIsOccurrence) GetCollector() string { return v.AllIsOccurrencesTree.Collector } + +func (v *IsOccurrencesIsOccurrence) UnmarshalJSON(b []byte) error { + + if string(b) == "null" { + return nil + } + + var firstPass struct { + *IsOccurrencesIsOccurrence + graphql.NoUnmarshalJSON + } + firstPass.IsOccurrencesIsOccurrence = v + + err := json.Unmarshal(b, &firstPass) + if err != nil { + return err + } + + err = json.Unmarshal( + b, &v.AllIsOccurrencesTree) + if err != nil { + return err + } + return nil +} + +type __premarshalIsOccurrencesIsOccurrence struct { + Id string `json:"id"` + + Subject json.RawMessage `json:"subject"` + + Artifact AllIsOccurrencesTreeArtifact `json:"artifact"` + + Justification string `json:"justification"` + + Origin string `json:"origin"` + + Collector string `json:"collector"` +} + +func (v *IsOccurrencesIsOccurrence) MarshalJSON() ([]byte, error) { + premarshaled, err := v.__premarshalJSON() + if err != nil { + return nil, err + } + return json.Marshal(premarshaled) +} + +func (v *IsOccurrencesIsOccurrence) __premarshalJSON() (*__premarshalIsOccurrencesIsOccurrence, error) { + var retval __premarshalIsOccurrencesIsOccurrence + + retval.Id = v.AllIsOccurrencesTree.Id + { + + dst := &retval.Subject + src := v.AllIsOccurrencesTree.Subject + var err error + *dst, err = __marshalAllIsOccurrencesTreeSubjectPackageOrSource( + &src) + if err != nil { + return nil, fmt.Errorf( + "unable to marshal IsOccurrencesIsOccurrence.AllIsOccurrencesTree.Subject: %w", err) + } + } + retval.Artifact = v.AllIsOccurrencesTree.Artifact + retval.Justification = v.AllIsOccurrencesTree.Justification + retval.Origin = v.AllIsOccurrencesTree.Origin + retval.Collector = v.AllIsOccurrencesTree.Collector + return &retval, nil +} + +// IsOccurrencesResponse is returned by IsOccurrences on success. +type IsOccurrencesResponse struct { + // Returns all artifacts-source/package mappings that match a filter. + IsOccurrence []IsOccurrencesIsOccurrence `json:"IsOccurrence"` +} + +// GetIsOccurrence returns IsOccurrencesResponse.IsOccurrence, and is useful for accessing the field via an interface. +func (v *IsOccurrencesResponse) GetIsOccurrence() []IsOccurrencesIsOccurrence { return v.IsOccurrence } + // LicenseInputSpec specifies an license for mutations. One of inline or // listVersion should be empty or missing. type LicenseInputSpec struct { @@ -22694,6 +22929,14 @@ type __HasSBOMsInput struct { // GetFilter returns __HasSBOMsInput.Filter, and is useful for accessing the field via an interface. func (v *__HasSBOMsInput) GetFilter() HasSBOMSpec { return v.Filter } +// __HashEqualsInput is used internally by genqlient +type __HashEqualsInput struct { + Filter HashEqualSpec `json:"filter"` +} + +// GetFilter returns __HashEqualsInput.Filter, and is useful for accessing the field via an interface. +func (v *__HashEqualsInput) GetFilter() HashEqualSpec { return v.Filter } + // __IngestArtifactInput is used internally by genqlient type __IngestArtifactInput struct { Artifact IDorArtifactInput `json:"artifact"` @@ -23764,6 +24007,14 @@ type __IngestVulnerabilityInput struct { // GetVuln returns __IngestVulnerabilityInput.Vuln, and is useful for accessing the field via an interface. func (v *__IngestVulnerabilityInput) GetVuln() IDorVulnerabilityInput { return v.Vuln } +// __IsOccurrencesInput is used internally by genqlient +type __IsOccurrencesInput struct { + Filter IsOccurrenceSpec `json:"filter"` +} + +// GetFilter returns __IsOccurrencesInput.Filter, and is useful for accessing the field via an interface. +func (v *__IsOccurrencesInput) GetFilter() IsOccurrenceSpec { return v.Filter } + // __LicensesInput is used internally by genqlient type __LicensesInput struct { Filter LicenseSpec `json:"filter"` @@ -24414,6 +24665,55 @@ func HasSBOMs( return &data_, err_ } +// The query or mutation executed by HashEquals. +const HashEquals_Operation = ` +query HashEquals ($filter: HashEqualSpec!) { + HashEqual(hashEqualSpec: $filter) { + ... AllHashEqualTree + } +} +fragment AllHashEqualTree on HashEqual { + id + justification + artifacts { + ... AllArtifactTree + } + origin + collector +} +fragment AllArtifactTree on Artifact { + id + algorithm + digest +} +` + +func HashEquals( + ctx_ context.Context, + client_ graphql.Client, + filter HashEqualSpec, +) (*HashEqualsResponse, error) { + req_ := &graphql.Request{ + OpName: "HashEquals", + Query: HashEquals_Operation, + Variables: &__HashEqualsInput{ + Filter: filter, + }, + } + var err_ error + + var data_ HashEqualsResponse + resp_ := &graphql.Response{Data: &data_} + + err_ = client_.MakeRequest( + ctx_, + req_, + resp_, + ) + + return &data_, err_ +} + // The query or mutation executed by IngestArtifact. const IngestArtifact_Operation = ` mutation IngestArtifact ($artifact: IDorArtifactInput!) { @@ -26960,6 +27260,99 @@ func IngestVulnerability( return &data_, err_ } +// The query or mutation executed by IsOccurrences. +const IsOccurrences_Operation = ` +query IsOccurrences ($filter: IsOccurrenceSpec!) { + IsOccurrence(isOccurrenceSpec: $filter) { + ... AllIsOccurrencesTree + } +} +fragment AllIsOccurrencesTree on IsOccurrence { + id + subject { + __typename + ... on Package { + ... AllPkgTree + } + ... on Source { + ... AllSourceTree + } + } + artifact { + ... AllArtifactTree + } + justification + origin + collector +} +fragment AllPkgTree on Package { + id + type + namespaces { + id + namespace + names { + id + name + versions { + id + version + qualifiers { + key + value + } + subpath + } + } + } +} +fragment AllSourceTree on Source { + id + type + namespaces { + id + namespace + names { + id + name + tag + commit + } + } +} +fragment AllArtifactTree on Artifact { + id + algorithm + digest +} +` + +func IsOccurrences( + ctx_ context.Context, + client_ graphql.Client, + filter IsOccurrenceSpec, +) (*IsOccurrencesResponse, error) { + req_ := &graphql.Request{ + OpName: "IsOccurrences", + Query: IsOccurrences_Operation, + Variables: &__IsOccurrencesInput{ + Filter: filter, + }, + } + var err_ error + + var data_ IsOccurrencesResponse + resp_ := &graphql.Response{Data: &data_} + + err_ = client_.MakeRequest( + ctx_, + req_, + resp_, + ) + + return &data_, err_ +} + // The query or mutation executed by Licenses. const Licenses_Operation = ` query Licenses ($filter: LicenseSpec!) { diff --git a/pkg/assembler/clients/operations/hashEqual.graphql b/pkg/assembler/clients/operations/hashEqual.graphql index a252b02d7e6..9d7176efb92 100644 --- a/pkg/assembler/clients/operations/hashEqual.graphql +++ b/pkg/assembler/clients/operations/hashEqual.graphql @@ -15,6 +15,12 @@ # NOTE: This is experimental and might change in the future! +query HashEquals($filter: HashEqualSpec!) { + HashEqual(hashEqualSpec: $filter) { + ...AllHashEqualTree + } +} + # Defines the GraphQL operations to certify that two artifacts are identical mutation IngestHashEqual( diff --git a/pkg/assembler/clients/operations/isOccurrence.graphql b/pkg/assembler/clients/operations/isOccurrence.graphql index 9a7ab19b455..0d21ce27446 100644 --- a/pkg/assembler/clients/operations/isOccurrence.graphql +++ b/pkg/assembler/clients/operations/isOccurrence.graphql @@ -17,6 +17,12 @@ # Defines the GraphQL operations to ingest occurrence information into GUAC +query IsOccurrences($filter: IsOccurrenceSpec!) { + IsOccurrence(isOccurrenceSpec: $filter) { + ...AllIsOccurrencesTree + } +} + mutation IngestIsOccurrencePkg( $pkg: IDorPkgInput! $artifact: IDorArtifactInput! diff --git a/pkg/assembler/helpers/purl.go b/pkg/assembler/helpers/purl.go index b8327322d22..b9354250581 100644 --- a/pkg/assembler/helpers/purl.go +++ b/pkg/assembler/helpers/purl.go @@ -22,6 +22,7 @@ import ( "sort" "strings" + "github.com/guacsec/guac/internal/testing/ptrfrom" model "github.com/guacsec/guac/pkg/assembler/clients/generated" purl "github.com/package-url/packageurl-go" ) @@ -42,6 +43,35 @@ func PurlToPkg(purlUri string) (*model.PkgInputSpec, error) { return purlConvert(p) } +// PurlToPkgFilter converts a purl URI string into a graphql package filter spec. +// The result will only match the input purl, and no other packages. The filter +// is created with Guac's purl special casing. +func PurlToPkgFilter(purl string) (model.PkgSpec, error) { + inputSpec, err := PurlToPkg(purl) + if err != nil { + return model.PkgSpec{}, err + } + + var qualifiers []model.PackageQualifierSpec + for _, q := range inputSpec.Qualifiers { + q := q + qualifiers = append(qualifiers, model.PackageQualifierSpec{ + Key: q.Key, + Value: &q.Value, + }) + } + + return model.PkgSpec{ + Type: &inputSpec.Type, + Namespace: ptrfrom.String(nilToEmpty(inputSpec.Namespace)), + Name: &inputSpec.Name, + Version: ptrfrom.String(nilToEmpty(inputSpec.Version)), + Qualifiers: qualifiers, + Subpath: ptrfrom.String(nilToEmpty(inputSpec.Subpath)), + MatchOnlyEmptyQualifiers: ptrfrom.Bool(len(qualifiers) == 0), + }, nil +} + // AllPkgTreeToPurl takes one package trie evaluation and converts it into a PURL // it will only do this for one PURL, and will ignore other pkg tries in the fragment func AllPkgTreeToPurl(v *model.AllPkgTree) string { @@ -258,3 +288,10 @@ func GuacGenericPurl(s string) string { return fmt.Sprintf("pkg:guac/generic/%s", sanitizedString) } } + +func nilToEmpty(s *string) string { + if s == nil { + return "" + } + return *s +} diff --git a/pkg/guacrest/client/client.go b/pkg/guacrest/client/client.go index 0475f86fd66..aa0db03ec9e 100644 --- a/pkg/guacrest/client/client.go +++ b/pkg/guacrest/client/client.go @@ -158,7 +158,7 @@ func NewAnalyzeDependenciesRequest(server string, params *AnalyzeDependenciesPar if params.PaginationSpec != nil { - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "PaginationSpec", runtime.ParamLocationQuery, *params.PaginationSpec); err != nil { + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "paginationSpec", runtime.ParamLocationQuery, *params.PaginationSpec); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err @@ -246,7 +246,7 @@ func NewRetrieveDependenciesRequest(server string, params *RetrieveDependenciesP if params.PaginationSpec != nil { - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "PaginationSpec", runtime.ParamLocationQuery, *params.PaginationSpec); err != nil { + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "paginationSpec", runtime.ParamLocationQuery, *params.PaginationSpec); err != nil { return nil, err } else if parsed, err := url.ParseQuery(queryFrag); err != nil { return nil, err @@ -260,16 +260,52 @@ func NewRetrieveDependenciesRequest(server string, params *RetrieveDependenciesP } - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "purl", runtime.ParamLocationQuery, params.Purl); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) + if params.LinkCondition != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "linkCondition", runtime.ParamLocationQuery, *params.LinkCondition); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } } } + + } + + if params.Purl != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "purl", runtime.ParamLocationQuery, *params.Purl); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Digest != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "digest", runtime.ParamLocationQuery, *params.Digest); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + } queryURL.RawQuery = queryValues.Encode() diff --git a/pkg/guacrest/client/models.go b/pkg/guacrest/client/models.go index 547e8b11834..0175aebc65d 100644 --- a/pkg/guacrest/client/models.go +++ b/pkg/guacrest/client/models.go @@ -9,6 +9,12 @@ const ( Scorecard AnalyzeDependenciesParamsSort = "scorecard" ) +// Defines values for RetrieveDependenciesParamsLinkCondition. +const ( + Digest RetrieveDependenciesParamsLinkCondition = "digest" + Name RetrieveDependenciesParamsLinkCondition = "name" +) + // Error defines model for Error. type Error struct { Message string `json:"Message"` @@ -50,7 +56,7 @@ type AnalyzeDependenciesParams struct { // PaginationSpec The pagination configuration for the query. // * 'PageSize' specifies the number of results returned // * 'Cursor' is returned by previous calls and specifies what page to return - PaginationSpec *PaginationSpec `form:"PaginationSpec,omitempty" json:"PaginationSpec,omitempty"` + PaginationSpec *PaginationSpec `form:"paginationSpec,omitempty" json:"paginationSpec,omitempty"` // Sort The sort order of the packages // * 'frequency' - The packages with the highest number of dependents @@ -66,8 +72,17 @@ type RetrieveDependenciesParams struct { // PaginationSpec The pagination configuration for the query. // * 'PageSize' specifies the number of results returned // * 'Cursor' is returned by previous calls and specifies what page to return - PaginationSpec *PaginationSpec `form:"PaginationSpec,omitempty" json:"PaginationSpec,omitempty"` + PaginationSpec *PaginationSpec `form:"paginationSpec,omitempty" json:"paginationSpec,omitempty"` - // Purl the purl of the dependent package - Purl string `form:"purl" json:"purl"` + // LinkCondition Whether links between nouns must be made by digest or if they can be made just by name (i.e. purl). Specify 'name' to allow using SBOMs that don't provide the digest of the subject. The default is 'digest'. To search by purl, 'name' must be specified. + LinkCondition *RetrieveDependenciesParamsLinkCondition `form:"linkCondition,omitempty" json:"linkCondition,omitempty"` + + // Purl The purl of the dependent package. + Purl *string `form:"purl,omitempty" json:"purl,omitempty"` + + // Digest The digest of the dependent package. + Digest *string `form:"digest,omitempty" json:"digest,omitempty"` } + +// RetrieveDependenciesParamsLinkCondition defines parameters for RetrieveDependencies. +type RetrieveDependenciesParamsLinkCondition string diff --git a/pkg/guacrest/generated/models.go b/pkg/guacrest/generated/models.go index d43d70e7958..0578c97155b 100644 --- a/pkg/guacrest/generated/models.go +++ b/pkg/guacrest/generated/models.go @@ -9,6 +9,12 @@ const ( Scorecard AnalyzeDependenciesParamsSort = "scorecard" ) +// Defines values for RetrieveDependenciesParamsLinkCondition. +const ( + Digest RetrieveDependenciesParamsLinkCondition = "digest" + Name RetrieveDependenciesParamsLinkCondition = "name" +) + // Error defines model for Error. type Error struct { Message string `json:"Message"` @@ -50,7 +56,7 @@ type AnalyzeDependenciesParams struct { // PaginationSpec The pagination configuration for the query. // * 'PageSize' specifies the number of results returned // * 'Cursor' is returned by previous calls and specifies what page to return - PaginationSpec *PaginationSpec `form:"PaginationSpec,omitempty" json:"PaginationSpec,omitempty"` + PaginationSpec *PaginationSpec `form:"paginationSpec,omitempty" json:"paginationSpec,omitempty"` // Sort The sort order of the packages // * 'frequency' - The packages with the highest number of dependents @@ -66,8 +72,17 @@ type RetrieveDependenciesParams struct { // PaginationSpec The pagination configuration for the query. // * 'PageSize' specifies the number of results returned // * 'Cursor' is returned by previous calls and specifies what page to return - PaginationSpec *PaginationSpec `form:"PaginationSpec,omitempty" json:"PaginationSpec,omitempty"` + PaginationSpec *PaginationSpec `form:"paginationSpec,omitempty" json:"paginationSpec,omitempty"` - // Purl the purl of the dependent package - Purl string `form:"purl" json:"purl"` + // LinkCondition Whether links between nouns must be made by digest or if they can be made just by name (i.e. purl). Specify 'name' to allow using SBOMs that don't provide the digest of the subject. The default is 'digest'. To search by purl, 'name' must be specified. + LinkCondition *RetrieveDependenciesParamsLinkCondition `form:"linkCondition,omitempty" json:"linkCondition,omitempty"` + + // Purl The purl of the dependent package. + Purl *string `form:"purl,omitempty" json:"purl,omitempty"` + + // Digest The digest of the dependent package. + Digest *string `form:"digest,omitempty" json:"digest,omitempty"` } + +// RetrieveDependenciesParamsLinkCondition defines parameters for RetrieveDependencies. +type RetrieveDependenciesParamsLinkCondition string diff --git a/pkg/guacrest/generated/server.go b/pkg/guacrest/generated/server.go index 87271d0c151..2b51f7a2db2 100644 --- a/pkg/guacrest/generated/server.go +++ b/pkg/guacrest/generated/server.go @@ -22,7 +22,7 @@ type ServerInterface interface { // Health check the server // (GET /healthz) HealthCheck(w http.ResponseWriter, r *http.Request) - // Retrieve the dependencies of a package + // Retrieve transitive dependencies // (GET /query/dependencies) RetrieveDependencies(w http.ResponseWriter, r *http.Request, params RetrieveDependenciesParams) } @@ -43,7 +43,7 @@ func (_ Unimplemented) HealthCheck(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotImplemented) } -// Retrieve the dependencies of a package +// Retrieve transitive dependencies // (GET /query/dependencies) func (_ Unimplemented) RetrieveDependencies(w http.ResponseWriter, r *http.Request, params RetrieveDependenciesParams) { w.WriteHeader(http.StatusNotImplemented) @@ -67,11 +67,11 @@ func (siw *ServerInterfaceWrapper) AnalyzeDependencies(w http.ResponseWriter, r // Parameter object where we will unmarshal all parameters from the context var params AnalyzeDependenciesParams - // ------------- Optional query parameter "PaginationSpec" ------------- + // ------------- Optional query parameter "paginationSpec" ------------- - err = runtime.BindQueryParameter("form", true, false, "PaginationSpec", r.URL.Query(), ¶ms.PaginationSpec) + err = runtime.BindQueryParameter("form", true, false, "paginationSpec", r.URL.Query(), ¶ms.PaginationSpec) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "PaginationSpec", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "paginationSpec", Err: err}) return } @@ -125,29 +125,38 @@ func (siw *ServerInterfaceWrapper) RetrieveDependencies(w http.ResponseWriter, r // Parameter object where we will unmarshal all parameters from the context var params RetrieveDependenciesParams - // ------------- Optional query parameter "PaginationSpec" ------------- + // ------------- Optional query parameter "paginationSpec" ------------- - err = runtime.BindQueryParameter("form", true, false, "PaginationSpec", r.URL.Query(), ¶ms.PaginationSpec) + err = runtime.BindQueryParameter("form", true, false, "paginationSpec", r.URL.Query(), ¶ms.PaginationSpec) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "PaginationSpec", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "paginationSpec", Err: err}) return } - // ------------- Required query parameter "purl" ------------- + // ------------- Optional query parameter "linkCondition" ------------- - if paramValue := r.URL.Query().Get("purl"); paramValue != "" { - - } else { - siw.ErrorHandlerFunc(w, r, &RequiredParamError{ParamName: "purl"}) + err = runtime.BindQueryParameter("form", true, false, "linkCondition", r.URL.Query(), ¶ms.LinkCondition) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "linkCondition", Err: err}) return } - err = runtime.BindQueryParameter("form", true, true, "purl", r.URL.Query(), ¶ms.Purl) + // ------------- Optional query parameter "purl" ------------- + + err = runtime.BindQueryParameter("form", true, false, "purl", r.URL.Query(), ¶ms.Purl) if err != nil { siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "purl", Err: err}) return } + // ------------- Optional query parameter "digest" ------------- + + err = runtime.BindQueryParameter("form", true, false, "digest", r.URL.Query(), ¶ms.Digest) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "digest", Err: err}) + return + } + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { siw.Handler.RetrieveDependencies(w, r, params) })) @@ -413,7 +422,7 @@ type StrictServerInterface interface { // Health check the server // (GET /healthz) HealthCheck(ctx context.Context, request HealthCheckRequestObject) (HealthCheckResponseObject, error) - // Retrieve the dependencies of a package + // Retrieve transitive dependencies // (GET /query/dependencies) RetrieveDependencies(ctx context.Context, request RetrieveDependenciesRequestObject) (RetrieveDependenciesResponseObject, error) } diff --git a/pkg/guacrest/generated/spec.go b/pkg/guacrest/generated/spec.go index f80c3c7d927..f8713cf96db 100644 --- a/pkg/guacrest/generated/spec.go +++ b/pkg/guacrest/generated/spec.go @@ -18,22 +18,26 @@ import ( // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+RWS2/jNhD+KwO2QIBCjYNte/Gtm74C9BFsctvdA02NLG6ooTIk4zqB/nsxlGTLXrnr", - "HnLqzSJnON88vm/8ooxvWk9IMajli2o16wYjcv661WtLOlpPdy0aOSkxGLatHKmluq8R2p0NGE+VXSfu", - "vyrPEGuEx4S8vfxAAN/Axa1e4519xgsILRpbWQzZiFKzQgZfAWNILgZgjIkJy8HxOnHwfAF2fwOrLbSM", - "T9anAEY7F0BTOXl4U+so+BCiH7w+kCqUFewZlioU6QbV8jjVQgVTY6NzTdi3yNFirkkPRH7FbSueIbKl", - "teoKNSY3ubQUcY2suq4Yj/zqE5qoOjliDK2n0L/8Vpe/6ogbvZUv4ykiRfmp29ZZk8EtPgWp/MsE3teM", - "lVqqrxb7Ti7627D4mdlzH+rzzgXkJ2RAMj5RRMYSNAGKi7SS0ERLa6mddKjUUcNKmwekUpJ9q8t3+Jgw", - "xNdH+1aXwH2wAkIyNegAFfsGLD1pZ0vwDI0NQfBORrgr1I1kRtrd5WT7CK+OdwwKfVQYDAt1m9j9bv9j", - "yQ7nbz+oN1T5L0E8sj6CYCM24YtPJHZqP76aWW9VP7yPyTKWavn+GNUkzMfZwT+s14/gbIjC/jaxC/n1", - "Ibyg23XtsBJ/YAh6jTNUPAI3Gn4OpZgp5yG0a09RW+pVymTuD2rCFp8QGs9ZAzFcwk0lVoygGYF8visA", - "/sS/Y68asLHOwQqBrLvMUnSY0d5yVl/ufdTuWsh6nsL0XZirTyciKOlScq5QvkXSrVVL9d3l1eWV4NKx", - "zpAWmrTbBhsWJbZIJZIZwK4xwxD8ff1K6aRYP+NPU9viYKu8n5+2vcniSIq7Ym7tBM8RPJf90oh5EZkH", - "6cOwMKosGGS2F/At3E/uYWNjnT1qu64xxMnyGXOM4yvBeEajuTz9ivMbeeSvFunu7hfYefS/Ti4cSUBN", - "5zRywunaQUqNTO8ukbyUhscns7xr6sejffLm6uoUt3d2ix1Pu0J9f47DRPe7Qv1wjsucBmffN2eFG5di", - "VoXUNJq3orHSJlttcw8aHyLYpvUcNUU4GFVxW9SoXayfT87tb/n+ukbzoObLeLZcz3DteDuU4j388xm2", - "sA3QYzzOs0cGRqBNHPq08kydx8x3g2K9LjUzERO7kZQ7Qo3EOcEG8flXNvy/h31s3kFNpYNSZ72rbdd1", - "3T8BAAD//+nLpofSCwAA", + "H4sIAAAAAAAC/+RWzW4bNxB+lQFbQG2xlYy0vfgWu0ljIGmMyEAPSQ40d6RlzB2uh6RUJdC7F0Nq5ZWy", + "atyDT73tkjOcb/6+mS/K+LbzhBSDOv+iOs26xYic/6710pKO1tO8QyMnNQbDtpMjda5uGoRuLwPG08Iu", + "E5e/hWeIDcJ9Qt5MPxDATzC51kuc2884gdChsQuLIQtRam+RwS+AMSQXAzDGxIT1TvEycfA8AftwA7cb", + "6BhX1qcARjsXQFM9eHjd6Cj4EKLfaX0gVSkr2DMsVSnSLapz1R26WqlgGmx1jgn7DjlazDEpQOQrbjrR", + "DJEtLdW2Ur1zg0tLEZfIarut+iN/+wlNVFs5Ygydp1BevtD1HzriWm/kz3iKSFE+ddc5azK42acgkf8y", + "gPc940Kdq+9mD5mcldswe8HsuZj6OnMBeYUMSMYnishYgyZAUZFUEppoaSmxkwzVOmq41eYOqRZnL3T9", + "Du8Thvj0aC90DVyMVRCSaUAHWLBvwdJKO1uDZ2htCIJ3UMLbSl2JZ6TdPDtbLDw53t4oFKuwE6zUdWL3", + "2v7HkB3W30NPXtHCfwvikfQRBBuxDd98IrFTD+WrmfVGleK9T5axVufvj1ENzHwcLfzDeD0HZ0OU7u8S", + "u5Bf35kXdPusHUbiDYaglzjSikfgesGvoVQj4TyEdukpakuFpUzu/R2bsMUVQus5cyCGKVwtRIoRNCOQ", + "z3cVwJ/4dyysAWvrHNwikHXTTEWHHj1IjvLLjY/aXUqzPo5hShbG4rMVEhR3KTlXKd8h6c6qc/XL9Gx6", + "Jrh0bDKkmSbtNsGGWY0dUo1kdmCXmGEI/hK/WjIp0p/x96FsdTBV3o9X24PI7GjqbKuxsRM8R/Bcl6ER", + "8yAyd5KH3cBYZMIgs5nAz3AzuIe1jU3WaOyywRAHw6f3MfavBOMZjeb69CvOr+WRtx3SfP4S9hrl6+TA", + "EQfUsE4jJxyOHaTUSvXuHclDaff4oJb3Sf14NE+enZ2d6u293Gzfp9tK/foYhQHvbyv122NUxjg46z57", + "lLl+KGZWSG2reSMcK2myi03OQetDBNt2nqOmCAelKmqzBrWLzeeTdfsq3182aO7UeBgfTdcjvXY8HWrR", + "3m0+uylsAxSMx34WZGAE2kChuJVr6lRnHlp9aanO+pE1BRvtCg/i1LeRpS7Faa71VzrML96+yVuVfL+e", + "P5eFq0cvLJeCbA3Fk/1rG2B0OTyhsV1Wl/ur8NaYxIxkMB/C9d3yxX3SbvTV6GEhmI2nYKXPpVNW2iHF", + "fRcWEj1M5bsdNT8tB/3VoHA9OEt3AW4xrhEJyCcK0KYQheVbXaMsqbVdCkN4BptjvAEwmvYSn7L4BoQY", + "4Ac7xWkegz9OYZ5X2Q1M5GoiEdHO+TWkvOhIbiTyOkLtaRKhY7+yNZZk7GyWpIaUR0JJa40LnVyUkoNJ", + "kZtM4cZDQM2myWt1Ylf1Znt3+sW6np4kNYnGpafa5iiNsVmx12uMsNgo2wue3pc9R/dVMD210svwq/6l", + "M0dNHQbu0cb2fp029//i574NT/GNMOP2nwAAAP///dINuX8OAAA=", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/pkg/guacrest/helpers/artifact.go b/pkg/guacrest/helpers/artifact.go new file mode 100644 index 00000000000..e8748f9b283 --- /dev/null +++ b/pkg/guacrest/helpers/artifact.go @@ -0,0 +1,47 @@ +// +// Copyright 2024 The GUAC Authors. +// +// 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 helpers + +import ( + "context" + "fmt" + + "github.com/Khan/genqlient/graphql" + gql "github.com/guacsec/guac/pkg/assembler/clients/generated" + "github.com/guacsec/guac/pkg/logging" +) + +// Queries for an artifact by digest and returns its id. The digest must uniquely +// identify an artifact, otherwise an error is returned. +func FindArtifactWithDigest(ctx context.Context, gqlClient graphql.Client, + digest string) (gql.AllArtifactTree, error) { + logger := logging.FromContext(ctx) + filter := gql.ArtifactSpec{Digest: &digest} + + artifacts, err := gql.Artifacts(ctx, gqlClient, filter) + if err != nil { + logger.Errorf(fmt.Sprintf("Artifacts query returned error: %v", err)) + return gql.AllArtifactTree{}, Err502 + } + if len(artifacts.GetArtifacts()) == 0 { + return gql.AllArtifactTree{}, fmt.Errorf("no artifacts matched the digest") + } + if len(artifacts.GetArtifacts()) > 1 { + logger.Errorf("More than one artifact was found with digest %s", digest) + return gql.AllArtifactTree{}, Err500 + } + return artifacts.GetArtifacts()[0].AllArtifactTree, nil +} diff --git a/pkg/guacrest/helpers/artifact_test.go b/pkg/guacrest/helpers/artifact_test.go new file mode 100644 index 00000000000..deaea9754b9 --- /dev/null +++ b/pkg/guacrest/helpers/artifact_test.go @@ -0,0 +1,54 @@ +// +// Copyright 2024 The GUAC Authors. +// +// 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 helpers_test + +import ( + "context" + "testing" + + test_helpers "github.com/guacsec/guac/internal/testing/graphqlClients" + gql "github.com/guacsec/guac/pkg/assembler/clients/generated" + "github.com/guacsec/guac/pkg/guacrest/helpers" + "github.com/guacsec/guac/pkg/logging" + "github.com/stretchr/testify/assert" +) + +func Test_FindArtifactWithDigest_ArtifactNotFound(t *testing.T) { + ctx := logging.WithLogger(context.Background()) + gqlClient := test_helpers.SetupTest(t) + + _, err := helpers.FindArtifactWithDigest(ctx, gqlClient, "xyz") + assert.ErrorContains(t, err, "no artifacts matched the digest") +} + +func Test_FindArtifactWithDigest_ArtifactFound(t *testing.T) { + ctx := logging.WithLogger(context.Background()) + gqlClient := test_helpers.SetupTest(t) + + idOrArtifactSpec := gql.IDorArtifactInput{ArtifactInput: &gql.ArtifactInputSpec{ + Algorithm: "sha256", + Digest: "abc", + }} + _, err := gql.IngestArtifact(ctx, gqlClient, idOrArtifactSpec) + if err != nil { + t.Fatalf("Error ingesting test data") + } + + res, err := helpers.FindArtifactWithDigest(ctx, gqlClient, "abc") + assert.NoError(t, err) + assert.Equal(t, res.Algorithm, "sha256") + assert.Equal(t, res.Digest, "abc") +} diff --git a/pkg/guacrest/helpers/errors.go b/pkg/guacrest/helpers/errors.go new file mode 100644 index 00000000000..3d5dbca4b33 --- /dev/null +++ b/pkg/guacrest/helpers/errors.go @@ -0,0 +1,25 @@ +// +// Copyright 2024 The GUAC Authors. +// +// 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 helpers + +import "errors" + +// Err502 is used to surface errors from the graphql server. +var Err502 error = errors.New("Error querying the graphql server. The error message should have been logged") + +// Err500 is used to surface generic internal errors, such as an unexpected response +// from Graphql server. +var Err500 error = errors.New("Internal Error. The error message should have been logged") diff --git a/pkg/guacrest/helpers/package.go b/pkg/guacrest/helpers/package.go new file mode 100644 index 00000000000..a35187bf193 --- /dev/null +++ b/pkg/guacrest/helpers/package.go @@ -0,0 +1,71 @@ +// +// Copyright 2024 The GUAC Authors. +// +// 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 helpers + +import ( + "context" + "fmt" + + "github.com/Khan/genqlient/graphql" + gql "github.com/guacsec/guac/pkg/assembler/clients/generated" + assembler_helpers "github.com/guacsec/guac/pkg/assembler/helpers" + "github.com/guacsec/guac/pkg/logging" +) + +// Returns all of the version nodes of the AllPkgTree fragment input +func GetVersionsOfAllPackageTree(trie gql.AllPkgTree) []gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageNameVersionsPackageVersion { + res := []gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageNameVersionsPackageVersion{} + for _, namespace := range trie.GetNamespaces() { + for _, name := range namespace.GetNames() { + res = append(res, name.GetVersions()...) + } + } + return res +} + +// Returns all of the version nodes of the Packages query result +func GetVersionsOfPackagesResponse(packages []gql.PackagesPackagesPackage) []gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageNameVersionsPackageVersion { + res := []gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageNameVersionsPackageVersion{} + for _, pkg := range packages { + res = append(res, GetVersionsOfAllPackageTree(pkg.AllPkgTree)...) + } + return res +} + +// Returns the version node of the package that matches the input purl. The purl +// must uniquely identify a package, otherwise an error is returned. +func FindPackageWithPurl(ctx context.Context, gqlClient graphql.Client, + purl string) (gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageNameVersionsPackageVersion, error) { + logger := logging.FromContext(ctx) + + filter, err := assembler_helpers.PurlToPkgFilter(purl) + if err != nil { + // return the error message, to indicate unparseable purls + return gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageNameVersionsPackageVersion{}, err + } + response, err := gql.Packages(ctx, gqlClient, filter) + if err != nil { + logger.Errorf(fmt.Sprintf("Packages query returned error: %v", err)) + return gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageNameVersionsPackageVersion{}, Err502 + } + + versions := GetVersionsOfPackagesResponse(response.GetPackages()) + if len(versions) == 0 { + return gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageNameVersionsPackageVersion{}, fmt.Errorf("no packages matched the input purl") + } + // The filter should have matched at most one package + return response.GetPackages()[0].AllPkgTree.GetNamespaces()[0].GetNames()[0].GetVersions()[0], nil +} diff --git a/pkg/guacrest/helpers/package_test.go b/pkg/guacrest/helpers/package_test.go new file mode 100644 index 00000000000..7b8e287e2ac --- /dev/null +++ b/pkg/guacrest/helpers/package_test.go @@ -0,0 +1,225 @@ +// +// Copyright 2024 The GUAC Authors. +// +// 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 helpers_test + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + test_helpers "github.com/guacsec/guac/internal/testing/graphqlClients" + gql "github.com/guacsec/guac/pkg/assembler/clients/generated" + "github.com/guacsec/guac/pkg/guacrest/helpers" + "github.com/guacsec/guac/pkg/guacrest/pagination" + "github.com/guacsec/guac/pkg/logging" +) + +func Test_GetVersionsOfPackagesResponse(t *testing.T) { + tests := []struct { + testName string + input []gql.PackagesPackagesPackage + expected []gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageNameVersionsPackageVersion + }{ + { + testName: "No package version nodes", + input: []gql.PackagesPackagesPackage{{AllPkgTree: gql.AllPkgTree{ + Id: "0", + Type: "golang", + Namespaces: []gql.AllPkgTreeNamespacesPackageNamespace{{ + Id: "1", + Namespace: "", + Names: []gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageName{{ + Id: "2", + Name: "foo", + }}, + }}, + }}}, + }, + { + testName: "Returns all package version nodes nested in one name node", + input: []gql.PackagesPackagesPackage{{AllPkgTree: gql.AllPkgTree{ + Id: "0", + Type: "golang", + Namespaces: []gql.AllPkgTreeNamespacesPackageNamespace{{ + Id: "1", + Namespace: "", + Names: []gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageName{{ + Id: "2", + Name: "foo", + Versions: []gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageNameVersionsPackageVersion{ + { + Id: "3", + Version: "v1", + }, + { + Id: "4", + Version: "v2", + }, + }, + }}, + }}, + }}}, + expected: []gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageNameVersionsPackageVersion{ + { + Id: "3", + Version: "v1", + }, + { + Id: "4", + Version: "v2", + }, + }, + }, + } + + for _, tt := range tests { + actual := helpers.GetVersionsOfPackagesResponse(tt.input) + if !cmp.Equal(tt.expected, actual, cmpopts.EquateEmpty()) { + t.Errorf("Got %v, wanted %v", actual, tt.expected) + } + } +} + +func Test_FindPackageWithPurl(t *testing.T) { + ctx := logging.WithLogger(context.Background()) + + tests := []struct { + testName string + input string + wantErr bool + + ingestedPkgToExpect *gql.PkgInputSpec // this package is ingested, and its ID is the expected output + otherPackageToIngest *gql.PkgInputSpec // other packages to ingest + }{ + { + testName: "Matched ID of version node, package does not have version", + input: "pkg:guac/bar", + ingestedPkgToExpect: &gql.PkgInputSpec{Type: "guac", Name: "bar"}, + }, + { + testName: "Matched ID of version node, package has version", + input: "pkg:guac/bar@v1", + ingestedPkgToExpect: &gql.PkgInputSpec{Type: "guac", Name: "bar", Version: pagination.PointerOf("v1")}, + }, + { + testName: "Matched the less specific (without version) package", + input: "pkg:guac/bar", + ingestedPkgToExpect: &gql.PkgInputSpec{Type: "guac", Name: "bar"}, + otherPackageToIngest: &gql.PkgInputSpec{Type: "guac", Name: "bar", Version: pagination.PointerOf("v1")}, + }, + { + testName: "Matched the less specific (without qualifiers) package", + input: "pkg:guac/bar", + ingestedPkgToExpect: &gql.PkgInputSpec{Type: "guac", Name: "bar"}, + otherPackageToIngest: &gql.PkgInputSpec{ + Type: "guac", Name: "bar", + Qualifiers: []gql.PackageQualifierInputSpec{{Key: "key", Value: "val"}}}, + }, + { + testName: "Matched the more specific (with version) package", + input: "pkg:guac/bar@v1", + ingestedPkgToExpect: &gql.PkgInputSpec{Type: "guac", Name: "bar", Version: pagination.PointerOf("v1")}, + otherPackageToIngest: &gql.PkgInputSpec{Type: "guac", Name: "bar"}, + }, + { + testName: "Matched the more specific (with qualifiers) package", + input: "pkg:guac/bar?key=val", + ingestedPkgToExpect: &gql.PkgInputSpec{ + Type: "guac", Name: "bar", + Qualifiers: []gql.PackageQualifierInputSpec{{Key: "key", Value: "val"}}, + }, + otherPackageToIngest: &gql.PkgInputSpec{Type: "guac", Name: "bar"}, + }, + { + testName: "Same qualifier key in both packages", + input: "pkg:guac/bar?key=val-1", + ingestedPkgToExpect: &gql.PkgInputSpec{ + Type: "guac", Name: "bar", + Qualifiers: []gql.PackageQualifierInputSpec{{Key: "key", Value: "val-1"}}, + }, + otherPackageToIngest: &gql.PkgInputSpec{ + Type: "guac", Name: "bar", + Qualifiers: []gql.PackageQualifierInputSpec{{Key: "key", Value: "val-2"}}}, + }, + { + testName: "Common qualifiers in both packages", + input: "pkg:guac/bar?a=b&c=d", + ingestedPkgToExpect: &gql.PkgInputSpec{ + Type: "guac", Name: "bar", + Qualifiers: []gql.PackageQualifierInputSpec{{Key: "a", Value: "b"}, {Key: "c", Value: "d"}}, + }, + otherPackageToIngest: &gql.PkgInputSpec{ + Type: "guac", Name: "bar", + Qualifiers: []gql.PackageQualifierInputSpec{{Key: "a", Value: "b"}, {Key: "c", Value: "e"}}}, + }, + { + testName: "Input without qualifiers does not match package with qualifiers", + input: "pkg:guac/bar", + otherPackageToIngest: &gql.PkgInputSpec{ + Type: "guac", Name: "bar", + Qualifiers: []gql.PackageQualifierInputSpec{{Key: "a", Value: "b"}}}, + wantErr: true, + }, + { + testName: "Input with qualifiers does not match package without qualifiers", + input: "pkg:guac/bar?a=b", + otherPackageToIngest: &gql.PkgInputSpec{Type: "guac", Name: "bar"}, + wantErr: true, + }, + { + testName: "Input without version does not match package with version", + input: "pkg:guac/bar", + otherPackageToIngest: &gql.PkgInputSpec{Type: "guac", Name: "bar", Version: pagination.PointerOf("v1")}, + wantErr: true, + }, + } + + for _, tt := range tests { + t.Run(tt.testName, func(t *testing.T) { + gqlClient := test_helpers.SetupTest(t) + + // ingest the expected output package and get its ID + var expected *gql.IngestPackageResponse + var err error + if tt.ingestedPkgToExpect != nil { + inputSpec := gql.IDorPkgInput{PackageInput: tt.ingestedPkgToExpect} + expected, err = gql.IngestPackage(ctx, gqlClient, inputSpec) + if err != nil { + t.Errorf("Error setting up test: %s", err) + } + } + + // ingest the other package + if tt.otherPackageToIngest != nil { + inputSpec := gql.IDorPkgInput{PackageInput: tt.otherPackageToIngest} + _, err = gql.IngestPackage(ctx, gqlClient, inputSpec) + if err != nil { + t.Errorf("Error setting up test: %s", err) + } + } + + // call the endpoint and check the output + res, err := helpers.FindPackageWithPurl(ctx, gqlClient, tt.input) + if (err != nil) != tt.wantErr { + t.Errorf("tt.wantErr is %v, but err is %s", tt.wantErr, err) + } + if !tt.wantErr && res.GetId() != expected.IngestPackage.PackageVersionID { + t.Errorf("Got %s, but expected %s", res, expected.IngestPackage.PackageVersionID) + } + }) + } +} diff --git a/pkg/guacrest/openapi.yaml b/pkg/guacrest/openapi.yaml index 259254ac3d1..0da2117abb9 100644 --- a/pkg/guacrest/openapi.yaml +++ b/pkg/guacrest/openapi.yaml @@ -30,14 +30,37 @@ paths: type: string "/query/dependencies": get: - summary: Retrieve the dependencies of a package + summary: Retrieve transitive dependencies + description: > + Find the transitive dependencies of the input. The HasSBOM and HasSLSA + predicates are used as the dependency relationship and the IsOccurrence and + PkgEqual predicates are used to find consider equivalent packages. operationId: retrieveDependencies parameters: - $ref: "#/components/parameters/PaginationSpec" + - name: linkCondition + description: > + Whether links between nouns must be made by digest or if they + can be made just by name (i.e. purl). Specify 'name' to allow using + SBOMs that don't provide the digest of the subject. The default is + 'digest'. To search by purl, 'name' must be specified. + in: query + required: false + schema: + type: string + enum: + - digest + - name - name: purl - description: the purl of the dependent package + description: The purl of the dependent package. in: query - required: true + required: false + schema: + type: string + - name: digest + description: The digest of the dependent package. + in: query + required: false schema: type: string responses: @@ -81,7 +104,7 @@ paths: components: parameters: PaginationSpec: - name: PaginationSpec + name: paginationSpec in: query description: > The pagination configuration for the query. diff --git a/pkg/guacrest/pagination/pagination.go b/pkg/guacrest/pagination/pagination.go index 35851966e67..32211736025 100644 --- a/pkg/guacrest/pagination/pagination.go +++ b/pkg/guacrest/pagination/pagination.go @@ -32,7 +32,7 @@ const ( // Returns the result of Paginate with a page size of DefaultPageSize func DefaultPaginate[T any](ctx context.Context, lst []T) ([]T, models.PaginationInfo) { logger := logging.FromContext(ctx) - page, info, err := Paginate(ctx, lst, models.PaginationSpec{PageSize: PointerOf(DefaultPageSize)}) + page, info, err := Paginate(ctx, lst, &models.PaginationSpec{PageSize: PointerOf(DefaultPageSize)}) if err != nil { // should not occur with the default pagination spec, see contract of Paginate logger.Fatalf("Pagate returned err: %s, but should not have", err) @@ -43,19 +43,20 @@ func DefaultPaginate[T any](ctx context.Context, lst []T) ([]T, models.Paginatio // Returns a single page from the input, selected using the given // pagination spec, along with a struct describing the pagination of the // returned page. The input result set should be the same for every call that -// uses chained PaginationSpecs and PaginationInfos. +// uses chained PaginationSpecs and PaginationInfos. If spec is nil, a default +// page size is used. // // Errors are suitable to directly return to clients. An error is returned only if: // - the cursor is the empty string // - the cursor decodes to an out of bounds index in the input // - the cursor can't be decoded // - PageSize < 0 -func Paginate[T any](ctx context.Context, lst []T, spec models.PaginationSpec) ([]T, +func Paginate[T any](ctx context.Context, lst []T, spec *models.PaginationSpec) ([]T, models.PaginationInfo, error) { logger := logging.FromContext(ctx) var pagesize int = DefaultPageSize - if spec.PageSize != nil { + if spec != nil && spec.PageSize != nil { pagesize = *spec.PageSize } if pagesize < 0 { @@ -66,7 +67,7 @@ func Paginate[T any](ctx context.Context, lst []T, spec models.PaginationSpec) ( var inputLength uint64 = uint64(len(lst)) var start uint64 = 0 - if spec.Cursor != nil { + if spec != nil && spec.Cursor != nil { if *spec.Cursor == "" { return nil, models.PaginationInfo{}, fmt.Errorf("Pagination error: The cursor is the empty string") diff --git a/pkg/guacrest/pagination/pagination_test.go b/pkg/guacrest/pagination/pagination_test.go index a9bb4b25f23..6248e14a1c5 100644 --- a/pkg/guacrest/pagination/pagination_test.go +++ b/pkg/guacrest/pagination/pagination_test.go @@ -31,7 +31,7 @@ func Test_Cursors(t *testing.T) { for i := range inputList { spec := models.PaginationSpec{PageSize: pagination.PointerOf(i)} - _, info, err := pagination.Paginate(ctx, inputList, spec) + _, info, err := pagination.Paginate(ctx, inputList, &spec) if err != nil { t.Fatalf("Unexpected error when calling Paginate to retrieve a cursor: %s", err) } @@ -44,7 +44,7 @@ func Test_Cursors(t *testing.T) { PageSize: pagination.PointerOf(100), Cursor: info.NextCursor, } - page, _, err := pagination.Paginate(ctx, inputList, spec) + page, _, err := pagination.Paginate(ctx, inputList, &spec) if err != nil { t.Fatalf("Unexpected error (%s) when calling Paginate to retrieve an element"+ " at index %d.", err, i) @@ -56,8 +56,8 @@ func Test_Cursors(t *testing.T) { } } -// Paginate is black-box by first retrieving some cursors, and then using them -// to test different combinations of PaginationSpec. This avoids testing +// Paginate is black-box tested by first retrieving some cursors, and then using +// them to test different combinations of PaginationSpec. This avoids testing // the implementation of the cursors. func Test_Paginate(t *testing.T) { ctx := context.Background() @@ -68,7 +68,7 @@ func Test_Paginate(t *testing.T) { cursors := []string{} for i := range inputList { spec := models.PaginationSpec{PageSize: pagination.PointerOf(i)} - _, info, err := pagination.Paginate(ctx, inputList, spec) + _, info, err := pagination.Paginate(ctx, inputList, &spec) if err != nil { t.Fatalf("Unexpected error when calling Paginate to set up the tests: %s", err) } @@ -81,7 +81,7 @@ func Test_Paginate(t *testing.T) { // generate a cursor that is out of range of inputList longerInputList := append(inputList, 18) spec := models.PaginationSpec{PageSize: pagination.PointerOf(6)} - _, info, err := pagination.Paginate(ctx, longerInputList, spec) + _, info, err := pagination.Paginate(ctx, longerInputList, &spec) if err != nil { t.Fatalf("Unexpected error when calling Paginate to set up the"+ " out-of-range cursor test: %s", err) @@ -95,14 +95,21 @@ func Test_Paginate(t *testing.T) { tests := []struct { name string - inputSpec models.PaginationSpec + inputSpec *models.PaginationSpec expectedPage []int expectedPaginationInfo models.PaginationInfo wantErr bool }{ + { + name: "PaginationSpec is nil, default is used", + expectedPage: inputList, + expectedPaginationInfo: models.PaginationInfo{ + TotalCount: pagination.PointerOf(6), + }, + }, { name: "Only PageSize specified", - inputSpec: models.PaginationSpec{PageSize: pagination.PointerOf(3)}, + inputSpec: &models.PaginationSpec{PageSize: pagination.PointerOf(3)}, expectedPage: []int{12, 13, 14}, expectedPaginationInfo: models.PaginationInfo{ TotalCount: pagination.PointerOf(6), @@ -111,7 +118,7 @@ func Test_Paginate(t *testing.T) { }, { name: "PageSize is greater than the number of entries", - inputSpec: models.PaginationSpec{PageSize: pagination.PointerOf(10)}, + inputSpec: &models.PaginationSpec{PageSize: pagination.PointerOf(10)}, expectedPage: inputList, expectedPaginationInfo: models.PaginationInfo{ TotalCount: pagination.PointerOf(6), @@ -119,7 +126,7 @@ func Test_Paginate(t *testing.T) { }, { name: "PageSize is equal to the number of entries", - inputSpec: models.PaginationSpec{PageSize: pagination.PointerOf(6)}, + inputSpec: &models.PaginationSpec{PageSize: pagination.PointerOf(6)}, expectedPage: inputList, expectedPaginationInfo: models.PaginationInfo{ TotalCount: pagination.PointerOf(6), @@ -127,7 +134,7 @@ func Test_Paginate(t *testing.T) { }, { name: "PageSize is 0", - inputSpec: models.PaginationSpec{PageSize: pagination.PointerOf(0)}, + inputSpec: &models.PaginationSpec{PageSize: pagination.PointerOf(0)}, expectedPage: []int{}, expectedPaginationInfo: models.PaginationInfo{ TotalCount: pagination.PointerOf(6), @@ -136,12 +143,12 @@ func Test_Paginate(t *testing.T) { }, { name: "PageSize is negative", - inputSpec: models.PaginationSpec{PageSize: pagination.PointerOf(-1)}, + inputSpec: &models.PaginationSpec{PageSize: pagination.PointerOf(-1)}, wantErr: true, }, { name: "PageSize is in range, Cursor is valid", - inputSpec: models.PaginationSpec{ + inputSpec: &models.PaginationSpec{ PageSize: pagination.PointerOf(2), Cursor: pagination.PointerOf(cursors[2]), }, @@ -153,7 +160,7 @@ func Test_Paginate(t *testing.T) { }, { name: "PageSize is 1, Cursor is valid", - inputSpec: models.PaginationSpec{ + inputSpec: &models.PaginationSpec{ PageSize: pagination.PointerOf(1), Cursor: pagination.PointerOf(cursors[5]), }, @@ -164,7 +171,7 @@ func Test_Paginate(t *testing.T) { }, { name: "PageSize + Cursor is greater than number of entries", - inputSpec: models.PaginationSpec{ + inputSpec: &models.PaginationSpec{ PageSize: pagination.PointerOf(3), Cursor: pagination.PointerOf(cursors[4]), }, @@ -175,7 +182,7 @@ func Test_Paginate(t *testing.T) { }, { name: "PageSize is in range, Cursor is empty string", - inputSpec: models.PaginationSpec{ + inputSpec: &models.PaginationSpec{ PageSize: pagination.PointerOf(3), Cursor: pagination.PointerOf(""), }, @@ -183,7 +190,7 @@ func Test_Paginate(t *testing.T) { }, { name: "PageSize is in range, Cursor is invalid base64", - inputSpec: models.PaginationSpec{ + inputSpec: &models.PaginationSpec{ PageSize: pagination.PointerOf(3), Cursor: pagination.PointerOf("$%^"), }, @@ -191,7 +198,7 @@ func Test_Paginate(t *testing.T) { }, { name: "PageSize is in range, Cursor is too large", - inputSpec: models.PaginationSpec{ + inputSpec: &models.PaginationSpec{ PageSize: pagination.PointerOf(3), Cursor: pagination.PointerOf("ABCDABCDABCD"), }, @@ -199,7 +206,7 @@ func Test_Paginate(t *testing.T) { }, { name: "PageSize is in range, Cursor is too small", - inputSpec: models.PaginationSpec{ + inputSpec: &models.PaginationSpec{ PageSize: pagination.PointerOf(3), Cursor: pagination.PointerOf("ABC"), }, @@ -207,14 +214,14 @@ func Test_Paginate(t *testing.T) { }, { name: "Cursor is out of range", - inputSpec: models.PaginationSpec{ + inputSpec: &models.PaginationSpec{ Cursor: outOfRangeCursor, }, wantErr: true, }, { name: "PageSize is not specified", - inputSpec: models.PaginationSpec{ + inputSpec: &models.PaginationSpec{ Cursor: pagination.PointerOf(cursors[1]), }, expectedPage: []int{13, 14, 15, 16, 17}, diff --git a/pkg/guacrest/server/errors.go b/pkg/guacrest/server/errors.go new file mode 100644 index 00000000000..b90aea45ac3 --- /dev/null +++ b/pkg/guacrest/server/errors.go @@ -0,0 +1,48 @@ +// +// Copyright 2024 The GUAC Authors. +// +// 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 server + +import ( + "context" + + gen "github.com/guacsec/guac/pkg/guacrest/generated" + "github.com/guacsec/guac/pkg/guacrest/helpers" +) + +// Maps helpers.Err502 and helpers.Err500 to the corresponding OpenAPI response type. +// Other errors are returned as Client errors. +func handleErr(ctx context.Context, err error) gen.RetrieveDependenciesResponseObject { + if err == nil { + return nil + } + switch err { + case helpers.Err502: + return gen.RetrieveDependencies502JSONResponse{ + BadGatewayJSONResponse: gen.BadGatewayJSONResponse{ + Message: err.Error(), + }} + case helpers.Err500: + return gen.RetrieveDependencies500JSONResponse{ + InternalServerErrorJSONResponse: gen.InternalServerErrorJSONResponse{ + Message: err.Error(), + }} + default: + return gen.RetrieveDependencies400JSONResponse{ + BadRequestJSONResponse: gen.BadRequestJSONResponse{ + Message: err.Error(), + }} + } +} diff --git a/pkg/guacrest/server/retrieveDependencies.go b/pkg/guacrest/server/retrieveDependencies.go new file mode 100644 index 00000000000..db09f8e367e --- /dev/null +++ b/pkg/guacrest/server/retrieveDependencies.go @@ -0,0 +1,394 @@ +package server + +import ( + "context" + "fmt" + + "github.com/Khan/genqlient/graphql" + gql "github.com/guacsec/guac/pkg/assembler/clients/generated" + assembler_helpers "github.com/guacsec/guac/pkg/assembler/helpers" + gen "github.com/guacsec/guac/pkg/guacrest/generated" + "github.com/guacsec/guac/pkg/guacrest/helpers" + "github.com/guacsec/guac/pkg/guacrest/pagination" + "github.com/guacsec/guac/pkg/logging" + "golang.org/x/exp/maps" +) + +// node is implemented by all graphQL client types +type node interface { + GetId() string +} + +// edgeGen defines the edges used by the transitive dependencies graph traversal. +type edgeGen interface { + // getDirectDependencies returns the nouns that are direct dependencies of the input noun. + getDirectDependencies(ctx context.Context, v node) ([]node, error) + + // getEquivalentNodes returns the nouns that are considered equivalent to the input noun. + getEquivalentNodes(ctx context.Context, v node) ([]node, error) +} + +// byDigest is an edgeGen that observes relationships between nouns when they are +// linked by digest. +// +// The dependency edges are: +// - artifact -> sbom -> package +// - artifact -> sbom -> artifact +// - artifact -> slsa -> artifact +// +// And the equivalence edges are: +// - artifact -> IsOccurrence -> package +// - artifact -> HashEquals -> artifact +// +// byDigest lazily generates edges using calls to the GraphQL server, instead +// of precomputing the graph. +type byDigest struct { + gqlClient graphql.Client +} + +func newByDigest(gqlClient graphql.Client) byDigest { + return byDigest{gqlClient: gqlClient} +} + +// byName is a edgeGen that respects all relationships between nouns, whether they +// are linked by hash or by name. It is useful when SBOMs don't provide the digest +// of the subject. +// +// It implements all edges defined by byDigest, in addition to the following: +// dependency edges: +// - package -> sbom -> package +// - package -> sbom -> artifact +// +// equivalence edges: +// - package -> IsOccurrence -> artifact +// +// byName lazily generates edges using calls to the GraphQL server, instead of +// precomputing the graph. +type byName struct { + gqlClient graphql.Client + bd byDigest +} + +func newByName(gqlClient graphql.Client) byName { + return byName{gqlClient: gqlClient, bd: newByDigest(gqlClient)} +} + +/********* The graph traversal *********/ + +func getTransitiveDependencies( + ctx context.Context, + gqlClient graphql.Client, + start node, + edges edgeGen) ([]node, error) { + + // As the queue in this function is essentially a list of IO actions, this + // function could be optimized by running through the queue and executing + // all of them concurrently. + + queue := []node{start} + visited := map[string]node{} + + // maintain the set of nodes are equivalent to the start node, including the start node + nodesEquivalentToStart := map[node]any{start: struct{}{}} + + for len(queue) > 0 { + node := queue[0] + queue = queue[1:] + + if _, ok := visited[node.GetId()]; ok { + continue + } + visited[node.GetId()] = node + + adjacent, err := edges.getDirectDependencies(ctx, node) + if err != nil { + return nil, err + } + queue = append(queue, adjacent...) + + adjacent, err = edges.getEquivalentNodes(ctx, node) + if err != nil { + return nil, err + } + queue = append(queue, adjacent...) + + if _, ok := nodesEquivalentToStart[node]; ok { + for _, equivalentNode := range adjacent { + nodesEquivalentToStart[equivalentNode] = struct{}{} + } + } + } + + // Nodes equivalent to the start node are not dependencies + for node := range nodesEquivalentToStart { + delete(visited, node.GetId()) + } + return maps.Values(visited), nil +} + +/********* Implementations of the interface *********/ + +func (eg byDigest) getDirectDependencies(ctx context.Context, v node) ([]node, error) { + edgesToPredicates := []gql.Edge{ + gql.EdgeArtifactHasSbom, + gql.EdgeArtifactHasSlsa, + } + edgesFromPredicates := []gql.Edge{ + gql.EdgeHasSbomIncludedSoftware, + gql.EdgeHasSlsaMaterials, + } + return neighborsTwoHops(ctx, eg.gqlClient, v, edgesToPredicates, edgesFromPredicates) +} + +func (eg byDigest) getEquivalentNodes(ctx context.Context, v node) ([]node, error) { + edgesToPredicates := []gql.Edge{ + gql.EdgeArtifactIsOccurrence, + gql.EdgeArtifactHashEqual, + } + edgesFromPredicates := []gql.Edge{ + gql.EdgeIsOccurrenceArtifact, + gql.EdgeIsOccurrencePackage, + gql.EdgeHashEqualArtifact, + } + return neighborsTwoHops(ctx, eg.gqlClient, v, edgesToPredicates, edgesFromPredicates) +} + +func (eg byName) getDirectDependencies(ctx context.Context, v node) ([]node, error) { + edgesToPredicates := []gql.Edge{ + gql.EdgePackageHasSbom, + gql.EdgeArtifactHasSbom, + gql.EdgeArtifactHasSlsa, + } + edgesFromPredicates := []gql.Edge{ + gql.EdgeHasSbomIncludedSoftware, + gql.EdgeHasSlsaMaterials, + } + return neighborsTwoHops(ctx, eg.gqlClient, v, edgesToPredicates, edgesFromPredicates) +} + +func (eg byName) getEquivalentNodes(ctx context.Context, v node) ([]node, error) { + edgesToPredicates := []gql.Edge{ + gql.EdgePackageIsOccurrence, + gql.EdgeArtifactIsOccurrence, + gql.EdgeArtifactHashEqual, + } + edgesFromPredicates := []gql.Edge{ + gql.EdgeIsOccurrenceArtifact, + gql.EdgeIsOccurrencePackage, + gql.EdgeHashEqualArtifact, + } + return neighborsTwoHops(ctx, eg.gqlClient, v, edgesToPredicates, edgesFromPredicates) +} + +/********* Graphql helper functions *********/ + +// neighborsTwoHops calls the GraphQL Neighbors endpoint once with edgesToPredicates, and +// then again on the result with edgesFromPredicates. +func neighborsTwoHops(ctx context.Context, gqlClient graphql.Client, v node, + edgesToPredicates []gql.Edge, edgesFromPredicates []gql.Edge) ([]node, error) { + predicates, err := neighbors(ctx, gqlClient, v, edgesToPredicates) + if err != nil { + return nil, err + } + + res := []node{} + for _, predicate := range predicates { + nodes, err := neighbors(ctx, gqlClient, predicate, edgesFromPredicates) + if err != nil { + return nil, err + } + res = append(res, nodes...) + } + return res, nil +} + +// neighbors calls the GraphQL Neighbors endpoint. +func neighbors(ctx context.Context, gqlClient graphql.Client, v node, edges []gql.Edge) ([]node, error) { + logger := logging.FromContext(ctx) + neighborsResponse, err := gql.Neighbors(ctx, gqlClient, v.GetId(), edges) + if err != nil { + logger.Errorf("Neighbors query returned err: ", err) + return nil, helpers.Err502 + } + if neighborsResponse == nil { + logger.Errorf("Neighbors query returned nil") + return nil, helpers.Err500 + } + return transformWithError(ctx, neighborsResponse.GetNeighbors(), neighborToNode) +} + +// Maps a list of As to a list of Bs +func transformWithError[A any, B any](ctx context.Context, lst []A, f func(context.Context, A) (B, error)) ([]B, error) { + res := []B{} + for _, x := range lst { + transformed, err := f(ctx, x) + if err != nil { + return nil, err + } + res = append(res, transformed) + } + return res, nil +} + +// Returns the graphQL type that is nested in the neighbors response node. For package tries, +// the leaf version node is returned. Only the types relevant to the retrieveDependecies +// graph traversal are implemented. +func neighborToNode(ctx context.Context, neighborsNode gql.NeighborsNeighborsNode) (node, error) { + logger := logging.FromContext(ctx) + switch val := neighborsNode.(type) { + case *gql.NeighborsNeighborsArtifact: + if val == nil { + logger.Errorf("neighbors node is nil") + return nil, helpers.Err500 + } + return &val.AllArtifactTree, nil + case *gql.NeighborsNeighborsPackage: + if val == nil { + logger.Errorf("neighbors node is nil") + return nil, helpers.Err500 + } + packageVersions := helpers.GetVersionsOfAllPackageTree(val.AllPkgTree) + if len(packageVersions) > 1 { + logger.Errorf("NeighborsNeighborsPackage value contains more than one package version node") + return nil, helpers.Err500 + } + + // this will occur if the neighbors response is a package name node + if len(packageVersions) == 0 { + return nil, nil + } + + return &packageVersions[0], nil + case *gql.NeighborsNeighborsHasSBOM: + if val == nil { + logger.Errorf("neighbors node is nil") + return nil, helpers.Err500 + } + return &val.AllHasSBOMTree, nil + case *gql.NeighborsNeighborsIsOccurrence: + if val == nil { + logger.Errorf("neighbors node is nil") + return nil, helpers.Err500 + } + return &val.AllIsOccurrencesTree, nil + case *gql.NeighborsNeighborsHashEqual: + if val == nil { + logger.Errorf("neighbors node is nil") + return nil, helpers.Err500 + } + return &val.AllHashEqualTree, nil + case *gql.NeighborsNeighborsHasSLSA: + if val == nil { + logger.Errorf("neighbors node is nil") + return nil, helpers.Err500 + } + return &val.AllSLSATree, nil + } + logger.Errorf("neighborsResponseToNode received an unexpected node type: %T", neighborsNode) + return nil, helpers.Err500 +} + +// Maps nodes in the input to purls, ignoring nodes that are not package version +// nodes. +func mapPkgNodesToPurls(ctx context.Context, gqlClient graphql.Client, + nodes []node) ([]string, error) { + logger := logging.FromContext(ctx) + + // get the IDs of the package nodes + pkgIds := []string{} + for _, node := range nodes { + if v, ok := node.(*gql.AllPkgTreeNamespacesPackageNamespaceNamesPackageNameVersionsPackageVersion); ok { + if v == nil { + logger.Warnf("An gql version node is unexpectedly nil") + continue + } + pkgIds = append(pkgIds, node.GetId()) + } + } + + // Call Nodes to get the entire package trie for each node + gqlNodes, err := gql.Nodes(ctx, gqlClient, pkgIds) + if err != nil { + logger.Errorf("Nodes query returned err: ", err) + return nil, helpers.Err502 + } + if gqlNodes == nil { + logger.Errorf("The Nodes query returned a nil result.") + return nil, helpers.Err500 + } + if len(gqlNodes.GetNodes()) != len(pkgIds) { + logger.Warnf("GQL query \"nodes\" did not return the expected number of results") + } + + // map the package tries to purls + purls := make([]string, 0, len(gqlNodes.GetNodes())) + for _, gqlNode := range gqlNodes.GetNodes() { + if v, ok := gqlNode.(*gql.NodesNodesPackage); ok { + purl := assembler_helpers.AllPkgTreeToPurl(&v.AllPkgTree) + purls = append(purls, purl) + } else { + logger.Warnf("Nodes query returned an unexpected type: %T", *gqlNode.GetTypename()) + } + } + return purls, nil +} + +/********* The endpoint handler *********/ +func (s *DefaultServer) RetrieveDependencies( + ctx context.Context, + request gen.RetrieveDependenciesRequestObject, +) (gen.RetrieveDependenciesResponseObject, error) { + // Find the start node + var start node + if request.Params.Purl != nil { + pkg, err := helpers.FindPackageWithPurl(ctx, s.gqlClient, *request.Params.Purl) + if err != nil { + return handleErr(ctx, err), nil + } + start = &pkg + } else if request.Params.Digest != nil { + artifact, err := helpers.FindArtifactWithDigest(ctx, s.gqlClient, *request.Params.Digest) + if err != nil { + return handleErr(ctx, err), nil + } + start = &artifact + } else { + return gen.RetrieveDependencies400JSONResponse{ + BadRequestJSONResponse: gen.BadRequestJSONResponse{ + Message: "Neither a purl or a digest argument was provided", + }}, nil + } + + // Select the edgeGen. The default is byDigest + var edgeGenerator edgeGen + cond := request.Params.LinkCondition + if cond == nil { + edgeGenerator = newByDigest(s.gqlClient) + } else if *cond == gen.Name { + edgeGenerator = newByName(s.gqlClient) + } else if *cond == gen.Digest { + edgeGenerator = newByDigest(s.gqlClient) + } else { + err := fmt.Errorf("Unrecognized linkCondition: %s", *request.Params.LinkCondition) + return handleErr(ctx, err), nil + } + + // Compute the result and map to purls + deps, err := getTransitiveDependencies(ctx, s.gqlClient, start, edgeGenerator) + if err != nil { + return handleErr(ctx, err), nil + } + purls, err := mapPkgNodesToPurls(ctx, s.gqlClient, deps) + if err != nil { + return handleErr(ctx, err), nil + } + + page, pageInfo, err := pagination.Paginate(ctx, purls, request.Params.PaginationSpec) + if err != nil { + return handleErr(ctx, err), nil + } + return gen.RetrieveDependencies200JSONResponse{PurlListJSONResponse: gen.PurlListJSONResponse{ + PurlList: page, + PaginationInfo: pageInfo, + }}, nil +} diff --git a/pkg/guacrest/server/retrieveDependencies_test.go b/pkg/guacrest/server/retrieveDependencies_test.go new file mode 100644 index 00000000000..3fe0b710767 --- /dev/null +++ b/pkg/guacrest/server/retrieveDependencies_test.go @@ -0,0 +1,632 @@ +// +// Copyright 2024 The GUAC Authors. +// +// 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 server_test + +import ( + stdcmp "cmp" + "context" + "testing" + + cmp "github.com/google/go-cmp/cmp" + + "github.com/google/go-cmp/cmp/cmpopts" + . "github.com/guacsec/guac/internal/testing/graphqlClients" + "github.com/guacsec/guac/internal/testing/ptrfrom" + _ "github.com/guacsec/guac/pkg/assembler/backends/keyvalue" + api "github.com/guacsec/guac/pkg/guacrest/generated" + "github.com/guacsec/guac/pkg/guacrest/server" + "github.com/guacsec/guac/pkg/logging" +) + +// Tests the edges in ByName that are not in ByDigest +func Test_RetrieveDependencies(t *testing.T) { + ctx := logging.WithLogger(context.Background()) + tests := []struct { + name string + data GuacData + + // Only specify Purl or Digest. The test will set linkCondition, because both are tested + input api.RetrieveDependenciesParams + + expectedByName []string + expectedByDigest []string + }{ + /******* + * Tests of specific edges. + * + * The test case name is the edge or edges intended to be tested, not necessarily all + * of the edges in the graph. Equivalence edges (e.g. IsOccurrence) can't be + * tested without some dependency edges, so some edges / graphs can't be tested in + * isolation. + *******/ + { + name: "Package -> SBOM -> package", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar"}, + HasSboms: []HasSbom{ + {Subject: "pkg:guac/foo", IncludedSoftware: []string{"pkg:guac/bar"}}, + }, + }, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:guac/foo")}, + expectedByName: []string{"pkg:guac/bar"}, + expectedByDigest: []string{}, + }, + { + name: "Package -> SBOM -> package, package", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar", "pkg:guac/baz"}, + HasSboms: []HasSbom{ + {Subject: "pkg:guac/foo", IncludedSoftware: []string{"pkg:guac/bar", "pkg:guac/baz"}}, + }, + }, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:guac/foo")}, + expectedByName: []string{"pkg:guac/bar", "pkg:guac/baz"}, + expectedByDigest: []string{}, + }, + { + name: "Artifact -> SBOM -> package", + data: GuacData{ + Packages: []string{"pkg:guac/bar"}, + Artifacts: []string{"sha-xyz"}, + HasSboms: []HasSbom{ + {Subject: "sha-xyz", IncludedSoftware: []string{"pkg:guac/bar"}}, + }, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-xyz")}, + expectedByName: []string{"pkg:guac/bar"}, + expectedByDigest: []string{"pkg:guac/bar"}, + }, + { + name: "Package -> SBOM -> package -> SBOM -> package", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar", "pkg:guac/baz"}, + HasSboms: []HasSbom{ + {Subject: "pkg:guac/foo", IncludedSoftware: []string{"pkg:guac/bar"}}, + {Subject: "pkg:guac/bar", IncludedSoftware: []string{"pkg:guac/baz"}}, + }, + }, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:guac/foo")}, + expectedByName: []string{"pkg:guac/bar", "pkg:guac/baz"}, + expectedByDigest: []string{}, + }, + { + name: "Artifact -> SBOM -> artifact -> SBOM -> package", + data: GuacData{ + Packages: []string{"pkg:guac/foo"}, + Artifacts: []string{"sha-xyz", "sha-123"}, + HasSboms: []HasSbom{ + {Subject: "sha-xyz", IncludedSoftware: []string{"sha-123"}}, + {Subject: "sha-123", IncludedSoftware: []string{"pkg:guac/foo"}}, + }, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-xyz")}, + expectedByName: []string{"pkg:guac/foo"}, + expectedByDigest: []string{"pkg:guac/foo"}, + }, + { + name: "Artifact -> SBOM -> package -> SBOM -> package", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar"}, + Artifacts: []string{"sha-xyz"}, + HasSboms: []HasSbom{ + {Subject: "sha-xyz", IncludedSoftware: []string{"pkg:guac/bar"}}, + {Subject: "pkg:guac/bar", IncludedSoftware: []string{"pkg:guac/foo"}}, + }, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-xyz")}, + expectedByName: []string{"pkg:guac/foo", "pkg:guac/bar"}, + expectedByDigest: []string{"pkg:guac/bar"}, + }, + { + name: "artifact -> occurrence -> package", + data: GuacData{ + Packages: []string{"pkg:guac/bar"}, + Artifacts: []string{"sha-123", "sha-xyz"}, + HasSboms: []HasSbom{{Subject: "sha-xyz", IncludedSoftware: []string{"sha-123"}}}, + IsOccurrences: []IsOccurrence{{Subject: "pkg:guac/bar", Artifact: "sha-123"}}, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-xyz")}, + expectedByName: []string{"pkg:guac/bar"}, + expectedByDigest: []string{"pkg:guac/bar"}, + }, + { + name: "Package -> occurrence -> artifact", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar"}, + Artifacts: []string{"sha-xyz"}, + HasSboms: []HasSbom{{Subject: "sha-xyz", IncludedSoftware: []string{"pkg:guac/bar"}}}, + IsOccurrences: []IsOccurrence{{Subject: "pkg:guac/foo", Artifact: "sha-xyz"}}, + }, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:guac/foo")}, + expectedByName: []string{"pkg:guac/bar"}, + expectedByDigest: []string{}, + }, + { + name: "package -> occurrence -> artifact, artifact", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar", "pkg:guac/baz"}, + Artifacts: []string{"sha-xyz", "sha-123"}, + HasSboms: []HasSbom{ + {Subject: "sha-xyz", IncludedSoftware: []string{"pkg:guac/bar"}}, + {Subject: "sha-123", IncludedSoftware: []string{"pkg:guac/baz"}}, + }, + IsOccurrences: []IsOccurrence{ + {Subject: "pkg:guac/foo", Artifact: "sha-xyz"}, + {Subject: "pkg:guac/foo", Artifact: "sha-123"}, + }, + }, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:guac/foo")}, + expectedByName: []string{"pkg:guac/bar", "pkg:guac/baz"}, + expectedByDigest: []string{}, + }, + { + name: "Artifact -> hashEqual -> artifact", + data: GuacData{ + Packages: []string{"pkg:guac/foo"}, + Artifacts: []string{"sha-123", "sha-456"}, + HasSboms: []HasSbom{{Subject: "sha-456", IncludedSoftware: []string{"pkg:guac/foo"}}}, + HashEquals: []HashEqual{{ArtifactA: "sha-123", ArtifactB: "sha-456"}}, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-123")}, + expectedByName: []string{"pkg:guac/foo"}, + expectedByDigest: []string{"pkg:guac/foo"}, + }, + { + name: "Artifact -> hashEqual -> artifact, artifact", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar"}, + Artifacts: []string{"sha-123", "sha-456", "sha-789"}, + HasSboms: []HasSbom{ + {Subject: "sha-456", IncludedSoftware: []string{"pkg:guac/foo"}}, + {Subject: "sha-789", IncludedSoftware: []string{"pkg:guac/bar"}}, + }, + HashEquals: []HashEqual{ + {ArtifactA: "sha-123", ArtifactB: "sha-456"}, + {ArtifactA: "sha-123", ArtifactB: "sha-789"}, + }, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-123")}, + expectedByName: []string{"pkg:guac/foo", "pkg:guac/bar"}, + expectedByDigest: []string{"pkg:guac/foo", "pkg:guac/bar"}, + }, + { + name: "Artifact -> hashEqual -> artifact -> hashEqual -> artifact", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar"}, + Artifacts: []string{"sha-123", "sha-456", "sha-789"}, + HasSboms: []HasSbom{ + {Subject: "sha-456", IncludedSoftware: []string{"pkg:guac/foo"}}, + {Subject: "sha-789", IncludedSoftware: []string{"pkg:guac/bar"}}, + }, + HashEquals: []HashEqual{ + {ArtifactA: "sha-123", ArtifactB: "sha-456"}, + {ArtifactA: "sha-456", ArtifactB: "sha-789"}, + }, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-123")}, + expectedByName: []string{"pkg:guac/foo", "pkg:guac/bar"}, + expectedByDigest: []string{"pkg:guac/foo", "pkg:guac/bar"}, + }, + { + name: "artifact -> SLSA -> artifact -> occurrence -> package", + data: GuacData{ + Packages: []string{"pkg:guac/foo"}, + Artifacts: []string{"sha-123", "sha-xyz"}, + Builders: []string{"GHA"}, + IsOccurrences: []IsOccurrence{{Subject: "pkg:guac/foo", Artifact: "sha-xyz"}}, + HasSlsas: []HasSlsa{{Subject: "sha-123", BuiltBy: "GHA", BuiltFrom: []string{"sha-xyz"}}}, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-123")}, + expectedByName: []string{"pkg:guac/foo"}, + expectedByDigest: []string{"pkg:guac/foo"}, + }, + { + name: "artifact -> SLSA -> artifact, artifact", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar"}, + Artifacts: []string{"sha-123", "sha-xyz", "sha-abc"}, + Builders: []string{"GHA"}, + IsOccurrences: []IsOccurrence{ + {Subject: "pkg:guac/foo", Artifact: "sha-xyz"}, + {Subject: "pkg:guac/bar", Artifact: "sha-abc"}, + }, + HasSlsas: []HasSlsa{{Subject: "sha-123", BuiltBy: "GHA", BuiltFrom: []string{"sha-xyz", "sha-abc"}}}, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-123")}, + expectedByName: []string{"pkg:guac/foo", "pkg:guac/bar"}, + expectedByDigest: []string{"pkg:guac/foo", "pkg:guac/bar"}, + }, + /******* + * Test some edge cases + *******/ + { + name: "Both Package and occurrence artifact in SBOM does not lead to duplicate packages", + data: GuacData{ + Packages: []string{"pkg:guac/bar"}, + Artifacts: []string{"sha-123", "sha-xyz"}, + HasSboms: []HasSbom{{ + Subject: "sha-xyz", + IncludedSoftware: []string{"pkg:guac/bar", "sha-123"}, + IncludedIsOccurrences: []IsOccurrence{{Subject: "pkg:guac/bar", Artifact: "sha-123"}}, + }}, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-xyz")}, + expectedByName: []string{"pkg:guac/bar"}, + expectedByDigest: []string{"pkg:guac/bar"}, + }, + { + name: "Dependent is not considered a dependency", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar", "pkg:guac/baz"}, + HasSboms: []HasSbom{ + {Subject: "pkg:guac/foo", IncludedSoftware: []string{"pkg:guac/bar"}}, + {Subject: "pkg:guac/baz", IncludedSoftware: []string{"pkg:guac/bar"}}, + }, + }, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:guac/foo")}, + expectedByName: []string{"pkg:guac/bar"}, + expectedByDigest: []string{}, + }, + { + name: "Transitive dependents are not considered dependencies", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar", "pkg:guac/baz"}, + HasSboms: []HasSbom{ + {Subject: "pkg:guac/foo", IncludedSoftware: []string{"pkg:guac/bar"}}, + {Subject: "pkg:guac/bar", IncludedSoftware: []string{"pkg:guac/baz"}}, + }, + }, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:guac/baz")}, + expectedByName: []string{}, + expectedByDigest: []string{}, + }, + { + name: "Packages with same names but different digests", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar", "pkg:guac/baz"}, + Artifacts: []string{"sha-123", "sha-xyz"}, + HasSboms: []HasSbom{ + // foo's sbom contains bar with a digest of sha-123 + { + Subject: "pkg:guac/foo", + IncludedSoftware: []string{"pkg:guac/bar"}, + IncludedIsOccurrences: []IsOccurrence{{Subject: "pkg:guac/bar", Artifact: "sha-123"}}, + }, + // an artifact with digest sha-xyz depends on baz + { + Subject: "sha-xyz", + IncludedSoftware: []string{"pkg:guac/baz"}, + }, + }, + // sha-xyz is an occurrence of bar + IsOccurrences: []IsOccurrence{{Subject: "pkg:guac/bar", Artifact: "sha-xyz"}}, + }, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:guac/foo")}, + // foo depends on baz + expectedByName: []string{"pkg:guac/bar", "pkg:guac/baz"}, + expectedByDigest: []string{}, + }, + /******* + * Test that equivalent packages aren't considered to be dependencies + *******/ + { + name: "Package IsOccurrence is not considered a dependency", + data: GuacData{ + Packages: []string{"pkg:guac/foo"}, + Artifacts: []string{"sha-123"}, + IsOccurrences: []IsOccurrence{{Subject: "pkg:guac/foo", Artifact: "sha-123"}}, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-123")}, + expectedByName: []string{}, + expectedByDigest: []string{}, + }, + { + name: "Artifact IsOccurrence is not considered a dependency", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar"}, + Artifacts: []string{"sha-123"}, + IsOccurrences: []IsOccurrence{ + {Subject: "pkg:guac/foo", Artifact: "sha-123"}, + {Subject: "pkg:guac/bar", Artifact: "sha-123"}, + }, + }, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:guac/foo")}, + expectedByName: []string{}, + expectedByDigest: []string{}, + }, + { + name: "Artifact HashEqual is not considered a dependency", + data: GuacData{ + Packages: []string{"pkg:guac/foo"}, + Artifacts: []string{"sha-123", "sha-456"}, + HashEquals: []HashEqual{{ArtifactA: "sha-123", ArtifactB: "sha-456"}}, + IsOccurrences: []IsOccurrence{{Subject: "pkg:guac/foo", Artifact: "sha-456"}}, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-123")}, + expectedByName: []string{}, + expectedByDigest: []string{}, + }, + /******* + * Test that cycles in the graph are handled correctly + *******/ + { + name: "Equivalence cycle including start node", + data: GuacData{ + Packages: []string{"pkg:guac/foo"}, + Artifacts: []string{"sha-123", "sha-456", "sha-789"}, + HashEquals: []HashEqual{ + {ArtifactA: "sha-123", ArtifactB: "sha-456"}, + {ArtifactA: "sha-456", ArtifactB: "sha-789"}, + {ArtifactA: "sha-789", ArtifactB: "sha-123"}, + }, + IsOccurrences: []IsOccurrence{{Subject: "pkg:guac/foo", Artifact: "sha-789"}}, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-123")}, + expectedByName: []string{}, + expectedByDigest: []string{}, + }, + { + name: "Equivalence cycle not including start node", + data: GuacData{ + Packages: []string{"pkg:guac/foo"}, + Artifacts: []string{"sha-123", "sha-456", "sha-789"}, + HasSboms: []HasSbom{{Subject: "sha-123", IncludedSoftware: []string{"sha-456"}}}, + HashEquals: []HashEqual{ + {ArtifactA: "sha-456", ArtifactB: "sha-789"}, + {ArtifactA: "sha-789", ArtifactB: "sha-456"}, + }, + IsOccurrences: []IsOccurrence{{Subject: "pkg:guac/foo", Artifact: "sha-789"}}, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-123")}, + expectedByName: []string{"pkg:guac/foo"}, + expectedByDigest: []string{"pkg:guac/foo"}, + }, + { + name: "Dependency cycle", + data: GuacData{ + Packages: []string{"pkg:guac/foo"}, + Artifacts: []string{"sha-123", "sha-456", "sha-789"}, + HasSboms: []HasSbom{ + {Subject: "sha-123", IncludedSoftware: []string{"sha-456"}}, + {Subject: "sha-456", IncludedSoftware: []string{"sha-789"}}, + {Subject: "sha-789", IncludedSoftware: []string{"sha-123"}}, + }, + IsOccurrences: []IsOccurrence{{Subject: "pkg:guac/foo", Artifact: "sha-789"}}, + }, + input: api.RetrieveDependenciesParams{Digest: ptrfrom.String("sha-123")}, + expectedByName: []string{"pkg:guac/foo"}, + expectedByDigest: []string{"pkg:guac/foo"}, + }, + /******* + * Test packages with versions + *******/ + { + name: "Package with version is not confused for package without version", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/foo@v1", "pkg:guac/bar", "pkg:guac/bar@v1"}, + HasSboms: []HasSbom{ + {Subject: "pkg:guac/foo", IncludedSoftware: []string{"pkg:guac/bar@v1"}}, + {Subject: "pkg:guac/foo@v1", IncludedSoftware: []string{"pkg:guac/bar"}}, + }, + }, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:guac/foo")}, + expectedByName: []string{"pkg:guac/bar@v1"}, + expectedByDigest: []string{}, + }, + { + name: "Package without version is not confused for package with version", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/foo@v1", "pkg:guac/bar", "pkg:guac/bar@v1"}, + HasSboms: []HasSbom{ + {Subject: "pkg:guac/foo", IncludedSoftware: []string{"pkg:guac/bar"}}, + {Subject: "pkg:guac/foo@v1", IncludedSoftware: []string{"pkg:guac/bar@v1"}}, + }, + }, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:guac/foo")}, + expectedByName: []string{"pkg:guac/bar"}, + expectedByDigest: []string{}, + }, + /******* + * Test that the Guac purl special-casing is handled correctly + *******/ + { + name: "Endpoint works for OCI purl", + data: GuacData{ + Packages: []string{ + "pkg:oci/debian@sha256%3A244fd47e07d10?repository_url=ghcr.io&tag=bullseye", + "pkg:oci/static@sha256%3A244fd47e07d10?repository_url=gcr.io%2Fdistroless&tag=latest", + }, + HasSboms: []HasSbom{{ + Subject: "pkg:oci/debian@sha256%3A244fd47e07d10?repository_url=ghcr.io&tag=bullseye", + IncludedSoftware: []string{"pkg:oci/static@sha256%3A244fd47e07d10?repository_url=gcr.io%2Fdistroless&tag=latest"}}, + }}, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:oci/debian@sha256%3A244fd47e07d10?repository_url=ghcr.io&tag=bullseye")}, + expectedByName: []string{"pkg:oci/static@sha256%3A244fd47e07d10?repository_url=gcr.io%2Fdistroless&tag=latest"}, + expectedByDigest: []string{}, + }, + /******* + * A test to record that purls are canonicalized upon ingestion, and so they + * may not round-trip. + *******/ + { + name: "Non-canonical purl may not round trip", + data: GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:github/Package-url/purl-Spec"}, + HasSboms: []HasSbom{{ + Subject: "pkg:guac/foo", + IncludedSoftware: []string{"pkg:github/Package-url/purl-Spec"}}, + }}, + input: api.RetrieveDependenciesParams{Purl: ptrfrom.String("pkg:guac/foo")}, + expectedByName: []string{"pkg:github/package-url/purl-spec"}, // lowercased + expectedByDigest: []string{}, + }, + } + + for _, tt := range tests { + + t.Run(tt.name, func(t *testing.T) { + /******** set up the test ********/ + gqlClient := SetupTest(t) + Ingest(ctx, t, gqlClient, tt.data) + + restApi := server.NewDefaultServer(gqlClient) + + /******** call the endpoint with byName link condition ********/ + inputByName := tt.input + inputByName.LinkCondition = ptrfrom.Any(api.Name) + resByName, err := restApi.RetrieveDependencies(ctx, api.RetrieveDependenciesRequestObject{Params: inputByName}) + if err != nil { + t.Fatalf("Endpoint returned unexpected error: %v", err) + } + /******** check the output ********/ + switch v := resByName.(type) { + case api.RetrieveDependencies200JSONResponse: + if !cmp.Equal(v.PurlList, tt.expectedByName, cmpopts.EquateEmpty(), cmpopts.SortSlices(stdcmp.Less[string])) { + t.Errorf("RetrieveDependencies with byName returned %v, but wanted %v", v.PurlList, tt.expectedByName) + } + default: + t.Errorf("RetrieveDependencies with byName returned unexpected error: %v", v) + } + + /******** call the endpoint with byDigest link condition ********/ + inputByDigest := tt.input + inputByDigest.LinkCondition = ptrfrom.Any(api.Digest) + resByDigest, err := restApi.RetrieveDependencies(ctx, api.RetrieveDependenciesRequestObject{Params: inputByDigest}) + if err != nil { + t.Fatalf("Endpoint returned unexpected error: %v", err) + } + /******** check the output ********/ + switch v := resByDigest.(type) { + case api.RetrieveDependencies200JSONResponse: + if !cmp.Equal(v.PurlList, tt.expectedByDigest, cmpopts.EquateEmpty(), cmpopts.SortSlices(stdcmp.Less[string])) { + t.Errorf("RetrieveDependencies with byDigest returned %v, but wanted %v", v.PurlList, tt.expectedByDigest) + } + default: + t.Errorf("RetrieveDependencies with byDigest returned unexpected error: %v", v) + } + }) + } +} + +func Test_ClientErrors(t *testing.T) { + ctx := logging.WithLogger(context.Background()) + tests := []struct { + name string + data GuacData + input api.RetrieveDependenciesParams + }{{ + name: "Package not found", + input: api.RetrieveDependenciesParams{ + Purl: ptrfrom.String("pkg:guac/foo"), + LinkCondition: ptrfrom.Any(api.Name), + }, + }, { + name: "Package not found because version was specified", + data: GuacData{Packages: []string{"pkg:guac/foo"}}, + input: api.RetrieveDependenciesParams{ + Purl: ptrfrom.String("pkg:guac/foo@v1"), + LinkCondition: ptrfrom.Any(api.Name), + }, + }, { + name: "Package not found because version was not specified", + data: GuacData{Packages: []string{"pkg:guac/foo@v1"}}, + input: api.RetrieveDependenciesParams{ + Purl: ptrfrom.String("pkg:guac/foo"), + LinkCondition: ptrfrom.Any(api.Name), + }, + }, { + name: "Package not found due to missing qualifiers", + data: GuacData{Packages: []string{"pkg:guac/foo?a=b"}}, + input: api.RetrieveDependenciesParams{ + Purl: ptrfrom.String("pkg:guac/foo"), + LinkCondition: ptrfrom.Any(api.Name), + }, + }, { + name: "Package not found due to providing qualifiers", + data: GuacData{Packages: []string{"pkg:guac/foo"}}, + input: api.RetrieveDependenciesParams{ + Purl: ptrfrom.String("pkg:guac/foo?a=b"), + LinkCondition: ptrfrom.Any(api.Name), + }, + }, { + name: "Artifact not found because version was not specified", + input: api.RetrieveDependenciesParams{ + Digest: ptrfrom.String("sha-abc"), + LinkCondition: ptrfrom.Any(api.Name), + }, + }, { + name: "Neither Purl nor Digest provided", + }, { + name: "Unrecognized link condition", + input: api.RetrieveDependenciesParams{ + Digest: ptrfrom.String("sha-abc"), + LinkCondition: ptrfrom.Any(api.RetrieveDependenciesParamsLinkCondition("foo")), + }, + }} + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gqlClient := SetupTest(t) + Ingest(ctx, t, gqlClient, tt.data) + restApi := server.NewDefaultServer(gqlClient) + + res, err := restApi.RetrieveDependencies(ctx, api.RetrieveDependenciesRequestObject{Params: tt.input}) + if err != nil { + t.Fatalf("RetrieveDependencies returned unexpected error: %v", err) + } + if _, ok := res.(api.RetrieveDependencies400JSONResponse); !ok { + t.Fatalf("Did not receive a 400 Response: recieved %v of type %T", res, res) + } + + }) + } +} + +func Test_DefaultLinkCondition(t *testing.T) { + /******** set up the test ********/ + ctx := logging.WithLogger(context.Background()) + gqlClient := SetupTest(t) + restApi := server.NewDefaultServer(gqlClient) + data := GuacData{ + Packages: []string{"pkg:guac/foo", "pkg:guac/bar"}, + HasSboms: []HasSbom{{ + Subject: "pkg:guac/foo", + IncludedSoftware: []string{"pkg:guac/bar"}}, + }} + Ingest(ctx, t, gqlClient, data) + + input := api.RetrieveDependenciesParams{ + Purl: ptrfrom.String("pkg:guac/foo"), + } + + /******** call the endpoint ********/ + res, err := restApi.RetrieveDependencies(ctx, api.RetrieveDependenciesRequestObject{Params: input}) + if err != nil { + t.Fatalf("RetrieveDependencies returned unexpected error: %v", err) + } + + /******** check the output ********/ + switch v := res.(type) { + case api.RetrieveDependencies200JSONResponse: + // that the default is byDigest is tested by asserting that no edges only in byName are used + if len(v.PurlList) != 0 { + t.Errorf("RetrieveDependencies returned %v, but no dependencies were expected", v) + } + default: + t.Errorf("RetrieveDependencies returned unexpected error: %v", v) + } + +} diff --git a/pkg/guacrest/server/server.go b/pkg/guacrest/server/server.go index 0a778caf248..0176623b345 100644 --- a/pkg/guacrest/server/server.go +++ b/pkg/guacrest/server/server.go @@ -18,9 +18,12 @@ package server import ( "context" "fmt" + "net/http" + "time" "github.com/Khan/genqlient/graphql" gen "github.com/guacsec/guac/pkg/guacrest/generated" + "github.com/guacsec/guac/pkg/logging" ) // DefaultServer implements the API, backed by the GraphQL Server @@ -32,6 +35,32 @@ func NewDefaultServer(gqlClient graphql.Client) *DefaultServer { return &DefaultServer{gqlClient: gqlClient} } +// Adds the logger to the http request context +func AddLoggerToCtxMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + newCtx := logging.WithLogger(r.Context()) + newReq := r.WithContext(newCtx) + next.ServeHTTP(w, newReq) + }) +} + +// Logs data for a request and its response. The request context should already contain +// the logger. +func LogRequestsMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() + newCtx := logging.WithLogger(r.Context(), + "method", r.Method, + "path", r.URL.Path, + ) + newReq := r.WithContext(newCtx) + next.ServeHTTP(w, newReq) + + logger := logging.FromContext(newReq.Context()) + logger.Infow("Request handled successfully", "latency", time.Since(start)) + }) +} + func (s *DefaultServer) HealthCheck(ctx context.Context, request gen.HealthCheckRequestObject) (gen.HealthCheckResponseObject, error) { return gen.HealthCheck200JSONResponse("Server is healthy"), nil } @@ -39,7 +68,3 @@ func (s *DefaultServer) HealthCheck(ctx context.Context, request gen.HealthCheck func (s *DefaultServer) AnalyzeDependencies(ctx context.Context, request gen.AnalyzeDependenciesRequestObject) (gen.AnalyzeDependenciesResponseObject, error) { return nil, fmt.Errorf("Unimplemented") } - -func (s *DefaultServer) RetrieveDependencies(ctx context.Context, request gen.RetrieveDependenciesRequestObject) (gen.RetrieveDependenciesResponseObject, error) { - return nil, fmt.Errorf("Unimplemented") -} diff --git a/pkg/logging/logger.go b/pkg/logging/logger.go index 5da27070507..9182db2a95a 100644 --- a/pkg/logging/logger.go +++ b/pkg/logging/logger.go @@ -99,14 +99,20 @@ func ParseLevel(level string) (LogLevel, error) { } } -func WithLogger(ctx context.Context) context.Context { +// Attaches the logger to the input context, optionally adding a number of fields +// to the logging context. The fields should be key-value pairs. +func WithLogger(ctx context.Context, fields ...interface{}) context.Context { if logger == nil { // defaults to Debug if InitLogger has not been called. // all cli commands should call InitLogger, so this should mostly be for unit tests InitLogger(Debug) logger.Debugf("InitLogger has not been called. Defaulting to debug log level") } + if len(fields) > 0 { + return context.WithValue(ctx, loggerKey{}, logger.With(fields...)) + } return context.WithValue(ctx, loggerKey{}, logger) + } func FromContext(ctx context.Context) *zap.SugaredLogger { From 90d95a533c1606531c805aaddc80f7468389cf3e Mon Sep 17 00:00:00 2001 From: Jeff Mendoza Date: Sun, 28 Apr 2024 12:37:41 -0700 Subject: [PATCH 14/17] Add standalone postgres compose (#1868) This compose will be used for new persistant setup instructions. It is a standalone file and doesn't need any additional files to be mounted into the containers. It is a complete single file (not multiple files merged) and doesn't contain anything unecessary. Future docs will build upon it for adding additional collectors, etc. Signed-off-by: Jeff Mendoza --- .github/workflows/release.yaml | 11 ++ container_files/guac-postgres-compose.yaml | 129 +++++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 container_files/guac-postgres-compose.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4b5364d8f21..84e08ecc35e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -189,3 +189,14 @@ jobs: gh release upload ${{ github.ref_name }} guac-demo-compose.yaml rm guac-demo-compose.yaml shell: bash + - name: Modify and publish postgres compose yaml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + #!/usr/bin/env bash + set -euo pipefail + cp container_files/guac-postgres-compose.yaml . + sed -i s/\$GUAC_IMAGE/ghcr.io\\/${{ github.repository_owner }}\\/guac:${{ github.ref_name }}/ guac-postgres-compose.yaml + gh release upload ${{ github.ref_name }} guac-postgres-compose.yaml + rm guac-postgres-compose.yaml + shell: bash diff --git a/container_files/guac-postgres-compose.yaml b/container_files/guac-postgres-compose.yaml new file mode 100644 index 00000000000..b9d0c08b03f --- /dev/null +++ b/container_files/guac-postgres-compose.yaml @@ -0,0 +1,129 @@ +version: "3.8" + +services: + + postgres: + image: docker.io/library/postgres:16 + environment: + POSTGRES_USER: guac + POSTGRES_PASSWORD: guac + volumes: + - ./postgres-data:/var/lib/postgresql/data:z + healthcheck: + test: ["CMD", "pg_isready", "--username=guac", "--dbname=guac"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s + + graphql: + image: $GUAC_IMAGE + command: "/opt/guac/guacgql --gql-debug --gql-backend=ent --db-address=postgres://guac:guac@postgres:5432/guac?sslmode=disable" + working_dir: /guac + restart: on-failure + depends_on: + postgres: + condition: service_healthy + ports: + - "8080:8080" + healthcheck: + test: ["CMD", "wget", "--spider", "http://localhost:8080"] + interval: 10s + timeout: 10s + retries: 3 + start_period: 5s + + nats: + image: "docker.io/library/nats:2.9.17-alpine" + command: "--jetstream -m 8222" + ports: + - "4222:4222" + # monitoring port + - "8222:8222" + restart: on-failure + healthcheck: + test: [ "CMD", "wget", "--spider", "http://localhost:8222/healthz" ] + interval: 10s + timeout: 10s + retries: 3 + start_period: 5s + + ingestor: + image: $GUAC_IMAGE + command: "/opt/guac/guacingest --blob-addr=file:///tmp/blobstore?no_tmp_dir=true --csub-addr=collectsub:2782 --gql-addr=http://graphql:8080/query --pubsub-addr=nats://nats:4222" + working_dir: /guac + restart: on-failure + depends_on: + collectsub: + condition: service_healthy + graphql: + condition: service_healthy + nats: + condition: service_healthy + volumes: + - ./blobstore:/tmp/blobstore:z + + + collectsub: + image: $GUAC_IMAGE + command: "/opt/guac/guaccsub" + working_dir: /guac + restart: on-failure + ports: + - "2782:2782" + healthcheck: + test: [ "CMD", "wget", "--spider", "http://localhost:2782" ] + interval: 10s + timeout: 10s + retries: 3 + start_period: 5s + + depsdev-collector: + image: $GUAC_IMAGE + command: "/opt/guac/guaccollect deps_dev --csub-addr=collectsub:2782 --blob-addr=file:///tmp/blobstore?no_tmp_dir=true --pubsub-addr=nats://nats:4222" + working_dir: /guac + restart: on-failure + environment: + - DEPS_DEV_APIKEY + depends_on: + collectsub: + condition: service_healthy + nats: + condition: service_healthy + volumes: + - ./blobstore:/tmp/blobstore:z + + oci-collector: + image: $GUAC_IMAGE + command: "/opt/guac/guaccollect image --csub-addr=collectsub:2782 --blob-addr=file:///tmp/blobstore?no_tmp_dir=true --pubsub-addr=nats://nats:4222" + working_dir: /guac + restart: on-failure + depends_on: + collectsub: + condition: service_healthy + nats: + condition: service_healthy + volumes: + - ./blobstore:/tmp/blobstore:z + + osv-certifier: + image: $GUAC_IMAGE + command: "/opt/guac/guacone certifier osv -p --csub-addr=collectsub:2782 --gql-addr=http://graphql:8080/query" + working_dir: /guac + restart: on-failure + depends_on: + collectsub: + condition: service_healthy + graphql: + condition: service_healthy + + guac-rest: + image: $GUAC_IMAGE + command: "/opt/guac/guacrest --rest-api-server-port=8081 --gql-addr=http://graphql:8080/query" + working_dir: /guac + restart: on-failure + ports: + - "8081:8081" + depends_on: + graphql: + condition: service_healthy From 81894955dc19393bc05b148b5ddfd1ec57b40060 Mon Sep 17 00:00:00 2001 From: Parth Patel <88045217+pxp928@users.noreply.github.com> Date: Mon, 29 Apr 2024 04:31:01 -0400 Subject: [PATCH 15/17] [ENT] Complete ent pagination and update backend tests (#1870) * add more descriptive error messages and update hasSBOM query Signed-off-by: pxp928 * remove unnecessary limit with pagination Signed-off-by: pxp928 * add certifyBad pagination Signed-off-by: pxp928 * add certifyGood pagination Signed-off-by: pxp928 * add certifyLegal pagination Signed-off-by: pxp928 * add vex pagination Signed-off-by: pxp928 * add certifyVuln and isDep pagination Signed-off-by: pxp928 * add hashequal pagination Signed-off-by: pxp928 * add hasMetadata and license pagination Signed-off-by: pxp928 * add occurrence pagination Signed-off-by: pxp928 * add package and pkgEqual pagination Signed-off-by: pxp928 * add point of contact pagination Signed-off-by: pxp928 * add sbom and scorecard pagination Signed-off-by: pxp928 * add slsa pagination Signed-off-by: pxp928 * add hasSourceAt pagination Signed-off-by: pxp928 * add source pagination Signed-off-by: pxp928 * add vulnEqual, vuln and vulnMeta pagination Signed-off-by: pxp928 * update backend unit tests for pagination Signed-off-by: pxp928 --------- Signed-off-by: pxp928 --- internal/testing/backend/artifact_test.go | 10 +- internal/testing/backend/builder_test.go | 10 +- internal/testing/backend/certifyBad_test.go | 24 +- internal/testing/backend/certifyGood_test.go | 20 +- internal/testing/backend/certifyLegal_test.go | 20 +- .../testing/backend/certifyScorecard_test.go | 20 +- .../backend/certifyVEXStatement_test.go | 20 +- internal/testing/backend/certifyVuln_test.go | 20 +- internal/testing/backend/hasMetadata_test.go | 20 +- internal/testing/backend/hasSBOM_test.go | 20 +- internal/testing/backend/hasSLSA_test.go | 24 +- internal/testing/backend/hasSourceAt_test.go | 20 +- internal/testing/backend/hashEqual_test.go | 24 +- internal/testing/backend/isDependency_test.go | 20 +- internal/testing/backend/isOccurrence_test.go | 20 +- internal/testing/backend/license_test.go | 20 +- internal/testing/backend/main_test.go | 54 +++- internal/testing/backend/pkgEqual_test.go | 20 +- internal/testing/backend/pkg_test.go | 10 +- .../testing/backend/pointOfContact_test.go | 20 +- internal/testing/backend/src_test.go | 10 +- internal/testing/backend/vulnEqual_test.go | 20 +- internal/testing/backend/vulnMetadata_test.go | 20 +- .../testing/backend/vulnerability_test.go | 41 ++- .../backends/arangodb/certifyGood.go | 2 +- .../backends/arangodb/certifyLegal.go | 2 +- .../backends/ent/backend/artifact.go | 50 ++-- pkg/assembler/backends/ent/backend/backend.go | 4 - .../backends/ent/backend/builders.go | 45 +-- pkg/assembler/backends/ent/backend/certify.go | 143 +++++++-- .../backends/ent/backend/certifyLegal.go | 70 ++++- .../ent/backend/certifyVEXStatement.go | 73 ++++- .../backends/ent/backend/certifyVuln.go | 72 ++++- .../backends/ent/backend/dependency.go | 71 ++++- .../backends/ent/backend/hasMetadata.go | 71 ++++- .../backends/ent/backend/hashequal.go | 76 ++++- pkg/assembler/backends/ent/backend/license.go | 69 ++++- .../backends/ent/backend/occurrence.go | 68 ++++- pkg/assembler/backends/ent/backend/package.go | 124 +++++--- .../backends/ent/backend/pkgequal.go | 76 ++++- .../backends/ent/backend/pointOfContact.go | 71 ++++- pkg/assembler/backends/ent/backend/sbom.go | 278 +++++++++++++++++- .../backends/ent/backend/scorecard.go | 71 ++++- pkg/assembler/backends/ent/backend/search.go | 9 +- pkg/assembler/backends/ent/backend/slsa.go | 71 ++++- pkg/assembler/backends/ent/backend/source.go | 183 +++++++++--- .../backends/ent/backend/transforms.go | 55 ++-- .../backends/ent/backend/vulnEqual.go | 77 ++++- .../backends/ent/backend/vulnMetadata.go | 80 ++++- .../backends/ent/backend/vulnerability.go | 89 ++++-- 50 files changed, 2059 insertions(+), 448 deletions(-) diff --git a/internal/testing/backend/artifact_test.go b/internal/testing/backend/artifact_test.go index 80ed14d5a13..b3e47444e3b 100644 --- a/internal/testing/backend/artifact_test.go +++ b/internal/testing/backend/artifact_test.go @@ -108,12 +108,18 @@ func TestArtifacts(t *testing.T) { if tt.idInFilter { tt.artifactSpec.ID = ptrfrom.String(ingestedArtID) } - got, err := b.Artifacts(ctx, tt.artifactSpec) + got, err := b.ArtifactsList(ctx, *tt.artifactSpec, nil, nil) if (err != nil) != tt.wantErr { t.Errorf("arangoClient.Artifacts() error = %v, wantErr %v", err, tt.wantErr) return } - if diff := cmp.Diff(tt.want, got, commonOpts); diff != "" { + var returnedObjects []*model.Artifact + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(tt.want, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/builder_test.go b/internal/testing/backend/builder_test.go index a541b1a5758..31d312aa5f9 100644 --- a/internal/testing/backend/builder_test.go +++ b/internal/testing/backend/builder_test.go @@ -84,12 +84,18 @@ func TestBuilders(t *testing.T) { if tt.idInFilter { tt.builderSpec.ID = &ingestedBuilderID } - got, err := b.Builders(ctx, tt.builderSpec) + got, err := b.BuildersList(ctx, *tt.builderSpec, nil, nil) if (err != nil) != tt.wantErr { t.Errorf("demoClient.Builders() error = %v, wantErr %v", err, tt.wantErr) return } - if diff := cmp.Diff(tt.want, got, commonOpts); diff != "" { + var returnedObjects []*model.Builder + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(tt.want, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/certifyBad_test.go b/internal/testing/backend/certifyBad_test.go index c7e81343371..f3ceaefc713 100644 --- a/internal/testing/backend/certifyBad_test.go +++ b/internal/testing/backend/certifyBad_test.go @@ -837,16 +837,22 @@ func TestCertifyBad(t *testing.T) { } } } - got, err := b.CertifyBad(ctx, test.Query) + got, err := b.CertifyBadList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - slices.SortFunc(got, cmpCB) + var returnedObjects []*model.CertifyBad + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + slices.SortFunc(returnedObjects, cmpCB) slices.SortFunc(test.ExpCB, cmpCB) - if diff := cmp.Diff(test.ExpCB, got, commonOpts); diff != "" { + if diff := cmp.Diff(test.ExpCB, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -1159,16 +1165,22 @@ func TestIngestCertifyBads(t *testing.T) { return } } - got, err := b.CertifyBad(ctx, test.Query) + got, err := b.CertifyBadList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - slices.SortFunc(got, cmpCB) + var returnedObjects []*model.CertifyBad + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + slices.SortFunc(returnedObjects, cmpCB) slices.SortFunc(test.ExpCB, cmpCB) - if diff := cmp.Diff(test.ExpCB, got, commonOpts); diff != "" { + if diff := cmp.Diff(test.ExpCB, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/certifyGood_test.go b/internal/testing/backend/certifyGood_test.go index e5358bb0b2c..c25ed3091ac 100644 --- a/internal/testing/backend/certifyGood_test.go +++ b/internal/testing/backend/certifyGood_test.go @@ -689,14 +689,20 @@ func TestCertifyGood(t *testing.T) { } } } - got, err := b.CertifyGood(ctx, test.Query) + got, err := b.CertifyGoodList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpCG, got, commonOpts); diff != "" { + var returnedObjects []*model.CertifyGood + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpCG, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -1006,14 +1012,20 @@ func TestIngestCertifyGoods(t *testing.T) { return } } - got, err := b.CertifyGood(ctx, test.Query) + got, err := b.CertifyGoodList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpCG, got, commonOpts); diff != "" { + var returnedObjects []*model.CertifyGood + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpCG, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/certifyLegal_test.go b/internal/testing/backend/certifyLegal_test.go index 1be03c3b924..5d47b17b2c2 100644 --- a/internal/testing/backend/certifyLegal_test.go +++ b/internal/testing/backend/certifyLegal_test.go @@ -582,14 +582,20 @@ func TestLegal(t *testing.T) { test.Query.ID = ptrfrom.String(clID) } } - got, err := b.CertifyLegal(ctx, test.Query) + got, err := b.CertifyLegalList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpLegal, got, commonOpts); diff != "" { + var returnedObjects []*model.CertifyLegal + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpLegal, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -704,14 +710,20 @@ func TestLegals(t *testing.T) { return } } - got, err := b.CertifyLegal(ctx, test.Query) + got, err := b.CertifyLegalList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpLegal, got, commonOpts); diff != "" { + var returnedObjects []*model.CertifyLegal + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpLegal, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/certifyScorecard_test.go b/internal/testing/backend/certifyScorecard_test.go index dd579c367c0..f0dc85e4c3f 100644 --- a/internal/testing/backend/certifyScorecard_test.go +++ b/internal/testing/backend/certifyScorecard_test.go @@ -533,14 +533,20 @@ func TestCertifyScorecard(t *testing.T) { } } } - got, err := b.Scorecards(ctx, test.Query) + got, err := b.ScorecardsList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpSC, got, commonOpts); diff != "" { + var returnedObjects []*model.CertifyScorecard + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpSC, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -757,14 +763,20 @@ func TestIngestScorecards(t *testing.T) { return } } - got, err := b.Scorecards(ctx, test.Query) + got, err := b.ScorecardsList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpSC, got, commonOpts); diff != "" { + var returnedObjects []*model.CertifyScorecard + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpSC, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/certifyVEXStatement_test.go b/internal/testing/backend/certifyVEXStatement_test.go index c8346d1e28b..82c0df3791c 100644 --- a/internal/testing/backend/certifyVEXStatement_test.go +++ b/internal/testing/backend/certifyVEXStatement_test.go @@ -931,14 +931,20 @@ func TestVEX(t *testing.T) { } } } - got, err := b.CertifyVEXStatement(ctx, test.Query) + got, err := b.CertifyVEXStatementList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpVEX, got, commonOpts); diff != "" { + var returnedObjects []*model.CertifyVEXStatement + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpVEX, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -1350,14 +1356,20 @@ func TestVEXBulkIngest(t *testing.T) { return } } - got, err := b.CertifyVEXStatement(ctx, test.Query) + got, err := b.CertifyVEXStatementList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpVEX, got, commonOpts); diff != "" { + var returnedObjects []*model.CertifyVEXStatement + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpVEX, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/certifyVuln_test.go b/internal/testing/backend/certifyVuln_test.go index 56328155134..4c992552d7f 100644 --- a/internal/testing/backend/certifyVuln_test.go +++ b/internal/testing/backend/certifyVuln_test.go @@ -1014,14 +1014,20 @@ func TestIngestCertifyVulnerability(t *testing.T) { } } } - got, err := b.CertifyVuln(ctx, test.Query) + got, err := b.CertifyVulnList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpVuln, got, commonOpts); diff != "" { + var returnedObjects []*model.CertifyVuln + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpVuln, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -1489,14 +1495,20 @@ func TestIngestCertifyVulns(t *testing.T) { } } - got, err := b.CertifyVuln(ctx, test.Query) + got, err := b.CertifyVulnList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpVuln, got, commonOpts); diff != "" { + var returnedObjects []*model.CertifyVuln + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpVuln, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/hasMetadata_test.go b/internal/testing/backend/hasMetadata_test.go index 67ad8e3fa27..b782eae61b8 100644 --- a/internal/testing/backend/hasMetadata_test.go +++ b/internal/testing/backend/hasMetadata_test.go @@ -824,14 +824,20 @@ func TestHasMetadata(t *testing.T) { } } } - got, err := b.HasMetadata(ctx, test.Query) + got, err := b.HasMetadataList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpHM, got, commonOpts); diff != "" { + var returnedObjects []*model.HasMetadata + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpHM, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -1148,14 +1154,20 @@ func TestIngestBulkHasMetadata(t *testing.T) { return } } - got, err := b.HasMetadata(ctx, test.Query) + got, err := b.HasMetadataList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpHM, got, commonOpts); diff != "" { + var returnedObjects []*model.HasMetadata + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpHM, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/hasSBOM_test.go b/internal/testing/backend/hasSBOM_test.go index 991262561ea..ea71b2f9d39 100644 --- a/internal/testing/backend/hasSBOM_test.go +++ b/internal/testing/backend/hasSBOM_test.go @@ -2802,14 +2802,20 @@ func TestHasSBOM(t *testing.T) { } } } - got, err := b.HasSBOM(ctx, test.Query) + got, err := b.HasSBOMList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpHS, got, commonOpts); diff != "" { + var returnedObjects []*model.HasSbom + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpHS, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -3144,14 +3150,20 @@ func TestIngestHasSBOMs(t *testing.T) { return } } - got, err := b.HasSBOM(ctx, test.Query) + got, err := b.HasSBOMList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpHS, got, commonOpts); diff != "" { + var returnedObjects []*model.HasSbom + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpHS, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/hasSLSA_test.go b/internal/testing/backend/hasSLSA_test.go index 2789fbf18c5..c6108b02c91 100644 --- a/internal/testing/backend/hasSLSA_test.go +++ b/internal/testing/backend/hasSLSA_test.go @@ -513,14 +513,14 @@ func TestHasSLSA(t *testing.T) { QueryBuilderID: true, ExpHS: []*model.HasSlsa{ { - Subject: testdata.A1out, + Subject: testdata.A3out, Slsa: &model.Slsa{ BuiltBy: testdata.B2out, BuiltFrom: []*model.Artifact{testdata.A2out}, }, }, { - Subject: testdata.A3out, + Subject: testdata.A1out, Slsa: &model.Slsa{ BuiltBy: testdata.B2out, BuiltFrom: []*model.Artifact{testdata.A2out}, @@ -654,14 +654,20 @@ func TestHasSLSA(t *testing.T) { } } } - got, err := b.HasSlsa(ctx, test.Query) + got, err := b.HasSLSAList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpHS, got, commonOpts); diff != "" { + var returnedObjects []*model.HasSlsa + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpHS, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -900,14 +906,20 @@ func TestIngestHasSLSAs(t *testing.T) { return } } - got, err := b.HasSlsa(ctx, test.Query) + got, err := b.HasSLSAList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpHS, got, commonOpts); diff != "" { + var returnedObjects []*model.HasSlsa + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpHS, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/hasSourceAt_test.go b/internal/testing/backend/hasSourceAt_test.go index d634b0df63d..f7c536ba1e1 100644 --- a/internal/testing/backend/hasSourceAt_test.go +++ b/internal/testing/backend/hasSourceAt_test.go @@ -614,14 +614,20 @@ func TestHasSourceAt(t *testing.T) { } } } - got, err := b.HasSourceAt(ctx, test.Query) + got, err := b.HasSourceAtList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpHSA, got, commonOpts); diff != "" { + var returnedObjects []*model.HasSourceAt + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpHSA, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -905,14 +911,20 @@ func TestIngestHasSourceAts(t *testing.T) { return } } - got, err := b.HasSourceAt(ctx, test.Query) + got, err := b.HasSourceAtList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpHSA, got, commonOpts); diff != "" { + var returnedObjects []*model.HasSourceAt + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpHSA, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/hashEqual_test.go b/internal/testing/backend/hashEqual_test.go index 0dc4ee5614f..9c4550e6310 100644 --- a/internal/testing/backend/hashEqual_test.go +++ b/internal/testing/backend/hashEqual_test.go @@ -487,21 +487,27 @@ func TestHashEqual(t *testing.T) { } } } - got, err := b.HashEqual(ctx, test.Query) + got, err := b.HashEqualList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } + var returnedObjects []*model.HashEqual + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } less := func(a, b *model.Artifact) int { return strings.Compare(a.Digest, b.Digest) } - for _, he := range got { + for _, he := range returnedObjects { slices.SortFunc(he.Artifacts, less) } for _, he := range test.ExpHE { slices.SortFunc(he.Artifacts, less) } - if diff := cmp.Diff(test.ExpHE, got, commonOpts); diff != "" { + if diff := cmp.Diff(test.ExpHE, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -809,21 +815,27 @@ func TestIngestHashEquals(t *testing.T) { return } } - got, err := b.HashEqual(ctx, test.Query) + got, err := b.HashEqualList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } + var returnedObjects []*model.HashEqual + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } less := func(a, b *model.Artifact) int { return strings.Compare(a.Digest, b.Digest) } - for _, he := range got { + for _, he := range returnedObjects { slices.SortFunc(he.Artifacts, less) } for _, he := range test.ExpHE { slices.SortFunc(he.Artifacts, less) } - if diff := cmp.Diff(test.ExpHE, got, commonOpts); diff != "" { + if diff := cmp.Diff(test.ExpHE, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/isDependency_test.go b/internal/testing/backend/isDependency_test.go index 4bcc3ed5bb8..c2985dfbab7 100644 --- a/internal/testing/backend/isDependency_test.go +++ b/internal/testing/backend/isDependency_test.go @@ -876,14 +876,20 @@ func TestIsDependency(t *testing.T) { } } } - got, err := b.IsDependency(ctx, test.Query) + got, err := b.IsDependencyList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpID, got, commonOpts); diff != "" { + var returnedObjects []*model.IsDependency + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpID, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -994,14 +1000,20 @@ func TestIsDependencies(t *testing.T) { if err != nil { return } - got, err := b.IsDependency(ctx, &model.IsDependencySpec{ID: ptrfrom.String(depID[0])}) + got, err := b.IsDependencyList(ctx, model.IsDependencySpec{ID: ptrfrom.String(depID[0])}, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpID, got, commonOpts); diff != "" { + var returnedObjects []*model.IsDependency + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpID, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } } diff --git a/internal/testing/backend/isOccurrence_test.go b/internal/testing/backend/isOccurrence_test.go index 15efaa6b4b1..761e8abce98 100644 --- a/internal/testing/backend/isOccurrence_test.go +++ b/internal/testing/backend/isOccurrence_test.go @@ -538,14 +538,20 @@ func TestOccurrence(t *testing.T) { } } } - got, err := b.IsOccurrence(ctx, test.Query) + got, err := b.IsOccurrenceList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpOcc, got, commonOpts); diff != "" { + var returnedObjects []*model.IsOccurrence + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpOcc, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -665,14 +671,20 @@ func TestIngestOccurrences(t *testing.T) { if err != nil { return } - got, err := b.IsOccurrence(ctx, &model.IsOccurrenceSpec{ID: ptrfrom.String(ocurID[0])}) + got, err := b.IsOccurrenceList(ctx, model.IsOccurrenceSpec{ID: ptrfrom.String(ocurID[0])}, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpOcc, got, commonOpts); diff != "" { + var returnedObjects []*model.IsOccurrence + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpOcc, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } } diff --git a/internal/testing/backend/license_test.go b/internal/testing/backend/license_test.go index 3b5f5953484..6d765a9c193 100644 --- a/internal/testing/backend/license_test.go +++ b/internal/testing/backend/license_test.go @@ -109,7 +109,7 @@ func TestLicenses(t *testing.T) { tt.Query.ID = ptrfrom.String(ingestedLicenseID) } } - got, err := b.Licenses(ctx, tt.Query) + got, err := b.LicenseList(ctx, *tt.Query, nil, nil) if (err != nil) != tt.ExpQueryErr { t.Errorf("arangoClient.Licenses() error = %v, wantErr %v", err, tt.ExpQueryErr) return @@ -117,7 +117,13 @@ func TestLicenses(t *testing.T) { if err != nil { return } - if diff := cmp.Diff(tt.Exp, got, commonOpts); diff != "" { + var returnedObjects []*model.License + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(tt.Exp, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -175,7 +181,7 @@ func TestLicensesBulk(t *testing.T) { if err != nil { return } - got, err := b.Licenses(ctx, tt.Query) + got, err := b.LicenseList(ctx, *tt.Query, nil, nil) if (err != nil) != tt.ExpQueryErr { t.Errorf("arangoClient.Licenses() error = %v, wantErr %v", err, tt.ExpQueryErr) return @@ -183,7 +189,13 @@ func TestLicensesBulk(t *testing.T) { if err != nil { return } - if diff := cmp.Diff(tt.Exp, got, commonOpts); diff != "" { + var returnedObjects []*model.License + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(tt.Exp, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/main_test.go b/internal/testing/backend/main_test.go index 1c6484ca123..f712ab19754 100644 --- a/internal/testing/backend/main_test.go +++ b/internal/testing/backend/main_test.go @@ -37,27 +37,63 @@ const ( ) var skipMatrix = map[string]map[string]bool{ + // pagination not implemented + "TestArtifacts": {arango: true, memmap: true, redis: true, tikv: true}, + "TestBuilder": {arango: true, memmap: true, redis: true, tikv: true}, + "TestBuilders": {arango: true, memmap: true, redis: true, tikv: true}, + "TestCertifyBad": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestCertifyBads": {arango: true, memmap: true, redis: true, tikv: true}, + "TestCertifyGood": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestCertifyGoods": {arango: true, memmap: true, redis: true, tikv: true}, + "TestLegal": {arango: true, memmap: true, redis: true, tikv: true}, + "TestLegals": {arango: true, memmap: true, redis: true, tikv: true}, + "TestCertifyScorecard": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestScorecards": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestCertifyVulnerability": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestCertifyVulns": {arango: true, memmap: true, redis: true, tikv: true}, + "TestHasMetadata": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestBulkHasMetadata": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestHasSBOMs": {arango: true, memmap: true, redis: true, tikv: true}, + "TestHasSLSA": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestHasSLSAs": {arango: true, memmap: true, redis: true, tikv: true}, + "TestHasSourceAt": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestHasSourceAts": {arango: true, memmap: true, redis: true, tikv: true}, + "TestHashEqual": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestHashEquals": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIsDependencies": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestOccurrences": {arango: true, memmap: true, redis: true, tikv: true}, + "TestLicenses": {arango: true, memmap: true, redis: true, tikv: true}, + "TestLicensesBulk": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestPkgEquals": {arango: true, memmap: true, redis: true, tikv: true}, + "TestPackages": {arango: true, memmap: true, redis: true, tikv: true}, + "TestPointOfContact": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestPointOfContacts": {arango: true, memmap: true, redis: true, tikv: true}, + "TestSources": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestVulnEquals": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestVulnMetadata": {arango: true, memmap: true, redis: true, tikv: true}, + "TestIngestVulnMetadatas": {arango: true, memmap: true, redis: true, tikv: true}, + // arango fails IncludedOccurrences_-_Valid_Included_ID and IncludedDependencies_-_Valid_Included_ID "TestHasSBOM": {arango: true}, // keyvalue: failing on dep package querying - "TestIsDependency": {memmap: true, redis: true, tikv: true}, + "TestIsDependency": {arango: true, memmap: true, redis: true, tikv: true}, // arango errors when ID is not found "TestOccurrence": {arango: true}, // keyvalue: path: input: No path found up to specified length // neighbors: sorting not done, testdata is only in order for arango "TestPath": {memmap: true, redis: true, tikv: true}, - "TestNeighbors": {memmap: true, redis: true, tikv: true}, + "TestNeighbors": {arango: true, memmap: true, redis: true, tikv: true}, // keyvalue: query on both packages fail - "TestPkgEqual": {memmap: true, redis: true, tikv: true}, + "TestPkgEqual": {arango: true, memmap: true, redis: true, tikv: true}, // keyvalue: Query_on_OSV_and_novuln_(return_nothing_as_not_valid) fails // arango: errors when ID is not found "TestVulnEqual": {memmap: true, redis: true, tikv: true, arango: true}, // arango: errors when ID is not found "TestVulnerability": {arango: true}, // redis order issues - "TestVEX": {redis: true}, + "TestVEX": {arango: true, redis: true}, // redis order issues - "TestVEXBulkIngest": {redis: true}, + "TestVEXBulkIngest": {arango: true, redis: true}, "TestFindSoftware": {redis: true, arango: true}, } @@ -69,11 +105,11 @@ type backend interface { } var testBackends = map[string]backend{ - memmap: newMemMap(), + // memmap: newMemMap(), arango: newArango(), - redis: newRedis(), - ent: newEnt(), - tikv: newTikv(), + // redis: newRedis(), + ent: newEnt(), + // tikv: newTikv(), } var currentBackend string diff --git a/internal/testing/backend/pkgEqual_test.go b/internal/testing/backend/pkgEqual_test.go index 54ce4cc5faa..ce704b0cab4 100644 --- a/internal/testing/backend/pkgEqual_test.go +++ b/internal/testing/backend/pkgEqual_test.go @@ -592,14 +592,20 @@ func TestPkgEqual(t *testing.T) { } } } - got, err := b.PkgEqual(ctx, test.Query) + got, err := b.PkgEqualList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpHE, got, commonOpts); diff != "" { + var returnedObjects []*model.PkgEqual + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpHE, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -820,14 +826,20 @@ func TestIngestPkgEquals(t *testing.T) { return } } - got, err := b.PkgEqual(ctx, test.Query) + got, err := b.PkgEqualList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpHE, got, commonOpts); diff != "" { + var returnedObjects []*model.PkgEqual + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpHE, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/pkg_test.go b/internal/testing/backend/pkg_test.go index cb404fae42c..3a96934de7d 100644 --- a/internal/testing/backend/pkg_test.go +++ b/internal/testing/backend/pkg_test.go @@ -126,12 +126,18 @@ func TestPackages(t *testing.T) { if tt.idInFilter { tt.pkgFilter.ID = ptrfrom.String(ingestedPkgIDs.PackageVersionID) } - got, err := b.Packages(ctx, tt.pkgFilter) + got, err := b.PackagesList(ctx, *tt.pkgFilter, nil, nil) if (err != nil) != tt.wantErr { t.Errorf("Packages() error = %v, wantErr %v", err, tt.wantErr) return } - if diff := cmp.Diff(tt.want, got, commonOpts); diff != "" { + var returnedObjects []*model.Package + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(tt.want, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/pointOfContact_test.go b/internal/testing/backend/pointOfContact_test.go index 20af12cf4f5..bb0676824c8 100644 --- a/internal/testing/backend/pointOfContact_test.go +++ b/internal/testing/backend/pointOfContact_test.go @@ -835,14 +835,20 @@ func TestPointOfContact(t *testing.T) { } } } - got, err := b.PointOfContact(ctx, test.Query) + got, err := b.PointOfContactList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpPoc, got, commonOpts); diff != "" { + var returnedObjects []*model.PointOfContact + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpPoc, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -1159,14 +1165,20 @@ func TestIngestPointOfContacts(t *testing.T) { return } } - got, err := b.PointOfContact(ctx, test.Query) + got, err := b.PointOfContactList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpPC, got, commonOpts); diff != "" { + var returnedObjects []*model.PointOfContact + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpPC, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/src_test.go b/internal/testing/backend/src_test.go index e6406f370bf..06706f25844 100644 --- a/internal/testing/backend/src_test.go +++ b/internal/testing/backend/src_test.go @@ -113,12 +113,18 @@ func TestSources(t *testing.T) { if tt.idInFilter { tt.srcFilter.ID = ptrfrom.String(ingestedSrcIDs.SourceNameID) } - got, err := b.Sources(ctx, tt.srcFilter) + got, err := b.SourcesList(ctx, *tt.srcFilter, nil, nil) if (err != nil) != tt.wantErr { t.Errorf("Sources() error = %v, wantErr %v", err, tt.wantErr) return } - if diff := cmp.Diff(tt.want, got, commonOpts); diff != "" { + var returnedObjects []*model.Source + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(tt.want, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/vulnEqual_test.go b/internal/testing/backend/vulnEqual_test.go index 5ceaf901d00..752f3d0895c 100644 --- a/internal/testing/backend/vulnEqual_test.go +++ b/internal/testing/backend/vulnEqual_test.go @@ -629,14 +629,20 @@ func TestVulnEqual(t *testing.T) { } } } - got, err := b.VulnEqual(ctx, test.Query) + got, err := b.VulnEqualList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpVulnEqual, got, commonOpts); diff != "" { + var returnedObjects []*model.VulnEqual + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpVulnEqual, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -852,14 +858,20 @@ func TestIngestVulnEquals(t *testing.T) { return } } - got, err := b.VulnEqual(ctx, test.Query) + got, err := b.VulnEqualList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpVulnEqual, got, commonOpts); diff != "" { + var returnedObjects []*model.VulnEqual + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpVulnEqual, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/vulnMetadata_test.go b/internal/testing/backend/vulnMetadata_test.go index 5d02caed51b..9512d0966ff 100644 --- a/internal/testing/backend/vulnMetadata_test.go +++ b/internal/testing/backend/vulnMetadata_test.go @@ -1046,14 +1046,20 @@ func TestIngestVulnMetadata(t *testing.T) { } } - got, err := b.VulnerabilityMetadata(ctx, test.Query) + got, err := b.VulnerabilityMetadataList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpVuln, got, commonOpts); diff != "" { + var returnedObjects []*model.VulnerabilityMetadata + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpVuln, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) @@ -1374,14 +1380,20 @@ func TestIngestVulnMetadatas(t *testing.T) { } } - got, err := b.VulnerabilityMetadata(ctx, test.Query) + got, err := b.VulnerabilityMetadataList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.ExpVuln, got, commonOpts); diff != "" { + var returnedObjects []*model.VulnerabilityMetadata + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.ExpVuln, returnedObjects, commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) diff --git a/internal/testing/backend/vulnerability_test.go b/internal/testing/backend/vulnerability_test.go index 8e2e53727f7..cdc741e1241 100644 --- a/internal/testing/backend/vulnerability_test.go +++ b/internal/testing/backend/vulnerability_test.go @@ -19,6 +19,7 @@ package backend_test import ( "context" + "strings" "testing" "github.com/google/go-cmp/cmp" @@ -210,20 +211,56 @@ func TestVulnerability(t *testing.T) { } } } - got, err := b.Vulnerabilities(ctx, test.Query) + got, err := b.VulnerabilityList(ctx, *test.Query, nil, nil) if (err != nil) != test.ExpQueryErr { t.Fatalf("did not get expected query error, want: %v, got: %v", test.ExpQueryErr, err) } if err != nil { return } - if diff := cmp.Diff(test.Exp, got, commonOpts); diff != "" { + var returnedObjects []*model.Vulnerability + if got != nil { + for _, obj := range got.Edges { + returnedObjects = append(returnedObjects, obj.Node) + } + } + if diff := cmp.Diff(test.Exp, convertToVulnTrie(returnedObjects), commonOpts); diff != "" { t.Errorf("Unexpected results. (-want +got):\n%s", diff) } }) } } +func convertToVulnTrie(vulnObjs []*model.Vulnerability) []*model.Vulnerability { + vulnTypes := map[string][]*model.VulnerabilityID{} + + for _, vulnObj := range vulnObjs { + typeString := vulnObj.Type + "," + strings.Join([]string{"vulnerability_types", vulnObj.Type}, ":") + vulnID := &model.VulnerabilityID{ + ID: vulnObj.VulnerabilityIDs[0].ID, + VulnerabilityID: vulnObj.VulnerabilityIDs[0].VulnerabilityID, + } + if _, ok := vulnTypes[typeString]; ok { + vulnTypes[typeString] = append(vulnTypes[typeString], vulnID) + } else { + var vulnIDs []*model.VulnerabilityID + vulnIDs = append(vulnIDs, vulnID) + vulnTypes[typeString] = vulnIDs + } + } + var vulnerabilities []*model.Vulnerability + for vulnType, vulnIDs := range vulnTypes { + typeValues := strings.Split(vulnType, ",") + vuln := &model.Vulnerability{ + ID: typeValues[1], + Type: typeValues[0], + VulnerabilityIDs: vulnIDs, + } + vulnerabilities = append(vulnerabilities, vuln) + } + return vulnerabilities +} + func TestIngestVulnerabilities(t *testing.T) { ctx := context.Background() b := setupTest(t) diff --git a/pkg/assembler/backends/arangodb/certifyGood.go b/pkg/assembler/backends/arangodb/certifyGood.go index d283236eafa..1741f764070 100644 --- a/pkg/assembler/backends/arangodb/certifyGood.go +++ b/pkg/assembler/backends/arangodb/certifyGood.go @@ -28,7 +28,7 @@ import ( ) func (c *arangoClient) CertifyGoodList(ctx context.Context, certifyGoodSpec model.CertifyGoodSpec, after *string, first *int) (*model.CertifyGoodConnection, error) { - return nil, fmt.Errorf("not implemented: CertifyBadList") + return nil, fmt.Errorf("not implemented: CertifyGoodList") } func (c *arangoClient) CertifyGood(ctx context.Context, certifyGoodSpec *model.CertifyGoodSpec) ([]*model.CertifyGood, error) { diff --git a/pkg/assembler/backends/arangodb/certifyLegal.go b/pkg/assembler/backends/arangodb/certifyLegal.go index 44c026f73af..fd76c10b03b 100644 --- a/pkg/assembler/backends/arangodb/certifyLegal.go +++ b/pkg/assembler/backends/arangodb/certifyLegal.go @@ -28,7 +28,7 @@ import ( ) func (c *arangoClient) CertifyLegalList(ctx context.Context, certifyLegalSpec model.CertifyLegalSpec, after *string, first *int) (*model.CertifyLegalConnection, error) { - return nil, fmt.Errorf("not implemented: CertifyBadList") + return nil, fmt.Errorf("not implemented: CertifyLegalList") } func (c *arangoClient) CertifyLegal(ctx context.Context, certifyLegalSpec *model.CertifyLegalSpec) ([]*model.CertifyLegal, error) { diff --git a/pkg/assembler/backends/ent/backend/artifact.go b/pkg/assembler/backends/ent/backend/artifact.go index e9b936bb642..c2b2b3acdd7 100644 --- a/pkg/assembler/backends/ent/backend/artifact.go +++ b/pkg/assembler/backends/ent/backend/artifact.go @@ -35,43 +35,54 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func artGlobalID(id string) string { + return toGlobalID(artifact.Table, id) +} + +func bulkArtGlobalID(ids []string) []string { + return toGlobalIDs(artifact.Table, ids) +} + func (b *EntBackend) ArtifactsList(ctx context.Context, artifactSpec model.ArtifactSpec, after *string, first *int) (*model.ArtifactConnection, error) { var afterCursor *entgql.Cursor[uuid.UUID] if after != nil { - afterUUID, err := uuid.Parse(*after) + globalID := fromGlobalID(*after) + if globalID.nodeType != artifact.Table { + return nil, fmt.Errorf("after cursor is not type artifact but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) } afterCursor = &ent.Cursor{ID: afterUUID} } else { afterCursor = nil } - query, err := b.client.Artifact.Query(). + artConn, err := b.client.Artifact.Query(). Where(artifactQueryPredicates(&artifactSpec)). - Limit(MaxPageSize). Paginate(ctx, afterCursor, first, nil, nil) if err != nil { - return nil, err + return nil, fmt.Errorf("failed artifact query with error: %w", err) } var edges []*model.ArtifactEdge - for _, edge := range query.Edges { + for _, edge := range artConn.Edges { edges = append(edges, &model.ArtifactEdge{ - Cursor: edge.Cursor.ID.String(), + Cursor: artGlobalID(edge.Cursor.ID.String()), Node: toModelArtifact(edge.Node), }) } - if query.PageInfo.StartCursor != nil { + if artConn.PageInfo.StartCursor != nil { return &model.ArtifactConnection{ - TotalCount: query.TotalCount, + TotalCount: artConn.TotalCount, PageInfo: &model.PageInfo{ - HasNextPage: query.PageInfo.HasNextPage, - StartCursor: ptrfrom.String(query.PageInfo.StartCursor.ID.String()), - EndCursor: ptrfrom.String(query.PageInfo.EndCursor.ID.String()), + HasNextPage: artConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(artGlobalID(artConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(artGlobalID(artConn.PageInfo.EndCursor.ID.String())), }, Edges: edges, }, nil @@ -86,12 +97,10 @@ func (b *EntBackend) Artifacts(ctx context.Context, artifactSpec *model.Artifact artifactSpec = &model.ArtifactSpec{} } query := b.client.Artifact.Query(). - Where(artifactQueryPredicates(artifactSpec)). - Limit(MaxPageSize) - + Where(artifactQueryPredicates(artifactSpec)) artifacts, err := query.All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed artifact query with error: %w", err) } return collect(artifacts, toModelArtifact), nil } @@ -125,7 +134,7 @@ func (b *EntBackend) IngestArtifacts(ctx context.Context, artifacts []*model.IDo return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(artifact.Table, *ids), nil + return bulkArtGlobalID(*ids), nil } func (b *EntBackend) IngestArtifact(ctx context.Context, art *model.IDorArtifactInput) (string, error) { @@ -136,7 +145,7 @@ func (b *EntBackend) IngestArtifact(ctx context.Context, art *model.IDorArtifact if txErr != nil { return "", txErr } - return toGlobalID(artifact.Table, *id), nil + return artGlobalID(*id), nil } func artConflictColumns() []string { @@ -220,7 +229,7 @@ func (b *EntBackend) artifactNeighbors(ctx context.Context, nodeID string, allow if allowedEdges[model.EdgeArtifactHasSbom] { query. WithSbom(func(q *ent.BillOfMaterialsQuery) { - getSBOMObject(q) + getSBOMObjectWithIncludes(q) }) } if allowedEdges[model.EdgeArtifactHasSlsa] { @@ -265,9 +274,6 @@ func (b *EntBackend) artifactNeighbors(ctx context.Context, nodeID string, allow }) } - query. - Limit(MaxPageSize) - artifacts, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed query artifact with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/backend.go b/pkg/assembler/backends/ent/backend/backend.go index b1066324f7c..a4011642bdc 100644 --- a/pkg/assembler/backends/ent/backend/backend.go +++ b/pkg/assembler/backends/ent/backend/backend.go @@ -28,10 +28,6 @@ import ( ) const ( - // MaxPageSize is the maximum number of results that will be returned in a single query. - // const MaxPageSize = 1000 - MaxPageSize = 999999 - // Batch size for ingesting in bulk. Increasing this could results in "PostgreSQL only supports 65535 parameters" error MaxBatchSize = 5000 ) diff --git a/pkg/assembler/backends/ent/backend/builders.go b/pkg/assembler/backends/ent/backend/builders.go index 0437302e527..ee66d638066 100644 --- a/pkg/assembler/backends/ent/backend/builders.go +++ b/pkg/assembler/backends/ent/backend/builders.go @@ -32,41 +32,53 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func buildGlobalID(id string) string { + return toGlobalID(builder.Table, id) +} + +func bulkBuildGlobalID(ids []string) []string { + return toGlobalIDs(builder.Table, ids) +} + func (b *EntBackend) BuildersList(ctx context.Context, builderSpec model.BuilderSpec, after *string, first *int) (*model.BuilderConnection, error) { var afterCursor *entgql.Cursor[uuid.UUID] if after != nil { - afterUUID, err := uuid.Parse(*after) + globalID := fromGlobalID(*after) + if globalID.nodeType != builder.Table { + return nil, fmt.Errorf("after cursor is not type builder but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) } afterCursor = &ent.Cursor{ID: afterUUID} } else { afterCursor = nil } - query, err := b.client.Builder.Query(). + buildConn, err := b.client.Builder.Query(). Where(builderQueryPredicate(&builderSpec)). Paginate(ctx, afterCursor, first, nil, nil) if err != nil { - return nil, err + return nil, fmt.Errorf("failed builder query with error: %w", err) } var edges []*model.BuilderEdge - for _, edge := range query.Edges { + for _, edge := range buildConn.Edges { edges = append(edges, &model.BuilderEdge{ - Cursor: edge.Cursor.ID.String(), + Cursor: buildGlobalID(edge.Cursor.ID.String()), Node: toModelBuilder(edge.Node), }) } - if query.PageInfo.StartCursor != nil { + if buildConn.PageInfo.StartCursor != nil { return &model.BuilderConnection{ - TotalCount: query.TotalCount, + TotalCount: buildConn.TotalCount, PageInfo: &model.PageInfo{ - HasNextPage: query.PageInfo.HasNextPage, - StartCursor: ptrfrom.String(query.PageInfo.StartCursor.ID.String()), - EndCursor: ptrfrom.String(query.PageInfo.EndCursor.ID.String()), + HasNextPage: buildConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(buildGlobalID(buildConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(buildGlobalID(buildConn.PageInfo.EndCursor.ID.String())), }, Edges: edges, }, nil @@ -83,9 +95,9 @@ func (b *EntBackend) Builders(ctx context.Context, builderSpec *model.BuilderSpe query := b.client.Builder.Query(). Where(builderQueryPredicate(builderSpec)) - builders, err := query.Limit(MaxPageSize).All(ctx) + builders, err := query.All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed builder query with error: %w", err) } return collect(builders, toModelBuilder), nil @@ -117,7 +129,7 @@ func (b *EntBackend) IngestBuilder(ctx context.Context, build *model.IDorBuilder if txErr != nil { return "", errors.Wrap(txErr, funcName) } - return toGlobalID(builder.Table, *id), nil + return buildGlobalID(*id), nil } func (b *EntBackend) IngestBuilders(ctx context.Context, builders []*model.IDorBuilderInput) ([]string, error) { @@ -134,7 +146,7 @@ func (b *EntBackend) IngestBuilders(ctx context.Context, builders []*model.IDorB return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(builder.Table, *ids), nil + return bulkBuildGlobalID(*ids), nil } func upsertBulkBuilder(ctx context.Context, tx *ent.Tx, buildInputs []*model.IDorBuilderInput) (*[]string, error) { @@ -203,9 +215,6 @@ func (b *EntBackend) builderNeighbors(ctx context.Context, nodeID string, allowe }) } - query. - Limit(MaxPageSize) - builders, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed query builder with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/certify.go b/pkg/assembler/backends/ent/backend/certify.go index 7fabf755fe2..c48710ccd8d 100644 --- a/pkg/assembler/backends/ent/backend/certify.go +++ b/pkg/assembler/backends/ent/backend/certify.go @@ -19,6 +19,7 @@ import ( "context" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -31,16 +32,79 @@ import ( ) const ( - certifyBadString = "certifyBad" - certifyGoodString = "certifyGood" + certifyBadString = "certify_bad" + certifyGoodString = "certify_good" ) type certificationInputSpec interface { model.CertifyGoodInputSpec | model.CertifyBadInputSpec } -func (b *EntBackend) CertifyBadList(ctx context.Context, certifyBadSpec model.CertifyBadSpec, after *string, first *int) (*model.CertifyBadConnection, error) { - return nil, fmt.Errorf("not implemented: CertifyBadList") +func certifyBadGlobalID(id string) string { + return toGlobalID(certifyBadString, id) +} + +func bulkCertifyBadGlobalID(ids []string) []string { + return toGlobalIDs(certifyBadString, ids) +} + +func certifyGoodGlobalID(id string) string { + return toGlobalID(certifyGoodString, id) +} + +func bulkCertifyGoodGlobalID(ids []string) []string { + return toGlobalIDs(certifyGoodString, ids) +} + +func (b *EntBackend) CertifyBadList(ctx context.Context, filter model.CertifyBadSpec, after *string, first *int) (*model.CertifyBadConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != certifyBadString { + return nil, fmt.Errorf("after cursor is not type certifyBad but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + certQuery := b.client.Certification.Query(). + Where(queryCertifications(certification.TypeBAD, &filter)) + + certBadConn, err := getCertificationObject(certQuery). + Paginate(ctx, afterCursor, first, nil, nil) + + if err != nil { + return nil, fmt.Errorf("failed certifyBad query with error: %w", err) + } + + var edges []*model.CertifyBadEdge + for _, edge := range certBadConn.Edges { + edges = append(edges, &model.CertifyBadEdge{ + Cursor: certifyBadGlobalID(edge.Cursor.ID.String()), + Node: toModelCertifyBad(edge.Node), + }) + } + + if certBadConn.PageInfo.StartCursor != nil { + return &model.CertifyBadConnection{ + TotalCount: certBadConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: certBadConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(certifyBadGlobalID(certBadConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(certifyBadGlobalID(certBadConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) CertifyBad(ctx context.Context, filter *model.CertifyBadSpec) ([]*model.CertifyBad, error) { @@ -52,17 +116,63 @@ func (b *EntBackend) CertifyBad(ctx context.Context, filter *model.CertifyBadSpe Where(queryCertifications(certification.TypeBAD, filter)) records, err := getCertificationObject(certQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed certifyBad query with error: %w", err) } return collect(records, toModelCertifyBad), nil } -func (b *EntBackend) CertifyGoodList(ctx context.Context, certifyGoodSpec model.CertifyGoodSpec, after *string, first *int) (*model.CertifyGoodConnection, error) { - return nil, fmt.Errorf("not implemented: CertifyGoodList") +func (b *EntBackend) CertifyGoodList(ctx context.Context, filter model.CertifyGoodSpec, after *string, first *int) (*model.CertifyGoodConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != certifyGoodString { + return nil, fmt.Errorf("after cursor is not type certifyGood but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + certQuery := b.client.Certification.Query(). + Where(queryCertifications(certification.TypeGOOD, (*model.CertifyBadSpec)(&filter))) + + certGoodConn, err := getCertificationObject(certQuery). + Paginate(ctx, afterCursor, first, nil, nil) + + if err != nil { + return nil, fmt.Errorf("failed certifyGood query with error: %w", err) + } + + var edges []*model.CertifyGoodEdge + for _, edge := range certGoodConn.Edges { + edges = append(edges, &model.CertifyGoodEdge{ + Cursor: certifyGoodGlobalID(edge.Cursor.ID.String()), + Node: toModelCertifyGood(edge.Node), + }) + } + + if certGoodConn.PageInfo.StartCursor != nil { + return &model.CertifyGoodConnection{ + TotalCount: certGoodConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: certGoodConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(certifyGoodGlobalID(certGoodConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(certifyGoodGlobalID(certGoodConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) CertifyGood(ctx context.Context, filter *model.CertifyGoodSpec) ([]*model.CertifyGood, error) { @@ -74,10 +184,9 @@ func (b *EntBackend) CertifyGood(ctx context.Context, filter *model.CertifyGoodS Where(queryCertifications(certification.TypeGOOD, (*model.CertifyBadSpec)(filter))) records, err := getCertificationObject(certQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed certifyGood query with error: %w", err) } return collect(records, toModelCertifyGood), nil @@ -128,7 +237,7 @@ func (b *EntBackend) IngestCertifyBad(ctx context.Context, subject model.Package return "", txErr } - return toGlobalID(certifyBadString, *certRecord), nil + return certifyBadGlobalID(*certRecord), nil } func (b *EntBackend) IngestCertifyBads(ctx context.Context, subjects model.PackageSourceOrArtifactInputs, pkgMatchType *model.MatchFlags, certifyBads []*model.CertifyBadInputSpec) ([]string, error) { @@ -145,7 +254,7 @@ func (b *EntBackend) IngestCertifyBads(ctx context.Context, subjects model.Packa return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(certifyBadString, *ids), nil + return bulkCertifyBadGlobalID(*ids), nil } func (b *EntBackend) IngestCertifyGood(ctx context.Context, subject model.PackageSourceOrArtifactInput, pkgMatchType *model.MatchFlags, spec model.CertifyGoodInputSpec) (string, error) { @@ -156,7 +265,7 @@ func (b *EntBackend) IngestCertifyGood(ctx context.Context, subject model.Packag return "", txErr } - return toGlobalID(certifyGoodString, *certRecord), nil + return certifyGoodGlobalID(*certRecord), nil } func (b *EntBackend) IngestCertifyGoods(ctx context.Context, subjects model.PackageSourceOrArtifactInputs, pkgMatchType *model.MatchFlags, certifyGoods []*model.CertifyGoodInputSpec) ([]string, error) { @@ -173,7 +282,7 @@ func (b *EntBackend) IngestCertifyGoods(ctx context.Context, subjects model.Pack return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(certifyGoodString, *ids), nil + return bulkCertifyGoodGlobalID(*ids), nil } func certifyConflictColumns() []string { @@ -570,9 +679,6 @@ func (b *EntBackend) certifyBadNeighbors(ctx context.Context, nodeID string, all WithSource() } - query. - Limit(MaxPageSize) - certifications, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for certifyBad with node ID: %s with error: %w", nodeID, err) @@ -616,9 +722,6 @@ func (b *EntBackend) certifyGoodNeighbors(ctx context.Context, nodeID string, al WithSource() } - query. - Limit(MaxPageSize) - certifications, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for certifyGood with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/certifyLegal.go b/pkg/assembler/backends/ent/backend/certifyLegal.go index e9e7cd3a655..2d3b8385869 100644 --- a/pkg/assembler/backends/ent/backend/certifyLegal.go +++ b/pkg/assembler/backends/ent/backend/certifyLegal.go @@ -19,6 +19,7 @@ import ( "context" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -31,8 +32,63 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -func (b *EntBackend) CertifyLegalList(ctx context.Context, certifyLegalSpec model.CertifyLegalSpec, after *string, first *int) (*model.CertifyLegalConnection, error) { - return nil, fmt.Errorf("not implemented: CertifyLegalList") +func certifyLegalGlobalID(id string) string { + return toGlobalID(certifylegal.Table, id) +} + +func bulkCertifyLegalGlobalID(ids []string) []string { + return toGlobalIDs(certifylegal.Table, ids) +} + +func (b *EntBackend) CertifyLegalList(ctx context.Context, spec model.CertifyLegalSpec, after *string, first *int) (*model.CertifyLegalConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != certifylegal.Table { + return nil, fmt.Errorf("after cursor is not type certifyLegal but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + certLegalQuery := b.client.CertifyLegal.Query(). + Where(certifyLegalQuery(spec)) + + certLegalConn, err := getCertifyLegalObject(certLegalQuery). + Paginate(ctx, afterCursor, first, nil, nil) + + if err != nil { + return nil, fmt.Errorf("failed certifyLegal query with error: %w", err) + } + + var edges []*model.CertifyLegalEdge + for _, edge := range certLegalConn.Edges { + edges = append(edges, &model.CertifyLegalEdge{ + Cursor: certifyLegalGlobalID(edge.Cursor.ID.String()), + Node: toModelCertifyLegal(edge.Node), + }) + } + + if certLegalConn.PageInfo.StartCursor != nil { + return &model.CertifyLegalConnection{ + TotalCount: certLegalConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: certLegalConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(certifyLegalGlobalID(certLegalConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(certifyLegalGlobalID(certLegalConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) CertifyLegal(ctx context.Context, spec *model.CertifyLegalSpec) ([]*model.CertifyLegal, error) { @@ -43,10 +99,9 @@ func (b *EntBackend) CertifyLegal(ctx context.Context, spec *model.CertifyLegalS Where(certifyLegalQuery(*spec)) records, err := getCertifyLegalObject(certLegalQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed certifyLegal query with error: %w", err) } return collect(records, toModelCertifyLegal), nil @@ -77,7 +132,7 @@ func (b *EntBackend) IngestCertifyLegals(ctx context.Context, subjects model.Pac return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(certifylegal.Table, *ids), nil + return bulkCertifyLegalGlobalID(*ids), nil } func certifyLegalConflictColumns() []string { @@ -141,7 +196,7 @@ func (b *EntBackend) IngestCertifyLegal(ctx context.Context, subject model.Packa return "", gqlerror.Errorf("IngestCertifyLegal :: %s", txErr) } - return toGlobalID(certifylegal.Table, *recordID), nil + return certifyLegalGlobalID(*recordID), nil } func generateCertifyLegalCreate(ctx context.Context, tx *ent.Tx, cl *model.CertifyLegalInputSpec, pkg *model.IDorPkgInput, src *model.IDorSourceInput, declaredLicenses []*model.IDorLicenseInput, discoveredLicenses []*model.IDorLicenseInput) (*ent.CertifyLegalCreate, error) { @@ -421,9 +476,6 @@ func (b *EntBackend) certifyLegalNeighbors(ctx context.Context, nodeID string, a WithDiscoveredLicenses() } - query. - Limit(MaxPageSize) - certLegals, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for certifyLegal with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/certifyVEXStatement.go b/pkg/assembler/backends/ent/backend/certifyVEXStatement.go index 44ca19e188e..00963cc93c8 100644 --- a/pkg/assembler/backends/ent/backend/certifyVEXStatement.go +++ b/pkg/assembler/backends/ent/backend/certifyVEXStatement.go @@ -19,6 +19,7 @@ import ( "context" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -31,6 +32,14 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func certifyVEXGlobalID(id string) string { + return toGlobalID(certifyvex.Table, id) +} + +func bulkCertifyVEXGlobalID(ids []string) []string { + return toGlobalIDs(certifyvex.Table, ids) +} + func certifyVexConflictColumns() []string { return []string{ certifyvex.FieldKnownSince, @@ -94,7 +103,7 @@ func (b *EntBackend) IngestVEXStatement(ctx context.Context, subject model.Packa return "", txErr } - return toGlobalID(certifyvex.Table, *recordID), nil + return certifyVEXGlobalID(*recordID), nil } func (b *EntBackend) IngestVEXStatements(ctx context.Context, subjects model.PackageOrArtifactInputs, vulnerabilities []*model.IDorVulnerabilityInput, vexStatements []*model.VexStatementInputSpec) ([]string, error) { @@ -111,7 +120,7 @@ func (b *EntBackend) IngestVEXStatements(ctx context.Context, subjects model.Pac return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(certifyvex.Table, *ids), nil + return bulkCertifyVEXGlobalID(*ids), nil } func generateVexCreate(ctx context.Context, tx *ent.Tx, pkg *model.IDorPkgInput, art *model.IDorArtifactInput, vuln *model.IDorVulnerabilityInput, vexStatement *model.VexStatementInputSpec) (*ent.CertifyVexCreate, error) { @@ -256,24 +265,69 @@ func upsertBulkVEX(ctx context.Context, tx *ent.Tx, subjects model.PackageOrArti return &ids, nil } -func (b *EntBackend) CertifyVEXStatementList(ctx context.Context, certifyVEXStatementSpec model.CertifyVEXStatementSpec, after *string, first *int) (*model.VEXConnection, error) { - return nil, fmt.Errorf("not implemented: CertifyVEXStatementList") +func (b *EntBackend) CertifyVEXStatementList(ctx context.Context, spec model.CertifyVEXStatementSpec, after *string, first *int) (*model.VEXConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != certifyvex.Table { + return nil, fmt.Errorf("after cursor is not type certifyVEX but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + vexQuery := b.client.CertifyVex.Query(). + Where(certifyVexPredicate(spec)) + + certVEXConn, err := getVEXObject(vexQuery). + Paginate(ctx, afterCursor, first, nil, nil) + + if err != nil { + return nil, fmt.Errorf("failed CertifyVEXStatement query with error: %w", err) + } + + var edges []*model.VEXEdge + for _, edge := range certVEXConn.Edges { + edges = append(edges, &model.VEXEdge{ + Cursor: certifyVEXGlobalID(edge.Cursor.ID.String()), + Node: toModelCertifyVEXStatement(edge.Node), + }) + } + + if certVEXConn.PageInfo.StartCursor != nil { + return &model.VEXConnection{ + TotalCount: certVEXConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: certVEXConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(certifyVEXGlobalID(certVEXConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(certifyVEXGlobalID(certVEXConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) CertifyVEXStatement(ctx context.Context, spec *model.CertifyVEXStatementSpec) ([]*model.CertifyVEXStatement, error) { if spec == nil { spec = &model.CertifyVEXStatementSpec{} } - funcName := "CertifyVEXStatement" vexQuery := b.client.CertifyVex.Query(). Where(certifyVexPredicate(*spec)) records, err := getVEXObject(vexQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, gqlerror.Errorf("%v :: %v", funcName, err) + return nil, fmt.Errorf("failed CertifyVEXStatement query with error: %w", err) } return collect(records, toModelCertifyVEXStatement), nil @@ -292,7 +346,7 @@ func getVEXObject(q *ent.CertifyVexQuery) *ent.CertifyVexQuery { func toModelCertifyVEXStatement(record *ent.CertifyVex) *model.CertifyVEXStatement { return &model.CertifyVEXStatement{ - ID: toGlobalID(certifyvex.Table, record.ID.String()), + ID: certifyVEXGlobalID(record.ID.String()), Subject: toPackageOrArtifact(record.Edges.Package, record.Edges.Artifact), Vulnerability: toModelVulnerabilityFromVulnerabilityID(record.Edges.Vulnerability), KnownSince: record.KnownSince, @@ -367,9 +421,6 @@ func (b *EntBackend) certifyVexNeighbors(ctx context.Context, nodeID string, all WithVulnerability() } - query. - Limit(MaxPageSize) - certVexs, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for certifyVex with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/certifyVuln.go b/pkg/assembler/backends/ent/backend/certifyVuln.go index 654c9bf7816..b0849965aed 100644 --- a/pkg/assembler/backends/ent/backend/certifyVuln.go +++ b/pkg/assembler/backends/ent/backend/certifyVuln.go @@ -19,6 +19,7 @@ import ( "context" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -31,6 +32,14 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func certifyVulnGlobalID(id string) string { + return toGlobalID(certifyvuln.Table, id) +} + +func bulkCertifyVulnGlobalID(ids []string) []string { + return toGlobalIDs(certifyvuln.Table, ids) +} + func certifyVulnConflictColumns() []string { return []string{ certifyvuln.FieldPackageID, @@ -73,7 +82,7 @@ func (b *EntBackend) IngestCertifyVuln(ctx context.Context, pkg model.IDorPkgInp return "", txErr } - return toGlobalID(certifyvuln.Table, *record), nil + return certifyVulnGlobalID(*record), nil } func (b *EntBackend) IngestCertifyVulns(ctx context.Context, pkgs []*model.IDorPkgInput, vulnerabilities []*model.IDorVulnerabilityInput, certifyVulns []*model.ScanMetadataInput) ([]string, error) { @@ -90,7 +99,7 @@ func (b *EntBackend) IngestCertifyVulns(ctx context.Context, pkgs []*model.IDorP return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(certifyvuln.Table, *ids), nil + return bulkCertifyVulnGlobalID(*ids), nil } func generateCertifyVulnCreate(ctx context.Context, tx *ent.Tx, pkg *model.IDorPkgInput, vuln *model.IDorVulnerabilityInput, certifyVuln *model.ScanMetadataInput) (*ent.CertifyVulnCreate, error) { @@ -191,8 +200,55 @@ func upsertBulkCertifyVuln(ctx context.Context, tx *ent.Tx, pkgs []*model.IDorPk return &ids, nil } -func (b *EntBackend) CertifyVulnList(ctx context.Context, certifyVulnSpec model.CertifyVulnSpec, after *string, first *int) (*model.CertifyVulnConnection, error) { - return nil, fmt.Errorf("not implemented: CertifyVulnList") +func (b *EntBackend) CertifyVulnList(ctx context.Context, spec model.CertifyVulnSpec, after *string, first *int) (*model.CertifyVulnConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != certifyvuln.Table { + return nil, fmt.Errorf("after cursor is not type certifyVuln but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + certVulnQuery := b.client.CertifyVuln.Query(). + Where(certifyVulnPredicate(spec)) + + certVulnConn, err := getCertVulnObject(certVulnQuery). + Paginate(ctx, afterCursor, first, nil, nil) + + if err != nil { + return nil, fmt.Errorf("failed certifyVuln query with error: %w", err) + } + + var edges []*model.CertifyVulnEdge + for _, edge := range certVulnConn.Edges { + edges = append(edges, &model.CertifyVulnEdge{ + Cursor: certifyVulnGlobalID(edge.Cursor.ID.String()), + Node: toModelCertifyVulnerability(edge.Node), + }) + } + + if certVulnConn.PageInfo.StartCursor != nil { + return &model.CertifyVulnConnection{ + TotalCount: certVulnConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: certVulnConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(certifyVulnGlobalID(certVulnConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(certifyVulnGlobalID(certVulnConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) CertifyVuln(ctx context.Context, spec *model.CertifyVulnSpec) ([]*model.CertifyVuln, error) { @@ -203,10 +259,9 @@ func (b *EntBackend) CertifyVuln(ctx context.Context, spec *model.CertifyVulnSpe Where(certifyVulnPredicate(*spec)) records, err := getCertVulnObject(certVulnQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed certifyVuln query with error: %w", err) } return collect(records, toModelCertifyVulnerability), nil @@ -248,7 +303,7 @@ func getCertVulnObject(q *ent.CertifyVulnQuery) *ent.CertifyVulnQuery { func toModelCertifyVulnerability(record *ent.CertifyVuln) *model.CertifyVuln { return &model.CertifyVuln{ - ID: toGlobalID(certifyvuln.Table, record.ID.String()), + ID: certifyVulnGlobalID(record.ID.String()), Package: toModelPackage(backReferencePackageVersion(record.Edges.Package)), Vulnerability: toModelVulnerabilityFromVulnerabilityID(record.Edges.Vulnerability), Metadata: &model.ScanMetadata{ @@ -280,9 +335,6 @@ func (b *EntBackend) certifyVulnNeighbors(ctx context.Context, nodeID string, al WithVulnerability() } - query. - Limit(MaxPageSize) - certVulns, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for certifyVuln with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/dependency.go b/pkg/assembler/backends/ent/backend/dependency.go index 69fb61f972e..7511e0b4f7f 100644 --- a/pkg/assembler/backends/ent/backend/dependency.go +++ b/pkg/assembler/backends/ent/backend/dependency.go @@ -19,6 +19,7 @@ import ( "context" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -30,12 +31,66 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -func (b *EntBackend) IsDependencyList(ctx context.Context, isDependencySpec model.IsDependencySpec, after *string, first *int) (*model.IsDependencyConnection, error) { - return nil, fmt.Errorf("not implemented: IsDependencyList") +func dependencyGlobalID(id string) string { + return toGlobalID(dependency.Table, id) +} + +func bulkDependencyGlobalID(ids []string) []string { + return toGlobalIDs(dependency.Table, ids) +} + +func (b *EntBackend) IsDependencyList(ctx context.Context, spec model.IsDependencySpec, after *string, first *int) (*model.IsDependencyConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != dependency.Table { + return nil, fmt.Errorf("after cursor is not type dependency but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + isDepQuery := b.client.Dependency.Query(). + Where(isDependencyQuery(&spec)) + + depConn, err := getIsDepObject(isDepQuery). + Paginate(ctx, afterCursor, first, nil, nil) + + if err != nil { + return nil, fmt.Errorf("failed isDependency query with error: %w", err) + } + + var edges []*model.IsDependencyEdge + for _, edge := range depConn.Edges { + edges = append(edges, &model.IsDependencyEdge{ + Cursor: dependencyGlobalID(edge.Cursor.ID.String()), + Node: toModelIsDependencyWithBackrefs(edge.Node), + }) + } + + if depConn.PageInfo.StartCursor != nil { + return &model.IsDependencyConnection{ + TotalCount: depConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: depConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(dependencyGlobalID(depConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(dependencyGlobalID(depConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) IsDependency(ctx context.Context, spec *model.IsDependencySpec) ([]*model.IsDependency, error) { - funcName := "IsDependency" if spec == nil { spec = &model.IsDependencySpec{} } @@ -44,10 +99,9 @@ func (b *EntBackend) IsDependency(ctx context.Context, spec *model.IsDependencyS Where(isDependencyQuery(spec)) deps, err := getIsDepObject(isDepQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, errors.Wrap(err, funcName) + return nil, fmt.Errorf("failed isDependency query with error: %w", err) } return collect(deps, toModelIsDependencyWithBackrefs), nil @@ -76,7 +130,7 @@ func (b *EntBackend) IngestDependencies(ctx context.Context, pkgs []*model.IDorP return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(dependency.Table, *ids), nil + return bulkDependencyGlobalID(*ids), nil } func dependencyConflictColumns() []string { @@ -280,7 +334,7 @@ func (b *EntBackend) IngestDependency(ctx context.Context, pkg model.IDorPkgInpu return "", errors.Wrap(txErr, funcName) } - return toGlobalID(dependency.Table, *recordID), nil + return dependencyGlobalID(*recordID), nil } func dependencyTypeToEnum(t model.DependencyType) dependency.DependencyType { @@ -373,9 +427,6 @@ func (b *EntBackend) isDependencyNeighbors(ctx context.Context, nodeID string, a WithDependentPackageName() } - query. - Limit(MaxPageSize) - deps, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for isDep with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/hasMetadata.go b/pkg/assembler/backends/ent/backend/hasMetadata.go index 39e7334a998..e99aa256d6a 100644 --- a/pkg/assembler/backends/ent/backend/hasMetadata.go +++ b/pkg/assembler/backends/ent/backend/hasMetadata.go @@ -19,6 +19,7 @@ import ( "context" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -30,8 +31,62 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -func (b *EntBackend) HasMetadataList(ctx context.Context, hasMetadataSpec model.HasMetadataSpec, after *string, first *int) (*model.HasMetadataConnection, error) { - return nil, fmt.Errorf("not implemented: HasMetadataList") +func hasMetadataGlobalID(id string) string { + return toGlobalID(hasmetadata.Table, id) +} + +func bulkHasMetadataGlobalID(ids []string) []string { + return toGlobalIDs(hasmetadata.Table, ids) +} + +func (b *EntBackend) HasMetadataList(ctx context.Context, spec model.HasMetadataSpec, after *string, first *int) (*model.HasMetadataConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != hasmetadata.Table { + return nil, fmt.Errorf("after cursor is not type hasMetadata but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + hmQuery := b.client.HasMetadata.Query(). + Where(hasMetadataPredicate(&spec)) + + hmConnect, err := getHasMetadataObject(hmQuery). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed hasMetadata query with error: %w", err) + } + + var edges []*model.HasMetadataEdge + for _, edge := range hmConnect.Edges { + edges = append(edges, &model.HasMetadataEdge{ + Cursor: hasMetadataGlobalID(edge.Cursor.ID.String()), + Node: toModelHasMetadata(edge.Node), + }) + } + + if hmConnect.PageInfo.StartCursor != nil { + return &model.HasMetadataConnection{ + TotalCount: hmConnect.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: hmConnect.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(hasMetadataGlobalID(hmConnect.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(hasMetadataGlobalID(hmConnect.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) HasMetadata(ctx context.Context, filter *model.HasMetadataSpec) ([]*model.HasMetadata, error) { @@ -42,10 +97,9 @@ func (b *EntBackend) HasMetadata(ctx context.Context, filter *model.HasMetadataS Where(hasMetadataPredicate(filter)) records, err := getHasMetadataObject(hmQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, fmt.Errorf("failed to retrieve HasMetadata :: %s", err) + return nil, fmt.Errorf("failed hasMetadata query with error: %w", err) } return collect(records, toModelHasMetadata), nil @@ -68,7 +122,7 @@ func (b *EntBackend) IngestHasMetadata(ctx context.Context, subject model.Packag return "", fmt.Errorf("failed to execute IngestHasMetadata :: %s", txErr) } - return toGlobalID(hasmetadata.Table, *recordID), nil + return hasMetadataGlobalID(*recordID), nil } func (b *EntBackend) IngestBulkHasMetadata(ctx context.Context, subjects model.PackageSourceOrArtifactInputs, pkgMatchType *model.MatchFlags, hasMetadataList []*model.HasMetadataInputSpec) ([]string, error) { @@ -85,7 +139,7 @@ func (b *EntBackend) IngestBulkHasMetadata(ctx context.Context, subjects model.P return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(hasmetadata.Table, *ids), nil + return bulkHasMetadataGlobalID(*ids), nil } func hasMetadataPredicate(filter *model.HasMetadataSpec) predicate.HasMetadata { @@ -389,7 +443,7 @@ func toModelHasMetadata(v *ent.HasMetadata) *model.HasMetadata { } return &model.HasMetadata{ - ID: toGlobalID(hasmetadata.Table, v.ID.String()), + ID: hasMetadataGlobalID(v.ID.String()), Subject: sub, Key: v.Key, Value: v.Value, @@ -421,9 +475,6 @@ func (b *EntBackend) hasMetadataNeighbors(ctx context.Context, nodeID string, al WithSource() } - query. - Limit(MaxPageSize) - hasMetas, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for hasMetadata with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/hashequal.go b/pkg/assembler/backends/ent/backend/hashequal.go index dd59cde015a..f1b88fbe1ea 100644 --- a/pkg/assembler/backends/ent/backend/hashequal.go +++ b/pkg/assembler/backends/ent/backend/hashequal.go @@ -22,11 +22,11 @@ import ( "fmt" "sort" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/pkg/assembler/backends/ent" - "github.com/guacsec/guac/pkg/assembler/backends/ent/artifact" "github.com/guacsec/guac/pkg/assembler/backends/ent/hashequal" "github.com/guacsec/guac/pkg/assembler/backends/ent/predicate" "github.com/guacsec/guac/pkg/assembler/graphql/model" @@ -34,8 +34,63 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -func (b *EntBackend) HashEqualList(ctx context.Context, hashEqualSpec model.HashEqualSpec, after *string, first *int) (*model.HashEqualConnection, error) { - return nil, fmt.Errorf("not implemented: HashEqualList") +func hashEqualGlobalID(id string) string { + return toGlobalID(hashequal.Table, id) +} + +func bulkHashEqualGlobalID(ids []string) []string { + return toGlobalIDs(hashequal.Table, ids) +} + +func (b *EntBackend) HashEqualList(ctx context.Context, spec model.HashEqualSpec, after *string, first *int) (*model.HashEqualConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != hashequal.Table { + return nil, fmt.Errorf("after cursor is not type hashEqual but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + heQuery := b.client.HashEqual.Query(). + Where(hashEqualQueryPredicates(&spec)) + + haConn, err := getHashEqualObject(heQuery). + Paginate(ctx, afterCursor, first, nil, nil) + + if err != nil { + return nil, fmt.Errorf("failed hashEqual query with error: %w", err) + } + + var edges []*model.HashEqualEdge + for _, edge := range haConn.Edges { + edges = append(edges, &model.HashEqualEdge{ + Cursor: hashEqualGlobalID(edge.Cursor.ID.String()), + Node: toModelHashEqual(edge.Node), + }) + } + + if haConn.PageInfo.StartCursor != nil { + return &model.HashEqualConnection{ + TotalCount: haConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: haConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(hashEqualGlobalID(haConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(hashEqualGlobalID(haConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) HashEqual(ctx context.Context, spec *model.HashEqualSpec) ([]*model.HashEqual, error) { @@ -53,7 +108,7 @@ func (b *EntBackend) HashEqual(ctx context.Context, spec *model.HashEqualSpec) ( records, err := getHashEqualObject(heQuery). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed hashEqual query with error: %w", err) } return collect(records, toModelHashEqual), nil @@ -97,7 +152,7 @@ func (b *EntBackend) IngestHashEqual(ctx context.Context, artifact model.IDorArt return "", txErr } - return toGlobalID(hashequal.Table, *record), nil + return hashEqualGlobalID(*record), nil } func (b *EntBackend) IngestHashEquals(ctx context.Context, artifacts []*model.IDorArtifactInput, otherArtifacts []*model.IDorArtifactInput, hashEquals []*model.HashEqualInputSpec) ([]string, error) { @@ -114,7 +169,7 @@ func (b *EntBackend) IngestHashEquals(ctx context.Context, artifacts []*model.ID return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(hashequal.Table, *ids), nil + return bulkHashEqualGlobalID(*ids), nil } func hasEqualConflictColumns() []string { @@ -180,7 +235,7 @@ func generateHashEqualCreate(ctx context.Context, tx *ent.Tx, artifactA *model.I if err != nil { return nil, err } - artifactA.ArtifactID = ptrfrom.String(toGlobalID(artifact.Table, foundArt.ID.String())) + artifactA.ArtifactID = ptrfrom.String(hashEqualGlobalID(foundArt.ID.String())) } if artifactB.ArtifactID == nil { @@ -188,7 +243,7 @@ func generateHashEqualCreate(ctx context.Context, tx *ent.Tx, artifactA *model.I if err != nil { return nil, err } - artifactB.ArtifactID = ptrfrom.String(toGlobalID(artifact.Table, foundArt.ID.String())) + artifactB.ArtifactID = ptrfrom.String(hashEqualGlobalID(foundArt.ID.String())) } sortedArtifacts := []model.IDorArtifactInput{*artifactA, *artifactB} @@ -264,7 +319,7 @@ func toModelHashEqual(record *ent.HashEqual) *model.HashEqual { artifacts := []*ent.Artifact{record.Edges.ArtifactA, record.Edges.ArtifactB} return &model.HashEqual{ - ID: toGlobalID(hashequal.Table, record.ID.String()), + ID: hashEqualGlobalID(record.ID.String()), Artifacts: collect(artifacts, toModelArtifact), Justification: record.Justification, Collector: record.Collector, @@ -300,9 +355,6 @@ func (b *EntBackend) hashEqualNeighbors(ctx context.Context, nodeID string, allo WithArtifactB() } - query. - Limit(MaxPageSize) - hasEquals, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for hashEqual with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/license.go b/pkg/assembler/backends/ent/backend/license.go index 89068d72dfe..310f42b4277 100644 --- a/pkg/assembler/backends/ent/backend/license.go +++ b/pkg/assembler/backends/ent/backend/license.go @@ -20,6 +20,7 @@ import ( stdsql "database/sql" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -32,6 +33,14 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) +func licenseGlobalID(id string) string { + return toGlobalID(license.Table, id) +} + +func bulkLicenseGlobalID(ids []string) []string { + return toGlobalIDs(license.Table, ids) +} + func (b *EntBackend) IngestLicenses(ctx context.Context, licenses []*model.IDorLicenseInput) ([]string, error) { funcName := "IngestLicenses" ids, txErr := WithinTX(ctx, b.client, func(ctx context.Context) (*[]string, error) { @@ -46,7 +55,7 @@ func (b *EntBackend) IngestLicenses(ctx context.Context, licenses []*model.IDorL return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(license.Table, *ids), nil + return bulkLicenseGlobalID(*ids), nil } func (b *EntBackend) IngestLicense(ctx context.Context, licenseInput *model.IDorLicenseInput) (string, error) { @@ -63,11 +72,55 @@ func (b *EntBackend) IngestLicense(ctx context.Context, licenseInput *model.IDor return "", txErr } - return toGlobalID(license.Table, *record), nil + return licenseGlobalID(*record), nil } -func (b *EntBackend) LicenseList(ctx context.Context, licenseSpec model.LicenseSpec, after *string, first *int) (*model.LicenseConnection, error) { - return nil, fmt.Errorf("not implemented: LicenseList") +func (b *EntBackend) LicenseList(ctx context.Context, spec model.LicenseSpec, after *string, first *int) (*model.LicenseConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != license.Table { + return nil, fmt.Errorf("after cursor is not type license but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + licenseConn, err := b.client.License.Query(). + Where(licenseQuery(spec)). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed license query with error: %w", err) + } + + var edges []*model.LicenseEdge + for _, edge := range licenseConn.Edges { + edges = append(edges, &model.LicenseEdge{ + Cursor: licenseGlobalID(edge.Cursor.ID.String()), + Node: toModelLicense(edge.Node), + }) + } + + if licenseConn.PageInfo.StartCursor != nil { + return &model.LicenseConnection{ + TotalCount: licenseConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: licenseConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(licenseGlobalID(licenseConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(licenseGlobalID(licenseConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) Licenses(ctx context.Context, filter *model.LicenseSpec) ([]*model.License, error) { @@ -76,7 +129,7 @@ func (b *EntBackend) Licenses(ctx context.Context, filter *model.LicenseSpec) ([ } records, err := getLicenses(ctx, b.client, *filter) if err != nil { - return nil, err + return nil, fmt.Errorf("getLicenses with error: %w", err) } return collect(records, toModelLicense), nil } @@ -84,10 +137,9 @@ func (b *EntBackend) Licenses(ctx context.Context, filter *model.LicenseSpec) ([ func getLicenses(ctx context.Context, client *ent.Client, filter model.LicenseSpec) ([]*ent.License, error) { results, err := client.License.Query(). Where(licenseQuery(filter)). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed license query with error: %w", err) } return results, nil } @@ -189,9 +241,6 @@ func (b *EntBackend) licenseNeighbors(ctx context.Context, nodeID string, allowe }) } - query. - Limit(MaxPageSize) - licenses, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for license with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/occurrence.go b/pkg/assembler/backends/ent/backend/occurrence.go index b13e1178408..31944d87244 100644 --- a/pkg/assembler/backends/ent/backend/occurrence.go +++ b/pkg/assembler/backends/ent/backend/occurrence.go @@ -19,6 +19,7 @@ import ( "context" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -30,8 +31,62 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -func (b *EntBackend) IsOccurrenceList(ctx context.Context, isOccurrenceSpec model.IsOccurrenceSpec, after *string, first *int) (*model.IsOccurrenceConnection, error) { - return nil, fmt.Errorf("not implemented: IsOccurrenceList") +func occurrenceGlobalID(id string) string { + return toGlobalID(occurrence.Table, id) +} + +func bulkOccurrenceGlobalID(ids []string) []string { + return toGlobalIDs(occurrence.Table, ids) +} + +func (b *EntBackend) IsOccurrenceList(ctx context.Context, spec model.IsOccurrenceSpec, after *string, first *int) (*model.IsOccurrenceConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != occurrence.Table { + return nil, fmt.Errorf("after cursor is not type occurrence but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + occurQuery := b.client.Occurrence.Query(). + Where(isOccurrenceQuery(&spec)) + + occurConn, err := getOccurrenceObject(occurQuery). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed isOccurrence query with error: %w", err) + } + + var edges []*model.IsOccurrenceEdge + for _, edge := range occurConn.Edges { + edges = append(edges, &model.IsOccurrenceEdge{ + Cursor: occurrenceGlobalID(edge.Cursor.ID.String()), + Node: toModelIsOccurrenceWithSubject(edge.Node), + }) + } + + if occurConn.PageInfo.StartCursor != nil { + return &model.IsOccurrenceConnection{ + TotalCount: occurConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: occurConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(occurrenceGlobalID(occurConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(occurrenceGlobalID(occurConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) IsOccurrence(ctx context.Context, query *model.IsOccurrenceSpec) ([]*model.IsOccurrence, error) { @@ -44,7 +99,7 @@ func (b *EntBackend) IsOccurrence(ctx context.Context, query *model.IsOccurrence records, err := getOccurrenceObject(occurQuery). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed isOccurrence query with error: %w", err) } return collect(records, toModelIsOccurrenceWithSubject), nil @@ -74,7 +129,7 @@ func (b *EntBackend) IngestOccurrences(ctx context.Context, subjects model.Packa return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(occurrence.Table, *ids), nil + return bulkOccurrenceGlobalID(*ids), nil } func occurrenceConflictColumns() []string { @@ -294,7 +349,7 @@ func (b *EntBackend) IngestOccurrence(ctx context.Context, return "", gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalID(occurrence.Table, *recordID), nil + return occurrenceGlobalID(*recordID), nil } func isOccurrenceQuery(filter *model.IsOccurrenceSpec) predicate.Occurrence { @@ -372,9 +427,6 @@ func (b *EntBackend) isOccurrenceNeighbors(ctx context.Context, nodeID string, a WithArtifact() } - query. - Limit(MaxPageSize) - occurs, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for isOccur with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/package.go b/pkg/assembler/backends/ent/backend/package.go index d4cc87f5f24..fc770ed35fe 100644 --- a/pkg/assembler/backends/ent/backend/package.go +++ b/pkg/assembler/backends/ent/backend/package.go @@ -24,8 +24,10 @@ import ( "sort" "strings" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" + "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/pkg/assembler/backends/ent" "github.com/guacsec/guac/pkg/assembler/backends/ent/certification" "github.com/guacsec/guac/pkg/assembler/backends/ent/packagename" @@ -43,8 +45,69 @@ const ( pkgNamespaceString = "package_namespaces" ) +func pkgTypeGlobalID(id string) string { + return toGlobalID(pkgTypeString, id) +} + +func pkgNamespaceGlobalID(id string) string { + return toGlobalID(pkgNamespaceString, id) +} + +func pkgNameGlobalID(id string) string { + return toGlobalID(packagename.Table, id) +} + +func pkgVersionGlobalID(id string) string { + return toGlobalID(packageversion.Table, id) +} + func (b *EntBackend) PackagesList(ctx context.Context, pkgSpec model.PkgSpec, after *string, first *int) (*model.PackageConnection, error) { - return nil, fmt.Errorf("not implemented: PackagesList") + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != packageversion.Table { + return nil, fmt.Errorf("after cursor is not type packageversion but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + pkgConn, err := b.client.PackageVersion.Query(). + Where(packageQueryPredicates(&pkgSpec)). + WithName(func(q *ent.PackageNameQuery) {}). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed package query with error: %w", err) + } + + var edges []*model.PackageEdge + for _, edge := range pkgConn.Edges { + edges = append(edges, &model.PackageEdge{ + Cursor: pkgVersionGlobalID(edge.Cursor.ID.String()), + Node: toModelPackage(backReferencePackageVersion(edge.Node)), + }) + } + + if pkgConn.PageInfo.StartCursor != nil { + return &model.PackageConnection{ + TotalCount: pkgConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: pkgConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(pkgVersionGlobalID(pkgConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(pkgVersionGlobalID(pkgConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) Packages(ctx context.Context, pkgSpec *model.PkgSpec) ([]*model.Package, error) { @@ -55,10 +118,9 @@ func (b *EntBackend) Packages(ctx context.Context, pkgSpec *model.PkgSpec) ([]*m pkgs, err := b.client.PackageVersion.Query(). Where(packageQueryPredicates(pkgSpec)). WithName(func(q *ent.PackageNameQuery) {}). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed package query with error: %w", err) } var pkgNames []*ent.PackageName @@ -191,10 +253,10 @@ func upsertBulkPackage(ctx context.Context, tx *ent.Tx, pkgInputs []*model.IDorP var collectedPkgIDs []model.PackageIDs for i := range pkgVersionIDs { collectedPkgIDs = append(collectedPkgIDs, model.PackageIDs{ - PackageTypeID: toGlobalID(pkgTypeString, pkgTypes[pkgNameIDs[i]]), - PackageNamespaceID: toGlobalID(pkgNamespaceString, pkgNamespaces[pkgNameIDs[i]]), - PackageNameID: toGlobalID(ent.TypePackageName, pkgNameIDs[i]), - PackageVersionID: toGlobalID(ent.TypePackageVersion, pkgVersionIDs[i])}) + PackageTypeID: pkgTypeGlobalID(pkgTypes[pkgNameIDs[i]]), + PackageNamespaceID: pkgNamespaceGlobalID(pkgNamespaces[pkgNameIDs[i]]), + PackageNameID: pkgNameGlobalID(pkgNameIDs[i]), + PackageVersionID: pkgVersionGlobalID(pkgVersionIDs[i])}) } return &collectedPkgIDs, nil @@ -236,10 +298,10 @@ func upsertPackage(ctx context.Context, tx *ent.Tx, pkg model.IDorPkgInput) (*mo } return &model.PackageIDs{ - PackageTypeID: toGlobalID(pkgTypeString, pkg.PackageInput.Type), - PackageNamespaceID: toGlobalID(pkgNamespaceString, strings.Join([]string{pkg.PackageInput.Type, stringOrEmpty(pkg.PackageInput.Namespace)}, guacIDSplit)), - PackageNameID: toGlobalID(packagename.Table, pkgNameID.String()), - PackageVersionID: toGlobalID(packageversion.Table, pkgVersionID.String())}, nil + PackageTypeID: pkgTypeGlobalID(pkg.PackageInput.Type), + PackageNamespaceID: pkgNamespaceGlobalID(strings.Join([]string{pkg.PackageInput.Type, stringOrEmpty(pkg.PackageInput.Namespace)}, guacIDSplit)), + PackageNameID: pkgNameGlobalID(pkgNameID.String()), + PackageVersionID: pkgVersionGlobalID(pkgVersionID.String())}, nil } func withPackageVersionTree() func(*ent.PackageVersionQuery) { @@ -411,8 +473,7 @@ func (b *EntBackend) packageTypeNeighbors(ctx context.Context, nodeID string, al query := b.client.PackageName.Query(). Where([]predicate.PackageName{ optionalPredicate(&nodeID, packagename.TypeEQ), - }...). - Limit(MaxPageSize) + }...) pkgNames, err := query.All(ctx) if err != nil { @@ -421,11 +482,11 @@ func (b *EntBackend) packageTypeNeighbors(ctx context.Context, nodeID string, al for _, foundPkgName := range pkgNames { out = append(out, &model.Package{ - ID: toGlobalID(pkgTypeString, foundPkgName.Type), + ID: pkgTypeGlobalID(foundPkgName.Type), Type: foundPkgName.Type, Namespaces: []*model.PackageNamespace{ { - ID: toGlobalID(pkgNamespaceString, strings.Join([]string{foundPkgName.Type, foundPkgName.Namespace}, guacIDSplit)), + ID: pkgNamespaceGlobalID(strings.Join([]string{foundPkgName.Type, foundPkgName.Namespace}, guacIDSplit)), Namespace: foundPkgName.Namespace, Names: []*model.PackageName{}, }, @@ -448,8 +509,7 @@ func (b *EntBackend) packageNamespaceNeighbors(ctx context.Context, nodeID strin Where([]predicate.PackageName{ optionalPredicate(&splitQueryValue[0], packagename.TypeEQ), optionalPredicate(&splitQueryValue[1], packagename.NamespaceEQ), - }...). - Limit(MaxPageSize) + }...) pkgNames, err := query.All(ctx) if err != nil { @@ -459,14 +519,14 @@ func (b *EntBackend) packageNamespaceNeighbors(ctx context.Context, nodeID strin for _, foundPkgName := range pkgNames { if allowedEdges[model.EdgePackageNamespacePackageName] { out = append(out, &model.Package{ - ID: toGlobalID(pkgTypeString, foundPkgName.Type), + ID: pkgTypeGlobalID(foundPkgName.Type), Type: foundPkgName.Type, Namespaces: []*model.PackageNamespace{ { - ID: toGlobalID(pkgNamespaceString, strings.Join([]string{foundPkgName.Type, foundPkgName.Namespace}, ":")), + ID: pkgNamespaceGlobalID(strings.Join([]string{foundPkgName.Type, foundPkgName.Namespace}, ":")), Namespace: foundPkgName.Namespace, Names: []*model.PackageName{{ - ID: toGlobalID(packagename.Table, foundPkgName.ID.String()), + ID: pkgNameGlobalID(foundPkgName.ID.String()), Name: foundPkgName.Name, Versions: []*model.PackageVersion{}, }}, @@ -476,7 +536,7 @@ func (b *EntBackend) packageNamespaceNeighbors(ctx context.Context, nodeID strin } if allowedEdges[model.EdgePackageNamespacePackageType] { out = append(out, &model.Package{ - ID: toGlobalID(pkgTypeString, foundPkgName.Type), + ID: pkgTypeGlobalID(foundPkgName.Type), Type: foundPkgName.Type, Namespaces: []*model.PackageNamespace{}, }) @@ -500,10 +560,6 @@ func (b *EntBackend) packageNameNeighbors(ctx context.Context, nodeID string, al q.WithName() }) } - if allowedEdges[model.EdgePackageNamePackageNamespace] { - query. - Limit(MaxPageSize) - } if allowedEdges[model.EdgePackageHasSourceAt] { query. WithHasSourceAt(func(q *ent.HasSourceAtQuery) { @@ -543,9 +599,6 @@ func (b *EntBackend) packageNameNeighbors(ctx context.Context, nodeID string, al }) } - query. - Limit(MaxPageSize) - pkgNames, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for pkgName with node ID: %s with error: %w", nodeID, err) @@ -567,11 +620,11 @@ func (b *EntBackend) packageNameNeighbors(ctx context.Context, nodeID string, al for _, foundPkgName := range pkgNames { if allowedEdges[model.EdgePackageNamePackageNamespace] { out = append(out, &model.Package{ - ID: toGlobalID(pkgTypeString, foundPkgName.Type), + ID: pkgTypeGlobalID(foundPkgName.Type), Type: foundPkgName.Type, Namespaces: []*model.PackageNamespace{ { - ID: toGlobalID(pkgNamespaceString, strings.Join([]string{foundPkgName.Type, foundPkgName.Namespace}, guacIDSplit)), + ID: pkgNamespaceGlobalID(strings.Join([]string{foundPkgName.Type, foundPkgName.Namespace}, guacIDSplit)), Namespace: foundPkgName.Namespace, Names: []*model.PackageName{}, }, @@ -642,7 +695,7 @@ func (b *EntBackend) packageVersionNeighbors(ctx context.Context, nodeID string, if allowedEdges[model.EdgePackageHasSbom] { query. WithSbom(func(q *ent.BillOfMaterialsQuery) { - getSBOMObject(q) + getSBOMObjectWithIncludes(q) }) } if allowedEdges[model.EdgePackageCertifyVexStatement] { @@ -693,9 +746,6 @@ func (b *EntBackend) packageVersionNeighbors(ctx context.Context, nodeID string, }) } - query. - Limit(MaxPageSize) - pkgVersions, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for packageVersion with node ID: %s with error: %w", nodeID, err) @@ -707,14 +757,14 @@ func (b *EntBackend) packageVersionNeighbors(ctx context.Context, nodeID string, pkgNames = append(pkgNames, backReferencePackageVersion(foundPkgVersion)) for _, foundPkgName := range pkgNames { out = append(out, &model.Package{ - ID: toGlobalID(pkgTypeString, foundPkgName.Type), + ID: pkgTypeGlobalID(foundPkgName.Type), Type: foundPkgName.Type, Namespaces: []*model.PackageNamespace{ { - ID: toGlobalID(pkgNamespaceString, strings.Join([]string{foundPkgName.Type, foundPkgName.Namespace}, guacIDSplit)), + ID: pkgNamespaceGlobalID(strings.Join([]string{foundPkgName.Type, foundPkgName.Namespace}, guacIDSplit)), Namespace: foundPkgName.Namespace, Names: []*model.PackageName{{ - ID: toGlobalID(packagename.Table, foundPkgName.ID.String()), + ID: pkgNameGlobalID(foundPkgName.ID.String()), Name: foundPkgName.Name, Versions: []*model.PackageVersion{}, }}, diff --git a/pkg/assembler/backends/ent/backend/pkgequal.go b/pkg/assembler/backends/ent/backend/pkgequal.go index 6b5b5c45ae3..49d638cb597 100644 --- a/pkg/assembler/backends/ent/backend/pkgequal.go +++ b/pkg/assembler/backends/ent/backend/pkgequal.go @@ -22,11 +22,11 @@ import ( "fmt" "sort" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/pkg/assembler/backends/ent" - "github.com/guacsec/guac/pkg/assembler/backends/ent/packageversion" "github.com/guacsec/guac/pkg/assembler/backends/ent/pkgequal" "github.com/guacsec/guac/pkg/assembler/backends/ent/predicate" "github.com/guacsec/guac/pkg/assembler/graphql/model" @@ -34,8 +34,62 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -func (b *EntBackend) PkgEqualList(ctx context.Context, pkgEqualSpec model.PkgEqualSpec, after *string, first *int) (*model.PkgEqualConnection, error) { - return nil, fmt.Errorf("not implemented: PkgEqualList") +func pkgEqualGlobalID(id string) string { + return toGlobalID(pkgequal.Table, id) +} + +func bulkPkgEqualGlobalID(ids []string) []string { + return toGlobalIDs(pkgequal.Table, ids) +} + +func (b *EntBackend) PkgEqualList(ctx context.Context, spec model.PkgEqualSpec, after *string, first *int) (*model.PkgEqualConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != pkgequal.Table { + return nil, fmt.Errorf("after cursor is not type pkgEqual but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + peQuery := b.client.PkgEqual.Query(). + Where(pkgEqualQueryPredicates(&spec)) + + peConn, err := getPkgEqualObject(peQuery). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed pkgEqual query with error: %w", err) + } + + var edges []*model.PkgEqualEdge + for _, edge := range peConn.Edges { + edges = append(edges, &model.PkgEqualEdge{ + Cursor: pkgEqualGlobalID(edge.Cursor.ID.String()), + Node: toModelPkgEqual(edge.Node), + }) + } + + if peConn.PageInfo.StartCursor != nil { + return &model.PkgEqualConnection{ + TotalCount: peConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: peConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(pkgEqualGlobalID(peConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(pkgEqualGlobalID(peConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) PkgEqual(ctx context.Context, spec *model.PkgEqualSpec) ([]*model.PkgEqual, error) { @@ -50,10 +104,9 @@ func (b *EntBackend) PkgEqual(ctx context.Context, spec *model.PkgEqualSpec) ([] Where(pkgEqualQueryPredicates(spec)) records, err := getPkgEqualObject(peQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed pkgEqual query with error: %w", err) } return collect(records, toModelPkgEqual), nil @@ -74,7 +127,7 @@ func (b *EntBackend) IngestPkgEqual(ctx context.Context, pkg model.IDorPkgInput, return "", txErr } - return toGlobalID(pkgequal.Table, *id), nil + return pkgEqualGlobalID(*id), nil } func (b *EntBackend) IngestPkgEquals(ctx context.Context, pkgs []*model.IDorPkgInput, otherPackages []*model.IDorPkgInput, pkgEquals []*model.PkgEqualInputSpec) ([]string, error) { @@ -91,7 +144,7 @@ func (b *EntBackend) IngestPkgEquals(ctx context.Context, pkgs []*model.IDorPkgI return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(pkgequal.Table, *ids), nil + return bulkPkgEqualGlobalID(*ids), nil } func pkgEqualConflictColumns() []string { @@ -158,7 +211,7 @@ func generatePkgEqualCreate(ctx context.Context, tx *ent.Tx, pkgA *model.IDorPkg if err != nil { return nil, fmt.Errorf("getPkgVersion :: %w", err) } - pkgA.PackageVersionID = ptrfrom.String(toGlobalID(packageversion.Table, pv.ID.String())) + pkgA.PackageVersionID = ptrfrom.String(pkgVersionGlobalID(pv.ID.String())) } if pkgB.PackageVersionID == nil { @@ -166,7 +219,7 @@ func generatePkgEqualCreate(ctx context.Context, tx *ent.Tx, pkgA *model.IDorPkg if err != nil { return nil, fmt.Errorf("getPkgVersion :: %w", err) } - pkgB.PackageVersionID = ptrfrom.String(toGlobalID(packageversion.Table, pv.ID.String())) + pkgB.PackageVersionID = ptrfrom.String(pkgVersionGlobalID(pv.ID.String())) } sortedPkgs := []model.IDorPkgInput{*pkgA, *pkgB} @@ -247,7 +300,7 @@ func toModelPkgEqual(record *ent.PkgEqual) *model.PkgEqual { packages := collect(equalPkgs, backReferencePackageVersion) return &model.PkgEqual{ - ID: toGlobalID(pkgequal.Table, record.ID.String()), + ID: pkgEqualGlobalID(record.ID.String()), Origin: record.Origin, Collector: record.Collector, Justification: record.Justification, @@ -297,9 +350,6 @@ func (b *EntBackend) pkgEqualNeighbors(ctx context.Context, nodeID string, allow WithPackageB(withPackageVersionTree()) } - query. - Limit(MaxPageSize) - pkgEquals, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for pkgEquals with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/pointOfContact.go b/pkg/assembler/backends/ent/backend/pointOfContact.go index 6fe2eb630c4..bf201d9b41d 100644 --- a/pkg/assembler/backends/ent/backend/pointOfContact.go +++ b/pkg/assembler/backends/ent/backend/pointOfContact.go @@ -19,6 +19,7 @@ import ( "context" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -30,8 +31,62 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -func (b *EntBackend) PointOfContactList(ctx context.Context, pointOfContactSpec model.PointOfContactSpec, after *string, first *int) (*model.PointOfContactConnection, error) { - return nil, fmt.Errorf("not implemented: PointOfContactList") +func pointOfContactGlobalID(id string) string { + return toGlobalID(pointofcontact.Table, id) +} + +func bulkPointOfContactGlobalID(ids []string) []string { + return toGlobalIDs(pointofcontact.Table, ids) +} + +func (b *EntBackend) PointOfContactList(ctx context.Context, spec model.PointOfContactSpec, after *string, first *int) (*model.PointOfContactConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != pointofcontact.Table { + return nil, fmt.Errorf("after cursor is not type Point of Contact but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + pocQuery := b.client.PointOfContact.Query(). + Where(pointOfContactPredicate(&spec)) + + pocConn, err := getPointOfContactObject(pocQuery). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed PointOfContact query with error: %w", err) + } + + var edges []*model.PointOfContactEdge + for _, edge := range pocConn.Edges { + edges = append(edges, &model.PointOfContactEdge{ + Cursor: pointOfContactGlobalID(edge.Cursor.ID.String()), + Node: toModelPointOfContact(edge.Node), + }) + } + + if pocConn.PageInfo.StartCursor != nil { + return &model.PointOfContactConnection{ + TotalCount: pocConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: pocConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(pointOfContactGlobalID(pocConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(pointOfContactGlobalID(pocConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) PointOfContact(ctx context.Context, filter *model.PointOfContactSpec) ([]*model.PointOfContact, error) { @@ -42,10 +97,9 @@ func (b *EntBackend) PointOfContact(ctx context.Context, filter *model.PointOfCo Where(pointOfContactPredicate(filter)) records, err := getPointOfContactObject(pocQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, fmt.Errorf("failed to retrieve PointOfContact :: %s", err) + return nil, fmt.Errorf("failed PointOfContact query with error: %w", err) } return collect(records, toModelPointOfContact), nil @@ -68,7 +122,7 @@ func (b *EntBackend) IngestPointOfContact(ctx context.Context, subject model.Pac return "", fmt.Errorf("failed to execute IngestPointOfContact :: %s", txErr) } - return toGlobalID(pointofcontact.Table, *recordID), nil + return pointOfContactGlobalID(*recordID), nil } func (b *EntBackend) IngestPointOfContacts(ctx context.Context, subjects model.PackageSourceOrArtifactInputs, pkgMatchType *model.MatchFlags, pointOfContactList []*model.PointOfContactInputSpec) ([]string, error) { @@ -85,7 +139,7 @@ func (b *EntBackend) IngestPointOfContacts(ctx context.Context, subjects model.P return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(pointofcontact.Table, *ids), nil + return bulkPointOfContactGlobalID(*ids), nil } func pointOfContactPredicate(filter *model.PointOfContactSpec) predicate.PointOfContact { @@ -384,7 +438,7 @@ func toModelPointOfContact(v *ent.PointOfContact) *model.PointOfContact { } return &model.PointOfContact{ - ID: toGlobalID(pointofcontact.Table, v.ID.String()), + ID: pointOfContactGlobalID(v.ID.String()), Subject: sub, Email: v.Email, Info: v.Info, @@ -416,9 +470,6 @@ func (b *EntBackend) pointOfContactNeighbors(ctx context.Context, nodeID string, WithSource() } - query. - Limit(MaxPageSize) - pocs, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for point of contact with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/sbom.go b/pkg/assembler/backends/ent/backend/sbom.go index c3bdd607666..96960b80c69 100644 --- a/pkg/assembler/backends/ent/backend/sbom.go +++ b/pkg/assembler/backends/ent/backend/sbom.go @@ -21,11 +21,16 @@ import ( "fmt" "strings" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/pkg/assembler/backends/ent" + "github.com/guacsec/guac/pkg/assembler/backends/ent/artifact" "github.com/guacsec/guac/pkg/assembler/backends/ent/billofmaterials" + "github.com/guacsec/guac/pkg/assembler/backends/ent/dependency" + "github.com/guacsec/guac/pkg/assembler/backends/ent/occurrence" + "github.com/guacsec/guac/pkg/assembler/backends/ent/packageversion" "github.com/guacsec/guac/pkg/assembler/backends/ent/predicate" "github.com/guacsec/guac/pkg/assembler/backends/helper" "github.com/guacsec/guac/pkg/assembler/graphql/model" @@ -33,8 +38,254 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -func (b *EntBackend) HasSBOMList(ctx context.Context, hasSBOMSpec model.HasSBOMSpec, after *string, first *int) (*model.HasSBOMConnection, error) { - return nil, fmt.Errorf("not implemented: HasSBOMList") +func hasSBOMGlobalID(id string) string { + return toGlobalID(billofmaterials.Table, id) +} + +func bulkHasSBOMGlobalID(ids []string) []string { + return toGlobalIDs(billofmaterials.Table, ids) +} + +func (b *EntBackend) HasSBOMList(ctx context.Context, spec model.HasSBOMSpec, after *string, first *int) (*model.HasSBOMConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, err + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + sbomQuery := b.client.BillOfMaterials.Query(). + Where(hasSBOMQuery(spec)) + + hasSBOMConnection, err := getSBOMObjectWithOutIncludes(sbomQuery).Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed hasSBOM query with error: %w", err) + } + + // Large SBOMs (50MB+) hit the postgres parameter issue (HasSBOM: pq: got 97137 parameters but PostgreSQL only supports 65535 parameters). + // To overcome this, we can breakout the "included" pieces of the hasSBOM node into individual queries and reconstruct the node at the end. + + reconstructedSBOMs := map[string]*model.HasSbom{} + includedFirst := 60000 + + type depResult struct { + deps []*ent.Dependency + depErr error + } + + type occurResult struct { + occurs []*ent.Occurrence + occurErr error + } + + type pkgVersionResult struct { + pkgVersions []*ent.PackageVersion + pkgVerErr error + } + + type artResult struct { + arts []*ent.Artifact + artErr error + } + + for _, foundSBOM := range hasSBOMConnection.Edges { + + var includedDeps []*ent.Dependency + var includedOccurs []*ent.Occurrence + var includedPackages []*ent.PackageVersion + var includedArtifacts []*ent.Artifact + + depsChan := make(chan depResult, 1) + occursChan := make(chan occurResult, 1) + pkgVerChan := make(chan pkgVersionResult, 1) + artChan := make(chan artResult, 1) + + sbomID := foundSBOM.Cursor.ID.String() + + // query included packages + + go func(ctx context.Context, b *EntBackend, sbomID string, first int, pkgChan chan<- pkgVersionResult) { + var afterCursor *entgql.Cursor[uuid.UUID] + defer close(pkgChan) + for { + pkgConn, err := b.client.PackageVersion.Query(). + Where(packageversion.HasIncludedInSbomsWith([]predicate.BillOfMaterials{ + optionalPredicate(&sbomID, IDEQ)}...)). + WithName(func(q *ent.PackageNameQuery) {}).Paginate(ctx, afterCursor, &first, nil, nil) + if err != nil { + pkgChan <- pkgVersionResult{pkgVersions: nil, + pkgVerErr: fmt.Errorf("failed included package query for hasSBOM with error: %w", err)} + } + + var paginatedPkgs []*ent.PackageVersion + + for _, edge := range pkgConn.Edges { + paginatedPkgs = append(paginatedPkgs, edge.Node) + } + + pkgChan <- pkgVersionResult{pkgVersions: paginatedPkgs, pkgVerErr: nil} + + if !pkgConn.PageInfo.HasNextPage { + break + } + afterCursor = pkgConn.PageInfo.EndCursor + } + }(ctx, b, sbomID, includedFirst, pkgVerChan) + + // query included artifacts + go func(ctx context.Context, b *EntBackend, sbomID string, first int, artChan chan<- artResult) { + var afterCursor *entgql.Cursor[uuid.UUID] + defer close(artChan) + for { + artConn, err := b.client.Artifact.Query(). + Where(artifact.HasIncludedInSbomsWith([]predicate.BillOfMaterials{ + optionalPredicate(&sbomID, IDEQ)}...)).Paginate(ctx, afterCursor, &first, nil, nil) + + if err != nil { + artChan <- artResult{arts: nil, + artErr: fmt.Errorf("failed included artifacts query for hasSBOM with error: %w", err)} + } + + var paginatedArts []*ent.Artifact + + for _, edge := range artConn.Edges { + paginatedArts = append(paginatedArts, edge.Node) + } + + artChan <- artResult{arts: paginatedArts, + artErr: nil} + + if !artConn.PageInfo.HasNextPage { + break + } + afterCursor = artConn.PageInfo.EndCursor + } + + }(ctx, b, sbomID, includedFirst, artChan) + + // query included dependencies + go func(ctx context.Context, b *EntBackend, sbomID string, first int, artChan chan<- depResult) { + var afterCursor *entgql.Cursor[uuid.UUID] + defer close(depsChan) + for { + isDepQuery := b.client.Dependency.Query(). + Where(dependency.HasIncludedInSbomsWith([]predicate.BillOfMaterials{ + optionalPredicate(&sbomID, IDEQ)}...)) + + depConnect, err := getIsDepObject(isDepQuery). + Paginate(ctx, afterCursor, &first, nil, nil) + if err != nil { + depsChan <- depResult{deps: nil, + depErr: fmt.Errorf("failed included dependency query for hasSBOM with error: %w", err)} + } + + var paginatedDeps []*ent.Dependency + + for _, edge := range depConnect.Edges { + paginatedDeps = append(paginatedDeps, edge.Node) + } + + depsChan <- depResult{deps: paginatedDeps, + depErr: nil} + + if !depConnect.PageInfo.HasNextPage { + break + } + afterCursor = depConnect.PageInfo.EndCursor + } + }(ctx, b, sbomID, includedFirst, depsChan) + + // query included occurrences + go func(ctx context.Context, b *EntBackend, sbomID string, first int, occursChan chan<- occurResult) { + var afterCursor *entgql.Cursor[uuid.UUID] + defer close(occursChan) + for { + occurQuery := b.client.Occurrence.Query(). + Where(occurrence.HasIncludedInSbomsWith([]predicate.BillOfMaterials{ + optionalPredicate(&sbomID, IDEQ)}...)) + + occurConnect, err := getOccurrenceObject(occurQuery). + Paginate(ctx, afterCursor, &first, nil, nil) + if err != nil { + occursChan <- occurResult{occurs: nil, + occurErr: fmt.Errorf("failed included occurrence query for hasSBOM with error: %w", err)} + } + + var paginatedOccurs []*ent.Occurrence + + for _, edge := range occurConnect.Edges { + paginatedOccurs = append(paginatedOccurs, edge.Node) + } + + occursChan <- occurResult{occurs: paginatedOccurs, + occurErr: nil} + + if !occurConnect.PageInfo.HasNextPage { + break + } + afterCursor = occurConnect.PageInfo.EndCursor + } + }(ctx, b, sbomID, includedFirst, occursChan) + + for art := range artChan { + if art.artErr != nil { + return nil, fmt.Errorf("artifact channel failure: %w", art.artErr) + } + includedArtifacts = append(includedArtifacts, art.arts...) + } + + for pkg := range pkgVerChan { + if pkg.pkgVerErr != nil { + return nil, fmt.Errorf("pkgVersion channel failure: %w", pkg.pkgVerErr) + } + includedPackages = append(includedPackages, pkg.pkgVersions...) + } + + for occur := range occursChan { + if occur.occurErr != nil { + return nil, fmt.Errorf("occurrence channel failure: %w", occur.occurErr) + } + includedOccurs = append(includedOccurs, occur.occurs...) + } + + for dep := range depsChan { + if dep.depErr != nil { + return nil, fmt.Errorf("dependency channel failure: %w", dep.depErr) + } + includedDeps = append(includedDeps, dep.deps...) + } + reconstructedSBOM := toModelHasSBOMWithIncluded(foundSBOM.Node, includedPackages, includedArtifacts, includedDeps, includedOccurs) + reconstructedSBOMs[sbomID] = reconstructedSBOM + } + + var edges []*model.HasSBOMEdge + for id, edge := range reconstructedSBOMs { + edges = append(edges, &model.HasSBOMEdge{ + Cursor: hasSBOMGlobalID(id), + Node: edge, + }) + } + + if hasSBOMConnection.PageInfo.StartCursor != nil { + return &model.HasSBOMConnection{ + TotalCount: hasSBOMConnection.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: hasSBOMConnection.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(hasSBOMGlobalID(hasSBOMConnection.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(hasSBOMGlobalID(hasSBOMConnection.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) HasSBOM(ctx context.Context, spec *model.HasSBOMSpec) ([]*model.HasSbom, error) { @@ -46,8 +297,7 @@ func (b *EntBackend) HasSBOM(ctx context.Context, spec *model.HasSBOMSpec) ([]*m sbomQuery := b.client.BillOfMaterials.Query(). Where(hasSBOMQuery(*spec)) - records, err := getSBOMObject(sbomQuery). - Limit(MaxPageSize). + records, err := getSBOMObjectWithIncludes(sbomQuery). All(ctx) if err != nil { return nil, errors.Wrap(err, funcName) @@ -93,8 +343,17 @@ func hasSBOMQuery(spec model.HasSBOMSpec) predicate.BillOfMaterials { return billofmaterials.And(predicates...) } -// getSBOMObject is used recreate the hasSBOM object be eager loading the edges -func getSBOMObject(q *ent.BillOfMaterialsQuery) *ent.BillOfMaterialsQuery { +// getSBOMObjectWithOutIncludes is used recreate the hasSBOM object without eager loading the included edges +func getSBOMObjectWithOutIncludes(q *ent.BillOfMaterialsQuery) *ent.BillOfMaterialsQuery { + return q. + WithPackage(func(q *ent.PackageVersionQuery) { + q.WithName(func(q *ent.PackageNameQuery) {}) + }). + WithArtifact() +} + +// getSBOMObjectWithIncludes is used recreate the hasSBOM object be eager loading the edges +func getSBOMObjectWithIncludes(q *ent.BillOfMaterialsQuery) *ent.BillOfMaterialsQuery { return q. WithPackage(func(q *ent.PackageVersionQuery) { q.WithName(func(q *ent.PackageNameQuery) {}) @@ -130,7 +389,7 @@ func (b *EntBackend) IngestHasSbom(ctx context.Context, subject model.PackageOrA return "", Errorf("%v :: %s", funcName, txErr) } - return toGlobalID(billofmaterials.Table, *sbomId), nil + return hasSBOMGlobalID(*sbomId), nil } func (b *EntBackend) IngestHasSBOMs(ctx context.Context, subjects model.PackageOrArtifactInputs, hasSBOMs []*model.HasSBOMInputSpec, includes []*model.HasSBOMIncludesInputSpec) ([]string, error) { @@ -148,7 +407,7 @@ func (b *EntBackend) IngestHasSBOMs(ctx context.Context, subjects model.PackageO } sbomIDs = append(sbomIDs, id) } - return toGlobalIDs(billofmaterials.Table, sbomIDs), nil + return bulkHasSBOMGlobalID(sbomIDs), nil } func sbomConflictColumns() []string { @@ -485,9 +744,6 @@ func (b *EntBackend) hasSbomNeighbors(ctx context.Context, nodeID string, allowe }) } - query. - Limit(MaxPageSize) - bills, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed query hasSBOM with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/scorecard.go b/pkg/assembler/backends/ent/backend/scorecard.go index 559c8331c92..24cb8d4d7cf 100644 --- a/pkg/assembler/backends/ent/backend/scorecard.go +++ b/pkg/assembler/backends/ent/backend/scorecard.go @@ -23,6 +23,7 @@ import ( "sort" "strconv" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -34,8 +35,62 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -func (b *EntBackend) ScorecardsList(ctx context.Context, scorecardSpec model.CertifyScorecardSpec, after *string, first *int) (*model.CertifyScorecardConnection, error) { - return nil, fmt.Errorf("not implemented: ScorecardsList") +func scorecardGlobalID(id string) string { + return toGlobalID(certifyscorecard.Table, id) +} + +func bulkScorecardGlobalID(ids []string) []string { + return toGlobalIDs(certifyscorecard.Table, ids) +} + +func (b *EntBackend) ScorecardsList(ctx context.Context, spec model.CertifyScorecardSpec, after *string, first *int) (*model.CertifyScorecardConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != certifyscorecard.Table { + return nil, fmt.Errorf("after cursor is not type Scorecard but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + scorecardQuery := b.client.CertifyScorecard.Query(). + Where(certifyScorecardQuery(&spec)) + + scorecardConn, err := getScorecardObject(scorecardQuery). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed scorecard query with error: %w", err) + } + + var edges []*model.CertifyScorecardEdge + for _, edge := range scorecardConn.Edges { + edges = append(edges, &model.CertifyScorecardEdge{ + Cursor: scorecardGlobalID(edge.Cursor.ID.String()), + Node: toModelCertifyScorecard(edge.Node), + }) + } + + if scorecardConn.PageInfo.StartCursor != nil { + return &model.CertifyScorecardConnection{ + TotalCount: scorecardConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: scorecardConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(scorecardGlobalID(scorecardConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(scorecardGlobalID(scorecardConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) Scorecards(ctx context.Context, filter *model.CertifyScorecardSpec) ([]*model.CertifyScorecard, error) { @@ -47,10 +102,9 @@ func (b *EntBackend) Scorecards(ctx context.Context, filter *model.CertifyScorec Where(certifyScorecardQuery(filter)) records, err := getScorecardObject(scorecardQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed scorecard query with error: %w", err) } return collect(records, toModelCertifyScorecard), nil @@ -110,7 +164,7 @@ func (b *EntBackend) IngestScorecard(ctx context.Context, source model.IDorSourc if txErr != nil { return "", txErr } - return toGlobalID(certifyscorecard.Table, *cscID), nil + return scorecardGlobalID(*cscID), nil } func (b *EntBackend) IngestScorecards(ctx context.Context, sources []*model.IDorSourceInput, scorecards []*model.ScorecardInputSpec) ([]string, error) { @@ -127,7 +181,7 @@ func (b *EntBackend) IngestScorecards(ctx context.Context, sources []*model.IDor return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(certifyscorecard.Table, *ids), nil + return bulkScorecardGlobalID(*ids), nil } func generateScorecardCreate(ctx context.Context, tx *ent.Tx, src *model.IDorSourceInput, scorecard *model.ScorecardInputSpec) (*ent.CertifyScorecardCreate, error) { @@ -256,7 +310,7 @@ func hashSortedScorecardChecks(checks []*model.ScorecardCheck) string { func toModelCertifyScorecard(record *ent.CertifyScorecard) *model.CertifyScorecard { return &model.CertifyScorecard{ - ID: toGlobalID(certifyscorecard.Table, record.ID.String()), + ID: scorecardGlobalID(record.ID.String()), Source: toModelSource(record.Edges.Source), Scorecard: toModelScorecard(record), } @@ -286,9 +340,6 @@ func (b *EntBackend) certifyScorecardNeighbors(ctx context.Context, nodeID strin WithSource() } - query. - Limit(MaxPageSize) - scorecards, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for scorecard with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/search.go b/pkg/assembler/backends/ent/backend/search.go index c2f21ce73a0..e5ff5406cc7 100644 --- a/pkg/assembler/backends/ent/backend/search.go +++ b/pkg/assembler/backends/ent/backend/search.go @@ -58,10 +58,9 @@ func (b *EntBackend) FindSoftware(ctx context.Context, searchText string) ([]mod packagename.NameContainsFold(searchText), ), ).WithName(func(q *ent.PackageNameQuery) {}). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed package version query with err: %w", err) } results = append(results, collect(packages, func(v *ent.PackageVersion) model.PackageSourceOrArtifact { @@ -75,10 +74,9 @@ func (b *EntBackend) FindSoftware(ctx context.Context, searchText string) ([]mod sourcename.NamespaceContainsFold(searchText), ), ). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed source name query with err: %w", err) } results = append(results, collect(sources, func(v *ent.SourceName) model.PackageSourceOrArtifact { return toModelSource(v) @@ -87,10 +85,9 @@ func (b *EntBackend) FindSoftware(ctx context.Context, searchText string) ([]mod artifacts, err := b.client.Artifact.Query().Where( artifact.DigestContains(searchText), ). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed artifact query with err: %w", err) } results = append(results, collect(artifacts, func(v *ent.Artifact) model.PackageSourceOrArtifact { diff --git a/pkg/assembler/backends/ent/backend/slsa.go b/pkg/assembler/backends/ent/backend/slsa.go index 0f01402e932..7ea24bfdd58 100644 --- a/pkg/assembler/backends/ent/backend/slsa.go +++ b/pkg/assembler/backends/ent/backend/slsa.go @@ -23,6 +23,7 @@ import ( "sort" "time" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -35,8 +36,62 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -func (b *EntBackend) HasSLSAList(ctx context.Context, hasSLSASpec model.HasSLSASpec, after *string, first *int) (*model.HasSLSAConnection, error) { - return nil, fmt.Errorf("not implemented: HasSLSAList") +func slsaGlobalID(id string) string { + return toGlobalID(slsaattestation.Table, id) +} + +func bulkSLSAGlobalID(ids []string) []string { + return toGlobalIDs(slsaattestation.Table, ids) +} + +func (b *EntBackend) HasSLSAList(ctx context.Context, spec model.HasSLSASpec, after *string, first *int) (*model.HasSLSAConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != slsaattestation.Table { + return nil, fmt.Errorf("after cursor is not type SLSA but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + slsaQuery := b.client.SLSAAttestation.Query(). + Where(hasSLSAQuery(spec)) + + slsaConn, err := getSLSAObject(slsaQuery). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed hasSLSA query with error: %w", err) + } + + var edges []*model.HasSLSAEdge + for _, edge := range slsaConn.Edges { + edges = append(edges, &model.HasSLSAEdge{ + Cursor: slsaGlobalID(edge.Cursor.ID.String()), + Node: toModelHasSLSA(edge.Node), + }) + } + + if slsaConn.PageInfo.StartCursor != nil { + return &model.HasSLSAConnection{ + TotalCount: slsaConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: slsaConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(slsaGlobalID(slsaConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(slsaGlobalID(slsaConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) HasSlsa(ctx context.Context, spec *model.HasSLSASpec) ([]*model.HasSlsa, error) { @@ -48,10 +103,9 @@ func (b *EntBackend) HasSlsa(ctx context.Context, spec *model.HasSLSASpec) ([]*m Where(hasSLSAQuery(*spec)) records, err := getSLSAObject(slsaQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed hasSLSA query with error: %w", err) } return collect(records, toModelHasSLSA), nil @@ -99,7 +153,7 @@ func (b *EntBackend) IngestSLSA(ctx context.Context, subject model.IDorArtifactI return "", txErr } - return toGlobalID(slsaattestation.Table, *id), nil + return slsaGlobalID(*id), nil } func (b *EntBackend) IngestSLSAs(ctx context.Context, subjects []*model.IDorArtifactInput, builtFromList [][]*model.IDorArtifactInput, builtByList []*model.IDorBuilderInput, slsaList []*model.SLSAInputSpec) ([]string, error) { @@ -116,7 +170,7 @@ func (b *EntBackend) IngestSLSAs(ctx context.Context, subjects []*model.IDorArti return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(slsaattestation.Table, *ids), nil + return bulkSLSAGlobalID(*ids), nil } func slsaConflictColumns() []string { @@ -326,7 +380,7 @@ func toModelHasSLSA(att *ent.SLSAAttestation) *model.HasSlsa { } return &model.HasSlsa{ - ID: toGlobalID(slsaattestation.Table, att.ID.String()), + ID: slsaGlobalID(att.ID.String()), Subject: toModelArtifact(att.Edges.Subject), Slsa: slsa, } @@ -417,9 +471,6 @@ func (b *EntBackend) hasSlsaNeighbors(ctx context.Context, nodeID string, allowe WithBuiltFrom() } - query. - Limit(MaxPageSize) - slsaAtts, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for hasSLSA with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/source.go b/pkg/assembler/backends/ent/backend/source.go index 82600b559ac..27657165a8f 100644 --- a/pkg/assembler/backends/ent/backend/source.go +++ b/pkg/assembler/backends/ent/backend/source.go @@ -21,6 +21,7 @@ import ( "fmt" "strings" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -40,8 +41,74 @@ const ( srcNamespaceString = "source_namespaces" ) -func (b *EntBackend) HasSourceAtList(ctx context.Context, hasSourceAtSpec model.HasSourceAtSpec, after *string, first *int) (*model.HasSourceAtConnection, error) { - return nil, fmt.Errorf("not implemented: HasSourceAtList") +func hasSourceAtGlobalID(id string) string { + return toGlobalID(hassourceat.Table, id) +} + +func bulkHasSourceAtGlobalID(ids []string) []string { + return toGlobalIDs(hassourceat.Table, ids) +} + +func srcTypeGlobalID(id string) string { + return toGlobalID(srcTypeString, id) +} + +func srcNamespaceGlobalID(id string) string { + return toGlobalID(srcNamespaceString, id) +} + +func srcNameGlobalID(id string) string { + return toGlobalID(sourcename.Table, id) +} + +func (b *EntBackend) HasSourceAtList(ctx context.Context, spec model.HasSourceAtSpec, after *string, first *int) (*model.HasSourceAtConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != hassourceat.Table { + return nil, fmt.Errorf("after cursor is not type hasSourceAt but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + hasSourceAtQuery := b.client.HasSourceAt.Query(). + Where(hasSourceAtQuery(spec)) + + hsaConn, err := getHasSourceAtObject(hasSourceAtQuery). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed hasSourceAt query with error: %w", err) + } + + var edges []*model.HasSourceAtEdge + for _, edge := range hsaConn.Edges { + edges = append(edges, &model.HasSourceAtEdge{ + Cursor: hasSourceAtGlobalID(edge.Cursor.ID.String()), + Node: toModelHasSourceAt(edge.Node), + }) + } + + if hsaConn.PageInfo.StartCursor != nil { + return &model.HasSourceAtConnection{ + TotalCount: hsaConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: hsaConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(hasSourceAtGlobalID(hsaConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(hasSourceAtGlobalID(hsaConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) HasSourceAt(ctx context.Context, filter *model.HasSourceAtSpec) ([]*model.HasSourceAt, error) { @@ -53,10 +120,9 @@ func (b *EntBackend) HasSourceAt(ctx context.Context, filter *model.HasSourceAtS Where(hasSourceAtQuery(*filter)) records, err := getHasSourceAtObject(hasSourceAtQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed hasSourceAt query with error: %w", err) } return collect(records, toModelHasSourceAt), nil @@ -103,7 +169,7 @@ func (b *EntBackend) IngestHasSourceAt(ctx context.Context, pkg model.IDorPkgInp return "", txErr } - return toGlobalID(hassourceat.Table, *record), nil + return hasSourceAtGlobalID(*record), nil } func (b *EntBackend) IngestHasSourceAts(ctx context.Context, pkgs []*model.IDorPkgInput, pkgMatchType *model.MatchFlags, sources []*model.IDorSourceInput, hasSourceAts []*model.HasSourceAtInputSpec) ([]string, error) { @@ -120,7 +186,7 @@ func (b *EntBackend) IngestHasSourceAts(ctx context.Context, pkgs []*model.IDorP return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(hassourceat.Table, *ids), nil + return bulkHasSourceAtGlobalID(*ids), nil } func hasSourceAtConflictColumns() []string { @@ -299,9 +365,6 @@ func (b *EntBackend) hasSourceAtNeighbors(ctx context.Context, nodeID string, al WithSource() } - query. - Limit(MaxPageSize) - hasSourceAts, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for hasSourceAt with node ID: %s with error: %w", nodeID, err) @@ -322,8 +385,52 @@ func (b *EntBackend) hasSourceAtNeighbors(ctx context.Context, nodeID string, al return out, nil } -func (b *EntBackend) SourcesList(ctx context.Context, sourceSpec model.SourceSpec, after *string, first *int) (*model.SourceConnection, error) { - return nil, fmt.Errorf("not implemented: SourcesList") +func (b *EntBackend) SourcesList(ctx context.Context, spec model.SourceSpec, after *string, first *int) (*model.SourceConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != sourcename.Table { + return nil, fmt.Errorf("after cursor is not type source but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + sourceConn, err := b.client.SourceName.Query(). + Where(sourceQuery(&spec)). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed sources query with error: %w", err) + } + + var edges []*model.SourceEdge + for _, edge := range sourceConn.Edges { + edges = append(edges, &model.SourceEdge{ + Cursor: srcNameGlobalID(edge.Cursor.ID.String()), + Node: toModelSource(edge.Node), + }) + } + + if sourceConn.PageInfo.StartCursor != nil { + return &model.SourceConnection{ + TotalCount: sourceConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: sourceConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(srcNameGlobalID(sourceConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(srcNameGlobalID(sourceConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) Sources(ctx context.Context, filter *model.SourceSpec) ([]*model.Source, error) { @@ -332,10 +439,9 @@ func (b *EntBackend) Sources(ctx context.Context, filter *model.SourceSpec) ([]* } records, err := b.client.SourceName.Query(). Where(sourceQuery(filter)). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed sources query with error: %w", err) } return toModelSourceTrie(records), nil @@ -414,9 +520,9 @@ func upsertBulkSource(ctx context.Context, tx *ent.Tx, srcInputs []*model.IDorSo var collectedSrcIDs []model.SourceIDs for i := range srcNameIDs { collectedSrcIDs = append(collectedSrcIDs, model.SourceIDs{ - SourceTypeID: toGlobalID(srcTypeString, srcTypes[srcNameIDs[i]]), - SourceNamespaceID: toGlobalID(srcNamespaceString, srcNamespaces[srcNameIDs[i]]), - SourceNameID: toGlobalID(sourcename.Table, srcNameIDs[i])}) + SourceTypeID: srcTypeGlobalID(srcTypes[srcNameIDs[i]]), + SourceNamespaceID: srcNamespaceGlobalID(srcNamespaces[srcNameIDs[i]]), + SourceNameID: srcNameGlobalID(srcNameIDs[i])}) } return &collectedSrcIDs, nil @@ -456,9 +562,9 @@ func upsertSource(ctx context.Context, tx *ent.Tx, src model.IDorSourceInput) (* } return &model.SourceIDs{ - SourceTypeID: toGlobalID(srcTypeString, src.SourceInput.Type), - SourceNamespaceID: toGlobalID(srcNamespaceString, strings.Join([]string{src.SourceInput.Type, src.SourceInput.Namespace}, guacIDSplit)), - SourceNameID: toGlobalID(sourcename.Table, srcNameID.String())}, nil + SourceTypeID: srcTypeGlobalID(src.SourceInput.Type), + SourceNamespaceID: srcNamespaceGlobalID(strings.Join([]string{src.SourceInput.Type, src.SourceInput.Namespace}, guacIDSplit)), + SourceNameID: srcNameGlobalID(srcNameID.String())}, nil } func sourceInputQuery(filter model.SourceInputSpec) predicate.SourceName { @@ -501,7 +607,7 @@ func toModelHasSourceAt(record *ent.HasSourceAt) *model.HasSourceAt { return &model.HasSourceAt{ Source: toModelSource(record.Edges.Source), Package: pkg, - ID: toGlobalID(hassourceat.Table, record.ID.String()), + ID: hasSourceAtGlobalID(record.ID.String()), KnownSince: record.KnownSince, Justification: record.Justification, Origin: record.Origin, @@ -515,11 +621,11 @@ func toModelSourceTrie(collectedSrcNames []*ent.SourceName) []*model.Source { for _, srcName := range collectedSrcNames { - namespaceString := srcName.Namespace + "," + toGlobalID(srcNamespaceString, strings.Join([]string{srcName.Type, srcName.Namespace}, guacIDSplit)) - typeString := srcName.Type + "," + toGlobalID(srcTypeString, srcName.Type) + namespaceString := srcName.Namespace + "," + srcNamespaceGlobalID(strings.Join([]string{srcName.Type, srcName.Namespace}, guacIDSplit)) + typeString := srcName.Type + "," + srcTypeGlobalID(srcName.Type) sourceName := &model.SourceName{ - ID: toGlobalID(sourcename.Table, srcName.ID.String()), + ID: srcNameGlobalID(srcName.ID.String()), Name: srcName.Name, } if srcName.Tag != "" { @@ -566,7 +672,7 @@ func toModelSource(s *ent.SourceName) *model.Source { } sourceName := &model.SourceName{ - ID: toGlobalID(sourcename.Table, s.ID.String()), + ID: srcNameGlobalID(s.ID.String()), Name: s.Name, } @@ -578,10 +684,10 @@ func toModelSource(s *ent.SourceName) *model.Source { } return &model.Source{ - ID: toGlobalID(srcTypeString, s.Type), + ID: srcTypeGlobalID(s.Type), Type: s.Type, Namespaces: []*model.SourceNamespace{{ - ID: toGlobalID(srcNamespaceString, strings.Join([]string{s.Type, s.Namespace}, guacIDSplit)), + ID: srcNamespaceGlobalID(strings.Join([]string{s.Type, s.Namespace}, guacIDSplit)), Namespace: s.Namespace, Names: []*model.SourceName{sourceName}, }}, @@ -596,8 +702,7 @@ func (b *EntBackend) srcTypeNeighbors(ctx context.Context, nodeID string, allowe var out []model.Node if allowedEdges[model.EdgeSourceTypeSourceNamespace] { query := b.client.SourceName.Query(). - Where(sourceQuery(&model.SourceSpec{Type: &nodeID})). - Limit(MaxPageSize) + Where(sourceQuery(&model.SourceSpec{Type: &nodeID})) srcNames, err := query.All(ctx) if err != nil { @@ -606,11 +711,11 @@ func (b *EntBackend) srcTypeNeighbors(ctx context.Context, nodeID string, allowe for _, foundSrcName := range srcNames { out = append(out, &model.Source{ - ID: toGlobalID(srcTypeString, foundSrcName.Type), + ID: srcTypeGlobalID(foundSrcName.Type), Type: foundSrcName.Type, Namespaces: []*model.SourceNamespace{ { - ID: toGlobalID(srcNamespaceString, strings.Join([]string{foundSrcName.Type, foundSrcName.Namespace}, guacIDSplit)), + ID: srcNamespaceGlobalID(strings.Join([]string{foundSrcName.Type, foundSrcName.Namespace}, guacIDSplit)), Namespace: foundSrcName.Namespace, Names: []*model.SourceName{}, }, @@ -631,8 +736,7 @@ func (b *EntBackend) srcNamespaceNeighbors(ctx context.Context, nodeID string, a } query := b.client.SourceName.Query(). - Where(sourceQuery(&model.SourceSpec{Type: &splitQueryValue[0], Namespace: &splitQueryValue[1]})). - Limit(MaxPageSize) + Where(sourceQuery(&model.SourceSpec{Type: &splitQueryValue[0], Namespace: &splitQueryValue[1]})) srcNames, err := query.All(ctx) if err != nil { @@ -642,15 +746,15 @@ func (b *EntBackend) srcNamespaceNeighbors(ctx context.Context, nodeID string, a if allowedEdges[model.EdgeSourceNamespaceSourceName] { for _, foundSrcName := range srcNames { out = append(out, &model.Source{ - ID: toGlobalID(srcTypeString, foundSrcName.Type), + ID: srcTypeGlobalID(foundSrcName.Type), Type: foundSrcName.Type, Namespaces: []*model.SourceNamespace{ { - ID: toGlobalID(srcNamespaceString, strings.Join([]string{foundSrcName.Type, foundSrcName.Namespace}, guacIDSplit)), + ID: srcNamespaceGlobalID(strings.Join([]string{foundSrcName.Type, foundSrcName.Namespace}, guacIDSplit)), Namespace: foundSrcName.Namespace, Names: []*model.SourceName{ { - ID: toGlobalID(sourcename.Table, foundSrcName.ID.String()), + ID: srcNameGlobalID(foundSrcName.ID.String()), Name: foundSrcName.Name, }, }, @@ -662,7 +766,7 @@ func (b *EntBackend) srcNamespaceNeighbors(ctx context.Context, nodeID string, a if allowedEdges[model.EdgeSourceNamespaceSourceType] { for _, foundSrcName := range srcNames { out = append(out, &model.Source{ - ID: toGlobalID(srcTypeString, foundSrcName.Type), + ID: srcTypeGlobalID(foundSrcName.Type), Type: foundSrcName.Type, Namespaces: []*model.SourceNamespace{}, }) @@ -728,9 +832,6 @@ func (b *EntBackend) srcNameNeighbors(ctx context.Context, nodeID string, allowe }) } - query. - Limit(MaxPageSize) - srcNames, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to get source Name for node ID: %s with error: %w", nodeID, err) @@ -739,11 +840,11 @@ func (b *EntBackend) srcNameNeighbors(ctx context.Context, nodeID string, allowe for _, foundSrcName := range srcNames { if allowedEdges[model.EdgeSourceNameSourceNamespace] { out = append(out, &model.Source{ - ID: toGlobalID(srcTypeString, foundSrcName.Type), + ID: srcTypeGlobalID(foundSrcName.Type), Type: foundSrcName.Type, Namespaces: []*model.SourceNamespace{ { - ID: toGlobalID(srcNamespaceString, strings.Join([]string{foundSrcName.Type, foundSrcName.Namespace}, guacIDSplit)), + ID: srcNamespaceGlobalID(strings.Join([]string{foundSrcName.Type, foundSrcName.Namespace}, guacIDSplit)), Namespace: foundSrcName.Namespace, Names: []*model.SourceName{}, }, diff --git a/pkg/assembler/backends/ent/backend/transforms.go b/pkg/assembler/backends/ent/backend/transforms.go index f7264f142ef..33bdad293c5 100644 --- a/pkg/assembler/backends/ent/backend/transforms.go +++ b/pkg/assembler/backends/ent/backend/transforms.go @@ -20,21 +20,13 @@ import ( "github.com/guacsec/guac/internal/testing/ptrfrom" "github.com/guacsec/guac/pkg/assembler/backends/ent" - "github.com/guacsec/guac/pkg/assembler/backends/ent/artifact" - "github.com/guacsec/guac/pkg/assembler/backends/ent/billofmaterials" - "github.com/guacsec/guac/pkg/assembler/backends/ent/builder" - "github.com/guacsec/guac/pkg/assembler/backends/ent/certifylegal" "github.com/guacsec/guac/pkg/assembler/backends/ent/dependency" - "github.com/guacsec/guac/pkg/assembler/backends/ent/license" - "github.com/guacsec/guac/pkg/assembler/backends/ent/occurrence" - "github.com/guacsec/guac/pkg/assembler/backends/ent/packagename" - "github.com/guacsec/guac/pkg/assembler/backends/ent/packageversion" "github.com/guacsec/guac/pkg/assembler/graphql/model" ) func toModelArtifact(a *ent.Artifact) *model.Artifact { return &model.Artifact{ - ID: toGlobalID(artifact.Table, a.ID.String()), + ID: artGlobalID(a.ID.String()), Algorithm: a.Algorithm, Digest: a.Digest, } @@ -42,7 +34,7 @@ func toModelArtifact(a *ent.Artifact) *model.Artifact { func toModelBuilder(b *ent.Builder) *model.Builder { return &model.Builder{ - ID: toGlobalID(builder.Table, b.ID.String()), + ID: buildGlobalID(b.ID.String()), URI: b.URI, } } @@ -51,10 +43,10 @@ func toModelPackageTrie(collectedPkgNames []*ent.PackageName) []*model.Package { pkgTypes := map[string]map[string]map[string][]*model.PackageVersion{} for _, pkgName := range collectedPkgNames { - nameString := pkgName.Name + "," + toGlobalID(packagename.Table, pkgName.ID.String()) + nameString := pkgName.Name + "," + pkgNameGlobalID(pkgName.ID.String()) - namespaceString := pkgName.Namespace + "," + toGlobalID(pkgNamespaceString, strings.Join([]string{pkgName.Type, pkgName.Namespace}, guacIDSplit)) - typeString := pkgName.Type + "," + toGlobalID(pkgTypeString, pkgName.Type) + namespaceString := pkgName.Namespace + "," + pkgNamespaceGlobalID(strings.Join([]string{pkgName.Type, pkgName.Namespace}, guacIDSplit)) + typeString := pkgName.Type + "," + pkgTypeGlobalID(pkgName.Type) if pkgNamespaces, ok := pkgTypes[typeString]; ok { if pkgNames, ok := pkgNamespaces[namespaceString]; ok { @@ -112,7 +104,7 @@ func toModelPackage(p *ent.PackageName) *model.Package { return nil } return &model.Package{ - ID: toGlobalID(pkgTypeString, p.Type), + ID: pkgTypeGlobalID(p.Type), Type: p.Type, Namespaces: collect([]*ent.PackageName{p}, toModelNamespace), } @@ -123,7 +115,7 @@ func toModelNamespace(n *ent.PackageName) *model.PackageNamespace { return nil } return &model.PackageNamespace{ - ID: toGlobalID(pkgNamespaceString, strings.Join([]string{n.Type, n.Namespace}, guacIDSplit)), + ID: pkgNamespaceGlobalID(strings.Join([]string{n.Type, n.Namespace}, guacIDSplit)), Namespace: n.Namespace, Names: collect([]*ent.PackageName{n}, toModelPackageName), } @@ -134,7 +126,7 @@ func toModelPackageName(n *ent.PackageName) *model.PackageName { return nil } return &model.PackageName{ - ID: toGlobalID(packagename.Table, n.ID.String()), + ID: pkgNameGlobalID(n.ID.String()), Name: n.Name, Versions: collect(n.Edges.Versions, toModelPackageVersion), } @@ -143,7 +135,7 @@ func toModelPackageName(n *ent.PackageName) *model.PackageName { func toModelPackageVersion(v *ent.PackageVersion) *model.PackageVersion { return &model.PackageVersion{ - ID: toGlobalID(packageversion.Table, v.ID.String()), + ID: pkgVersionGlobalID(v.ID.String()), Version: v.Version, Qualifiers: toPtrSlice(v.Qualifiers), Subpath: v.Subpath, @@ -183,7 +175,7 @@ func valueOrDefault[T any](v *T, def T) T { func toModelIsOccurrenceWithSubject(o *ent.Occurrence) *model.IsOccurrence { return &model.IsOccurrence{ - ID: toGlobalID(occurrence.Table, o.ID.String()), + ID: occurrenceGlobalID(o.ID.String()), Subject: toModelPackageOrSource(o.Edges.Package, o.Edges.Source), Artifact: toModelArtifact(o.Edges.Artifact), Justification: o.Justification, @@ -250,7 +242,7 @@ func toModelIsDependency(id *ent.Dependency, backrefs bool) *model.IsDependency } return &model.IsDependency{ - ID: toGlobalID(dependency.Table, id.ID.String()), + ID: dependencyGlobalID(id.ID.String()), Package: pkg, DependencyPackage: depPkg, VersionRange: id.VersionRange, @@ -273,9 +265,28 @@ func dependencyTypeFromEnum(t dependency.DependencyType) model.DependencyType { } } +func toModelHasSBOMWithIncluded(sbom *ent.BillOfMaterials, includedSoftwarePackages []*ent.PackageVersion, includedSoftwareArtifacts []*ent.Artifact, + includedDependencies []*ent.Dependency, includedOccurrences []*ent.Occurrence) *model.HasSbom { + + return &model.HasSbom{ + ID: hasSBOMGlobalID(sbom.ID.String()), + Subject: toPackageOrArtifact(sbom.Edges.Package, sbom.Edges.Artifact), + URI: sbom.URI, + Algorithm: sbom.Algorithm, + Digest: sbom.Digest, + DownloadLocation: sbom.DownloadLocation, + Origin: sbom.Origin, + Collector: sbom.Collector, + DocumentRef: sbom.DocumentRef, + KnownSince: sbom.KnownSince, + IncludedSoftware: toIncludedSoftware(includedSoftwarePackages, includedSoftwareArtifacts), + IncludedDependencies: collect(includedDependencies, toModelIsDependencyWithBackrefs), + IncludedOccurrences: collect(includedOccurrences, toModelIsOccurrenceWithSubject), + } +} func toModelHasSBOM(sbom *ent.BillOfMaterials) *model.HasSbom { return &model.HasSbom{ - ID: toGlobalID(billofmaterials.Table, sbom.ID.String()), + ID: hasSBOMGlobalID(sbom.ID.String()), Subject: toPackageOrArtifact(sbom.Edges.Package, sbom.Edges.Artifact), URI: sbom.URI, Algorithm: sbom.Algorithm, @@ -323,7 +334,7 @@ func toModelLicense(entLicense *ent.License) *model.License { } return &model.License{ - ID: toGlobalID(license.Table, entLicense.ID.String()), + ID: licenseGlobalID(entLicense.ID.String()), Name: entLicense.Name, Inline: dbInLine, ListVersion: dbListVersion, @@ -332,7 +343,7 @@ func toModelLicense(entLicense *ent.License) *model.License { func toModelCertifyLegal(cl *ent.CertifyLegal) *model.CertifyLegal { return &model.CertifyLegal{ - ID: toGlobalID(certifylegal.Table, cl.ID.String()), + ID: certifyLegalGlobalID(cl.ID.String()), Subject: toModelPackageOrSource(cl.Edges.Package, cl.Edges.Source), DeclaredLicense: cl.DeclaredLicense, DeclaredLicenses: collect(cl.Edges.DeclaredLicenses, toModelLicense), diff --git a/pkg/assembler/backends/ent/backend/vulnEqual.go b/pkg/assembler/backends/ent/backend/vulnEqual.go index c6d4b6409c5..99069e20921 100644 --- a/pkg/assembler/backends/ent/backend/vulnEqual.go +++ b/pkg/assembler/backends/ent/backend/vulnEqual.go @@ -22,6 +22,7 @@ import ( "fmt" "sort" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -34,8 +35,62 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -func (b *EntBackend) VulnEqualList(ctx context.Context, vulnEqualSpec model.VulnEqualSpec, after *string, first *int) (*model.VulnEqualConnection, error) { - return nil, fmt.Errorf("not implemented: VulnEqualList") +func vulnEqualGlobalID(id string) string { + return toGlobalID(vulnequal.Table, id) +} + +func bulkVulnEqualGlobalID(ids []string) []string { + return toGlobalIDs(vulnequal.Table, ids) +} + +func (b *EntBackend) VulnEqualList(ctx context.Context, spec model.VulnEqualSpec, after *string, first *int) (*model.VulnEqualConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != vulnequal.Table { + return nil, fmt.Errorf("after cursor is not type vulnEqual but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + veQuery := b.client.VulnEqual.Query(). + Where(vulnEqualQuery(&spec)) + + veConn, err := getVulnEqualObject(veQuery). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed vulnEqual query with error: %w", err) + } + + var edges []*model.VulnEqualEdge + for _, edge := range veConn.Edges { + edges = append(edges, &model.VulnEqualEdge{ + Cursor: vulnEqualGlobalID(edge.Cursor.ID.String()), + Node: toModelVulnEqual(edge.Node), + }) + } + + if veConn.PageInfo.StartCursor != nil { + return &model.VulnEqualConnection{ + TotalCount: veConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: veConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(vulnEqualGlobalID(veConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(vulnEqualGlobalID(veConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) VulnEqual(ctx context.Context, filter *model.VulnEqualSpec) ([]*model.VulnEqual, error) { @@ -50,10 +105,9 @@ func (b *EntBackend) VulnEqual(ctx context.Context, filter *model.VulnEqualSpec) Where(vulnEqualQuery(filter)) query, err := getVulnEqualObject(veQuery). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed vulnEqual query with error: %w", err) } return collect(query, toModelVulnEqual), nil @@ -115,7 +169,7 @@ func (b *EntBackend) IngestVulnEquals(ctx context.Context, vulnerabilities []*mo return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(vulnequal.Table, *ids), nil + return bulkVulnEqualGlobalID(*ids), nil } func (b *EntBackend) IngestVulnEqual(ctx context.Context, vulnerability model.IDorVulnerabilityInput, otherVulnerability model.IDorVulnerabilityInput, vulnEqual model.VulnEqualInputSpec) (string, error) { @@ -128,7 +182,7 @@ func (b *EntBackend) IngestVulnEqual(ctx context.Context, vulnerability model.ID return "", txErr } - return toGlobalID(vulnequal.Table, *id), nil + return vulnEqualGlobalID(*id), nil } func vulnEqualConflictColumns() []string { @@ -200,7 +254,7 @@ func generateVulnEqualCreate(ctx context.Context, tx *ent.Tx, vulnerability *mod if err != nil { return nil, Errorf("%v :: %s", "generateVexCreate", err) } - vulnerability.VulnerabilityNodeID = ptrfrom.String(toGlobalID(vulnerabilityid.Table, foundVulnID.String())) + vulnerability.VulnerabilityNodeID = ptrfrom.String(vulnIDGlobalID(foundVulnID.String())) } if otherVulnerability.VulnerabilityNodeID == nil { @@ -213,7 +267,7 @@ func generateVulnEqualCreate(ctx context.Context, tx *ent.Tx, vulnerability *mod if err != nil { return nil, Errorf("%v :: %s", "generateVexCreate", err) } - otherVulnerability.VulnerabilityNodeID = ptrfrom.String(toGlobalID(vulnerabilityid.Table, foundVulnID.String())) + otherVulnerability.VulnerabilityNodeID = ptrfrom.String(vulnIDGlobalID(foundVulnID.String())) } sortedVulns := []model.IDorVulnerabilityInput{*vulnerability, *otherVulnerability} @@ -288,7 +342,7 @@ func toModelVulnEqual(record *ent.VulnEqual) *model.VulnEqual { vulnerabilities := []*ent.VulnerabilityID{record.Edges.VulnerabilityA, record.Edges.VulnerabilityB} return &model.VulnEqual{ - ID: toGlobalID(vulnequal.Table, record.ID.String()), + ID: vulnEqualGlobalID(record.ID.String()), Vulnerabilities: collect(vulnerabilities, toModelVulnerabilityFromVulnerabilityID), Justification: record.Justification, Origin: record.Origin, @@ -299,7 +353,7 @@ func toModelVulnEqual(record *ent.VulnEqual) *model.VulnEqual { func toModelVulnerabilityFromVulnerabilityID(vulnID *ent.VulnerabilityID) *model.Vulnerability { return &model.Vulnerability{ - ID: toGlobalID(vulnTypeString, vulnID.ID.String()), + ID: vulnTypeGlobalID(vulnID.ID.String()), Type: vulnID.Type, VulnerabilityIDs: []*model.VulnerabilityID{toModelVulnerabilityID(vulnID)}, } @@ -332,9 +386,6 @@ func (b *EntBackend) vulnEqualNeighbors(ctx context.Context, nodeID string, allo WithVulnerabilityB() } - query. - Limit(MaxPageSize) - vulnEquals, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for vulnEquals with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/vulnMetadata.go b/pkg/assembler/backends/ent/backend/vulnMetadata.go index 1d82ac40e51..8b2fb36d6bd 100644 --- a/pkg/assembler/backends/ent/backend/vulnMetadata.go +++ b/pkg/assembler/backends/ent/backend/vulnMetadata.go @@ -19,6 +19,7 @@ import ( "context" "fmt" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -31,8 +32,67 @@ import ( "github.com/vektah/gqlparser/v2/gqlerror" ) -func (b *EntBackend) VulnerabilityMetadataList(ctx context.Context, vulnerabilityMetadataSpec model.VulnerabilityMetadataSpec, after *string, first *int) (*model.VulnerabilityMetadataConnection, error) { - return nil, fmt.Errorf("not implemented: VulnerabilityMetadataList") +func vulnMetaGlobalID(id string) string { + return toGlobalID(vulnerabilitymetadata.Table, id) +} + +func bulkVulnMetaGlobalID(ids []string) []string { + return toGlobalIDs(vulnerabilitymetadata.Table, ids) +} + +func (b *EntBackend) VulnerabilityMetadataList(ctx context.Context, spec model.VulnerabilityMetadataSpec, after *string, first *int) (*model.VulnerabilityMetadataConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != vulnerabilitymetadata.Table { + return nil, fmt.Errorf("after cursor is not type vulnMetadata but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + vulnMetadataPred, err := vulnerabilityMetadataPredicate(&spec) + if err != nil { + return nil, fmt.Errorf("failed to generate vulnerabilityMetadataPredicate :: %w", err) + } + + veQuery := b.client.VulnerabilityMetadata.Query(). + Where(vulnMetadataPred) + + vmConn, err := getVulnMetadataObject(veQuery). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed vulnMetadata query with error: %w", err) + } + + var edges []*model.VulnerabilityMetadataEdge + for _, edge := range vmConn.Edges { + edges = append(edges, &model.VulnerabilityMetadataEdge{ + Cursor: vulnMetaGlobalID(edge.Cursor.ID.String()), + Node: toModelVulnerabilityMetadata(edge.Node), + }) + } + + if vmConn.PageInfo.StartCursor != nil { + return &model.VulnerabilityMetadataConnection{ + TotalCount: vmConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: vmConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(vulnMetaGlobalID(vmConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(vulnMetaGlobalID(vmConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) VulnerabilityMetadata(ctx context.Context, filter *model.VulnerabilityMetadataSpec) ([]*model.VulnerabilityMetadata, error) { @@ -44,14 +104,13 @@ func (b *EntBackend) VulnerabilityMetadata(ctx context.Context, filter *model.Vu return nil, fmt.Errorf("failed to generate vulnerabilityMetadataPredicate :: %w", err) } - veQuery := b.client.VulnerabilityMetadata.Query(). + vmConn := b.client.VulnerabilityMetadata.Query(). Where(vulnMetadataPred) - records, err := getVulnMetadataObject(veQuery). - Limit(MaxPageSize). + records, err := getVulnMetadataObject(vmConn). All(ctx) if err != nil { - return nil, fmt.Errorf("failed to retrieve VulnerabilityMetadata :: %w", err) + return nil, fmt.Errorf("failed vulnMetadata query with error: %w", err) } return collect(records, toModelVulnerabilityMetadata), nil @@ -71,7 +130,7 @@ func (b *EntBackend) IngestVulnerabilityMetadata(ctx context.Context, vulnerabil return "", fmt.Errorf("failed to execute IngestVulnerabilityMetadata :: %s", txErr) } - return toGlobalID(vulnerabilitymetadata.Table, *recordID), nil + return vulnMetaGlobalID(*recordID), nil } func (b *EntBackend) IngestBulkVulnerabilityMetadata(ctx context.Context, vulnerabilities []*model.IDorVulnerabilityInput, vulnerabilityMetadataList []*model.VulnerabilityMetadataInputSpec) ([]string, error) { @@ -88,7 +147,7 @@ func (b *EntBackend) IngestBulkVulnerabilityMetadata(ctx context.Context, vulner return nil, gqlerror.Errorf("%v :: %s", funcName, txErr) } - return toGlobalIDs(vulnerabilitymetadata.Table, *ids), nil + return bulkVulnMetaGlobalID(*ids), nil } func vulnerabilityMetadataPredicate(filter *model.VulnerabilityMetadataSpec) (predicate.VulnerabilityMetadata, error) { @@ -243,7 +302,7 @@ func upsertVulnerabilityMetadata(ctx context.Context, tx *ent.Tx, vulnerability func toModelVulnerabilityMetadata(v *ent.VulnerabilityMetadata) *model.VulnerabilityMetadata { return &model.VulnerabilityMetadata{ - ID: toGlobalID(vulnerabilitymetadata.Table, v.ID.String()), + ID: vulnMetaGlobalID(v.ID.String()), Vulnerability: toModelVulnerabilityFromVulnerabilityID(v.Edges.VulnerabilityID), ScoreType: model.VulnerabilityScoreType(v.ScoreType), ScoreValue: v.ScoreValue, @@ -270,9 +329,6 @@ func (b *EntBackend) vulnMetadataNeighbors(ctx context.Context, nodeID string, a WithVulnerabilityID() } - query. - Limit(MaxPageSize) - vulnMetas, err := query.All(ctx) if err != nil { return []model.Node{}, fmt.Errorf("failed to query for vulnerability Metadata with node ID: %s with error: %w", nodeID, err) diff --git a/pkg/assembler/backends/ent/backend/vulnerability.go b/pkg/assembler/backends/ent/backend/vulnerability.go index 6d2440512f4..b158b4819ee 100644 --- a/pkg/assembler/backends/ent/backend/vulnerability.go +++ b/pkg/assembler/backends/ent/backend/vulnerability.go @@ -21,6 +21,7 @@ import ( "fmt" "strings" + "entgo.io/contrib/entgql" "entgo.io/ent/dialect/sql" "github.com/google/uuid" "github.com/guacsec/guac/internal/testing/ptrfrom" @@ -38,6 +39,14 @@ const ( NoVuln = "novuln" ) +func vulnTypeGlobalID(id string) string { + return toGlobalID(vulnTypeString, id) +} + +func vulnIDGlobalID(id string) string { + return toGlobalID(vulnerabilityid.Table, id) +} + func (b *EntBackend) IngestVulnerability(ctx context.Context, vuln model.IDorVulnerabilityInput) (*model.VulnerabilityIDs, error) { id, txErr := WithinTX(ctx, b.client, func(ctx context.Context) (*model.VulnerabilityIDs, error) { return upsertVulnerability(ctx, ent.TxFromContext(ctx), vuln) @@ -73,8 +82,52 @@ func (b *EntBackend) IngestVulnerabilities(ctx context.Context, vulns []*model.I return collectedVulnIDs, nil } -func (b *EntBackend) VulnerabilityList(ctx context.Context, vulnSpec model.VulnerabilitySpec, after *string, first *int) (*model.VulnerabilityConnection, error) { - return nil, fmt.Errorf("not implemented: VulnerabilityList") +func (b *EntBackend) VulnerabilityList(ctx context.Context, spec model.VulnerabilitySpec, after *string, first *int) (*model.VulnerabilityConnection, error) { + var afterCursor *entgql.Cursor[uuid.UUID] + + if after != nil { + globalID := fromGlobalID(*after) + if globalID.nodeType != vulnerabilityid.Table { + return nil, fmt.Errorf("after cursor is not type vulnerability but type: %s", globalID.nodeType) + } + afterUUID, err := uuid.Parse(globalID.id) + if err != nil { + return nil, fmt.Errorf("failed to parse global ID with error: %w", err) + } + afterCursor = &ent.Cursor{ID: afterUUID} + } else { + afterCursor = nil + } + + vulnConn, err := b.client.VulnerabilityID.Query(). + Where(vulnerabilityQueryPredicates(spec)...). + Paginate(ctx, afterCursor, first, nil, nil) + if err != nil { + return nil, fmt.Errorf("failed vulnerability query with error: %w", err) + } + + var edges []*model.VulnerabilityEdge + for _, edge := range vulnConn.Edges { + edges = append(edges, &model.VulnerabilityEdge{ + Cursor: vulnIDGlobalID(edge.Cursor.ID.String()), + Node: toModelVulnerabilityFromVulnerabilityID(edge.Node), + }) + } + + if vulnConn.PageInfo.StartCursor != nil { + return &model.VulnerabilityConnection{ + TotalCount: vulnConn.TotalCount, + PageInfo: &model.PageInfo{ + HasNextPage: vulnConn.PageInfo.HasNextPage, + StartCursor: ptrfrom.String(vulnIDGlobalID(vulnConn.PageInfo.StartCursor.ID.String())), + EndCursor: ptrfrom.String(vulnIDGlobalID(vulnConn.PageInfo.EndCursor.ID.String())), + }, + Edges: edges, + }, nil + } else { + // if not found return nil + return nil, nil + } } func (b *EntBackend) Vulnerabilities(ctx context.Context, filter *model.VulnerabilitySpec) ([]*model.Vulnerability, error) { @@ -83,19 +136,18 @@ func (b *EntBackend) Vulnerabilities(ctx context.Context, filter *model.Vulnerab } records, err := getVulnerabilities(ctx, b.client, *filter) if err != nil { - return nil, err + return nil, fmt.Errorf("getVulnerabilities with error: %w", err) } - return toModelVulnerability(records), nil // collect(records, toModelVulnerabilityFromVulnerabilityID), nil + return toModelVulnerability(records), nil } func getVulnerabilities(ctx context.Context, client *ent.Client, filter model.VulnerabilitySpec) (ent.VulnerabilityIDs, error) { results, err := client.VulnerabilityID.Query(). Where(vulnerabilityQueryPredicates(filter)...). - Limit(MaxPageSize). All(ctx) if err != nil { - return nil, err + return nil, fmt.Errorf("failed vulnerability query with error: %w", err) } return results, nil } @@ -138,8 +190,8 @@ func upsertBulkVulnerability(ctx context.Context, tx *ent.Tx, vulnInputs []*mode creates[i] = generateVulnerabilityIDCreate(tx, &vulnID, v) ids = append(ids, model.VulnerabilityIDs{ - VulnerabilityTypeID: toGlobalID(vulnTypeString, v.VulnerabilityInput.Type), - VulnerabilityNodeID: toGlobalID(ent.TypeVulnerabilityID, vulnID.String())}) + VulnerabilityTypeID: vulnTypeGlobalID(v.VulnerabilityInput.Type), + VulnerabilityNodeID: vulnIDGlobalID(vulnID.String())}) } err := tx.VulnerabilityID.CreateBulk(creates...). @@ -180,8 +232,8 @@ func upsertVulnerability(ctx context.Context, tx *ent.Tx, spec model.IDorVulnera } return &model.VulnerabilityIDs{ - VulnerabilityTypeID: toGlobalID(vulnTypeString, spec.VulnerabilityInput.Type), - VulnerabilityNodeID: toGlobalID(vulnerabilityid.Table, vulnID.String()), + VulnerabilityTypeID: vulnTypeGlobalID(spec.VulnerabilityInput.Type), + VulnerabilityNodeID: vulnIDGlobalID(vulnID.String()), }, nil } @@ -189,9 +241,9 @@ func toModelVulnerability(collectedVulnID []*ent.VulnerabilityID) []*model.Vulne vulnTypes := map[string][]*model.VulnerabilityID{} for _, vulnID := range collectedVulnID { - typeString := vulnID.Type + "," + toGlobalID(vulnTypeString, vulnID.Type) + typeString := vulnID.Type + "," + vulnTypeGlobalID(vulnID.Type) vulnID := &model.VulnerabilityID{ - ID: toGlobalID(vulnerabilityid.Table, vulnID.ID.String()), + ID: vulnIDGlobalID(vulnID.ID.String()), VulnerabilityID: vulnID.VulnerabilityID, } if _, ok := vulnTypes[typeString]; ok { @@ -217,7 +269,7 @@ func toModelVulnerability(collectedVulnID []*ent.VulnerabilityID) []*model.Vulne func toModelVulnerabilityID(vulnID *ent.VulnerabilityID) *model.VulnerabilityID { return &model.VulnerabilityID{ - ID: toGlobalID(vulnerabilityid.Table, vulnID.ID.String()), + ID: vulnIDGlobalID(vulnID.ID.String()), VulnerabilityID: vulnID.VulnerabilityID, } } @@ -226,8 +278,7 @@ func (b *EntBackend) vulnTypeNeighbors(ctx context.Context, nodeID string, allow var out []model.Node if allowedEdges[model.EdgeVulnerabilityTypeVulnerabilityID] { query := b.client.VulnerabilityID.Query(). - Where(vulnerabilityQueryPredicates(model.VulnerabilitySpec{Type: &nodeID})...). - Limit(MaxPageSize) + Where(vulnerabilityQueryPredicates(model.VulnerabilitySpec{Type: &nodeID})...) vulnIDs, err := query.All(ctx) if err != nil { @@ -236,11 +287,11 @@ func (b *EntBackend) vulnTypeNeighbors(ctx context.Context, nodeID string, allow for _, foundVulnID := range vulnIDs { out = append(out, &model.Vulnerability{ - ID: toGlobalID(vulnTypeString, foundVulnID.Type), + ID: vulnTypeGlobalID(foundVulnID.Type), Type: foundVulnID.Type, VulnerabilityIDs: []*model.VulnerabilityID{ { - ID: toGlobalID(vulnerabilityid.Table, foundVulnID.ID.String()), + ID: vulnIDGlobalID(foundVulnID.ID.String()), VulnerabilityID: foundVulnID.VulnerabilityID, }, }, @@ -283,8 +334,6 @@ func (b *EntBackend) vulnIdNeighbors(ctx context.Context, nodeID string, allowed getVulnMetadataObject(q) }) } - query. - Limit(MaxPageSize) vulnIDs, err := query.All(ctx) if err != nil { @@ -294,7 +343,7 @@ func (b *EntBackend) vulnIdNeighbors(ctx context.Context, nodeID string, allowed for _, foundVulnID := range vulnIDs { if allowedEdges[model.EdgeVulnerabilityIDVulnerabilityType] { out = append(out, &model.Vulnerability{ - ID: toGlobalID(vulnTypeString, foundVulnID.Type), + ID: vulnTypeGlobalID(foundVulnID.Type), Type: foundVulnID.Type, VulnerabilityIDs: []*model.VulnerabilityID{}, }) From 46e8893ba0dfefd86286baebaffb6b3617aca79c Mon Sep 17 00:00:00 2001 From: Narsimham Chelluri Date: Mon, 29 Apr 2024 09:35:49 -0300 Subject: [PATCH 16/17] Fixes to HTTP Header functionality for CLI commands (#1852) * Simplify HTTP header transport creation - Since we only ever parse and store header values at command startup, we can just log fatally if there is a problem getting the values, instead of propagating an error. This makes the code to construct our http.Transport cleaner and simpler. Signed-off-by: Narsimham Chelluri (Narsa) * Move --header-file to guacone root command Signed-off-by: Narsimham Chelluri (Narsa) * Fix ingestor not using HTTP header file - also fix guacone collect github not using GQL address Signed-off-by: Narsimham Chelluri (Narsa) * Remove unused GQL addr field (dead code) Signed-off-by: Narsimham Chelluri (Narsa) --------- Signed-off-by: Narsimham Chelluri (Narsa) --- cmd/guaccollect/cmd/gcs.go | 8 ++--- cmd/guaccollect/cmd/s3.go | 4 --- cmd/guacingest/cmd/ingest.go | 13 +++++--- cmd/guacingest/cmd/root.go | 2 +- cmd/guacone/cmd/bad.go | 9 ++---- cmd/guacone/cmd/certify.go | 16 ++++++---- cmd/guacone/cmd/deps_dev.go | 12 +++++--- cmd/guacone/cmd/files.go | 15 ++++++---- cmd/guacone/cmd/gcs.go | 17 +++++++---- cmd/guacone/cmd/gcs_test.go | 2 +- cmd/guacone/cmd/github.go | 29 +++++++++++------- cmd/guacone/cmd/known.go | 18 +---------- cmd/guacone/cmd/oci.go | 16 ++++++---- cmd/guacone/cmd/osv.go | 31 +++++-------------- cmd/guacone/cmd/patch.go | 8 +---- cmd/guacone/cmd/root.go | 2 +- cmd/guacone/cmd/s3.go | 38 +++++++++++++----------- cmd/guacone/cmd/scorecard.go | 25 ++++------------ cmd/guacone/cmd/vulnerability.go | 10 ++----- cmd/guacrest/cmd/server.go | 7 +---- pkg/cli/headers.go | 14 +++++---- pkg/cli/headers_test.go | 51 ++++++++++++++++++++++---------- pkg/ingestor/ingestor.go | 32 +++++++++++++++----- pkg/logging/logger.go | 7 +++-- 24 files changed, 197 insertions(+), 189 deletions(-) diff --git a/cmd/guaccollect/cmd/gcs.go b/cmd/guaccollect/cmd/gcs.go index bf7c88e71ea..b5ee233fd1a 100644 --- a/cmd/guaccollect/cmd/gcs.go +++ b/cmd/guaccollect/cmd/gcs.go @@ -20,7 +20,6 @@ import ( type gcsOptions struct { pubSubAddr string blobAddr string - graphqlEndpoint string csubClientOptions csub_client.CsubClientOptions bucket string } @@ -39,7 +38,6 @@ var gcsCmd = &cobra.Command{ opts, err := validateGCSFlags( viper.GetString("pubsub-addr"), viper.GetString("blob-addr"), - viper.GetString("gql-addr"), viper.GetString("csub-addr"), viper.GetString(gcsCredentialsPathFlag), viper.GetBool("csub-tls"), @@ -93,7 +91,6 @@ var gcsCmd = &cobra.Command{ func validateGCSFlags( pubSubAddr, blobAddr, - gqlEndpoint, csubAddr, credentialsPath string, csubTls, @@ -101,9 +98,8 @@ func validateGCSFlags( args []string, ) (gcsOptions, error) { opts := gcsOptions{ - pubSubAddr: pubSubAddr, - blobAddr: blobAddr, - graphqlEndpoint: gqlEndpoint, + pubSubAddr: pubSubAddr, + blobAddr: blobAddr, } csubOpts, err := csub_client.ValidateCsubClientFlags(csubAddr, csubTls, csubTlsSkipVerify) diff --git a/cmd/guaccollect/cmd/s3.go b/cmd/guaccollect/cmd/s3.go index b1b89da922a..f83de9f072b 100644 --- a/cmd/guaccollect/cmd/s3.go +++ b/cmd/guaccollect/cmd/s3.go @@ -28,7 +28,6 @@ type s3Options struct { mp string // message provider name (sqs or kafka, will default to kafka) mpEndpoint string // endpoint for the message provider (only for polling behaviour) poll bool // polling or non-polling behaviour? (defaults to non-polling) - graphqlEndpoint string // endpoint for the graphql server csubClientOptions csub_client.CsubClientOptions // options for the collectsub client } @@ -64,7 +63,6 @@ $ guacone collect s3 --s3-url http://localhost:9000 --s3-bucket guac-test --poll s3Opts, err := validateS3Opts( viper.GetString("pubsub-addr"), viper.GetString("blob-addr"), - viper.GetString("gql-addr"), viper.GetString("csub-addr"), viper.GetString("s3-url"), viper.GetString("s3-bucket"), @@ -116,7 +114,6 @@ $ guacone collect s3 --s3-url http://localhost:9000 --s3-bucket guac-test --poll func validateS3Opts( pubSubAddr, blobAddr, - graphqlEndpoint, csubAddr, s3url, s3bucket, @@ -162,7 +159,6 @@ func validateS3Opts( mp: mp, mpEndpoint: mpEndpoint, poll: poll, - graphqlEndpoint: graphqlEndpoint, csubClientOptions: csubClientOptions, } diff --git a/cmd/guacingest/cmd/ingest.go b/cmd/guacingest/cmd/ingest.go index ede3a34c641..639c221c248 100644 --- a/cmd/guacingest/cmd/ingest.go +++ b/cmd/guacingest/cmd/ingest.go @@ -18,6 +18,7 @@ package cmd import ( "context" "fmt" + "net/http" "os" "os/signal" "strings" @@ -25,6 +26,7 @@ import ( "syscall" "github.com/guacsec/guac/pkg/blob" + "github.com/guacsec/guac/pkg/cli" "github.com/guacsec/guac/pkg/collectsub/client" csub_client "github.com/guacsec/guac/pkg/collectsub/client" "github.com/guacsec/guac/pkg/emitter" @@ -41,17 +43,18 @@ type options struct { blobAddr string csubClientOptions client.CsubClientOptions graphqlEndpoint string + headerFile string } func ingest(cmd *cobra.Command, args []string) { - opts, err := validateFlags( viper.GetString("pubsub-addr"), viper.GetString("blob-addr"), viper.GetString("csub-addr"), + viper.GetString("gql-addr"), + viper.GetString("header-file"), viper.GetBool("csub-tls"), viper.GetBool("csub-tls-skip-verify"), - viper.GetString("gql-addr"), args) if err != nil { fmt.Printf("unable to validate flags: %v\n", err) @@ -61,6 +64,7 @@ func ingest(cmd *cobra.Command, args []string) { ctx, cf := context.WithCancel(logging.WithLogger(context.Background())) logger := logging.FromContext(ctx) + transport := cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport) if strings.HasPrefix(opts.pubsubAddr, "nats://") { // initialize jetstream @@ -90,7 +94,7 @@ func ingest(cmd *cobra.Command, args []string) { defer csubClient.Close() emit := func(d *processor.Document) error { - if err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, csubClient); err != nil { + if err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient); err != nil { logger.Errorf("unable to ingest document %q : %v", d.SourceInformation.Source, err) } return nil @@ -116,7 +120,7 @@ func ingest(cmd *cobra.Command, args []string) { wg.Wait() } -func validateFlags(pubsubAddr string, blobAddr string, csubAddr string, csubTls bool, csubTlsSkipVerify bool, graphqlEndpoint string, args []string) (options, error) { +func validateFlags(pubsubAddr, blobAddr, csubAddr, graphqlEndpoint, headerFile string, csubTls, csubTlsSkipVerify bool, args []string) (options, error) { var opts options opts.pubsubAddr = pubsubAddr opts.blobAddr = blobAddr @@ -126,6 +130,7 @@ func validateFlags(pubsubAddr string, blobAddr string, csubAddr string, csubTls } opts.csubClientOptions = csubOpts opts.graphqlEndpoint = graphqlEndpoint + opts.headerFile = headerFile return opts, nil } diff --git a/cmd/guacingest/cmd/root.go b/cmd/guacingest/cmd/root.go index 54c70a8dd44..40fe74a50e3 100644 --- a/cmd/guacingest/cmd/root.go +++ b/cmd/guacingest/cmd/root.go @@ -30,7 +30,7 @@ import ( func init() { cobra.OnInitialize(cli.InitConfig) - set, err := cli.BuildFlags([]string{"pubsub-addr", "blob-addr", "csub-addr", "gql-addr"}) + set, err := cli.BuildFlags([]string{"pubsub-addr", "blob-addr", "csub-addr", "gql-addr", "header-file"}) if err != nil { fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err) os.Exit(1) diff --git a/cmd/guacone/cmd/bad.go b/cmd/guacone/cmd/bad.go index 72d0eb1c579..ff729df8396 100644 --- a/cmd/guacone/cmd/bad.go +++ b/cmd/guacone/cmd/bad.go @@ -57,12 +57,7 @@ var queryBadCmd = &cobra.Command{ os.Exit(1) } - transport, err := cli.NewHTTPHeaderTransport(opts.headerFile, http.DefaultTransport) - if err != nil { - logger.Fatalf("unable to create HTTP transport: %v", err) - } - - httpClient := http.Client{Transport: transport} + httpClient := http.Client{Transport: cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport)} gqlclient := graphql.NewClient(opts.graphqlEndpoint, &httpClient) certifyBadResponse, err := model.CertifyBads(ctx, gqlclient, model.CertifyBadSpec{}) @@ -258,7 +253,7 @@ func validateQueryBadFlags(graphqlEndpoint, headerFile string, depth int) (query } func init() { - set, err := cli.BuildFlags([]string{"header-file", "search-depth"}) + set, err := cli.BuildFlags([]string{"search-depth"}) if err != nil { fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err) os.Exit(1) diff --git a/cmd/guacone/cmd/certify.go b/cmd/guacone/cmd/certify.go index 2580b00cad6..6be20732806 100644 --- a/cmd/guacone/cmd/certify.go +++ b/cmd/guacone/cmd/certify.go @@ -18,6 +18,7 @@ package cmd import ( "context" "fmt" + "net/http" "os" "strings" "time" @@ -35,6 +36,7 @@ import ( type certifyOptions struct { // gql endpoint graphqlEndpoint string + headerFile string // // certifyBad/certifyGood good bool certifyType string @@ -53,23 +55,24 @@ var certifyCmd = &cobra.Command{ is in the form of "" for package, "+" for source, or ":" for artifact.`, TraverseChildren: true, Run: func(cmd *cobra.Command, args []string) { - ctx := logging.WithLogger(context.Background()) - logger := logging.FromContext(ctx) - opts, err := validateCertifyFlags( viper.GetString("gql-addr"), + viper.GetString("header-file"), viper.GetBool("cert-good"), viper.GetBool("package-name"), args, ) - if err != nil { fmt.Printf("unable to validate flags: %v\n", err) _ = cmd.Help() os.Exit(1) } - assemblerFunc := ingestor.GetAssembler(ctx, logger, opts.graphqlEndpoint) + ctx := logging.WithLogger(context.Background()) + logger := logging.FromContext(ctx) + transport := cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport) + + assemblerFunc := ingestor.GetAssembler(ctx, logger, opts.graphqlEndpoint, transport) preds := &assembler.IngestPredicates{} var pkgInput *model.PkgInputSpec @@ -156,9 +159,10 @@ var certifyCmd = &cobra.Command{ }, } -func validateCertifyFlags(graphqlEndpoint string, good, pkgName bool, args []string) (certifyOptions, error) { +func validateCertifyFlags(graphqlEndpoint, headerFile string, good, pkgName bool, args []string) (certifyOptions, error) { var opts certifyOptions opts.graphqlEndpoint = graphqlEndpoint + opts.headerFile = headerFile opts.good = good opts.pkgName = pkgName if len(args) != 3 { diff --git a/cmd/guacone/cmd/deps_dev.go b/cmd/guacone/cmd/deps_dev.go index e8c83d6bdac..8d3ea55be4f 100644 --- a/cmd/guacone/cmd/deps_dev.go +++ b/cmd/guacone/cmd/deps_dev.go @@ -18,6 +18,7 @@ package cmd import ( "context" "fmt" + "net/http" "os" "os/signal" "sync" @@ -48,15 +49,13 @@ type depsDevOptions struct { retrieveDependencies bool // gql endpoint graphqlEndpoint string + headerFile string } var depsDevCmd = &cobra.Command{ Use: "deps_dev [flags] ...", Short: "takes purls and queries them against deps.dev to find additional metadata to add to GUAC graph utilizing Nats pubsub and blob store", Run: func(cmd *cobra.Command, args []string) { - ctx := logging.WithLogger(context.Background()) - logger := logging.FromContext(ctx) - opts, csc, err := validateDepsDevFlags(args) if err != nil { fmt.Printf("unable to validate flags: %v\n", err) @@ -64,6 +63,10 @@ var depsDevCmd = &cobra.Command{ os.Exit(1) } + ctx := logging.WithLogger(context.Background()) + logger := logging.FromContext(ctx) + transport := cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport) + // Register collector depsDevCollector, err := deps_dev.NewDepsCollector(ctx, opts.dataSource, opts.poll, opts.retrieveDependencies, 30*time.Second) if err != nil { @@ -80,7 +83,7 @@ var depsDevCmd = &cobra.Command{ emit := func(d *processor.Document) error { totalNum += 1 - if err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, csc); err != nil { + if err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csc); err != nil { gotErr = true return fmt.Errorf("unable to ingest document: %w", err) } @@ -135,6 +138,7 @@ func validateDepsDevFlags(args []string) (*depsDevOptions, client.Client, error) poll: viper.GetBool("poll"), retrieveDependencies: viper.GetBool("retrieve-dependencies"), graphqlEndpoint: viper.GetString("gql-addr"), + headerFile: viper.GetString("header-file"), } useCsub := viper.GetBool("use-csub") if useCsub { diff --git a/cmd/guacone/cmd/files.go b/cmd/guacone/cmd/files.go index c9d643d2974..9ceea328d6d 100644 --- a/cmd/guacone/cmd/files.go +++ b/cmd/guacone/cmd/files.go @@ -19,6 +19,7 @@ import ( "context" "errors" "fmt" + "net/http" "os" "strings" "time" @@ -48,6 +49,7 @@ type fileOptions struct { path string // gql endpoint graphqlEndpoint string + headerFile string // csub client options for identifier strings csubClientOptions client.CsubClientOptions } @@ -56,13 +58,11 @@ var filesCmd = &cobra.Command{ Use: "files [flags] file_path", Short: "take a folder of files and create a GUAC graph, this command talks directly to the graphQL endpoint", Run: func(cmd *cobra.Command, args []string) { - ctx := logging.WithLogger(context.Background()) - logger := logging.FromContext(ctx) - opts, err := validateFilesFlags( viper.GetString("verifier-key-path"), viper.GetString("verifier-key-id"), viper.GetString("gql-addr"), + viper.GetString("header-file"), viper.GetString("csub-addr"), viper.GetBool("csub-tls"), viper.GetBool("csub-tls-skip-verify"), @@ -73,6 +73,10 @@ var filesCmd = &cobra.Command{ os.Exit(1) } + ctx := logging.WithLogger(context.Background()) + logger := logging.FromContext(ctx) + transport := cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport) + // Register Keystore inmemory := inmemory.NewInmemoryProvider() err = key.RegisterKeyProvider(inmemory, inmemory.Type()) @@ -122,7 +126,7 @@ var filesCmd = &cobra.Command{ emit := func(d *processor.Document) error { totalNum += 1 - if err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, csubClient); err != nil { + if err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient); err != nil { gotErr = true filesWithErrors = append(filesWithErrors, d.SourceInformation.Source) return fmt.Errorf("unable to ingest document: %w", err) @@ -154,9 +158,10 @@ var filesCmd = &cobra.Command{ }, } -func validateFilesFlags(keyPath string, keyID string, graphqlEndpoint string, csubAddr string, csubTls bool, csubTlsSkipVerify bool, args []string) (fileOptions, error) { +func validateFilesFlags(keyPath, keyID, graphqlEndpoint, headerFile, csubAddr string, csubTls, csubTlsSkipVerify bool, args []string) (fileOptions, error) { var opts fileOptions opts.graphqlEndpoint = graphqlEndpoint + opts.headerFile = headerFile if keyPath != "" { if strings.HasSuffix(keyPath, "pem") { diff --git a/cmd/guacone/cmd/gcs.go b/cmd/guacone/cmd/gcs.go index 847d7bc9d93..d2ca3bc5cc6 100644 --- a/cmd/guacone/cmd/gcs.go +++ b/cmd/guacone/cmd/gcs.go @@ -18,6 +18,7 @@ package cmd import ( "context" "fmt" + "net/http" "os" "cloud.google.com/go/storage" @@ -37,6 +38,7 @@ import ( type gcsOptions struct { graphqlEndpoint string + headerFile string csubClientOptions client.CsubClientOptions bucket string } @@ -49,15 +51,13 @@ var gcsCmd = &cobra.Command{ Example: "guacone collect gcs my-bucket --gcs-credentials-path /secret/sa.json", Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - ctx := logging.WithLogger(context.Background()) - logger := logging.FromContext(ctx) - opts, err := validateGCSFlags( viper.GetString("gql-addr"), + viper.GetString("header-file"), viper.GetString("csub-addr"), + viper.GetString(gcsCredentialsPathFlag), viper.GetBool("csub-tls"), viper.GetBool("csub-tls-skip-verify"), - viper.GetString(gcsCredentialsPathFlag), args) if err != nil { fmt.Printf("unable to validate flags: %v\n", err) @@ -65,6 +65,10 @@ var gcsCmd = &cobra.Command{ os.Exit(1) } + ctx := logging.WithLogger(context.Background()) + logger := logging.FromContext(ctx) + transport := cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport) + gcsOpts := []option.ClientOption{ option.WithUserAgent(version.UserAgent), } @@ -105,7 +109,7 @@ var gcsCmd = &cobra.Command{ emit := func(d *processor.Document) error { totalNum += 1 - err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, csubClient) + err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient) if err != nil { gotErr = true @@ -135,9 +139,10 @@ var gcsCmd = &cobra.Command{ }, } -func validateGCSFlags(gqlEndpoint string, csubAddr string, csubTls bool, csubTlsSkipVerify bool, credentialsPath string, args []string) (gcsOptions, error) { +func validateGCSFlags(gqlEndpoint, headerFile, csubAddr, credentialsPath string, csubTls, csubTlsSkipVerify bool, args []string) (gcsOptions, error) { var opts gcsOptions opts.graphqlEndpoint = gqlEndpoint + opts.headerFile = headerFile csubOpts, err := client.ValidateCsubClientFlags(csubAddr, csubTls, csubTlsSkipVerify) if err != nil { diff --git a/cmd/guacone/cmd/gcs_test.go b/cmd/guacone/cmd/gcs_test.go index c4e9594d157..cb417749766 100644 --- a/cmd/guacone/cmd/gcs_test.go +++ b/cmd/guacone/cmd/gcs_test.go @@ -62,7 +62,7 @@ func TestValidateGCSFlags(t *testing.T) { t.Setenv("GOOGLE_APPLICATION_CREDENTIALS", "/path/to/creds.json") } - o, err := validateGCSFlags("", "", false, false, tc.credentialsPath, tc.args) + o, err := validateGCSFlags("", "", "", tc.credentialsPath, false, false, tc.args) if err != nil { if tc.errorMsg != err.Error() { t.Errorf("expected error message: %s, got: %s", tc.errorMsg, err.Error()) diff --git a/cmd/guacone/cmd/github.go b/cmd/guacone/cmd/github.go index 94df8a81793..b4074b8420e 100644 --- a/cmd/guacone/cmd/github.go +++ b/cmd/guacone/cmd/github.go @@ -18,16 +18,20 @@ package cmd import ( "context" "fmt" - "github.com/guacsec/guac/pkg/cli" - "github.com/guacsec/guac/pkg/collectsub/datasource/csubsource" - "github.com/guacsec/guac/pkg/handler/processor" - "github.com/guacsec/guac/pkg/ingestor" + "net/http" "os" "strings" "sync" "syscall" "time" + "github.com/guacsec/guac/pkg/cli" + "github.com/guacsec/guac/pkg/collectsub/datasource/csubsource" + "github.com/guacsec/guac/pkg/handler/processor" + "github.com/guacsec/guac/pkg/ingestor" + + "os/signal" + "github.com/guacsec/guac/internal/client/githubclient" "github.com/guacsec/guac/pkg/collectsub/client" csubclient "github.com/guacsec/guac/pkg/collectsub/client" @@ -38,7 +42,6 @@ import ( "github.com/guacsec/guac/pkg/logging" "github.com/spf13/cobra" "github.com/spf13/viper" - "os/signal" ) const ( @@ -64,6 +67,7 @@ type githubOptions struct { csubClientOptions client.CsubClientOptions // graphql endpoint graphqlEndpoint string + headerFile string } var githubCmd = &cobra.Command{ @@ -73,10 +77,9 @@ var githubCmd = &cobra.Command{ if is "release" then [flags] release_url1 release_url2..., otherwise if is "workflow" then [flags] /.`, Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { - ctx := logging.WithLogger(context.Background()) - logger := logging.FromContext(ctx) - opts, err := validateGithubFlags( + viper.GetString("gql-addr"), + viper.GetString("header-file"), viper.GetString(githubMode), viper.GetString(githubSbom), viper.GetString(githubWorkflowFile), @@ -92,6 +95,10 @@ var githubCmd = &cobra.Command{ os.Exit(1) } + ctx := logging.WithLogger(context.Background()) + logger := logging.FromContext(ctx) + transport := cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport) + // GITHUB_TOKEN is the default token name ghc, err := githubclient.NewGithubClient(ctx, os.Getenv("GITHUB_TOKEN")) if err != nil { @@ -145,7 +152,7 @@ var githubCmd = &cobra.Command{ var errFound bool emit := func(d *processor.Document) error { - err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, csubClient) + err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient) if err != nil { errFound = true @@ -198,8 +205,10 @@ var githubCmd = &cobra.Command{ }, } -func validateGithubFlags(githubMode, sbomName, workflowFileName, csubAddr string, csubTls, csubTlsSkipVerify, useCsub, poll bool, args []string) (githubOptions, error) { +func validateGithubFlags(graphqlEndpoint, headerFile, githubMode, sbomName, workflowFileName, csubAddr string, csubTls, csubTlsSkipVerify, useCsub, poll bool, args []string) (githubOptions, error) { var opts githubOptions + opts.graphqlEndpoint = graphqlEndpoint + opts.headerFile = headerFile opts.poll = poll opts.githubMode = githubMode opts.sbomName = sbomName diff --git a/cmd/guacone/cmd/known.go b/cmd/guacone/cmd/known.go index d6fce656344..f31ba7e27af 100644 --- a/cmd/guacone/cmd/known.go +++ b/cmd/guacone/cmd/known.go @@ -102,12 +102,7 @@ var queryKnownCmd = &cobra.Command{ os.Exit(1) } - transport, err := cli.NewHTTPHeaderTransport(opts.headerFile, http.DefaultTransport) - if err != nil { - logger.Fatalf("unable to create HTTP transport: %v", err) - } - - httpClient := http.Client{Transport: transport} + httpClient := http.Client{Transport: cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport)} gqlclient := graphql.NewClient(opts.graphqlEndpoint, &httpClient) t := table.NewWriter() @@ -472,16 +467,5 @@ func validateQueryKnownFlags(graphqlEndpoint, headerFile string, args []string) } func init() { - set, err := cli.BuildFlags([]string{"header-file"}) - if err != nil { - fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err) - os.Exit(1) - } - queryKnownCmd.Flags().AddFlagSet(set) - if err := viper.BindPFlags(queryKnownCmd.Flags()); err != nil { - fmt.Fprintf(os.Stderr, "failed to bind flags: %v", err) - os.Exit(1) - } - queryCmd.AddCommand(queryKnownCmd) } diff --git a/cmd/guacone/cmd/oci.go b/cmd/guacone/cmd/oci.go index 5127670ebee..1da5629bdb8 100644 --- a/cmd/guacone/cmd/oci.go +++ b/cmd/guacone/cmd/oci.go @@ -18,9 +18,11 @@ package cmd import ( "context" "fmt" + "net/http" "os" "time" + "github.com/guacsec/guac/pkg/cli" "github.com/guacsec/guac/pkg/collectsub/client" csub_client "github.com/guacsec/guac/pkg/collectsub/client" "github.com/guacsec/guac/pkg/collectsub/datasource" @@ -37,6 +39,7 @@ import ( type ociOptions struct { graphqlEndpoint string + headerFile string dataSource datasource.CollectSource csubClientOptions client.CsubClientOptions } @@ -46,11 +49,9 @@ 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) { - ctx := logging.WithLogger(context.Background()) - logger := logging.FromContext(ctx) - opts, err := validateOCIFlags( viper.GetString("gql-addr"), + viper.GetString("header-file"), viper.GetString("csub-addr"), viper.GetBool("csub-tls"), viper.GetBool("csub-tls-skip-verify"), @@ -61,6 +62,10 @@ var ociCmd = &cobra.Command{ os.Exit(1) } + ctx := logging.WithLogger(context.Background()) + logger := logging.FromContext(ctx) + transport := cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport) + // Register collector ociCollector := oci.NewOCICollector(ctx, opts.dataSource, false, 10*time.Minute) err = collector.RegisterDocumentCollector(ociCollector, oci.OCICollector) @@ -82,7 +87,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, d, opts.graphqlEndpoint, csubClient) + err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient) if err != nil { gotErr = true @@ -112,9 +117,10 @@ var ociCmd = &cobra.Command{ }, } -func validateOCIFlags(gqlEndpoint string, csubAddr string, csubTls bool, csubTlsSkipVerify bool, args []string) (ociOptions, error) { +func validateOCIFlags(gqlEndpoint, headerFile, csubAddr string, csubTls, csubTlsSkipVerify bool, args []string) (ociOptions, error) { var opts ociOptions opts.graphqlEndpoint = gqlEndpoint + opts.headerFile = headerFile csubOpts, err := client.ValidateCsubClientFlags(csubAddr, csubTls, csubTlsSkipVerify) if err != nil { diff --git a/cmd/guacone/cmd/osv.go b/cmd/guacone/cmd/osv.go index 220c346e5a3..fd075b1475e 100644 --- a/cmd/guacone/cmd/osv.go +++ b/cmd/guacone/cmd/osv.go @@ -53,9 +53,6 @@ var osvCmd = &cobra.Command{ Use: "osv [flags]", Short: "runs the osv certifier", Run: func(cmd *cobra.Command, args []string) { - ctx := logging.WithLogger(context.Background()) - logger := logging.FromContext(ctx) - opts, err := validateOSVFlags( viper.GetString("gql-addr"), viper.GetString("header-file"), @@ -71,6 +68,10 @@ var osvCmd = &cobra.Command{ os.Exit(1) } + ctx := logging.WithLogger(context.Background()) + logger := logging.FromContext(ctx) + transport := cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport) + if err := certify.RegisterCertifier(osv.NewOSVCertificationParser, certifier.CertifierOSV); err != nil { logger.Fatalf("unable to register certifier: %v", err) } @@ -84,11 +85,6 @@ var osvCmd = &cobra.Command{ defer csubClient.Close() } - transport, err := cli.NewHTTPHeaderTransport(opts.headerFile, http.DefaultTransport) - if err != nil { - logger.Fatalf("unable to create HTTP transport: %v", err) - } - httpClient := http.Client{Transport: transport} gqlclient := graphql.NewClient(opts.graphqlEndpoint, &httpClient) packageQuery := root_package.NewPackageQuery(gqlclient, 0) @@ -110,7 +106,7 @@ var osvCmd = &cobra.Command{ select { case <-ticker.C: if len(totalDocs) > 0 { - err = ingestor.MergedIngest(ctx, totalDocs, opts.graphqlEndpoint, csubClient) + err = ingestor.MergedIngest(ctx, totalDocs, opts.graphqlEndpoint, transport, csubClient) if err != nil { stop = true atomic.StoreInt32(&gotErr, 1) @@ -123,7 +119,7 @@ var osvCmd = &cobra.Command{ totalNum += 1 totalDocs = append(totalDocs, d) if len(totalDocs) >= threshold { - err = ingestor.MergedIngest(ctx, totalDocs, opts.graphqlEndpoint, csubClient) + err = ingestor.MergedIngest(ctx, totalDocs, opts.graphqlEndpoint, transport, csubClient) if err != nil { stop = true atomic.StoreInt32(&gotErr, 1) @@ -142,7 +138,7 @@ var osvCmd = &cobra.Command{ totalNum += 1 totalDocs = append(totalDocs, <-docChan) if len(totalDocs) >= threshold { - err = ingestor.MergedIngest(ctx, totalDocs, opts.graphqlEndpoint, csubClient) + err = ingestor.MergedIngest(ctx, totalDocs, opts.graphqlEndpoint, transport, csubClient) if err != nil { atomic.StoreInt32(&gotErr, 1) logger.Errorf("unable to ingest documents: %v", err) @@ -151,7 +147,7 @@ var osvCmd = &cobra.Command{ } } if len(totalDocs) > 0 { - err = ingestor.MergedIngest(ctx, totalDocs, opts.graphqlEndpoint, csubClient) + err = ingestor.MergedIngest(ctx, totalDocs, opts.graphqlEndpoint, transport, csubClient) if err != nil { atomic.StoreInt32(&gotErr, 1) logger.Errorf("unable to ingest documents: %v", err) @@ -239,16 +235,5 @@ func validateOSVFlags( } func init() { - set, err := cli.BuildFlags([]string{"header-file"}) - if err != nil { - fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err) - os.Exit(1) - } - osvCmd.Flags().AddFlagSet(set) - if err := viper.BindPFlags(osvCmd.Flags()); err != nil { - fmt.Fprintf(os.Stderr, "failed to bind flags: %v", err) - os.Exit(1) - } - certifierCmd.AddCommand(osvCmd) } diff --git a/cmd/guacone/cmd/patch.go b/cmd/guacone/cmd/patch.go index 5f49f8c691a..3137a858d52 100644 --- a/cmd/guacone/cmd/patch.go +++ b/cmd/guacone/cmd/patch.go @@ -62,12 +62,7 @@ var queryPatchCmd = &cobra.Command{ logger.Fatalf("unable to validate flags: %s\n", err) } - transport, err := cli.NewHTTPHeaderTransport(opts.headerFile, http.DefaultTransport) - if err != nil { - logger.Fatalf("unable to create HTTP transport: %v", err) - } - - httpClient := http.Client{Transport: transport} + httpClient := http.Client{Transport: cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport)} gqlClient := graphql.NewClient(opts.graphqlEndpoint, &httpClient) var startID string @@ -304,7 +299,6 @@ func validateQueryPatchFlags( func init() { set, err := cli.BuildFlags([]string{ - "header-file", "start-purl", "stop-purl", "search-depth", diff --git a/cmd/guacone/cmd/root.go b/cmd/guacone/cmd/root.go index a56e8ddd116..b6ca9c1f8a8 100644 --- a/cmd/guacone/cmd/root.go +++ b/cmd/guacone/cmd/root.go @@ -30,7 +30,7 @@ import ( func init() { cobra.OnInitialize(cli.InitConfig) - set, err := cli.BuildFlags([]string{"gql-addr", "csub-addr", "csub-tls", "csub-tls-skip-verify"}) + set, err := cli.BuildFlags([]string{"gql-addr", "header-file", "csub-addr", "csub-tls", "csub-tls-skip-verify"}) if err != nil { fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err) os.Exit(1) diff --git a/cmd/guacone/cmd/s3.go b/cmd/guacone/cmd/s3.go index 6a6f93abd2a..bde8d540a1b 100644 --- a/cmd/guacone/cmd/s3.go +++ b/cmd/guacone/cmd/s3.go @@ -18,6 +18,7 @@ package cmd import ( "context" "fmt" + "net/http" "os" "os/signal" "sync" @@ -36,15 +37,16 @@ import ( // s3Options flags for configuring the command type s3Options struct { - s3url string // base url of the s3 to collect from - s3bucket string // name of bucket to collect from - s3item string // s3 item (only for non-polling behaviour) - region string // AWS region, for s3/sqs configuration (defaults to us-east-1) - queues string // comma-separated list of queues/topics (only for polling behaviour) - mp string // message provider name (sqs or kafka, will default to kafka) - mpEndpoint string // endpoint for the message provider (only for polling behaviour) - poll bool // polling or non-polling behaviour? (defaults to non-polling) - graphqlEndpoint string // endpoint for the graphql server + s3url string // base url of the s3 to collect from + s3bucket string // name of bucket to collect from + s3item string // s3 item (only for non-polling behaviour) + region string // AWS region, for s3/sqs configuration (defaults to us-east-1) + queues string // comma-separated list of queues/topics (only for polling behaviour) + mp string // message provider name (sqs or kafka, will default to kafka) + mpEndpoint string // endpoint for the message provider (only for polling behaviour) + poll bool // polling or non-polling behaviour? (defaults to non-polling) + graphqlEndpoint string // endpoint for the graphql server + headerFile string csubClientOptions csub_client.CsubClientOptions // options for the collectsub client } @@ -74,14 +76,10 @@ $ guacone collect s3 --s3-url http://localhost:9000 --s3-bucket guac-test --poll `, Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { - ctx := logging.WithLogger(context.Background()) - logger := logging.FromContext(ctx) - s3Opts, err := validateS3Opts( viper.GetString("gql-addr"), + viper.GetString("header-file"), viper.GetString("csub-addr"), - viper.GetBool("csub-tls"), - viper.GetBool("csub-tls-skip-verify"), viper.GetString("s3-url"), viper.GetString("s3-bucket"), viper.GetString("s3-region"), @@ -89,6 +87,8 @@ $ guacone collect s3 --s3-url http://localhost:9000 --s3-bucket guac-test --poll viper.GetString("s3-mp"), viper.GetString("s3-mp-endpoint"), viper.GetString("s3-queues"), + viper.GetBool("csub-tls"), + viper.GetBool("csub-tls-skip-verify"), viper.GetBool("poll"), ) if err != nil { @@ -97,6 +97,10 @@ $ guacone collect s3 --s3-url http://localhost:9000 --s3-bucket guac-test --poll os.Exit(1) } + ctx := logging.WithLogger(context.Background()) + logger := logging.FromContext(ctx) + transport := cli.HTTPHeaderTransport(ctx, s3Opts.headerFile, http.DefaultTransport) + signals := make(chan os.Signal, 1) signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM) @@ -126,7 +130,7 @@ $ guacone collect s3 --s3-url http://localhost:9000 --s3-bucket guac-test --poll errFound := false emit := func(d *processor.Document) error { - err := ingestor.Ingest(ctx, d, s3Opts.graphqlEndpoint, csubClient) + err := ingestor.Ingest(ctx, d, s3Opts.graphqlEndpoint, transport, csubClient) if err != nil { errFound = true @@ -172,7 +176,7 @@ $ guacone collect s3 --s3-url http://localhost:9000 --s3-bucket guac-test --poll }, } -func validateS3Opts(graphqlEndpoint string, csubAddr string, csubTls bool, csubTlsSkipVerify bool, s3url string, s3bucket string, region string, s3item string, mp string, mpEndpoint string, queues string, poll bool) (s3Options, error) { +func validateS3Opts(graphqlEndpoint, headerFile, csubAddr, s3url, s3bucket, region, s3item, mp, mpEndpoint, queues string, csubTls, csubTlsSkipVerify, poll bool) (s3Options, error) { var opts s3Options if poll { @@ -195,7 +199,7 @@ func validateS3Opts(graphqlEndpoint string, csubAddr string, csubTls bool, csubT return opts, fmt.Errorf("unable to validate csub client flags: %w", err) } - opts = s3Options{s3url, s3bucket, s3item, region, queues, mp, mpEndpoint, poll, graphqlEndpoint, csubClientOptions} + opts = s3Options{s3url, s3bucket, s3item, region, queues, mp, mpEndpoint, poll, graphqlEndpoint, headerFile, csubClientOptions} return opts, nil } diff --git a/cmd/guacone/cmd/scorecard.go b/cmd/guacone/cmd/scorecard.go index ac54cbfa0a8..8c6642917c6 100644 --- a/cmd/guacone/cmd/scorecard.go +++ b/cmd/guacone/cmd/scorecard.go @@ -54,9 +54,6 @@ var scorecardCmd = &cobra.Command{ Use: "scorecard [flags]", Short: "runs the scorecard certifier", Run: func(cmd *cobra.Command, args []string) { - ctx := logging.WithLogger(context.Background()) - logger := logging.FromContext(ctx) - opts, err := validateScorecardFlags( viper.GetString("gql-addr"), viper.GetString("header-file"), @@ -72,6 +69,10 @@ var scorecardCmd = &cobra.Command{ os.Exit(1) } + ctx := logging.WithLogger(context.Background()) + logger := logging.FromContext(ctx) + transport := cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport) + // scorecard runner is the scorecard library that runs the scorecard checks scorecardRunner, err := scorecard.NewScorecardRunner(ctx) if err != nil { @@ -89,11 +90,6 @@ var scorecardCmd = &cobra.Command{ defer csubClient.Close() } - transport, err := cli.NewHTTPHeaderTransport(opts.headerFile, http.DefaultTransport) - if err != nil { - logger.Fatalf("unable to create HTTP transport: %v", err) - } - httpClient := http.Client{Transport: transport} gqlclient := graphql.NewClient(opts.graphqlEndpoint, &httpClient) @@ -128,7 +124,7 @@ var scorecardCmd = &cobra.Command{ // Set emit function to go through the entire pipeline emit := func(d *processor.Document) error { totalNum += 1 - err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, csubClient) + err := ingestor.Ingest(ctx, d, opts.graphqlEndpoint, transport, csubClient) if err != nil { return fmt.Errorf("unable to ingest document: %v", err) @@ -207,16 +203,5 @@ func validateScorecardFlags( } func init() { - set, err := cli.BuildFlags([]string{"header-file"}) - if err != nil { - fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err) - os.Exit(1) - } - scorecardCmd.Flags().AddFlagSet(set) - if err := viper.BindPFlags(scorecardCmd.Flags()); err != nil { - fmt.Fprintf(os.Stderr, "failed to bind flags: %v", err) - os.Exit(1) - } - certifierCmd.AddCommand(scorecardCmd) } diff --git a/cmd/guacone/cmd/vulnerability.go b/cmd/guacone/cmd/vulnerability.go index 0d08fd352e8..05671ea5742 100644 --- a/cmd/guacone/cmd/vulnerability.go +++ b/cmd/guacone/cmd/vulnerability.go @@ -18,7 +18,6 @@ package cmd import ( "context" "fmt" - "log" "net/http" "os" "strings" @@ -69,12 +68,7 @@ var queryVulnCmd = &cobra.Command{ os.Exit(1) } - transport, err := cli.NewHTTPHeaderTransport(opts.headerFile, http.DefaultTransport) - if err != nil { - log.Fatalf("unable to create HTTP transport: %v", err) - } - - httpClient := http.Client{Transport: transport} + httpClient := http.Client{Transport: cli.HTTPHeaderTransport(ctx, opts.headerFile, http.DefaultTransport)} gqlclient := graphql.NewClient(opts.graphqlEndpoint, &httpClient) t := table.NewWriter() @@ -667,7 +661,7 @@ func validateQueryVulnFlags(graphqlEndpoint, headerFile, vulnID string, depth, p } func init() { - set, err := cli.BuildFlags([]string{"header-file", "vuln-id", "search-depth", "num-path"}) + set, err := cli.BuildFlags([]string{"vuln-id", "search-depth", "num-path"}) if err != nil { fmt.Fprintf(os.Stderr, "failed to setup flag: %v", err) os.Exit(1) diff --git a/cmd/guacrest/cmd/server.go b/cmd/guacrest/cmd/server.go index 5a44e14abb5..664e6e374f7 100644 --- a/cmd/guacrest/cmd/server.go +++ b/cmd/guacrest/cmd/server.go @@ -37,12 +37,7 @@ func startServer() { ctx := logging.WithLogger(context.Background()) logger := logging.FromContext(ctx) - transport, err := cli.NewHTTPHeaderTransport(flags.headerFile, http.DefaultTransport) - if err != nil { - logger.Fatalf("unable to create HTTP transport: %+v", err) - } - - httpClient := &http.Client{Transport: transport} + httpClient := &http.Client{Transport: cli.HTTPHeaderTransport(ctx, flags.headerFile, http.DefaultTransport)} gqlClient := getGraphqlServerClientOrExit(ctx, httpClient) restApiHandler := gen.Handler(gen.NewStrictHandler(server.NewDefaultServer(gqlClient), nil)) diff --git a/pkg/cli/headers.go b/pkg/cli/headers.go index f47b01b1676..96160e95460 100644 --- a/pkg/cli/headers.go +++ b/pkg/cli/headers.go @@ -15,10 +15,12 @@ package cli import ( + "context" "net/http" "os" "github.com/ProtonMail/gluon/rfc822" + "github.com/guacsec/guac/pkg/logging" ) type httpHeaderTransport struct { @@ -26,19 +28,21 @@ type httpHeaderTransport struct { http.RoundTripper } -func NewHTTPHeaderTransport(filename string, transport http.RoundTripper) (http.RoundTripper, error) { +func HTTPHeaderTransport(ctx context.Context, filename string, transport http.RoundTripper) http.RoundTripper { if filename == "" { - return transport, nil + return transport } + logger := logging.FromContext(ctx) + b, err := os.ReadFile(filename) if err != nil { - return nil, err + logger.Fatalf("error reading header file: %v", err) } rh, err := rfc822.NewHeader(b) if err != nil { - return nil, err + logger.Fatalf("error parsing header file: %v", err) } h := make(map[string][]string) @@ -46,7 +50,7 @@ func NewHTTPHeaderTransport(filename string, transport http.RoundTripper) (http. h[k] = append(h[k], v) }) - return &httpHeaderTransport{h, transport}, nil + return &httpHeaderTransport{h, transport} } func (t *httpHeaderTransport) RoundTrip(req *http.Request) (*http.Response, error) { diff --git a/pkg/cli/headers_test.go b/pkg/cli/headers_test.go index b81011575d4..b60aec7996c 100644 --- a/pkg/cli/headers_test.go +++ b/pkg/cli/headers_test.go @@ -15,18 +15,23 @@ package cli import ( + "context" "net/http" "net/http/httptest" "testing" + "github.com/guacsec/guac/pkg/logging" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.uber.org/zap" + "go.uber.org/zap/zapcore" ) -func TestNewHTTPHeaderTransport(t *testing.T) { +func TestHTTPHeaderTransport(t *testing.T) { type test struct { name string headerFile string - wantErr string + wantErr any wantHeaders map[string][]string } @@ -34,7 +39,7 @@ func TestNewHTTPHeaderTransport(t *testing.T) { { name: "creating a header transport with a non-existent file results in an error", headerFile: "does-not-exist.txt", - wantErr: "open does-not-exist.txt: no such file or directory", + wantErr: "error reading header file: open does-not-exist.txt: no such file or directory", }, { name: "creating a header transport with a valid RFC 822 header file works", @@ -54,21 +59,35 @@ func TestNewHTTPHeaderTransport(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - transport, err := NewHTTPHeaderTransport(test.headerFile, http.DefaultTransport) - if err != nil { - if err.Error() == test.wantErr { - return - } else if test.wantErr == "" { - t.Fatalf("did not want an error, but got %v", err) - } + // The zap.WithFatalHook value WriteThenPanic makes it so that instead of + // exiting on .Fatal() calls, the logger panics. You can recover from these + // panics in a goroutine, and this makes it possible to test such cases. + logging.InitLogger(logging.Debug, zap.WithFatalHook(zapcore.WriteThenPanic)) + ctx := logging.WithLogger(context.Background()) - t.Fatalf("want error %s, but got %v", test.wantErr, err) - } + var transport http.RoundTripper + recovered := make(chan any) + finished := false + + go func() { + defer func() { + recovered <- recover() + }() + + transport = HTTPHeaderTransport(ctx, test.headerFile, http.DefaultTransport) - if test.wantErr != "" { - t.Fatalf("want error %s, but got %v", test.wantErr, err) + finished = true + }() + + require.Equal(t, test.wantErr, <-recovered, "fatal error message") + + if test.wantErr != nil { + assert.False(t, finished, "call did not finish") + return } + assert.True(t, finished, "call finished") + var gotHeaders map[string][]string srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { gotHeaders = r.Header @@ -77,12 +96,12 @@ func TestNewHTTPHeaderTransport(t *testing.T) { client := http.Client{Transport: transport} - _, err = client.Get(srv.URL) + _, err := client.Get(srv.URL) if err != nil { t.Fatalf("error making test server request: %+v", err) } - assert.Equalf(t, test.wantHeaders, gotHeaders, "headers as expected") + assert.Equalf(t, test.wantHeaders, gotHeaders, "headers") }) } } diff --git a/pkg/ingestor/ingestor.go b/pkg/ingestor/ingestor.go index 34b74dd7ee7..df3848be1ec 100644 --- a/pkg/ingestor/ingestor.go +++ b/pkg/ingestor/ingestor.go @@ -18,10 +18,11 @@ package ingestor import ( "context" "fmt" - "go.uber.org/zap" "net/http" "time" + "go.uber.org/zap" + "github.com/Khan/genqlient/graphql" "github.com/guacsec/guac/pkg/assembler" "github.com/guacsec/guac/pkg/assembler/clients/helpers" @@ -35,13 +36,19 @@ import ( ) // Synchronously ingest document using GraphQL endpoint -func Ingest(ctx context.Context, d *processor.Document, graphqlEndpoint string, csubClient csub_client.Client) error { +func Ingest( + ctx context.Context, + d *processor.Document, + graphqlEndpoint string, + transport http.RoundTripper, + csubClient csub_client.Client, +) error { logger := d.ChildLogger // Get pipeline of components processorFunc := GetProcessor(ctx) ingestorFunc := GetIngestor(ctx) collectSubEmitFunc := GetCollectSubEmit(ctx, csubClient) - assemblerFunc := GetAssembler(ctx, d.ChildLogger, graphqlEndpoint) + assemblerFunc := GetAssembler(ctx, d.ChildLogger, graphqlEndpoint, transport) start := time.Now() @@ -69,13 +76,19 @@ func Ingest(ctx context.Context, d *processor.Document, graphqlEndpoint string, return nil } -func MergedIngest(ctx context.Context, docs []*processor.Document, graphqlEndpoint string, csubClient csub_client.Client) error { +func MergedIngest( + ctx context.Context, + docs []*processor.Document, + graphqlEndpoint string, + transport http.RoundTripper, + csubClient csub_client.Client, +) error { logger := logging.FromContext(ctx) // Get pipeline of components processorFunc := GetProcessor(ctx) ingestorFunc := GetIngestor(ctx) collectSubEmitFunc := GetCollectSubEmit(ctx, csubClient) - assemblerFunc := GetAssembler(ctx, logger, graphqlEndpoint) + assemblerFunc := GetAssembler(ctx, logger, graphqlEndpoint, transport) start := time.Now() @@ -152,8 +165,13 @@ func GetIngestor(ctx context.Context) func(processor.DocumentTree) ([]assembler. } } -func GetAssembler(ctx context.Context, childLogger *zap.SugaredLogger, graphqlEndpoint string) func([]assembler.IngestPredicates) error { - httpClient := http.Client{} +func GetAssembler( + ctx context.Context, + childLogger *zap.SugaredLogger, + graphqlEndpoint string, + transport http.RoundTripper, +) func([]assembler.IngestPredicates) error { + httpClient := http.Client{Transport: transport} gqlclient := graphql.NewClient(graphqlEndpoint, &httpClient) f := helpers.GetBulkAssembler(ctx, childLogger, gqlclient) return f diff --git a/pkg/logging/logger.go b/pkg/logging/logger.go index 9182db2a95a..f02c71fdd25 100644 --- a/pkg/logging/logger.go +++ b/pkg/logging/logger.go @@ -18,9 +18,10 @@ package logging import ( "context" "fmt" - "github.com/guacsec/guac/pkg/version" "strings" + "github.com/guacsec/guac/pkg/version" + "go.uber.org/zap" "go.uber.org/zap/zapcore" ) @@ -48,7 +49,7 @@ const ( type loggerKey struct{} // Initializes the logger with the input level, defaulting to Info if the input is invalid -func InitLogger(level LogLevel) { +func InitLogger(level LogLevel, opts ...zap.Option) { zapLevel, levelErr := zapcore.ParseLevel(string(level)) if levelErr != nil { zapLevel = zapcore.InfoLevel @@ -69,7 +70,7 @@ func InitLogger(level LogLevel) { _ = zapLogger.Sync() }() - logger = zapLogger.Sugar().With(guacVersion, version.Version) + logger = zapLogger.Sugar().With(guacVersion, version.Version).WithOptions(opts...) if levelErr != nil { logger.Infof("Invalid log level %s: ", level, levelErr) From 610042708ad484fee970c108cd43b6b16edab4e7 Mon Sep 17 00:00:00 2001 From: Narsimham Chelluri Date: Mon, 29 Apr 2024 10:00:42 -0300 Subject: [PATCH 17/17] Make the CSub GetCollectEntries() RPC response streaming (#1865) * Fix Makefile proto target - The deps.dev API proto file was removed in a6c67d3f96454921f031bb166561935ea4f3345b Signed-off-by: Narsimham Chelluri (Narsa) * Make GetCollectEntries() rpc have a streaming response - also fix typo in CollectSubscriberServiceClient name Signed-off-by: Narsimham Chelluri (Narsa) * Bump up response message size - In my testing the message size gets too big at ~55K pURLs. - So I bumped message size up from 1K entries to 15K entries. This should allow plenty of room for large data source entries and also still result in far fewer roundtrips. Signed-off-by: Narsimham Chelluri (Narsa) * Add missing header comments Signed-off-by: Narsimham Chelluri (Narsa) * Make cb error more descriptive Signed-off-by: Narsimham Chelluri (Narsa) --------- Signed-off-by: Narsimham Chelluri (Narsa) --- Makefile | 3 - pkg/collectsub/client/client.go | 19 ++- pkg/collectsub/collectsub/collectsub.pb.go | 66 ++++---- pkg/collectsub/collectsub/collectsub.proto | 7 +- .../collectsub/collectsub_grpc.pb.go | 142 +++++++++++------- pkg/collectsub/server/server.go | 29 ++-- pkg/misc/slice/chunk.go | 33 ++++ pkg/misc/slice/chunk_test.go | 91 +++++++++++ 8 files changed, 279 insertions(+), 111 deletions(-) create mode 100644 pkg/misc/slice/chunk.go create mode 100644 pkg/misc/slice/chunk_test.go diff --git a/Makefile b/Makefile index 46ac3713655..7623ee37187 100644 --- a/Makefile +++ b/Makefile @@ -78,9 +78,6 @@ proto: protoc --go_out=. --go_opt=paths=source_relative \ --go-grpc_out=. --go-grpc_opt=paths=source_relative \ pkg/collectsub/collectsub/collectsub.proto - protoc --go_out=. --go_opt=paths=source_relative \ - --go-grpc_out=. --go-grpc_opt=paths=source_relative \ - pkg/handler/collector/deps_dev/internal/api.proto # Remove temporary files .PHONY: clean diff --git a/pkg/collectsub/client/client.go b/pkg/collectsub/client/client.go index eb63ee7d6f5..a05a1f64ea3 100644 --- a/pkg/collectsub/client/client.go +++ b/pkg/collectsub/client/client.go @@ -20,6 +20,7 @@ import ( "crypto/tls" "crypto/x509" "fmt" + "io" pb "github.com/guacsec/guac/pkg/collectsub/collectsub" "google.golang.org/grpc" @@ -34,7 +35,7 @@ type Client interface { } type client struct { - client pb.ColectSubscriberServiceClient + client pb.CollectSubscriberServiceClient conn *grpc.ClientConn } @@ -72,7 +73,7 @@ func NewClient(opts CsubClientOptions) (Client, error) { if err != nil { return nil, err } - c := pb.NewColectSubscriberServiceClient(conn) + c := pb.NewCollectSubscriberServiceClient(conn) return &client{ client: c, @@ -92,7 +93,7 @@ func (c *client) AddCollectEntries(ctx context.Context, entries []*pb.CollectEnt return err } if !res.Success { - return fmt.Errorf("add collect entry unsuccessful") + return fmt.Errorf("add collect entries unsuccessful") } return nil } @@ -105,5 +106,15 @@ func (c *client) GetCollectEntries(ctx context.Context, filters []*pb.CollectEnt return nil, err } - return res.Entries, nil + var allEntries []*pb.CollectEntry + for { + entries, err := res.Recv() + if err == io.EOF { + return allEntries, nil + } else if err != nil { + return nil, err + } + + allEntries = append(allEntries, entries.Entries...) + } } diff --git a/pkg/collectsub/collectsub/collectsub.pb.go b/pkg/collectsub/collectsub/collectsub.pb.go index 46667aebd5c..f3005ecfa65 100644 --- a/pkg/collectsub/collectsub/collectsub.pb.go +++ b/pkg/collectsub/collectsub/collectsub.pb.go @@ -15,8 +15,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.4 +// protoc-gen-go v1.28.1 +// protoc v5.26.1 // source: pkg/collectsub/collectsub/collectsub.proto package collectsub @@ -154,7 +154,7 @@ func (x *CollectEntry) GetSinceTime() int64 { return 0 } -// rpc AddCollectEntry +// rpc AddCollectEntries type AddCollectEntriesRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -466,32 +466,32 @@ var file_pkg_collectsub_collectsub_collectsub_proto_rawDesc = []byte{ 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, 0xcf, 0x02, - 0x0a, 0x17, 0x43, 0x6f, 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, 0x98, 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, 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, + 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, } var ( @@ -523,10 +523,10 @@ var file_pkg_collectsub_collectsub_collectsub_proto_depIdxs = []int32{ 0, // 2: guacsec.guac.collect_subscriber.schema.CollectEntryFilter.type:type_name -> guacsec.guac.collect_subscriber.schema.CollectDataType 4, // 3: guacsec.guac.collect_subscriber.schema.GetCollectEntriesRequest.filters:type_name -> guacsec.guac.collect_subscriber.schema.CollectEntryFilter 1, // 4: guacsec.guac.collect_subscriber.schema.GetCollectEntriesResponse.entries:type_name -> guacsec.guac.collect_subscriber.schema.CollectEntry - 2, // 5: guacsec.guac.collect_subscriber.schema.ColectSubscriberService.AddCollectEntries:input_type -> guacsec.guac.collect_subscriber.schema.AddCollectEntriesRequest - 5, // 6: guacsec.guac.collect_subscriber.schema.ColectSubscriberService.GetCollectEntries:input_type -> guacsec.guac.collect_subscriber.schema.GetCollectEntriesRequest - 3, // 7: guacsec.guac.collect_subscriber.schema.ColectSubscriberService.AddCollectEntries:output_type -> guacsec.guac.collect_subscriber.schema.AddCollectEntriesResponse - 6, // 8: guacsec.guac.collect_subscriber.schema.ColectSubscriberService.GetCollectEntries:output_type -> guacsec.guac.collect_subscriber.schema.GetCollectEntriesResponse + 2, // 5: guacsec.guac.collect_subscriber.schema.CollectSubscriberService.AddCollectEntries:input_type -> guacsec.guac.collect_subscriber.schema.AddCollectEntriesRequest + 5, // 6: guacsec.guac.collect_subscriber.schema.CollectSubscriberService.GetCollectEntries:input_type -> guacsec.guac.collect_subscriber.schema.GetCollectEntriesRequest + 3, // 7: guacsec.guac.collect_subscriber.schema.CollectSubscriberService.AddCollectEntries:output_type -> guacsec.guac.collect_subscriber.schema.AddCollectEntriesResponse + 6, // 8: guacsec.guac.collect_subscriber.schema.CollectSubscriberService.GetCollectEntries:output_type -> guacsec.guac.collect_subscriber.schema.GetCollectEntriesResponse 7, // [7:9] is the sub-list for method output_type 5, // [5:7] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name diff --git a/pkg/collectsub/collectsub/collectsub.proto b/pkg/collectsub/collectsub/collectsub.proto index a42537bfff7..a45b6756f9d 100644 --- a/pkg/collectsub/collectsub/collectsub.proto +++ b/pkg/collectsub/collectsub/collectsub.proto @@ -33,7 +33,7 @@ message CollectEntry { int64 since_time = 3; } -// rpc AddCollectEntry +// rpc AddCollectEntries message AddCollectEntriesRequest { repeated CollectEntry entries = 1; } @@ -42,7 +42,6 @@ message AddCollectEntriesResponse { bool success = 1; } - // rpc GetCollectEntries message CollectEntryFilter { CollectDataType type = 1; @@ -59,7 +58,7 @@ message GetCollectEntriesResponse { repeated CollectEntry entries = 1; } -service ColectSubscriberService { +service CollectSubscriberService { rpc AddCollectEntries(AddCollectEntriesRequest) returns (AddCollectEntriesResponse); - rpc GetCollectEntries (GetCollectEntriesRequest) returns (GetCollectEntriesResponse); + rpc GetCollectEntries (GetCollectEntriesRequest) returns (stream GetCollectEntriesResponse); } diff --git a/pkg/collectsub/collectsub/collectsub_grpc.pb.go b/pkg/collectsub/collectsub/collectsub_grpc.pb.go index 77020464020..a15daa1c9bc 100644 --- a/pkg/collectsub/collectsub/collectsub_grpc.pb.go +++ b/pkg/collectsub/collectsub/collectsub_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.2.0 -// - protoc v4.23.4 +// - protoc v5.26.1 // source: pkg/collectsub/collectsub/collectsub.proto package collectsub @@ -18,125 +18,153 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 -// ColectSubscriberServiceClient is the client API for ColectSubscriberService service. +// CollectSubscriberServiceClient is the client API for CollectSubscriberService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type ColectSubscriberServiceClient interface { +type CollectSubscriberServiceClient interface { AddCollectEntries(ctx context.Context, in *AddCollectEntriesRequest, opts ...grpc.CallOption) (*AddCollectEntriesResponse, error) - GetCollectEntries(ctx context.Context, in *GetCollectEntriesRequest, opts ...grpc.CallOption) (*GetCollectEntriesResponse, error) + GetCollectEntries(ctx context.Context, in *GetCollectEntriesRequest, opts ...grpc.CallOption) (CollectSubscriberService_GetCollectEntriesClient, error) } -type colectSubscriberServiceClient struct { +type collectSubscriberServiceClient struct { cc grpc.ClientConnInterface } -func NewColectSubscriberServiceClient(cc grpc.ClientConnInterface) ColectSubscriberServiceClient { - return &colectSubscriberServiceClient{cc} +func NewCollectSubscriberServiceClient(cc grpc.ClientConnInterface) CollectSubscriberServiceClient { + return &collectSubscriberServiceClient{cc} } -func (c *colectSubscriberServiceClient) AddCollectEntries(ctx context.Context, in *AddCollectEntriesRequest, opts ...grpc.CallOption) (*AddCollectEntriesResponse, error) { +func (c *collectSubscriberServiceClient) AddCollectEntries(ctx context.Context, in *AddCollectEntriesRequest, opts ...grpc.CallOption) (*AddCollectEntriesResponse, error) { out := new(AddCollectEntriesResponse) - err := c.cc.Invoke(ctx, "/guacsec.guac.collect_subscriber.schema.ColectSubscriberService/AddCollectEntries", in, out, opts...) + err := c.cc.Invoke(ctx, "/guacsec.guac.collect_subscriber.schema.CollectSubscriberService/AddCollectEntries", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *colectSubscriberServiceClient) GetCollectEntries(ctx context.Context, in *GetCollectEntriesRequest, opts ...grpc.CallOption) (*GetCollectEntriesResponse, error) { - out := new(GetCollectEntriesResponse) - err := c.cc.Invoke(ctx, "/guacsec.guac.collect_subscriber.schema.ColectSubscriberService/GetCollectEntries", in, out, opts...) +func (c *collectSubscriberServiceClient) GetCollectEntries(ctx context.Context, in *GetCollectEntriesRequest, opts ...grpc.CallOption) (CollectSubscriberService_GetCollectEntriesClient, error) { + stream, err := c.cc.NewStream(ctx, &CollectSubscriberService_ServiceDesc.Streams[0], "/guacsec.guac.collect_subscriber.schema.CollectSubscriberService/GetCollectEntries", opts...) if err != nil { return nil, err } - return out, nil + x := &collectSubscriberServiceGetCollectEntriesClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type CollectSubscriberService_GetCollectEntriesClient interface { + Recv() (*GetCollectEntriesResponse, error) + grpc.ClientStream } -// ColectSubscriberServiceServer is the server API for ColectSubscriberService service. -// All implementations must embed UnimplementedColectSubscriberServiceServer +type collectSubscriberServiceGetCollectEntriesClient struct { + grpc.ClientStream +} + +func (x *collectSubscriberServiceGetCollectEntriesClient) Recv() (*GetCollectEntriesResponse, error) { + m := new(GetCollectEntriesResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// CollectSubscriberServiceServer is the server API for CollectSubscriberService service. +// All implementations must embed UnimplementedCollectSubscriberServiceServer // for forward compatibility -type ColectSubscriberServiceServer interface { +type CollectSubscriberServiceServer interface { AddCollectEntries(context.Context, *AddCollectEntriesRequest) (*AddCollectEntriesResponse, error) - GetCollectEntries(context.Context, *GetCollectEntriesRequest) (*GetCollectEntriesResponse, error) - mustEmbedUnimplementedColectSubscriberServiceServer() + GetCollectEntries(*GetCollectEntriesRequest, CollectSubscriberService_GetCollectEntriesServer) error + mustEmbedUnimplementedCollectSubscriberServiceServer() } -// UnimplementedColectSubscriberServiceServer must be embedded to have forward compatible implementations. -type UnimplementedColectSubscriberServiceServer struct { +// UnimplementedCollectSubscriberServiceServer must be embedded to have forward compatible implementations. +type UnimplementedCollectSubscriberServiceServer struct { } -func (UnimplementedColectSubscriberServiceServer) AddCollectEntries(context.Context, *AddCollectEntriesRequest) (*AddCollectEntriesResponse, error) { +func (UnimplementedCollectSubscriberServiceServer) AddCollectEntries(context.Context, *AddCollectEntriesRequest) (*AddCollectEntriesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddCollectEntries not implemented") } -func (UnimplementedColectSubscriberServiceServer) GetCollectEntries(context.Context, *GetCollectEntriesRequest) (*GetCollectEntriesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetCollectEntries not implemented") +func (UnimplementedCollectSubscriberServiceServer) GetCollectEntries(*GetCollectEntriesRequest, CollectSubscriberService_GetCollectEntriesServer) error { + return status.Errorf(codes.Unimplemented, "method GetCollectEntries not implemented") } -func (UnimplementedColectSubscriberServiceServer) mustEmbedUnimplementedColectSubscriberServiceServer() { +func (UnimplementedCollectSubscriberServiceServer) mustEmbedUnimplementedCollectSubscriberServiceServer() { } -// UnsafeColectSubscriberServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ColectSubscriberServiceServer will +// UnsafeCollectSubscriberServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to CollectSubscriberServiceServer will // result in compilation errors. -type UnsafeColectSubscriberServiceServer interface { - mustEmbedUnimplementedColectSubscriberServiceServer() +type UnsafeCollectSubscriberServiceServer interface { + mustEmbedUnimplementedCollectSubscriberServiceServer() } -func RegisterColectSubscriberServiceServer(s grpc.ServiceRegistrar, srv ColectSubscriberServiceServer) { - s.RegisterService(&ColectSubscriberService_ServiceDesc, srv) +func RegisterCollectSubscriberServiceServer(s grpc.ServiceRegistrar, srv CollectSubscriberServiceServer) { + s.RegisterService(&CollectSubscriberService_ServiceDesc, srv) } -func _ColectSubscriberService_AddCollectEntries_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _CollectSubscriberService_AddCollectEntries_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(AddCollectEntriesRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ColectSubscriberServiceServer).AddCollectEntries(ctx, in) + return srv.(CollectSubscriberServiceServer).AddCollectEntries(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/guacsec.guac.collect_subscriber.schema.ColectSubscriberService/AddCollectEntries", + FullMethod: "/guacsec.guac.collect_subscriber.schema.CollectSubscriberService/AddCollectEntries", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ColectSubscriberServiceServer).AddCollectEntries(ctx, req.(*AddCollectEntriesRequest)) + return srv.(CollectSubscriberServiceServer).AddCollectEntries(ctx, req.(*AddCollectEntriesRequest)) } return interceptor(ctx, in, info, handler) } -func _ColectSubscriberService_GetCollectEntries_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetCollectEntriesRequest) - if err := dec(in); err != nil { - return nil, err +func _CollectSubscriberService_GetCollectEntries_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(GetCollectEntriesRequest) + if err := stream.RecvMsg(m); err != nil { + return err } - if interceptor == nil { - return srv.(ColectSubscriberServiceServer).GetCollectEntries(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/guacsec.guac.collect_subscriber.schema.ColectSubscriberService/GetCollectEntries", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ColectSubscriberServiceServer).GetCollectEntries(ctx, req.(*GetCollectEntriesRequest)) - } - return interceptor(ctx, in, info, handler) + return srv.(CollectSubscriberServiceServer).GetCollectEntries(m, &collectSubscriberServiceGetCollectEntriesServer{stream}) } -// ColectSubscriberService_ServiceDesc is the grpc.ServiceDesc for ColectSubscriberService service. +type CollectSubscriberService_GetCollectEntriesServer interface { + Send(*GetCollectEntriesResponse) error + grpc.ServerStream +} + +type collectSubscriberServiceGetCollectEntriesServer struct { + grpc.ServerStream +} + +func (x *collectSubscriberServiceGetCollectEntriesServer) Send(m *GetCollectEntriesResponse) error { + return x.ServerStream.SendMsg(m) +} + +// CollectSubscriberService_ServiceDesc is the grpc.ServiceDesc for CollectSubscriberService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var ColectSubscriberService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "guacsec.guac.collect_subscriber.schema.ColectSubscriberService", - HandlerType: (*ColectSubscriberServiceServer)(nil), +var CollectSubscriberService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "guacsec.guac.collect_subscriber.schema.CollectSubscriberService", + HandlerType: (*CollectSubscriberServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "AddCollectEntries", - Handler: _ColectSubscriberService_AddCollectEntries_Handler, + Handler: _CollectSubscriberService_AddCollectEntries_Handler, }, + }, + Streams: []grpc.StreamDesc{ { - MethodName: "GetCollectEntries", - Handler: _ColectSubscriberService_GetCollectEntries_Handler, + StreamName: "GetCollectEntries", + Handler: _CollectSubscriberService_GetCollectEntries_Handler, + ServerStreams: true, }, }, - Streams: []grpc.StreamDesc{}, Metadata: "pkg/collectsub/collectsub/collectsub.proto", } diff --git a/pkg/collectsub/server/server.go b/pkg/collectsub/server/server.go index 6e10e08947d..bcc8d34a3e9 100644 --- a/pkg/collectsub/server/server.go +++ b/pkg/collectsub/server/server.go @@ -25,10 +25,12 @@ import ( grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" grpc_zap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap" "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" + "github.com/guacsec/guac/pkg/collectsub/collectsub" pb "github.com/guacsec/guac/pkg/collectsub/collectsub" "github.com/guacsec/guac/pkg/collectsub/server/db/simpledb" db "github.com/guacsec/guac/pkg/collectsub/server/db/types" "github.com/guacsec/guac/pkg/logging" + "github.com/guacsec/guac/pkg/misc/slice" "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/credentials" @@ -36,7 +38,7 @@ import ( ) type server struct { - pb.UnimplementedColectSubscriberServiceServer + pb.UnimplementedCollectSubscriberServiceServer // Db points to the backend DB, public for mocking testing purposes. Db db.CollectSubscriberDb @@ -65,7 +67,7 @@ func (s *server) AddCollectEntries(ctx context.Context, in *pb.AddCollectEntries err := s.Db.AddCollectEntries(ctx, in.Entries) if err != nil { - return nil, fmt.Errorf("failed to add entry to db: %w", err) + return nil, fmt.Errorf("failed to add entries to db: %w", err) } logger.Infof("AddCollectEntries added %d entries", len(in.Entries)) @@ -74,19 +76,26 @@ func (s *server) AddCollectEntries(ctx context.Context, in *pb.AddCollectEntries }, nil } -func (s *server) GetCollectEntries(ctx context.Context, in *pb.GetCollectEntriesRequest) (*pb.GetCollectEntriesResponse, error) { +func (s *server) GetCollectEntries(in *pb.GetCollectEntriesRequest, out collectsub.CollectSubscriberService_GetCollectEntriesServer) error { + ctx := out.Context() + logger := ctxzap.Extract(ctx).Sugar() logger.Debugf("GetCollectEntries called with filters: %v", in.Filters) - ret, err := s.Db.GetCollectEntries(ctx, in.Filters, in.SinceTime) + entries, err := s.Db.GetCollectEntries(ctx, in.Filters, in.SinceTime) if err != nil { - return nil, fmt.Errorf("failed to get collect entries from db: %w", err) + return fmt.Errorf("failed to get collect entries from db: %w", err) } - logger.Infof("GetCollectEntries returning %d entries", len(ret)) + logger.Infof("GetCollectEntries returning %d entries", len(entries)) - return &pb.GetCollectEntriesResponse{ - Entries: ret, - }, nil + err = slice.Chunk(entries, 15_000, func(subslice []*pb.CollectEntry) error { + return out.Send(&pb.GetCollectEntriesResponse{Entries: subslice}) + }) + if err != nil { + return fmt.Errorf("failed to write entries to client stream: %w", err) + } + + return nil } func contextPropagationUnaryServerInterceptor() grpc.UnaryServerInterceptor { @@ -146,7 +155,7 @@ func (s *server) Serve(ctx context.Context) error { gs := grpc.NewServer(opts...) - pb.RegisterColectSubscriberServiceServer(gs, s) + pb.RegisterCollectSubscriberServiceServer(gs, s) var wg sync.WaitGroup var retErr error diff --git a/pkg/misc/slice/chunk.go b/pkg/misc/slice/chunk.go new file mode 100644 index 00000000000..7493eba83a3 --- /dev/null +++ b/pkg/misc/slice/chunk.go @@ -0,0 +1,33 @@ +// +// Copyright 2024 The GUAC Authors. +// +// 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 slice + +import "fmt" + +func Chunk[T any](slice []T, maxChunkSize int, cb func([]T) error) error { + for start := 0; start < len(slice); start += maxChunkSize { + end := start + maxChunkSize + if end > len(slice) { + end = len(slice) + } + + if err := cb(slice[start:end]); err != nil { + return fmt.Errorf("error running chunk callback on input slice[%d:%d]: %w", start, end, err) + } + } + + return nil +} diff --git a/pkg/misc/slice/chunk_test.go b/pkg/misc/slice/chunk_test.go new file mode 100644 index 00000000000..7a1bcb55e55 --- /dev/null +++ b/pkg/misc/slice/chunk_test.go @@ -0,0 +1,91 @@ +// Copyright 2024 The GUAC Authors. +// +// 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 slice + +import ( + "errors" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestChunk(t *testing.T) { + t.Run("error case", func(t *testing.T) { + wantErr := errors.New("some error") + err := Chunk([]uint{0, 1, 2}, 2, func([]uint) error { + return wantErr + }) + + assert.Equal(t, "error running chunk callback on input slice[0:2]: some error", err.Error()) + assert.True(t, errors.Is(err, wantErr)) + }) + + tests := []struct { + name string + input []uint + want [][]uint + }{ + {}, + { + name: "nil slice", + input: nil, + want: nil, + }, + { + name: "empty slice", + input: []uint{}, + want: nil, + }, + { + name: "one element slice", + input: []uint{0}, + want: [][]uint{{0}}, + }, + { + name: "two element slice", + input: []uint{0, 1}, + want: [][]uint{{0, 1}}, + }, + { + name: "three element slice", + input: []uint{0, 1, 2}, + want: [][]uint{{0, 1}, {2}}, + }, + { + name: "four element slice", + input: []uint{0, 1, 2, 3}, + want: [][]uint{{0, 1}, {2, 3}}, + }, + { + name: "five element slice", + input: []uint{0, 1, 2, 3, 4}, + want: [][]uint{{0, 1}, {2, 3}, {4}}, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + var got [][]uint + err := Chunk(test.input, 2, func(subslice []uint) error { + got = append(got, subslice) + return nil + }) + + assert.NoError(t, err) + + assert.Equal(t, test.want, got) + }) + } +}