Help us shape the future of Go! Take the 2026 Go Developer Survey

repositories

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Copyright (C) 2024 Tim Bastin, l3montree GmbH

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var CleanupOrphanedRecordsSQL = `` /* 1696-byte string literal not displayed */
View Source
var Module = fx.Options(
	fx.Provide(fx.Annotate(NewPATRepository, fx.As(new(shared.PersonalAccessTokenRepository)))),
	fx.Provide(fx.Annotate(NewAssetRepository, fx.As(new(shared.AssetRepository)))),
	fx.Provide(fx.Annotate(NewArtifactRiskHistoryRepository, fx.As(new(shared.ArtifactRiskHistoryRepository)))),
	fx.Provide(fx.Annotate(NewAssetVersionRepository, fx.As(new(shared.AssetVersionRepository)))),
	fx.Provide(fx.Annotate(NewStatisticsRepository, fx.As(new(shared.StatisticsRepository)))),
	fx.Provide(fx.Annotate(NewReleaseRepository, fx.As(new(shared.ReleaseRepository)))),
	fx.Provide(fx.Annotate(NewProjectRepository, fx.As(new(shared.ProjectRepository)))),
	fx.Provide(fx.Annotate(NewComponentRepository, fx.As(new(shared.ComponentRepository)))),
	fx.Provide(fx.Annotate(NewVulnEventRepository, fx.As(new(shared.VulnEventRepository)))),
	fx.Provide(fx.Annotate(NewOrgRepository, fx.As(new(shared.OrganizationRepository)))),
	fx.Provide(fx.Annotate(NewCVERepository, fx.As(new(shared.CveRepository)))),
	fx.Provide(fx.Annotate(NewCWERepository, fx.As(new(shared.CweRepository)))),
	fx.Provide(fx.Annotate(NewExploitRepository, fx.As(new(shared.ExploitRepository)))),
	fx.Provide(fx.Annotate(NewAffectedComponentRepository, fx.As(new(shared.AffectedComponentRepository)))),
	fx.Provide(fx.Annotate(NewDependencyVulnRepository, fx.As(new(shared.DependencyVulnRepository)))),
	fx.Provide(fx.Annotate(NewFirstPartyVulnerabilityRepository, fx.As(new(shared.FirstPartyVulnRepository)))),
	fx.Provide(fx.Annotate(NewInTotoLinkRepository, fx.As(new(shared.InTotoLinkRepository)))),
	fx.Provide(fx.Annotate(NewSupplyChainRepository, fx.As(new(shared.SupplyChainRepository)))),
	fx.Provide(fx.Annotate(NewAttestationRepository, fx.As(new(shared.AttestationRepository)))),
	fx.Provide(fx.Annotate(NewPolicyRepository, fx.As(new(shared.PolicyRepository)))),
	fx.Provide(fx.Annotate(NewLicenseRiskRepository, fx.As(new(shared.LicenseRiskRepository)))),
	fx.Provide(fx.Annotate(NewWebhookRepository, fx.As(new(shared.WebhookIntegrationRepository)))),
	fx.Provide(fx.Annotate(NewArtifactRepository, fx.As(new(shared.ArtifactRepository)))),
	fx.Provide(fx.Annotate(NewInvitationRepository, fx.As(new(shared.InvitationRepository)))),
	fx.Provide(fx.Annotate(NewExternalUserRepository, fx.As(new(shared.ExternalUserRepository)))),
	fx.Provide(fx.Annotate(NewComponentProjectRepository, fx.As(new(shared.ComponentProjectRepository)))),
	fx.Provide(fx.Annotate(NewGitLabIntegrationRepository, fx.As(new(shared.GitlabIntegrationRepository)))),
	fx.Provide(fx.Annotate(NewGitlabOauth2TokenRepository, fx.As(new(shared.GitLabOauth2TokenRepository)))),
	fx.Provide(fx.Annotate(NewAggregatedVulnRepository, fx.As(new(shared.VulnRepository)))),
	fx.Provide(fx.Annotate(NewGithubAppInstallationRepository, fx.As(new(shared.GithubAppInstallationRepository)))),
	fx.Provide(fx.Annotate(NewJiraIntegrationRepository, fx.As(new(shared.JiraIntegrationRepository)))),
	fx.Provide(fx.Annotate(NewCveRelationshipRepository, fx.As(new(shared.CVERelationshipRepository)))),
	fx.Provide(fx.Annotate(NewVEXRuleRepository, fx.As(new(shared.VEXRuleRepository)))),
	fx.Provide(fx.Annotate(NewExternalReferenceRepository, fx.As(new(shared.ExternalReferenceRepository)))),
	fx.Provide(fx.Annotate(NewTrustedEntityRepository, fx.As(new(shared.TrustedEntityRepository)))),
)

Module provides all repository constructors as their interfaces

Functions

func BuildQualifierQuery

func BuildQualifierQuery(db *gorm.DB, qualifiers packageurl.Qualifiers, namespace string) *gorm.DB

BuildQualifierQuery creates the database query for qualifier matching

func BuildQueryBasedOnMatchContext

func BuildQueryBasedOnMatchContext(db *gorm.DB, ctx *normalize.PurlMatchContext) *gorm.DB

func NewAffectedComponentRepository

func NewAffectedComponentRepository(db *gorm.DB) *affectedCmpRepository

func NewArtifactRepository

func NewArtifactRepository(db *gorm.DB) *artifactRepository

func NewArtifactRiskHistoryRepository

func NewArtifactRiskHistoryRepository(db *gorm.DB) *artifactRiskHistoryRepository

func NewAssetRepository

func NewAssetRepository(db *gorm.DB) *assetRepository

func NewAssetVersionRepository

func NewAssetVersionRepository(db *gorm.DB, synchronizer utils.FireAndForgetSynchronizer) *assetVersionRepository

func NewAttestationRepository

func NewAttestationRepository(db *gorm.DB) *attestationRepository

func NewCVERepository

func NewCVERepository(db *gorm.DB) *cveRepository

func NewCWERepository

func NewCWERepository(db *gorm.DB) *cweRepository

func NewComponentProjectRepository

func NewComponentProjectRepository(db *gorm.DB) *componentProjectRepository

func NewComponentRepository

func NewComponentRepository(db *gorm.DB) *componentRepository

func NewConfigRepository

func NewConfigRepository(db *gorm.DB) *configRepository

func NewCveRelationshipRepository

func NewCveRelationshipRepository(db *gorm.DB) *cveRelationshipRepository

func NewDependencyVulnRepository

func NewDependencyVulnRepository(db *gorm.DB) *dependencyVulnRepository

func NewExploitRepository

func NewExploitRepository(db *gorm.DB) *exploitRepository

func NewExternalReferenceRepository

func NewExternalReferenceRepository(db *gorm.DB) shared.ExternalReferenceRepository

func NewExternalUserRepository

func NewExternalUserRepository(db *gorm.DB) *externalUserRepository

func NewFirstPartyVulnerabilityRepository

func NewFirstPartyVulnerabilityRepository(db *gorm.DB) *firstPartyVulnerabilityRepository

func NewGitLabIntegrationRepository

func NewGitLabIntegrationRepository(db *gorm.DB) *gitlabIntegrationRepository

func NewGithubAppInstallationRepository

func NewGithubAppInstallationRepository(db *gorm.DB) *githubAppInstallationRepository

func NewGitlabOauth2TokenRepository

func NewGitlabOauth2TokenRepository(db *gorm.DB) *gitlabOauth2TokenRepository

func NewInTotoLinkRepository

func NewInTotoLinkRepository(db *gorm.DB) *inTotoLinkRepository

func NewJiraIntegrationRepository

func NewJiraIntegrationRepository(db *gorm.DB) *jiraIntegrationRepository

func NewOrgRepository

func NewOrgRepository(db *gorm.DB) *orgRepository

func NewPATRepository

func NewPATRepository(db *gorm.DB) *gormPatRepository

func NewPolicyRepository

func NewPolicyRepository(db *gorm.DB) *policyRepository

func NewProjectRepository

func NewProjectRepository(db *gorm.DB) *projectRepository

func NewProjectRiskHistoryRepository

func NewProjectRiskHistoryRepository(db *gorm.DB) *projectRiskHistoryRepository

func NewReleaseRepository

func NewReleaseRepository(db *gorm.DB) *releaseRepository

func NewStatisticsRepository

func NewStatisticsRepository(db *gorm.DB) *statisticsRepository

func NewSupplyChainRepository

func NewSupplyChainRepository(db *gorm.DB) *supplyChainRepository

func NewTrustedEntityRepository added in v1.2.0

func NewTrustedEntityRepository(db *gorm.DB) *trustedEntityRepository

func NewVEXRuleRepository

func NewVEXRuleRepository(db *gorm.DB) *vexRuleRepository

func NewVulnEventRepository

func NewVulnEventRepository(db *gorm.DB) *eventRepository

func NewWebhookRepository

func NewWebhookRepository(db *gorm.DB) *webhookRepository

Types

type AggregatedVulnRepository

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

func NewAggregatedVulnRepository

func NewAggregatedVulnRepository(db *gorm.DB) *AggregatedVulnRepository

func (AggregatedVulnRepository) ApplyAndSave

func (a AggregatedVulnRepository) ApplyAndSave(ctx context.Context, tx *gorm.DB, vuln models.Vuln, vulnEvent *models.VulnEvent) error

func (AggregatedVulnRepository) FindByTicketID

func (a AggregatedVulnRepository) FindByTicketID(ctx context.Context, tx *gorm.DB, ticketID string) (models.Vuln, error)

func (AggregatedVulnRepository) GetOrgFromVuln

func (a AggregatedVulnRepository) GetOrgFromVuln(ctx context.Context, tx *gorm.DB, vuln models.Vuln) (models.Org, error)

func (AggregatedVulnRepository) Save

func (a AggregatedVulnRepository) Save(ctx context.Context, tx *gorm.DB, vuln *models.Vuln) error

func (AggregatedVulnRepository) Transaction

func (a AggregatedVulnRepository) Transaction(ctx context.Context, txFunc func(tx *gorm.DB) error) error

type GormRepository

type GormRepository[ID comparable, T utils.Tabler] struct {
	// contains filtered or unexported fields
}

func (*GormRepository[ID, T]) Activate

func (g *GormRepository[ID, T]) Activate(ctx context.Context, tx *gorm.DB, id ID) error

func (*GormRepository[ID, T]) All

func (g *GormRepository[ID, T]) All(ctx context.Context, tx *gorm.DB) ([]T, error)

func (*GormRepository[ID, T]) Begin

func (g *GormRepository[ID, T]) Begin(ctx context.Context) *gorm.DB

func (*GormRepository[ID, T]) CleanupOrphanedRecords added in v1.2.0

func (g *GormRepository[ID, T]) CleanupOrphanedRecords(ctx context.Context) error

func (*GormRepository[ID, T]) Create

func (g *GormRepository[ID, T]) Create(ctx context.Context, tx *gorm.DB, t *T) error

func (*GormRepository[ID, T]) CreateBatch

func (g *GormRepository[ID, T]) CreateBatch(ctx context.Context, tx *gorm.DB, ts []T) error

func (*GormRepository[ID, T]) Delete

func (g *GormRepository[ID, T]) Delete(ctx context.Context, tx *gorm.DB, id ID) error

func (*GormRepository[ID, T]) DeleteBatch

func (g *GormRepository[ID, T]) DeleteBatch(ctx context.Context, tx *gorm.DB, m []T) error

func (*GormRepository[ID, T]) GetDB

func (g *GormRepository[ID, T]) GetDB(ctx context.Context, tx *gorm.DB) *gorm.DB

func (*GormRepository[ID, T]) List

func (g *GormRepository[ID, T]) List(ctx context.Context, tx *gorm.DB, ids []ID) ([]T, error)

func (*GormRepository[ID, T]) Read

func (g *GormRepository[ID, T]) Read(ctx context.Context, tx *gorm.DB, id ID) (T, error)

func (*GormRepository[ID, T]) Save

func (g *GormRepository[ID, T]) Save(ctx context.Context, tx *gorm.DB, t *T) error

func (*GormRepository[ID, T]) SaveBatch

func (g *GormRepository[ID, T]) SaveBatch(ctx context.Context, tx *gorm.DB, ts []T) error

func (*GormRepository[ID, T]) SaveBatchBestEffort

func (g *GormRepository[ID, T]) SaveBatchBestEffort(
	ctx context.Context,
	tx *gorm.DB,
	ts []T,
) error

it does not save any associations, so it is the caller's responsibility to save them separately if needed

func (*GormRepository[ID, T]) Transaction

func (g *GormRepository[ID, T]) Transaction(ctx context.Context, f func(tx *gorm.DB) error) error

func (*GormRepository[ID, T]) Upsert

func (g *GormRepository[ID, T]) Upsert(ctx context.Context, tx *gorm.DB, t *[]*T, conflictingColumns []clause.Column, updateOnly []string) error

type InvitationRepository

type InvitationRepository struct {
	utils.Repository[uuid.UUID, models.Invitation, *gorm.DB]
	// contains filtered or unexported fields
}

func NewInvitationRepository

func NewInvitationRepository(db *gorm.DB) *InvitationRepository

func (*InvitationRepository) FindByCode

func (g *InvitationRepository) FindByCode(ctx context.Context, tx *gorm.DB, code string) (models.Invitation, error)

func (*InvitationRepository) Save

func (g *InvitationRepository) Save(ctx context.Context, tx *gorm.DB, invitation *models.Invitation) error

type LicenseRiskRepository

type LicenseRiskRepository struct {
	utils.Repository[string, models.LicenseRisk, *gorm.DB]
	// contains filtered or unexported fields
}

func NewLicenseRiskRepository

func NewLicenseRiskRepository(db *gorm.DB) *LicenseRiskRepository

func (*LicenseRiskRepository) ApplyAndSave

func (repository *LicenseRiskRepository) ApplyAndSave(ctx context.Context, tx *gorm.DB, licenseRisk *models.LicenseRisk, vulnEvent *models.VulnEvent) error

func (*LicenseRiskRepository) DeleteByComponentPurl

func (repository *LicenseRiskRepository) DeleteByComponentPurl(ctx context.Context, tx *gorm.DB, assetID uuid.UUID, assetVersionName string, pURL packageurl.PackageURL) error

func (*LicenseRiskRepository) GetAllLicenseRisksForAssetVersion

func (repository *LicenseRiskRepository) GetAllLicenseRisksForAssetVersion(ctx context.Context, tx *gorm.DB, assetID uuid.UUID, assetVersionName string) ([]models.LicenseRisk, error)

func (*LicenseRiskRepository) GetAllLicenseRisksForAssetVersionPaged

func (repository *LicenseRiskRepository) GetAllLicenseRisksForAssetVersionPaged(ctx context.Context, tx *gorm.DB, assetID uuid.UUID, assetVersionName string, pageInfo shared.PageInfo, search string, filter []shared.FilterQuery, sort []shared.SortQuery) (shared.Paged[models.LicenseRisk], error)

func (*LicenseRiskRepository) GetAllOverwrittenLicensesForAssetVersion

func (repository *LicenseRiskRepository) GetAllOverwrittenLicensesForAssetVersion(ctx context.Context, tx *gorm.DB, assetID uuid.UUID, assetVersionName string) ([]models.LicenseRisk, error)

func (*LicenseRiskRepository) GetByAssetID

func (repository *LicenseRiskRepository) GetByAssetID(ctx context.Context, tx *gorm.DB, assetID uuid.UUID) ([]models.LicenseRisk, error)

func (*LicenseRiskRepository) GetLicenseRisksByOtherAssetVersions

func (repository *LicenseRiskRepository) GetLicenseRisksByOtherAssetVersions(ctx context.Context, tx *gorm.DB, assetVersionName string, assetID uuid.UUID) ([]models.LicenseRisk, error)

func (*LicenseRiskRepository) ListByArtifactName

func (repository *LicenseRiskRepository) ListByArtifactName(ctx context.Context, tx *gorm.DB, assetVersionName string, assetID uuid.UUID, artifactName string) ([]models.LicenseRisk, error)

func (*LicenseRiskRepository) MaybeGetLicenseOverwriteForComponent

func (repository *LicenseRiskRepository) MaybeGetLicenseOverwriteForComponent(ctx context.Context, tx *gorm.DB, assetID uuid.UUID, assetVersionName string, pURL packageurl.PackageURL) (models.LicenseRisk, error)

func (*LicenseRiskRepository) Read

func (repository *LicenseRiskRepository) Read(ctx context.Context, tx *gorm.DB, vulnID string) (models.LicenseRisk, error)

type MaliciousPackageRepository

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

func NewMaliciousPackageRepository

func NewMaliciousPackageRepository(db *gorm.DB) *MaliciousPackageRepository

func (*MaliciousPackageRepository) BatchUpsertAffectedComponents

func (r *MaliciousPackageRepository) BatchUpsertAffectedComponents(ctx context.Context, tx *gorm.DB, components []models.MaliciousAffectedComponent, batchSize int) error

func (*MaliciousPackageRepository) BatchUpsertPackages

func (r *MaliciousPackageRepository) BatchUpsertPackages(ctx context.Context, tx *gorm.DB, packages []models.MaliciousPackage, batchSize int) error

BatchUpsert handles large batches by splitting them into chunks

func (*MaliciousPackageRepository) Count

func (*MaliciousPackageRepository) CountByEcosystem

func (r *MaliciousPackageRepository) CountByEcosystem(ctx context.Context, tx *gorm.DB) (map[string]int64, error)

func (*MaliciousPackageRepository) DeleteAll

func (r *MaliciousPackageRepository) DeleteAll(ctx context.Context, tx *gorm.DB) error

func (*MaliciousPackageRepository) GetDB

func (r *MaliciousPackageRepository) GetDB(ctx context.Context, tx *gorm.DB) *gorm.DB

func (*MaliciousPackageRepository) GetMaliciousAffectedComponents

func (r *MaliciousPackageRepository) GetMaliciousAffectedComponents(ctx context.Context, tx *gorm.DB, purl packageurl.PackageURL) ([]models.MaliciousAffectedComponent, error)

GetMaliciousAffectedComponents finds malicious packages for a given purl (similar to GetAffectedComponents)

func (*MaliciousPackageRepository) UpsertAffectedComponents

func (r *MaliciousPackageRepository) UpsertAffectedComponents(ctx context.Context, tx *gorm.DB, components []models.MaliciousAffectedComponent) error

func (*MaliciousPackageRepository) UpsertPackages

func (r *MaliciousPackageRepository) UpsertPackages(ctx context.Context, tx *gorm.DB, packages []models.MaliciousPackage) error

type VulnStats

type VulnStats struct {
	TotalRisk           float64 `json:"total_risk"`
	AvgRisk             float64 `json:"avg_risk"`
	MaxRisk             float64 `json:"max_risk"`
	DependencyVulnCount int64   `json:"dependencyVuln_count"`
	PackageName         string  `json:"package_name"`
}

type VulnerabilityRepository

type VulnerabilityRepository[T utils.Tabler] struct {
	utils.Repository[string, T, *gorm.DB]
	// contains filtered or unexported fields
}

func NewVulnerabilityRepository

func NewVulnerabilityRepository[T utils.Tabler](db *gorm.DB) *VulnerabilityRepository[T]

func (*VulnerabilityRepository[T]) FindByTicketID

func (r *VulnerabilityRepository[T]) FindByTicketID(ctx context.Context, tx *gorm.DB, ticketID string) (T, error)

func (*VulnerabilityRepository[T]) GetAllByAssetIDAndState

func (r *VulnerabilityRepository[T]) GetAllByAssetIDAndState(
	ctx context.Context,
	tx *gorm.DB,
	assetID uuid.UUID,
	state dtos.VulnState,
	durationSinceStateChange time.Duration,
) ([]T, error)

func (*VulnerabilityRepository[T]) GetAllOpenVulnsByAssetVersionNameAndAssetID

func (r *VulnerabilityRepository[T]) GetAllOpenVulnsByAssetVersionNameAndAssetID(ctx context.Context, tx *gorm.DB, assetVersionName string, assetID uuid.UUID) ([]T, error)

func (*VulnerabilityRepository[T]) GetAllVulnsByAssetID

func (r *VulnerabilityRepository[T]) GetAllVulnsByAssetID(ctx context.Context, tx *gorm.DB, assetID uuid.UUID) ([]T, error)

func (*VulnerabilityRepository[T]) GetByAssetID

func (r *VulnerabilityRepository[T]) GetByAssetID(
	ctx context.Context,
	tx *gorm.DB,
	assetID uuid.UUID,
) ([]T, error)

Jump to

Keyboard shortcuts

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