gitlabint

package
v1.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoGitlabIntegration = fmt.Errorf("no gitlab app installations found")

Functions

func ExtractProjectIDFromRepoID

func ExtractProjectIDFromRepoID(repoID string) (int, error)

func FetchPaginatedData

func FetchPaginatedData[T any](
	fetchPage func(page int) ([]T, *gitlab.Response, error),
) ([]T, error)

Generic function to fetch paginated data with rate limiting and concurrency

func NewGitLabOauth2Integrations

func NewGitLabOauth2Integrations(db shared.DB, gitlabOauth2TokenRepository shared.GitLabOauth2TokenRepository) map[string]*GitlabOauth2Config

func NewGitlabBatchClient

func NewGitlabBatchClient(clients []shared.GitlabClientFacade) *gitlabBatchClient

groups multiple gitlab clients - since an org can have multiple installations

Types

type GitlabIntegration

type GitlabIntegration struct {
	utils.FireAndForgetSynchronizer
	// contains filtered or unexported fields
}

func NewGitlabIntegration

func NewGitlabIntegration(
	oauth2GitlabIntegration map[string]*GitlabOauth2Config,
	casbinRBACProvider shared.RBACProvider,
	clientFactory shared.GitlabClientFactory,
	gitlabIntegrationRepository shared.GitlabIntegrationRepository,
	aggregatedVulnRepository shared.VulnRepository,
	dependencyVulnRepository shared.DependencyVulnRepository,
	vulnEventRepository shared.VulnEventRepository,
	externalUserRepository shared.ExternalUserRepository,
	assetRepository shared.AssetRepository,
	assetVersionRepository shared.AssetVersionRepository,
	projectRepository shared.ProjectRepository,
	componentRepository shared.ComponentRepository,
	firstPartyVulnRepository shared.FirstPartyVulnRepository,
	gitlabOauth2TokenRepository shared.GitLabOauth2TokenRepository,
	licenseRiskRepository shared.LicenseRiskRepository,
	orgRepository shared.OrganizationRepository,
	statisticsService shared.StatisticsService,
	synchronizer utils.FireAndForgetSynchronizer,
) *GitlabIntegration

func (*GitlabIntegration) AutoSetup

func (g *GitlabIntegration) AutoSetup(ctx shared.Context) error

func (*GitlabIntegration) CreateIssue

func (g *GitlabIntegration) CreateIssue(ctx context.Context, asset models.Asset, assetVersionName string, vuln models.Vuln, projectSlug string, orgSlug string, justification string, userID string) error

func (*GitlabIntegration) CreateLabels

func (g *GitlabIntegration) CreateLabels(ctx context.Context, asset models.Asset) error

func (*GitlabIntegration) Delete

func (g *GitlabIntegration) Delete(ctx shared.Context) error

func (*GitlabIntegration) GetClientBasedOnAsset

func (g *GitlabIntegration) GetClientBasedOnAsset(asset models.Asset) (shared.GitlabClientFacade, int, error)

func (*GitlabIntegration) GetGroup

func (g *GitlabIntegration) GetGroup(ctx context.Context, userID string, providerID string, groupID string) (models.Project, error)

func (*GitlabIntegration) GetID

func (*GitlabIntegration) GetRoleInGroup

func (g *GitlabIntegration) GetRoleInGroup(ctx context.Context, userID string, providerID string, groupID string) (shared.Role, error)

func (*GitlabIntegration) GetRoleInProject

func (g *GitlabIntegration) GetRoleInProject(ctx context.Context, userID string, providerID string, projectID string) (shared.Role, error)

func (*GitlabIntegration) GetUsers

func (g *GitlabIntegration) GetUsers(org models.Org) []dtos.UserDTO

func (*GitlabIntegration) HandleEvent

func (g *GitlabIntegration) HandleEvent(event any) error

func (*GitlabIntegration) HandleWebhook

func (g *GitlabIntegration) HandleWebhook(ctx shared.Context) error

func (*GitlabIntegration) HasAccessToExternalEntityProvider

func (g *GitlabIntegration) HasAccessToExternalEntityProvider(ctx shared.Context, externalEntityProviderID string) (bool, error)

func (*GitlabIntegration) ListGroups

func (g *GitlabIntegration) ListGroups(ctx context.Context, userID string, providerID string) ([]models.Project, []shared.Role, error)

func (*GitlabIntegration) ListOrgs

func (g *GitlabIntegration) ListOrgs(ctx shared.Context) ([]models.Org, error)

func (*GitlabIntegration) ListProjects

func (g *GitlabIntegration) ListProjects(ctx context.Context, userID string, providerID string, groupID string) ([]models.Asset, []shared.Role, error)

func (*GitlabIntegration) ListRepositories

func (g *GitlabIntegration) ListRepositories(ctx shared.Context) ([]dtos.GitRepository, error)

func (*GitlabIntegration) TestAndSave

func (g *GitlabIntegration) TestAndSave(ctx shared.Context) error

func (*GitlabIntegration) UpdateIssue

func (g *GitlabIntegration) UpdateIssue(ctx context.Context, asset models.Asset, assetVersionSlug string, vuln models.Vuln) error

func (*GitlabIntegration) UpdateLabels

func (g *GitlabIntegration) UpdateLabels(ctx context.Context, asset models.Asset, labelsToUpdate []commonint.Label) error

func (*GitlabIntegration) WantsToHandleWebhook

func (g *GitlabIntegration) WantsToHandleWebhook(ctx shared.Context) bool

type GitlabOauth2Config

type GitlabOauth2Config struct {
	ProviderID    string
	GitlabBaseURL string

	GitlabOauth2TokenRepository shared.GitLabOauth2TokenRepository

	Oauth2Conf *oauth2.Config

	DevGuardBotUserID          int    // the user id of the devguard bot user, used to create issues
	DevGuardBotUserAccessToken string // the access token of the devguard bot user, used to create issues
	AdminToken                 *string
}

func NewGitLabOauth2Config

func NewGitLabOauth2Config(id, gitlabBaseURL, gitlabOauth2ClientID, gitlabOauth2ClientSecret, gitlabOauth2Scopes string, botUserID int, botUserAccessToken string, adminToken *string, gitlabOauth2TokenRepository shared.GitLabOauth2TokenRepository) *GitlabOauth2Config

func (*GitlabOauth2Config) GetBaseURL

func (c *GitlabOauth2Config) GetBaseURL() string

func (*GitlabOauth2Config) GetProviderID

func (c *GitlabOauth2Config) GetProviderID() string

func (*GitlabOauth2Config) Oauth2Callback

func (c *GitlabOauth2Config) Oauth2Callback(ctx shared.Context) error

func (*GitlabOauth2Config) Oauth2Login

func (c *GitlabOauth2Config) Oauth2Login(ctx shared.Context) error

type SimpleGitlabClientFactory

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

func NewGitlabClientFactory

func NewGitlabClientFactory(gitlabIntegrationRepository shared.GitlabIntegrationRepository, oauth2GitlabIntegration map[string]*GitlabOauth2Config) SimpleGitlabClientFactory

func (SimpleGitlabClientFactory) FromAccessToken

func (factory SimpleGitlabClientFactory) FromAccessToken(accessToken string, baseURL string) (shared.GitlabClientFacade, error)

func (SimpleGitlabClientFactory) FromIntegration

func (factory SimpleGitlabClientFactory) FromIntegration(integration models.GitLabIntegration) (shared.GitlabClientFacade, error)

func (SimpleGitlabClientFactory) FromIntegrationUUID

func (factory SimpleGitlabClientFactory) FromIntegrationUUID(id uuid.UUID) (shared.GitlabClientFacade, error)

func (SimpleGitlabClientFactory) FromOauth2Token

func (factory SimpleGitlabClientFactory) FromOauth2Token(token models.GitLabOauth2Token, enableClientCache bool) (shared.GitlabClientFacade, error)

Jump to

Keyboard shortcuts

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