backend

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2024 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Batch size for ingesting in bulk. Increasing this could results in "PostgreSQL only supports 65535 parameters" error
	MaxBatchSize = 5000
)
View Source
const (
	NoVuln = "novuln"
)

Variables

View Source
var Errorf = gqlerror.Errorf

Functions

func GetBackend

func GetBackend(client *ent.Client) (backends.Backend, error)

func GetReadOnlyClient added in v0.8.0

func GetReadOnlyClient(ctx context.Context, options *BackendOptions) (*ent.Client, error)

GetReadOnlyClient sets up the ent backend and returns a read-only client.

func IDEQ

func IDEQ(id string) func(*sql.Selector)

func NoOpSelector

func NoOpSelector() func(*sql.Selector)

func SetupBackend

func SetupBackend(ctx context.Context, options *BackendOptions) (*ent.Client, error)

SetupBackend sets up the ent backend, preparing the database and returning a client

func WithinTX

func WithinTX[T any](ctx context.Context, entClient *ent.Client, exec func(ctx context.Context) (*T, error)) (*T, error)

Types

type BackendOptions

type BackendOptions struct {
	DriverName  string
	Address     string
	Debug       bool
	AutoMigrate bool
	// sets the maximum amount of time a connection may be reused.
	// If nil, this is set to default of 0
	ConnectionMaxLifeTime *time.Duration
}

type EntBackend

type EntBackend struct {
	// contains filtered or unexported fields
}

func (*EntBackend) Artifacts

func (b *EntBackend) Artifacts(ctx context.Context, artifactSpec *model.ArtifactSpec) ([]*model.Artifact, error)

func (*EntBackend) ArtifactsList added in v0.6.0

func (b *EntBackend) ArtifactsList(ctx context.Context, artifactSpec model.ArtifactSpec, after *string, first *int) (*model.ArtifactConnection, error)

func (*EntBackend) Builders

func (b *EntBackend) Builders(ctx context.Context, builderSpec *model.BuilderSpec) ([]*model.Builder, error)

func (*EntBackend) BuildersList added in v0.6.0

func (b *EntBackend) BuildersList(ctx context.Context, builderSpec model.BuilderSpec, after *string, first *int) (*model.BuilderConnection, error)

func (*EntBackend) CertifyBad

func (b *EntBackend) CertifyBad(ctx context.Context, filter *model.CertifyBadSpec) ([]*model.CertifyBad, error)

func (*EntBackend) CertifyBadList added in v0.6.0

func (b *EntBackend) CertifyBadList(ctx context.Context, filter model.CertifyBadSpec, after *string, first *int) (*model.CertifyBadConnection, error)

func (*EntBackend) CertifyGood

func (b *EntBackend) CertifyGood(ctx context.Context, filter *model.CertifyGoodSpec) ([]*model.CertifyGood, error)

func (*EntBackend) CertifyGoodList added in v0.6.0

func (b *EntBackend) CertifyGoodList(ctx context.Context, filter model.CertifyGoodSpec, after *string, first *int) (*model.CertifyGoodConnection, error)

func (*EntBackend) CertifyLegal

func (b *EntBackend) CertifyLegal(ctx context.Context, spec *model.CertifyLegalSpec) ([]*model.CertifyLegal, error)

func (*EntBackend) CertifyLegalList added in v0.6.0

func (b *EntBackend) CertifyLegalList(ctx context.Context, spec model.CertifyLegalSpec, after *string, first *int) (*model.CertifyLegalConnection, error)

func (*EntBackend) CertifyVEXStatement

func (b *EntBackend) CertifyVEXStatement(ctx context.Context, spec *model.CertifyVEXStatementSpec) ([]*model.CertifyVEXStatement, error)

func (*EntBackend) CertifyVEXStatementList added in v0.6.0

func (b *EntBackend) CertifyVEXStatementList(ctx context.Context, spec model.CertifyVEXStatementSpec, after *string, first *int) (*model.VEXConnection, error)

func (*EntBackend) CertifyVuln

func (b *EntBackend) CertifyVuln(ctx context.Context, spec *model.CertifyVulnSpec) ([]*model.CertifyVuln, error)

func (*EntBackend) CertifyVulnList added in v0.6.0

func (b *EntBackend) CertifyVulnList(ctx context.Context, spec model.CertifyVulnSpec, after *string, first *int) (*model.CertifyVulnConnection, error)

func (*EntBackend) Delete added in v0.8.0

func (b *EntBackend) Delete(ctx context.Context, node string) (bool, error)

Delete node and all associated relationships. This functionality is only implemented for certifyVuln, HasSBOM and HasSLSA.

func (*EntBackend) FindPackagesThatNeedScanning added in v0.10.0

func (b *EntBackend) FindPackagesThatNeedScanning(ctx context.Context, queryType model.QueryType, lastScan *int) ([]string, error)

func (*EntBackend) FindSoftware

func (b *EntBackend) FindSoftware(ctx context.Context, searchText string) ([]model.PackageSourceOrArtifact, error)

Warning: This is an EXPERIMENTAL feature. This is subject to change. Warning: This is an OPTIONAL feature. Backends are not required to implement this API.

func (*EntBackend) FindSoftwareList added in v0.6.0

func (b *EntBackend) FindSoftwareList(ctx context.Context, searchText string, after *string, first *int) (*model.FindSoftwareConnection, error)

func (*EntBackend) HasMetadata added in v0.2.1

func (b *EntBackend) HasMetadata(ctx context.Context, filter *model.HasMetadataSpec) ([]*model.HasMetadata, error)

func (*EntBackend) HasMetadataList added in v0.6.0

func (b *EntBackend) HasMetadataList(ctx context.Context, spec model.HasMetadataSpec, after *string, first *int) (*model.HasMetadataConnection, error)

func (*EntBackend) HasSBOM

func (b *EntBackend) HasSBOM(ctx context.Context, spec *model.HasSBOMSpec) ([]*model.HasSbom, error)

func (*EntBackend) HasSBOMList added in v0.6.0

func (b *EntBackend) HasSBOMList(ctx context.Context, spec model.HasSBOMSpec, after *string, first *int) (*model.HasSBOMConnection, error)

func (*EntBackend) HasSLSAList added in v0.6.0

func (b *EntBackend) HasSLSAList(ctx context.Context, spec model.HasSLSASpec, after *string, first *int) (*model.HasSLSAConnection, error)

func (*EntBackend) HasSlsa

func (b *EntBackend) HasSlsa(ctx context.Context, spec *model.HasSLSASpec) ([]*model.HasSlsa, error)

func (*EntBackend) HasSourceAt

func (b *EntBackend) HasSourceAt(ctx context.Context, filter *model.HasSourceAtSpec) ([]*model.HasSourceAt, error)

func (*EntBackend) HasSourceAtList added in v0.6.0

func (b *EntBackend) HasSourceAtList(ctx context.Context, spec model.HasSourceAtSpec, after *string, first *int) (*model.HasSourceAtConnection, error)

func (*EntBackend) HashEqual

func (b *EntBackend) HashEqual(ctx context.Context, spec *model.HashEqualSpec) ([]*model.HashEqual, error)

func (*EntBackend) HashEqualList added in v0.6.0

func (b *EntBackend) HashEqualList(ctx context.Context, spec model.HashEqualSpec, after *string, first *int) (*model.HashEqualConnection, error)

func (*EntBackend) IngestArtifact

func (b *EntBackend) IngestArtifact(ctx context.Context, art *model.IDorArtifactInput) (string, error)

func (*EntBackend) IngestArtifacts

func (b *EntBackend) IngestArtifacts(ctx context.Context, artifacts []*model.IDorArtifactInput) ([]string, error)

func (*EntBackend) IngestBuilder

func (b *EntBackend) IngestBuilder(ctx context.Context, build *model.IDorBuilderInput) (string, error)

func (*EntBackend) IngestBuilders

func (b *EntBackend) IngestBuilders(ctx context.Context, builders []*model.IDorBuilderInput) ([]string, error)

func (*EntBackend) IngestBulkHasMetadata added in v0.2.1

func (b *EntBackend) IngestBulkHasMetadata(ctx context.Context, subjects model.PackageSourceOrArtifactInputs, pkgMatchType *model.MatchFlags, hasMetadataList []*model.HasMetadataInputSpec) ([]string, error)

func (*EntBackend) IngestBulkVulnerabilityMetadata added in v0.4.0

func (b *EntBackend) IngestBulkVulnerabilityMetadata(ctx context.Context, vulnerabilities []*model.IDorVulnerabilityInput, vulnerabilityMetadataList []*model.VulnerabilityMetadataInputSpec) ([]string, error)

func (*EntBackend) IngestCertifyBad

func (b *EntBackend) IngestCertifyBad(ctx context.Context, subject model.PackageSourceOrArtifactInput, pkgMatchType *model.MatchFlags, spec model.CertifyBadInputSpec) (string, error)

func (*EntBackend) IngestCertifyBads

func (b *EntBackend) IngestCertifyBads(ctx context.Context, subjects model.PackageSourceOrArtifactInputs, pkgMatchType *model.MatchFlags, certifyBads []*model.CertifyBadInputSpec) ([]string, error)

func (*EntBackend) IngestCertifyGood

func (b *EntBackend) IngestCertifyGood(ctx context.Context, subject model.PackageSourceOrArtifactInput, pkgMatchType *model.MatchFlags, spec model.CertifyGoodInputSpec) (string, error)

func (*EntBackend) IngestCertifyGoods

func (b *EntBackend) IngestCertifyGoods(ctx context.Context, subjects model.PackageSourceOrArtifactInputs, pkgMatchType *model.MatchFlags, certifyGoods []*model.CertifyGoodInputSpec) ([]string, error)

func (*EntBackend) IngestCertifyLegal

func (b *EntBackend) IngestCertifyLegal(ctx context.Context, subject model.PackageOrSourceInput, declaredLicenses []*model.IDorLicenseInput, discoveredLicenses []*model.IDorLicenseInput, spec *model.CertifyLegalInputSpec) (string, error)

func (*EntBackend) IngestCertifyLegals

func (b *EntBackend) IngestCertifyLegals(ctx context.Context, subjects model.PackageOrSourceInputs, declaredLicensesList [][]*model.IDorLicenseInput, discoveredLicensesList [][]*model.IDorLicenseInput, certifyLegals []*model.CertifyLegalInputSpec) ([]string, error)

func (*EntBackend) IngestCertifyVuln

func (b *EntBackend) IngestCertifyVuln(ctx context.Context, pkg model.IDorPkgInput, vulnerability model.IDorVulnerabilityInput, certifyVuln model.ScanMetadataInput) (string, error)

func (*EntBackend) IngestCertifyVulns

func (b *EntBackend) IngestCertifyVulns(ctx context.Context, pkgs []*model.IDorPkgInput, vulnerabilities []*model.IDorVulnerabilityInput, certifyVulns []*model.ScanMetadataInput) ([]string, error)

func (*EntBackend) IngestDependencies

func (b *EntBackend) IngestDependencies(ctx context.Context, pkgs []*model.IDorPkgInput, depPkgs []*model.IDorPkgInput, dependencies []*model.IsDependencyInputSpec) ([]string, error)

func (*EntBackend) IngestDependency

func (b *EntBackend) IngestDependency(ctx context.Context, pkg model.IDorPkgInput, depPkg model.IDorPkgInput, dep model.IsDependencyInputSpec) (string, error)

func (*EntBackend) IngestHasMetadata added in v0.2.1

func (b *EntBackend) IngestHasMetadata(ctx context.Context, subject model.PackageSourceOrArtifactInput, pkgMatchType *model.MatchFlags, hasMetadata model.HasMetadataInputSpec) (string, error)

func (*EntBackend) IngestHasSBOMs

func (b *EntBackend) IngestHasSBOMs(ctx context.Context, subjects model.PackageOrArtifactInputs, hasSBOMs []*model.HasSBOMInputSpec, includes []*model.HasSBOMIncludesInputSpec) ([]string, error)

func (*EntBackend) IngestHasSbom

func (*EntBackend) IngestHasSourceAt

func (b *EntBackend) IngestHasSourceAt(ctx context.Context, pkg model.IDorPkgInput, pkgMatchType model.MatchFlags, source model.IDorSourceInput, hasSourceAt model.HasSourceAtInputSpec) (string, error)

func (*EntBackend) IngestHasSourceAts

func (b *EntBackend) IngestHasSourceAts(ctx context.Context, pkgs []*model.IDorPkgInput, pkgMatchType *model.MatchFlags, sources []*model.IDorSourceInput, hasSourceAts []*model.HasSourceAtInputSpec) ([]string, error)

func (*EntBackend) IngestHashEqual

func (b *EntBackend) IngestHashEqual(ctx context.Context, artifact model.IDorArtifactInput, equalArtifact model.IDorArtifactInput, spec model.HashEqualInputSpec) (string, error)

func (*EntBackend) IngestHashEquals

func (b *EntBackend) IngestHashEquals(ctx context.Context, artifacts []*model.IDorArtifactInput, otherArtifacts []*model.IDorArtifactInput, hashEquals []*model.HashEqualInputSpec) ([]string, error)

func (*EntBackend) IngestLicense

func (b *EntBackend) IngestLicense(ctx context.Context, licenseInput *model.IDorLicenseInput) (string, error)

func (*EntBackend) IngestLicenses

func (b *EntBackend) IngestLicenses(ctx context.Context, licenses []*model.IDorLicenseInput) ([]string, error)

func (*EntBackend) IngestOccurrence

func (*EntBackend) IngestOccurrences

func (b *EntBackend) IngestOccurrences(ctx context.Context, subjects model.PackageOrSourceInputs, artifacts []*model.IDorArtifactInput, occurrences []*model.IsOccurrenceInputSpec) ([]string, error)

func (*EntBackend) IngestPackage

func (b *EntBackend) IngestPackage(ctx context.Context, pkg model.IDorPkgInput) (*model.PackageIDs, error)

func (*EntBackend) IngestPackages

func (b *EntBackend) IngestPackages(ctx context.Context, pkgs []*model.IDorPkgInput) ([]*model.PackageIDs, error)

func (*EntBackend) IngestPkgEqual

func (b *EntBackend) IngestPkgEqual(ctx context.Context, pkg model.IDorPkgInput, depPkg model.IDorPkgInput, pkgEqual model.PkgEqualInputSpec) (string, error)

func (*EntBackend) IngestPkgEquals

func (b *EntBackend) IngestPkgEquals(ctx context.Context, pkgs []*model.IDorPkgInput, otherPackages []*model.IDorPkgInput, pkgEquals []*model.PkgEqualInputSpec) ([]string, error)

func (*EntBackend) IngestPointOfContact added in v0.2.1

func (b *EntBackend) IngestPointOfContact(ctx context.Context, subject model.PackageSourceOrArtifactInput, pkgMatchType *model.MatchFlags, pointOfContact model.PointOfContactInputSpec) (string, error)

func (*EntBackend) IngestPointOfContacts added in v0.2.1

func (b *EntBackend) IngestPointOfContacts(ctx context.Context, subjects model.PackageSourceOrArtifactInputs, pkgMatchType *model.MatchFlags, pointOfContactList []*model.PointOfContactInputSpec) ([]string, error)

func (*EntBackend) IngestSLSA

func (b *EntBackend) IngestSLSA(ctx context.Context, subject model.IDorArtifactInput, builtFrom []*model.IDorArtifactInput, builtBy model.IDorBuilderInput, slsa model.SLSAInputSpec) (string, error)

func (*EntBackend) IngestSLSAs

func (b *EntBackend) IngestSLSAs(ctx context.Context, subjects []*model.IDorArtifactInput, builtFromList [][]*model.IDorArtifactInput, builtByList []*model.IDorBuilderInput, slsaList []*model.SLSAInputSpec) ([]string, error)

func (*EntBackend) IngestScorecard

func (b *EntBackend) IngestScorecard(ctx context.Context, source model.IDorSourceInput, scorecard model.ScorecardInputSpec) (string, error)

Mutations for evidence trees (read-write queries, assume software trees ingested) IngestScorecard takes a scorecard and a source and creates a certifyScorecard

func (*EntBackend) IngestScorecards

func (b *EntBackend) IngestScorecards(ctx context.Context, sources []*model.IDorSourceInput, scorecards []*model.ScorecardInputSpec) ([]string, error)

func (*EntBackend) IngestSource

func (b *EntBackend) IngestSource(ctx context.Context, source model.IDorSourceInput) (*model.SourceIDs, error)

func (*EntBackend) IngestSources

func (b *EntBackend) IngestSources(ctx context.Context, sources []*model.IDorSourceInput) ([]*model.SourceIDs, error)

func (*EntBackend) IngestVEXStatement

func (b *EntBackend) IngestVEXStatement(ctx context.Context, subject model.PackageOrArtifactInput, vulnerability model.IDorVulnerabilityInput, vexStatement model.VexStatementInputSpec) (string, error)

func (*EntBackend) IngestVEXStatements

func (b *EntBackend) IngestVEXStatements(ctx context.Context, subjects model.PackageOrArtifactInputs, vulnerabilities []*model.IDorVulnerabilityInput, vexStatements []*model.VexStatementInputSpec) ([]string, error)

func (*EntBackend) IngestVulnEqual

func (b *EntBackend) IngestVulnEqual(ctx context.Context, vulnerability model.IDorVulnerabilityInput, otherVulnerability model.IDorVulnerabilityInput, vulnEqual model.VulnEqualInputSpec) (string, error)

func (*EntBackend) IngestVulnEquals

func (b *EntBackend) IngestVulnEquals(ctx context.Context, vulnerabilities []*model.IDorVulnerabilityInput, otherVulnerabilities []*model.IDorVulnerabilityInput, vulnEquals []*model.VulnEqualInputSpec) ([]string, error)

func (*EntBackend) IngestVulnerabilities

func (b *EntBackend) IngestVulnerabilities(ctx context.Context, vulns []*model.IDorVulnerabilityInput) ([]*model.VulnerabilityIDs, error)

func (*EntBackend) IngestVulnerability

func (b *EntBackend) IngestVulnerability(ctx context.Context, vuln model.IDorVulnerabilityInput) (*model.VulnerabilityIDs, error)

func (*EntBackend) IngestVulnerabilityMetadata added in v0.4.0

func (b *EntBackend) IngestVulnerabilityMetadata(ctx context.Context, vulnerability model.IDorVulnerabilityInput, vulnerabilityMetadata model.VulnerabilityMetadataInputSpec) (string, error)

func (*EntBackend) IsDependency

func (b *EntBackend) IsDependency(ctx context.Context, spec *model.IsDependencySpec) ([]*model.IsDependency, error)

func (*EntBackend) IsDependencyList added in v0.6.0

func (b *EntBackend) IsDependencyList(ctx context.Context, spec model.IsDependencySpec, after *string, first *int) (*model.IsDependencyConnection, error)

func (*EntBackend) IsOccurrence

func (b *EntBackend) IsOccurrence(ctx context.Context, query *model.IsOccurrenceSpec) ([]*model.IsOccurrence, error)

func (*EntBackend) IsOccurrenceList added in v0.6.0

func (b *EntBackend) IsOccurrenceList(ctx context.Context, spec model.IsOccurrenceSpec, after *string, first *int) (*model.IsOccurrenceConnection, error)

func (*EntBackend) LicenseList added in v0.6.0

func (b *EntBackend) LicenseList(ctx context.Context, spec model.LicenseSpec, after *string, first *int) (*model.LicenseConnection, error)

func (*EntBackend) Licenses

func (b *EntBackend) Licenses(ctx context.Context, filter *model.LicenseSpec) ([]*model.License, error)

func (*EntBackend) Neighbors

func (b *EntBackend) Neighbors(ctx context.Context, nodeID string, usingOnly []model.Edge) ([]model.Node, error)

func (*EntBackend) NeighborsList added in v0.6.0

func (b *EntBackend) NeighborsList(ctx context.Context, node string, usingOnly []model.Edge, after *string, first *int) (*model.NeighborConnection, error)

func (*EntBackend) Node

func (b *EntBackend) Node(ctx context.Context, node string) (model.Node, error)

func (*EntBackend) Nodes

func (b *EntBackend) Nodes(ctx context.Context, nodes []string) ([]model.Node, error)

func (*EntBackend) Packages

func (b *EntBackend) Packages(ctx context.Context, pkgSpec *model.PkgSpec) ([]*model.Package, error)

func (*EntBackend) PackagesList added in v0.6.0

func (b *EntBackend) PackagesList(ctx context.Context, pkgSpec model.PkgSpec, after *string, first *int) (*model.PackageConnection, error)

func (*EntBackend) Path added in v0.4.0

func (b *EntBackend) Path(ctx context.Context, subject string, target string, maxPathLength int, usingOnly []model.Edge) ([]model.Node, error)

func (*EntBackend) PkgEqual

func (b *EntBackend) PkgEqual(ctx context.Context, spec *model.PkgEqualSpec) ([]*model.PkgEqual, error)

func (*EntBackend) PkgEqualList added in v0.6.0

func (b *EntBackend) PkgEqualList(ctx context.Context, spec model.PkgEqualSpec, after *string, first *int) (*model.PkgEqualConnection, error)

func (*EntBackend) PointOfContact added in v0.2.1

func (b *EntBackend) PointOfContact(ctx context.Context, filter *model.PointOfContactSpec) ([]*model.PointOfContact, error)

func (*EntBackend) PointOfContactList added in v0.6.0

func (b *EntBackend) PointOfContactList(ctx context.Context, spec model.PointOfContactSpec, after *string, first *int) (*model.PointOfContactConnection, error)

func (*EntBackend) QueryPackagesListForScan added in v0.9.0

func (b *EntBackend) QueryPackagesListForScan(ctx context.Context, pkgIDs []string, after *string, first *int) (*model.PackageConnection, error)

func (*EntBackend) Scorecards

func (b *EntBackend) Scorecards(ctx context.Context, filter *model.CertifyScorecardSpec) ([]*model.CertifyScorecard, error)

func (*EntBackend) ScorecardsList added in v0.6.0

func (b *EntBackend) ScorecardsList(ctx context.Context, spec model.CertifyScorecardSpec, after *string, first *int) (*model.CertifyScorecardConnection, error)

func (*EntBackend) Sources

func (b *EntBackend) Sources(ctx context.Context, filter *model.SourceSpec) ([]*model.Source, error)

func (*EntBackend) SourcesList added in v0.6.0

func (b *EntBackend) SourcesList(ctx context.Context, spec model.SourceSpec, after *string, first *int) (*model.SourceConnection, error)

func (*EntBackend) VulnEqual

func (b *EntBackend) VulnEqual(ctx context.Context, filter *model.VulnEqualSpec) ([]*model.VulnEqual, error)

func (*EntBackend) VulnEqualList added in v0.6.0

func (b *EntBackend) VulnEqualList(ctx context.Context, spec model.VulnEqualSpec, after *string, first *int) (*model.VulnEqualConnection, error)

func (*EntBackend) Vulnerabilities

func (b *EntBackend) Vulnerabilities(ctx context.Context, filter *model.VulnerabilitySpec) ([]*model.Vulnerability, error)

func (*EntBackend) VulnerabilityList added in v0.6.0

func (b *EntBackend) VulnerabilityList(ctx context.Context, spec model.VulnerabilitySpec, after *string, first *int) (*model.VulnerabilityConnection, error)

func (*EntBackend) VulnerabilityMetadata added in v0.4.0

func (b *EntBackend) VulnerabilityMetadata(ctx context.Context, filter *model.VulnerabilityMetadataSpec) ([]*model.VulnerabilityMetadata, error)

func (*EntBackend) VulnerabilityMetadataList added in v0.6.0

func (b *EntBackend) VulnerabilityMetadataList(ctx context.Context, spec model.VulnerabilityMetadataSpec, after *string, first *int) (*model.VulnerabilityMetadataConnection, error)

type Predicate

type Predicate interface {
	~func(*sql.Selector)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL