db

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertRepository

type AlertRepository interface {
	// Alert
	ListAlert(context.Context, uint32, []string, []string, string, int64, int64) (*[]model.Alert, error)
	GetAlert(context.Context, uint32, uint32) (*model.Alert, error)
	UpsertAlert(context.Context, *model.Alert) (*model.Alert, error)
	UpdateAlertFirstViewedAt(context.Context, uint32, uint32, int64) error
	DeleteAlert(context.Context, uint32, uint32) error
	ListAlertHistory(context.Context, uint32, uint32, string, uint32) (*[]model.AlertHistory, error)
	GetAlertHistory(context.Context, uint32, uint32) (*model.AlertHistory, error)
	UpsertAlertHistory(context.Context, *model.AlertHistory) (*model.AlertHistory, error)
	DeleteAlertHistory(context.Context, uint32, uint32) error
	ListRelAlertFinding(context.Context, uint32, uint32, uint64, int64, int64) (*[]model.RelAlertFinding, error)
	GetRelAlertFinding(context.Context, uint32, uint32, uint64) (*model.RelAlertFinding, error)
	UpsertRelAlertFinding(context.Context, *model.RelAlertFinding) (*model.RelAlertFinding, error)
	DeleteRelAlertFinding(context.Context, uint32, uint32, uint64) error
	ListAlertCondition(context.Context, uint32, []string, bool, int64, int64) (*[]model.AlertCondition, error)
	GetAlertCondition(context.Context, uint32, uint32) (*model.AlertCondition, error)
	UpsertAlertCondition(context.Context, *model.AlertCondition) (*model.AlertCondition, error)
	DeleteAlertCondition(context.Context, uint32, uint32) error
	ListAlertRule(context.Context, uint32, float32, float32, int64, int64) (*[]model.AlertRule, error)
	GetAlertRule(context.Context, uint32, uint32) (*model.AlertRule, error)
	UpsertAlertRule(context.Context, *model.AlertRule) (*model.AlertRule, error)
	DeleteAlertRule(context.Context, uint32, uint32) error
	ListAlertCondRule(context.Context, uint32, uint32, uint32, int64, int64) (*[]model.AlertCondRule, error)
	GetAlertCondRule(context.Context, uint32, uint32, uint32) (*model.AlertCondRule, error)
	UpsertAlertCondRule(context.Context, *model.AlertCondRule) (*model.AlertCondRule, error)
	DeleteAlertCondRule(context.Context, uint32, uint32, uint32) error
	ListNotification(context.Context, uint32, string, int64, int64) (*[]model.Notification, error)
	GetNotification(context.Context, uint32, uint32) (*model.Notification, error)
	UpsertNotification(context.Context, *model.Notification) (*model.Notification, error)
	DeleteNotification(context.Context, uint32, uint32) error
	ListAlertCondNotification(context.Context, uint32, uint32, uint32, int64, int64) (*[]model.AlertCondNotification, error)
	GetAlertCondNotification(context.Context, uint32, uint32, uint32) (*model.AlertCondNotification, error)
	UpsertAlertCondNotification(context.Context, *model.AlertCondNotification) (*model.AlertCondNotification, error)
	DeleteAlertCondNotification(context.Context, uint32, uint32, uint32) error

	// forAnalyze
	ListAlertRuleByAlertConditionID(context.Context, uint32, uint32) (*[]model.AlertRule, error)
	DeactivateAlert(context.Context, *model.Alert) error
	GetAlertByAlertConditionIDStatus(context.Context, uint32, uint32, []string) (*model.Alert, error)
	ListEnabledAlertCondition(context.Context, uint32, []uint32) (*[]model.AlertCondition, error)
	ListDisabledAlertCondition(context.Context, uint32, []uint32) (*[]model.AlertCondition, error)
}

type Client

type Client struct {
	Master *gorm.DB
	Slave  *gorm.DB
	// contains filtered or unexported fields
}

func NewClient

func NewClient(conf *Config, l logging.Logger) (*Client, error)

func (*Client) AttachAccessTokenRole

func (c *Client) AttachAccessTokenRole(ctx context.Context, projectID, roleID, accessTokenID uint32) (*model.AccessTokenRole, error)

func (*Client) AttachAllAdminRole

func (c *Client) AttachAllAdminRole(ctx context.Context, userID uint32) error

func (*Client) AttachPolicy

func (c *Client) AttachPolicy(ctx context.Context, projectID, roleID, policyID uint32) (*model.RolePolicy, error)

func (*Client) AttachRole

func (c *Client) AttachRole(ctx context.Context, projectID, roleID, userID uint32) (*model.UserRole, error)

func (*Client) BatchListFinding

func (c *Client) BatchListFinding(ctx context.Context, req *finding.BatchListFindingRequest) (*[]model.Finding, error)

func (*Client) BulkUpsertFinding

func (c *Client) BulkUpsertFinding(ctx context.Context, data []*model.Finding) error

func (*Client) BulkUpsertFindingTag

func (c *Client) BulkUpsertFindingTag(ctx context.Context, data []*model.FindingTag) error

func (*Client) BulkUpsertRecommend

func (c *Client) BulkUpsertRecommend(ctx context.Context, data []*model.Recommend) error

func (*Client) BulkUpsertRecommendFinding

func (c *Client) BulkUpsertRecommendFinding(ctx context.Context, data []*model.RecommendFinding) error

func (*Client) BulkUpsertResource

func (c *Client) BulkUpsertResource(ctx context.Context, data []*model.Resource) error

func (*Client) BulkUpsertResourceTag

func (c *Client) BulkUpsertResourceTag(ctx context.Context, data []*model.ResourceTag) error

func (*Client) CleanWithNoProject added in v0.5.0

func (c *Client) CleanWithNoProject(ctx context.Context) error

func (*Client) ClearScoreFinding

func (c *Client) ClearScoreFinding(ctx context.Context, req *finding.ClearScoreRequest) error

func (*Client) CollectReportFinding

func (c *Client) CollectReportFinding(ctx context.Context) error

func (*Client) CreateProject

func (c *Client) CreateProject(ctx context.Context, name string) (*model.Project, error)

func (*Client) CreateUser added in v0.5.0

func (c *Client) CreateUser(ctx context.Context, u *model.User) (*model.User, error)

func (*Client) DeactivateAlert

func (c *Client) DeactivateAlert(ctx context.Context, data *model.Alert) error

func (*Client) DeleteAccessToken

func (c *Client) DeleteAccessToken(ctx context.Context, projectID, accessTokenID uint32) error

func (*Client) DeleteAlert

func (c *Client) DeleteAlert(ctx context.Context, projectID uint32, alertID uint32) error

func (*Client) DeleteAlertCondNotification

func (c *Client) DeleteAlertCondNotification(ctx context.Context, projectID, alertConditionID, notificationID uint32) error

func (*Client) DeleteAlertCondRule

func (c *Client) DeleteAlertCondRule(ctx context.Context, projectID, alertConditionID, alertRuleID uint32) error

func (*Client) DeleteAlertCondition

func (c *Client) DeleteAlertCondition(ctx context.Context, projectID uint32, alertConditionID uint32) error

func (*Client) DeleteAlertHistory

func (c *Client) DeleteAlertHistory(ctx context.Context, projectID uint32, alertHistoryID uint32) error

func (*Client) DeleteAlertRule

func (c *Client) DeleteAlertRule(ctx context.Context, projectID uint32, alertRuleID uint32) error

func (*Client) DeleteFinding

func (c *Client) DeleteFinding(ctx context.Context, projectID uint32, findingID uint64) error

func (*Client) DeleteFindingSetting

func (c *Client) DeleteFindingSetting(ctx context.Context, projectID uint32, findingSettingID uint32) error

func (*Client) DeleteNoFindingIdTag added in v0.9.0

func (c *Client) DeleteNoFindingIdTag(ctx context.Context) error

func (*Client) DeleteNoResourceIdTag added in v0.9.0

func (c *Client) DeleteNoResourceIdTag(ctx context.Context) error

func (*Client) DeleteNotification

func (c *Client) DeleteNotification(ctx context.Context, projectID uint32, NotificationID uint32) error

func (*Client) DeleteOldFinding added in v0.9.0

func (c *Client) DeleteOldFinding(ctx context.Context, excludeDataSource []string) error

func (*Client) DeleteOldResource added in v0.9.0

func (c *Client) DeleteOldResource(ctx context.Context, excludeDataSource []string) error

func (*Client) DeletePendFinding

func (c *Client) DeletePendFinding(ctx context.Context, projectID uint32, findingID uint64) error

func (*Client) DeletePolicy

func (c *Client) DeletePolicy(ctx context.Context, projectID, policyID uint32) error

func (*Client) DeleteProject added in v0.5.0

func (c *Client) DeleteProject(ctx context.Context, projectID uint32) error

func (*Client) DeleteRelAlertFinding

func (c *Client) DeleteRelAlertFinding(ctx context.Context, projectID, alertID uint32, findingID uint64) error

func (*Client) DeleteResource

func (c *Client) DeleteResource(ctx context.Context, projectID uint32, resourceID uint64) error

func (*Client) DeleteRole

func (c *Client) DeleteRole(ctx context.Context, projectID, roleID uint32) error

func (*Client) DeleteTagByFindingID

func (c *Client) DeleteTagByFindingID(ctx context.Context, projectID uint32, findingID uint64) error

func (*Client) DeleteTagByResourceID

func (c *Client) DeleteTagByResourceID(ctx context.Context, projectID uint32, resourceID uint64) error

func (*Client) DeleteUserReserved added in v0.5.0

func (c *Client) DeleteUserReserved(ctx context.Context, projectID, reservedID uint32) error

func (*Client) DetachAccessTokenRole

func (c *Client) DetachAccessTokenRole(ctx context.Context, projectID, roleID, accessTokenID uint32) error

func (*Client) DetachPolicy

func (c *Client) DetachPolicy(ctx context.Context, projectID, roleID, policyID uint32) error

func (*Client) DetachRole

func (c *Client) DetachRole(ctx context.Context, projectID, roleID, userID uint32) error

func (*Client) ExistsAccessTokenMaintainer

func (c *Client) ExistsAccessTokenMaintainer(ctx context.Context, projectID, accessTokenID uint32) (bool, error)

func (*Client) GetAccessTokenByID

func (c *Client) GetAccessTokenByID(ctx context.Context, projectID, accessTokenID uint32) (*model.AccessToken, error)

func (*Client) GetAccessTokenByUniqueKey

func (c *Client) GetAccessTokenByUniqueKey(ctx context.Context, projectID uint32, name string) (*model.AccessToken, error)

func (*Client) GetAccessTokenRole

func (c *Client) GetAccessTokenRole(ctx context.Context, accessTokenID, roleID uint32) (*model.AccessTokenRole, error)

func (*Client) GetActiveAccessTokenHash

func (c *Client) GetActiveAccessTokenHash(ctx context.Context, projectID, accessTokenID uint32, tokenHash string) (*model.AccessToken, error)

func (*Client) GetActiveUserCount

func (c *Client) GetActiveUserCount(ctx context.Context) (*int, error)

func (*Client) GetAdminPolicy

func (c *Client) GetAdminPolicy(ctx context.Context, userID uint32) (*[]model.Policy, error)

func (*Client) GetAlert

func (c *Client) GetAlert(ctx context.Context, projectID uint32, alertID uint32) (*model.Alert, error)

func (*Client) GetAlertByAlertConditionIDStatus

func (c *Client) GetAlertByAlertConditionIDStatus(ctx context.Context, projectID uint32, AlertConditionID uint32, status []string) (*model.Alert, error)

func (*Client) GetAlertCondNotification

func (c *Client) GetAlertCondNotification(ctx context.Context, projectID, alertConditionID, notificationID uint32) (*model.AlertCondNotification, error)

func (*Client) GetAlertCondRule

func (c *Client) GetAlertCondRule(ctx context.Context, projectID, alertConditionID, alertRuleID uint32) (*model.AlertCondRule, error)

func (*Client) GetAlertCondition

func (c *Client) GetAlertCondition(ctx context.Context, projectID uint32, alertConditionID uint32) (*model.AlertCondition, error)

func (*Client) GetAlertHistory

func (c *Client) GetAlertHistory(ctx context.Context, projectID uint32, alertHistoryID uint32) (*model.AlertHistory, error)

func (*Client) GetAlertRule

func (c *Client) GetAlertRule(ctx context.Context, projectID uint32, alertRuleID uint32) (*model.AlertRule, error)

func (*Client) GetFinding

func (c *Client) GetFinding(ctx context.Context, projectID uint32, findingID uint64, immediately bool) (*model.Finding, error)

func (*Client) GetFindingByDataSource

func (c *Client) GetFindingByDataSource(ctx context.Context, projectID uint32, dataSource, dataSourceID string) (*model.Finding, error)

func (*Client) GetFindingSetting

func (c *Client) GetFindingSetting(ctx context.Context, projectID uint32, findingSettingID uint32) (*model.FindingSetting, error)

func (*Client) GetFindingSettingByResource

func (c *Client) GetFindingSettingByResource(ctx context.Context, projectID uint32, resourceName string) (*model.FindingSetting, error)

func (*Client) GetFindingTagByKey

func (c *Client) GetFindingTagByKey(ctx context.Context, projectID uint32, findingID uint64, tag string) (*model.FindingTag, error)

func (*Client) GetNotification

func (c *Client) GetNotification(ctx context.Context, projectID uint32, NotificationID uint32) (*model.Notification, error)

func (*Client) GetPendFinding

func (c *Client) GetPendFinding(ctx context.Context, projectID uint32, findingID uint64) (*model.PendFinding, error)

func (*Client) GetPolicy

func (c *Client) GetPolicy(ctx context.Context, projectID, policyID uint32) (*model.Policy, error)

func (*Client) GetPolicyByName

func (c *Client) GetPolicyByName(ctx context.Context, projectID uint32, name string) (*model.Policy, error)

func (*Client) GetProjectByName

func (c *Client) GetProjectByName(ctx context.Context, name string) (*model.Project, error)

func (*Client) GetProjectTag

func (c *Client) GetProjectTag(ctx context.Context, projectID uint32, tag string) (*model.ProjectTag, error)

func (*Client) GetRecommend

func (c *Client) GetRecommend(ctx context.Context, projectID uint32, findingID uint64) (*model.Recommend, error)

func (*Client) GetRecommendByDataSourceType

func (c *Client) GetRecommendByDataSourceType(ctx context.Context, dataSource, recommendType string) (*model.Recommend, error)

func (*Client) GetRelAlertFinding

func (c *Client) GetRelAlertFinding(ctx context.Context, projectID, alertID uint32, findingID uint64) (*model.RelAlertFinding, error)

func (*Client) GetReportFinding

func (c *Client) GetReportFinding(ctx context.Context, projectID uint32, dataSource []string, fromDate, toDate string, score float32) (*[]model.ReportFinding, error)

func (*Client) GetReportFindingAll

func (c *Client) GetReportFindingAll(ctx context.Context, dataSource []string, fromDate, toDate string, score float32) (*[]model.ReportFinding, error)

func (*Client) GetResource

func (c *Client) GetResource(ctx context.Context, projectID uint32, resourceID uint64) (*model.Resource, error)

func (*Client) GetResourceByName

func (c *Client) GetResourceByName(ctx context.Context, projectID uint32, resourceName string) (*model.Resource, error)

func (*Client) GetResourceTagByKey

func (c *Client) GetResourceTagByKey(ctx context.Context, projectID uint32, resourceID uint64, tag string) (*model.ResourceTag, error)

func (*Client) GetRole

func (c *Client) GetRole(ctx context.Context, projectID, roleID uint32) (*model.Role, error)

func (*Client) GetRoleByName

func (c *Client) GetRoleByName(ctx context.Context, projectID uint32, name string) (*model.Role, error)

func (*Client) GetRolePolicy

func (c *Client) GetRolePolicy(ctx context.Context, projectID, roleID, policyID uint32) (*model.RolePolicy, error)

func (*Client) GetTokenPolicy

func (c *Client) GetTokenPolicy(ctx context.Context, accessTokenID uint32) (*[]model.Policy, error)

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, userID uint32, sub, userIdpKey string) (*model.User, error)

func (*Client) GetUserBySub

func (c *Client) GetUserBySub(ctx context.Context, sub string) (*model.User, error)

func (*Client) GetUserByUserIdpKey added in v0.5.0

func (c *Client) GetUserByUserIdpKey(ctx context.Context, userIdpKey string) (*model.User, error)

func (*Client) GetUserPolicy

func (c *Client) GetUserPolicy(ctx context.Context, userID uint32) (*[]model.Policy, error)

func (*Client) GetUserRole

func (c *Client) GetUserRole(ctx context.Context, projectID, userID, roleID uint32) (*model.UserRole, error)

func (*Client) ListAccessToken

func (c *Client) ListAccessToken(ctx context.Context, projectID uint32, name string, accessTokenID uint32) (*[]model.AccessToken, error)

func (*Client) ListAlert

func (c *Client) ListAlert(ctx context.Context, projectID uint32, status []string, severity []string, description string, fromAt, toAt int64) (*[]model.Alert, error)

func (*Client) ListAlertCondNotification

func (c *Client) ListAlertCondNotification(ctx context.Context, projectID, alertConditionID, notificationID uint32, fromAt, toAt int64) (*[]model.AlertCondNotification, error)

func (*Client) ListAlertCondRule

func (c *Client) ListAlertCondRule(ctx context.Context, projectID, alertConditionID, alertRuleID uint32, fromAt, toAt int64) (*[]model.AlertCondRule, error)

func (*Client) ListAlertCondition

func (c *Client) ListAlertCondition(ctx context.Context, projectID uint32, severity []string, enabled bool, fromAt, toAt int64) (*[]model.AlertCondition, error)

func (*Client) ListAlertHistory

func (c *Client) ListAlertHistory(ctx context.Context, projectID, alertID uint32, historyType string, limit uint32) (*[]model.AlertHistory, error)

func (*Client) ListAlertRule

func (c *Client) ListAlertRule(ctx context.Context, projectID uint32, fromScore, toScore float32, fromAt, toAt int64) (*[]model.AlertRule, error)

func (*Client) ListAlertRuleByAlertConditionID

func (c *Client) ListAlertRuleByAlertConditionID(ctx context.Context, projectID, alertConditionID uint32) (*[]model.AlertRule, error)

func (*Client) ListDisabledAlertCondition

func (c *Client) ListDisabledAlertCondition(ctx context.Context, projectID uint32, alertConditionID []uint32) (*[]model.AlertCondition, error)

func (*Client) ListEnabledAlertCondition

func (c *Client) ListEnabledAlertCondition(ctx context.Context, projectID uint32, alertConditionID []uint32) (*[]model.AlertCondition, error)

func (*Client) ListExpiredAccessToken

func (c *Client) ListExpiredAccessToken(ctx context.Context) (*[]model.AccessToken, error)

func (*Client) ListFinding

func (c *Client) ListFinding(ctx context.Context, req *finding.ListFindingRequest) (*[]model.Finding, error)

func (*Client) ListFindingCount

func (c *Client) ListFindingCount(
	ctx context.Context,
	projectID, alertID uint32,
	fromScore, toScore float32,
	findingID uint64,
	dataSources, resourceNames, tags []string,
	status finding.FindingStatus) (int64, error)

func (*Client) ListFindingSetting

func (c *Client) ListFindingSetting(ctx context.Context, req *finding.ListFindingSettingRequest) (*[]model.FindingSetting, error)

func (*Client) ListFindingTag

func (c *Client) ListFindingTag(ctx context.Context, param *finding.ListFindingTagRequest) (*[]model.FindingTag, error)

func (*Client) ListFindingTagByFindingID

func (c *Client) ListFindingTagByFindingID(ctx context.Context, projectID uint32, findingID uint64) (*[]model.FindingTag, error)

func (*Client) ListFindingTagCount

func (c *Client) ListFindingTagCount(ctx context.Context, param *finding.ListFindingTagRequest) (int64, error)

func (*Client) ListFindingTagName

func (c *Client) ListFindingTagName(ctx context.Context, param *finding.ListFindingTagNameRequest) (*[]TagName, error)

func (*Client) ListFindingTagNameCount

func (c *Client) ListFindingTagNameCount(ctx context.Context, param *finding.ListFindingTagNameRequest) (int64, error)

func (*Client) ListNotification

func (c *Client) ListNotification(ctx context.Context, projectID uint32, notifyType string, fromAt, toAt int64) (*[]model.Notification, error)

func (*Client) ListPolicy

func (c *Client) ListPolicy(ctx context.Context, projectID uint32, name string, roleID uint32) (*[]model.Policy, error)

func (*Client) ListProject

func (c *Client) ListProject(ctx context.Context, userID, projectID uint32, name string) (*[]ProjectWithTag, error)

func (*Client) ListRelAlertFinding

func (c *Client) ListRelAlertFinding(ctx context.Context, projectID, alertID uint32, findingID uint64, fromAt, toAt int64) (*[]model.RelAlertFinding, error)

func (*Client) ListResource

func (c *Client) ListResource(ctx context.Context, req *finding.ListResourceRequest) (*[]model.Resource, error)

func (*Client) ListResourceCount

func (c *Client) ListResourceCount(ctx context.Context, req *finding.ListResourceRequest) (int64, error)

func (*Client) ListResourceTag

func (c *Client) ListResourceTag(ctx context.Context, param *finding.ListResourceTagRequest) (*[]model.ResourceTag, error)

func (*Client) ListResourceTagByResourceID

func (c *Client) ListResourceTagByResourceID(ctx context.Context, projectID uint32, resourceID uint64) (*[]model.ResourceTag, error)

func (*Client) ListResourceTagCount

func (c *Client) ListResourceTagCount(ctx context.Context, param *finding.ListResourceTagRequest) (int64, error)

func (*Client) ListResourceTagName

func (c *Client) ListResourceTagName(ctx context.Context, param *finding.ListResourceTagNameRequest) (*[]TagName, error)

func (*Client) ListResourceTagNameCount

func (c *Client) ListResourceTagNameCount(ctx context.Context, param *finding.ListResourceTagNameRequest) (int64, error)

func (*Client) ListRole

func (c *Client) ListRole(ctx context.Context, projectID uint32, name string, userID uint32, accessTokenID uint32) (*[]model.Role, error)

func (*Client) ListUser

func (c *Client) ListUser(ctx context.Context, activated bool, projectID uint32, name string, userID uint32, admin bool, userIdpKey string) (*[]model.User, error)

func (*Client) ListUserReserved added in v0.5.0

func (c *Client) ListUserReserved(ctx context.Context, projectID uint32, userIdpKey string) (*[]model.UserReserved, error)

func (*Client) ListUserReservedWithProjectID added in v0.5.0

func (c *Client) ListUserReservedWithProjectID(ctx context.Context, userIdpKey string) (*[]UserReservedWithProjectID, error)

func (*Client) PurgeReportFinding added in v0.7.0

func (c *Client) PurgeReportFinding(ctx context.Context) error

func (*Client) PutAccessToken

func (c *Client) PutAccessToken(ctx context.Context, r *model.AccessToken) (*model.AccessToken, error)

func (*Client) PutPolicy

func (c *Client) PutPolicy(ctx context.Context, p *model.Policy) (*model.Policy, error)

func (*Client) PutRole

func (c *Client) PutRole(ctx context.Context, r *model.Role) (*model.Role, error)

func (*Client) PutUser

func (c *Client) PutUser(ctx context.Context, u *model.User) (*model.User, error)

func (*Client) PutUserReserved added in v0.5.0

func (c *Client) PutUserReserved(ctx context.Context, data *model.UserReserved) (*model.UserReserved, error)

func (*Client) TagFinding

func (c *Client) TagFinding(ctx context.Context, tag *model.FindingTag) (*model.FindingTag, error)

func (*Client) TagProject

func (c *Client) TagProject(ctx context.Context, projectID uint32, tag, color string) (*model.ProjectTag, error)

func (*Client) TagResource

func (c *Client) TagResource(ctx context.Context, tag *model.ResourceTag) (*model.ResourceTag, error)

func (*Client) UntagFinding

func (c *Client) UntagFinding(ctx context.Context, projectID uint32, findingTagID uint64) error

func (*Client) UntagProject

func (c *Client) UntagProject(ctx context.Context, projectID uint32, tag string) error

func (*Client) UntagResource

func (c *Client) UntagResource(ctx context.Context, projectID uint32, resourceTagID uint64) error

func (*Client) UpdateAlertFirstViewedAt added in v0.10.0

func (c *Client) UpdateAlertFirstViewedAt(ctx context.Context, projectID, alertID uint32, viewedAt int64) error

func (*Client) UpdateProject

func (c *Client) UpdateProject(ctx context.Context, projectID uint32, name string) (*model.Project, error)

func (*Client) UpsertAlert

func (c *Client) UpsertAlert(ctx context.Context, data *model.Alert) (*model.Alert, error)

func (*Client) UpsertAlertCondNotification

func (c *Client) UpsertAlertCondNotification(ctx context.Context, data *model.AlertCondNotification) (*model.AlertCondNotification, error)

func (*Client) UpsertAlertCondRule

func (c *Client) UpsertAlertCondRule(ctx context.Context, data *model.AlertCondRule) (*model.AlertCondRule, error)

func (*Client) UpsertAlertCondition

func (c *Client) UpsertAlertCondition(ctx context.Context, data *model.AlertCondition) (*model.AlertCondition, error)

func (*Client) UpsertAlertHistory

func (c *Client) UpsertAlertHistory(ctx context.Context, data *model.AlertHistory) (*model.AlertHistory, error)

func (*Client) UpsertAlertRule

func (c *Client) UpsertAlertRule(ctx context.Context, data *model.AlertRule) (*model.AlertRule, error)

func (*Client) UpsertFinding

func (c *Client) UpsertFinding(ctx context.Context, data *model.Finding) (*model.Finding, error)

func (*Client) UpsertFindingSetting

func (c *Client) UpsertFindingSetting(ctx context.Context, data *model.FindingSetting) (*model.FindingSetting, error)

func (*Client) UpsertNotification

func (c *Client) UpsertNotification(ctx context.Context, data *model.Notification) (*model.Notification, error)

func (*Client) UpsertPendFinding

func (c *Client) UpsertPendFinding(ctx context.Context, findingID uint64, projectID uint32, pendUserID uint32, note string, reason string, expiredAtInt int64) (*model.PendFinding, error)

func (*Client) UpsertRecommend

func (c *Client) UpsertRecommend(ctx context.Context, data *model.Recommend) (*model.Recommend, error)

func (*Client) UpsertRecommendFinding

func (c *Client) UpsertRecommendFinding(ctx context.Context, data *model.RecommendFinding) (*model.RecommendFinding, error)

func (*Client) UpsertRelAlertFinding

func (c *Client) UpsertRelAlertFinding(ctx context.Context, data *model.RelAlertFinding) (*model.RelAlertFinding, error)

func (*Client) UpsertResource

func (c *Client) UpsertResource(ctx context.Context, data *model.Resource) (*model.Resource, error)

type Config

type Config struct {
	MasterHost     string
	MasterUser     string
	MasterPassword string
	SlaveHost      string
	SlaveUser      string
	SlavePassword  string

	Schema        string
	Port          int
	LogMode       bool
	MaxConnection int
}

type FindingRepository

type FindingRepository interface {
	// Finding
	ListFinding(context.Context, *finding.ListFindingRequest) (*[]model.Finding, error)
	BatchListFinding(context.Context, *finding.BatchListFindingRequest) (*[]model.Finding, error)
	ListFindingCount(
		ctx context.Context,
		projectID, alertID uint32,
		fromScore, toScore float32,
		findingID uint64,
		dataSources, resourceNames, tags []string,
		status finding.FindingStatus,
	) (int64, error)
	GetFinding(context.Context, uint32, uint64, bool) (*model.Finding, error)
	GetFindingByDataSource(context.Context, uint32, string, string) (*model.Finding, error)
	UpsertFinding(context.Context, *model.Finding) (*model.Finding, error)
	DeleteFinding(context.Context, uint32, uint64) error
	ListFindingTag(ctx context.Context, param *finding.ListFindingTagRequest) (*[]model.FindingTag, error)
	ListFindingTagByFindingID(ctx context.Context, projectID uint32, findingID uint64) (*[]model.FindingTag, error)
	ListFindingTagCount(ctx context.Context, param *finding.ListFindingTagRequest) (int64, error)
	ListFindingTagName(ctx context.Context, param *finding.ListFindingTagNameRequest) (*[]TagName, error)
	ListFindingTagNameCount(ctx context.Context, param *finding.ListFindingTagNameRequest) (int64, error)
	GetFindingTagByKey(context.Context, uint32, uint64, string) (*model.FindingTag, error)
	TagFinding(context.Context, *model.FindingTag) (*model.FindingTag, error)
	UntagFinding(context.Context, uint32, uint64) error
	ClearScoreFinding(ctx context.Context, req *finding.ClearScoreRequest) error
	BulkUpsertFinding(ctx context.Context, data []*model.Finding) error
	BulkUpsertFindingTag(ctx context.Context, data []*model.FindingTag) error

	// Resource
	ListResource(context.Context, *finding.ListResourceRequest) (*[]model.Resource, error)
	ListResourceCount(ctx context.Context, req *finding.ListResourceRequest) (int64, error)
	GetResource(context.Context, uint32, uint64) (*model.Resource, error)
	GetResourceByName(context.Context, uint32, string) (*model.Resource, error)
	UpsertResource(context.Context, *model.Resource) (*model.Resource, error)
	DeleteResource(context.Context, uint32, uint64) error
	ListResourceTag(ctx context.Context, param *finding.ListResourceTagRequest) (*[]model.ResourceTag, error)
	ListResourceTagByResourceID(ctx context.Context, projectID uint32, resourceID uint64) (*[]model.ResourceTag, error)
	ListResourceTagCount(ctx context.Context, param *finding.ListResourceTagRequest) (int64, error)
	ListResourceTagName(ctx context.Context, param *finding.ListResourceTagNameRequest) (*[]TagName, error)
	ListResourceTagNameCount(ctx context.Context, param *finding.ListResourceTagNameRequest) (int64, error)
	GetResourceTagByKey(context.Context, uint32, uint64, string) (*model.ResourceTag, error)
	TagResource(context.Context, *model.ResourceTag) (*model.ResourceTag, error)
	UntagResource(context.Context, uint32, uint64) error
	BulkUpsertResource(ctx context.Context, data []*model.Resource) error
	BulkUpsertResourceTag(ctx context.Context, data []*model.ResourceTag) error

	// PendFinding
	GetPendFinding(ctx context.Context, projectID uint32, findingID uint64) (*model.PendFinding, error)
	UpsertPendFinding(ctx context.Context, findingID uint64, projectID uint32, pendUserID uint32, note string, reason string, expiredAtInt int64) (*model.PendFinding, error)
	DeletePendFinding(ctx context.Context, projectID uint32, findingID uint64) error

	// FindingSetting
	ListFindingSetting(ctx context.Context, req *finding.ListFindingSettingRequest) (*[]model.FindingSetting, error)
	GetFindingSetting(ctx context.Context, projectID uint32, findingSettingID uint32) (*model.FindingSetting, error)
	GetFindingSettingByResource(ctx context.Context, projectID uint32, resourceName string) (*model.FindingSetting, error)
	UpsertFindingSetting(ctx context.Context, data *model.FindingSetting) (*model.FindingSetting, error)
	DeleteFindingSetting(ctx context.Context, projectID uint32, findingSettingID uint32) error

	// Recommend
	GetRecommend(ctx context.Context, projectID uint32, findingID uint64) (*model.Recommend, error)
	UpsertRecommend(ctx context.Context, data *model.Recommend) (*model.Recommend, error)
	UpsertRecommendFinding(ctx context.Context, data *model.RecommendFinding) (*model.RecommendFinding, error)
	GetRecommendByDataSourceType(ctx context.Context, dataSource, recommendType string) (*model.Recommend, error)
	BulkUpsertRecommend(ctx context.Context, data []*model.Recommend) error
	BulkUpsertRecommendFinding(ctx context.Context, data []*model.RecommendFinding) error

	// Clean
	DeleteOldResource(ctx context.Context, excludeDataSource []string) error
	DeleteNoResourceIdTag(ctx context.Context) error
	DeleteOldFinding(ctx context.Context, excludeDataSource []string) error
	DeleteNoFindingIdTag(ctx context.Context) error
}

type IAMRepository

type IAMRepository interface {
	// User
	ListUser(ctx context.Context, activated bool, projectID uint32, name string, userID uint32, admin bool, userIdpKey string) (*[]model.User, error)
	GetUser(ctx context.Context, userID uint32, sub, userIdpKey string) (*model.User, error)
	GetUserBySub(ctx context.Context, sub string) (*model.User, error)
	CreateUser(ctx context.Context, u *model.User) (*model.User, error)
	PutUser(ctx context.Context, u *model.User) (*model.User, error)
	GetActiveUserCount(ctx context.Context) (*int, error)
	GetUserByUserIdpKey(ctx context.Context, userIdpKey string) (*model.User, error)

	// Role
	ListRole(ctx context.Context, projectID uint32, name string, userID uint32, accessTokenID uint32) (*[]model.Role, error)
	GetRole(ctx context.Context, projectID, roleID uint32) (*model.Role, error)
	GetRoleByName(ctx context.Context, projectID uint32, name string) (*model.Role, error)
	PutRole(ctx context.Context, r *model.Role) (*model.Role, error)
	DeleteRole(ctx context.Context, projectID, roleID uint32) error
	AttachRole(ctx context.Context, projectID, roleID, userID uint32) (*model.UserRole, error)
	AttachAllAdminRole(ctx context.Context, userID uint32) error
	DetachRole(ctx context.Context, projectID, roleID, userID uint32) error

	// Policy
	GetUserPolicy(ctx context.Context, userID uint32) (*[]model.Policy, error)
	GetTokenPolicy(ctx context.Context, accessTokenID uint32) (*[]model.Policy, error)
	GetAdminPolicy(ctx context.Context, userID uint32) (*[]model.Policy, error)
	ListPolicy(ctx context.Context, projectID uint32, name string, roleID uint32) (*[]model.Policy, error)
	GetPolicy(ctx context.Context, projectID, policyID uint32) (*model.Policy, error)
	GetPolicyByName(ctx context.Context, projectID uint32, name string) (*model.Policy, error)
	PutPolicy(ctx context.Context, p *model.Policy) (*model.Policy, error)
	DeletePolicy(ctx context.Context, projectID, policyID uint32) error
	AttachPolicy(ctx context.Context, projectID, roleID, policyID uint32) (*model.RolePolicy, error)
	DetachPolicy(ctx context.Context, projectID, roleID, policyID uint32) error

	// AccessToken
	ListAccessToken(ctx context.Context, projectID uint32, name string, accessTokenID uint32) (*[]model.AccessToken, error)
	GetAccessTokenByUniqueKey(ctx context.Context, projectID uint32, name string) (*model.AccessToken, error)
	GetActiveAccessTokenHash(ctx context.Context, projectID, accessTokenID uint32, tokenHash string) (*model.AccessToken, error)
	PutAccessToken(ctx context.Context, r *model.AccessToken) (*model.AccessToken, error)
	DeleteAccessToken(ctx context.Context, projectID, accessTokenID uint32) error
	AttachAccessTokenRole(ctx context.Context, projectID, roleID, accessTokenID uint32) (*model.AccessTokenRole, error)
	DetachAccessTokenRole(ctx context.Context, projectID, roleID, accessTokenID uint32) error
	ExistsAccessTokenMaintainer(ctx context.Context, projectID, accessTokenID uint32) (bool, error)
	ListExpiredAccessToken(ctx context.Context) (*[]model.AccessToken, error)

	// UserReserved
	ListUserReserved(ctx context.Context, projectID uint32, userIdpKey string) (*[]model.UserReserved, error)
	ListUserReservedWithProjectID(ctx context.Context, userIdpKey string) (*[]UserReservedWithProjectID, error)
	PutUserReserved(ctx context.Context, u *model.UserReserved) (*model.UserReserved, error)
	DeleteUserReserved(ctx context.Context, projectID, reservedID uint32) error
}

type ProjectRepository

type ProjectRepository interface {
	ListProject(ctx context.Context, userID, projectID uint32, name string) (*[]ProjectWithTag, error)
	CreateProject(ctx context.Context, name string) (*model.Project, error)
	UpdateProject(ctx context.Context, projectID uint32, name string) (*model.Project, error)
	DeleteProject(ctx context.Context, projectID uint32) error

	TagProject(ctx context.Context, projectID uint32, tag, color string) (*model.ProjectTag, error)
	UntagProject(ctx context.Context, projectID uint32, tag string) error

	CleanWithNoProject(context.Context) error
}

type ProjectWithTag

type ProjectWithTag struct {
	ProjectID uint32
	Name      string
	Tag       *[]model.ProjectTag
	CreatedAt time.Time
	UpdatedAt time.Time
}

type ReportRepository

type ReportRepository interface {
	// Report
	GetReportFinding(context.Context, uint32, []string, string, string, float32) (*[]model.ReportFinding, error)
	GetReportFindingAll(context.Context, []string, string, string, float32) (*[]model.ReportFinding, error)
	CollectReportFinding(ctx context.Context) error
	PurgeReportFinding(ctx context.Context) error
}

type TagName

type TagName struct {
	Tag string
}

type UserReservedWithProjectID added in v0.5.0

type UserReservedWithProjectID struct {
	ProjectID  uint32
	ReservedID uint32
	RoleID     uint32
}

For ListUserReservedWithProjectID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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