postgresql

package
v1.1.17 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrParsingFinding indicates an error when parsing finding data retrieved from database.
	ErrParsingFinding = errors.New("Error parsing finding data")
)

Functions

This section is empty.

Types

type ConnStr

type ConnStr struct {
	Host    string `toml:"host"`
	Port    string `toml:"port"`
	User    string `toml:"user"`
	Pass    string `toml:"pass"`
	DB      string `toml:"db"`
	SSLMode string `toml:"sslmode"`
}

ConnStr holds the PostgreSQL connection information.

type DB

type DB struct {
	DB     *sqlx.DB
	DBRw   *sqlx.DB
	Logger echo.Logger
}

DB holds the database connection.

func NewDB

func NewDB(cs ConnStr, csRead ConnStr, logger echo.Logger) (*DB, error)

NewDB instantiates a new PosgreSQL connection.

func (DB) CreateTarget

func (db DB) CreateTarget(t model.Target) (model.Target, error)

CreateTarget creates the given target. If the target contains teams associated, these are created as part of the same transaction. If target or associated teams already exist, no error is returned.

func (DB) DeleteTargetTeam added in v1.1.0

func (db DB) DeleteTargetTeam(targetID, teamID string) error

DeleteTargetTeam deletes the association between a target and a team.

func (DB) DeleteTeam added in v1.1.0

func (db DB) DeleteTeam(teamID string) error

DeleteTeam deletes all target associations for a team.

func (DB) GetFinding

func (db DB) GetFinding(id string) (model.FindingExpanded, error)

GetFinding returns a specific finding.

func (DB) GetFindingFromTargetIssueAndResource

func (db DB) GetFindingFromTargetIssueAndResource(targetID, affectedResource, issueID string) (model.FindingExpanded, error)

GetFindingFromTargetIssueAndResource returns a concrete finding specified by the given target ID, issue ID and affected resource.

func (DB) GetFindingMTTR

func (db DB) GetFindingMTTR(id string) (float32, error)

GetFindingMTTR returns the mean time to rememdiate a specific finding.

func (DB) GetIssue

func (db DB) GetIssue(id string) (model.Issue, error)

GetIssue returns a specific issue.

func (DB) GetIssueMTTR

func (db DB) GetIssueMTTR(id string) (float32, error)

GetIssueMTTR returns the mean time to remediate a specific issue.

func (DB) GetSource

func (db DB) GetSource(id string) (model.Source, error)

GetSource returns a specifc source.

func (DB) GetSourceMTTR

func (db DB) GetSourceMTTR(id string) (float32, error)

GetSourceMTTR returns the mean time to remedite among all the sources with the same name, component and options as the given source ID.

func (DB) GetTarget

func (db DB) GetTarget(id string) (model.Target, error)

GetTarget returns a specific target.

func (DB) GetTargetMTTR

func (db DB) GetTargetMTTR(id string) (float32, error)

GetTargetMTTR returns the mean time to remediate findings in a specific target.

func (DB) IssuesSummary

func (db DB) IssuesSummary(filter storage.Filter) ([]model.IssueSummary, storage.Pagination, error)

IssuesSummary returns a filtered list of issues.

func (DB) ListFindingEvents

func (db DB) ListFindingEvents(filter storage.Filter) ([]model.FindingEvent, storage.Pagination, error)

ListFindingEvents returns a filtered list of finding events.

func (DB) ListFindingEventsByFinding

func (db DB) ListFindingEventsByFinding(id string, filter storage.Filter) ([]model.FindingEvent, storage.Pagination, error)

ListFindingEventsByFinding returns a filtered list of finding events for a specific finding.

func (DB) ListFindings

func (db DB) ListFindings(filter storage.Filter) ([]model.FindingExpanded, storage.Pagination, error)

ListFindings returns a filtered list of findings.

func (DB) ListFindingsByIssue

func (db DB) ListFindingsByIssue(id string, filter storage.Filter) ([]model.FindingExpanded, storage.Pagination, error)

ListFindingsByIssue returns a paginated list of findings for a specific issue for a given status.

func (DB) ListFindingsBySource

func (db DB) ListFindingsBySource(id string, filter storage.Filter) ([]model.FindingExpanded, storage.Pagination, error)

ListFindingsBySource returns a paginated list of findings for a specific source for a given status.

func (DB) ListFindingsByTarget

func (db DB) ListFindingsByTarget(id string, filter storage.Filter) ([]model.FindingExpanded, storage.Pagination, error)

ListFindingsByTarget returns a filtered list of findings for a specific target.

func (DB) ListIssues

func (db DB) ListIssues(filter storage.Filter) ([]model.Issue, storage.Pagination, error)

ListIssues returns a filtered list of issues.

func (DB) ListLabels

func (db DB) ListLabels(filter storage.Filter) ([]string, error)

ListLabels returns a filtered list of labels.

func (DB) ListSources

func (db DB) ListSources(filter storage.Filter) ([]model.Source, storage.Pagination, error)

ListSources returns a paginated list of sources.

func (DB) ListTargets

func (db DB) ListTargets(filter storage.Filter) ([]model.Target, storage.Pagination, error)

ListTargets returns a paginated list of targets.

func (DB) PatchFinding

func (db DB) PatchFinding(id string, payload model.PatchFindingPayload) error

PatchFinding returns a specific finding.

func (DB) StatsAssetsPerSeverity

func (db DB) StatsAssetsPerSeverity(filter storage.Filter) (model.StatsAssetsSeverity, error)

StatsAssetsPerSeverity returns the number of assets per severity taking into account the open vulnerability with highest score from the ones associated with the target.

func (DB) StatsCurrentExposure

func (db DB) StatsCurrentExposure(filter storage.Filter) (model.StatsExposure, error)

StatsCurrentExposure returns the current exposure times by diferent averages.

func (DB) StatsExposure

func (db DB) StatsExposure(filter storage.Filter) (model.StatsExposure, error)

StatsExposure returns the exposure times by diferent averages.

func (DB) StatsFixedIssues

func (db DB) StatsFixedIssues(filter storage.Filter) (model.StatsIssueSeverity, error)

StatsFixedIssues returns statistics about the number of FIXED findings for each issue severity.

func (DB) StatsIssues

func (db DB) StatsIssues(filter storage.Filter) ([]model.Issue, storage.Pagination, error)

StatsIssues returns a list of aggregated issues from a set of finding events.

func (DB) StatsMTTR

func (db DB) StatsMTTR(filter storage.Filter) (model.StatsMTTRSeverity, error)

StatsMTTR returns the mean time to remediate by issue severity.

func (DB) StatsOpenIssues

func (db DB) StatsOpenIssues(filter storage.Filter) (model.StatsIssueSeverity, error)

StatsOpenIssues returns statistics about the number of OPEN findings for each issue severity.

func (DB) StatsSize

func (db DB) StatsSize() (model.StatsSize, error)

StatsSize returns statistics about the size of each data set.

func (DB) TargetsSummary

func (db DB) TargetsSummary(filter storage.Filter) ([]model.TargetSummary, storage.Pagination, error)

TargetsSummary returns a filtered list of issues.

Jump to

Keyboard shortcuts

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