Documentation
¶
Overview ¶
Package rest implements the HTTP presentation layer for ScanVault. Controllers, routes, and request/response types all live here.
Index ¶
- func RegisterRoutes(router *gin.Engine, h *ScanController, disableLocalSave bool, jsonPath string) *fuego.Engine
- type AffectedImageDTO
- type CVEAffectedImagesResponseDTO
- type FixableSummaryResponseDTO
- type FixableVulnerabilityDTO
- type HealthResponse
- type ScanController
- func (h *ScanController) CreateScan(c *gin.Context)
- func (h *ScanController) GetCVEAffectedImages(c *gin.Context)
- func (h *ScanController) GetFixableSummary(c *gin.Context)
- func (h *ScanController) GetLatestScan(c *gin.Context)
- func (h *ScanController) GetScanVulnerabilities(c *gin.Context)
- func (h *ScanController) GetTopCVEs(c *gin.Context)
- func (h *ScanController) GetVulnerabilitySummary(c *gin.Context)
- func (h *ScanController) GetVulnerabilityTrends(c *gin.Context)
- func (h *ScanController) HealthCheck(c *gin.Context)
- func (h *ScanController) ListAllScans(c *gin.Context)
- func (h *ScanController) ListScans(c *gin.Context)
- type ScanResponseDTO
- type ScanVulnerabilitiesResponseDTO
- type ScanVulnerabilityDetailDTO
- type ScanVulnerabilityItemDTO
- type ScansListResponseDTO
- type Server
- type SeverityCountDTO
- type TopCVEDTO
- type TopCVEsResponseDTO
- type TrivyMetadataDTO
- type TrivyMetadataResponseDTO
- type TrivyReportDTO
- type TrivyReportResponseDTO
- type TrivyResultDTO
- type TrivyResultResponseDTO
- type TrivyVulnerabilityDTO
- type TrivyVulnerabilityResponseDTO
- type VulnerabilitySummaryResponseDTO
- type VulnerabilityTrendPointDTO
- type VulnerabilityTrendsResponseDTO
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶
func RegisterRoutes(router *gin.Engine, h *ScanController, disableLocalSave bool, jsonPath string) *fuego.Engine
RegisterRoutes wires all HTTP routes and returns the fuego Engine (for OpenAPI generation).
Types ¶
type AffectedImageDTO ¶
type AffectedImageDTO struct {
ImageName string `json:"ImageName"`
ImageTag string `json:"ImageTag"`
PkgName string `json:"PkgName"`
PkgVersion string `json:"PkgVersion,omitempty"`
FixedVersion string `json:"FixedVersion,omitempty"`
ScannedAt time.Time `json:"ScannedAt"`
}
AffectedImageDTO is one image affected by a specific CVE.
type CVEAffectedImagesResponseDTO ¶
type CVEAffectedImagesResponseDTO struct {
CVEID string `json:"CVEID"`
Count int `json:"Count"`
Images []AffectedImageDTO `json:"Images"`
}
CVEAffectedImagesResponseDTO is the API response DTO for CVE affected images.
type FixableSummaryResponseDTO ¶
type FixableSummaryResponseDTO struct {
Image string `json:"Image,omitempty"`
TotalVulns int64 `json:"TotalVulns"`
Fixable int64 `json:"Fixable"`
NotFixable int64 `json:"NotFixable"`
FixablePct float64 `json:"FixablePct"`
FixableItems []FixableVulnerabilityDTO `json:"FixableItems"`
}
FixableSummaryResponseDTO is the API response DTO for fixable analytics.
type FixableVulnerabilityDTO ¶
type FixableVulnerabilityDTO struct {
CVEID string `json:"CVEID"`
PkgName string `json:"PkgName"`
PkgVersion string `json:"PkgVersion,omitempty"`
FixedVersion string `json:"FixedVersion"`
Severity string `json:"Severity"`
Title string `json:"Title,omitempty"`
ImageName string `json:"ImageName"`
ImageTag string `json:"ImageTag"`
}
FixableVulnerabilityDTO is one vulnerability with a known fix.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
}
HealthResponse is the response envelope for health checks.
type ScanController ¶
type ScanController struct {
// contains filtered or unexported fields
}
ScanController handles scan CRUD HTTP endpoints.
func NewScanController ¶
func NewScanController(uc *usecases.ScanUseCases, logger zerolog.Logger) *ScanController
NewScanController creates a new ScanController.
func (*ScanController) CreateScan ¶
func (h *ScanController) CreateScan(c *gin.Context)
CreateScan handles POST /scans.
func (*ScanController) GetCVEAffectedImages ¶
func (h *ScanController) GetCVEAffectedImages(c *gin.Context)
GetCVEAffectedImages handles GET /analytics/vulnerabilities/cve/:cve_id/images.
func (*ScanController) GetFixableSummary ¶
func (h *ScanController) GetFixableSummary(c *gin.Context)
GetFixableSummary handles GET /analytics/vulnerabilities/fixable.
func (*ScanController) GetLatestScan ¶
func (h *ScanController) GetLatestScan(c *gin.Context)
GetLatestScan handles GET /scans/latest?image=<name>.
func (*ScanController) GetScanVulnerabilities ¶
func (h *ScanController) GetScanVulnerabilities(c *gin.Context)
GetScanVulnerabilities handles GET /scans/:id/vulnerabilities.
func (*ScanController) GetTopCVEs ¶
func (h *ScanController) GetTopCVEs(c *gin.Context)
GetTopCVEs handles GET /analytics/vulnerabilities/top-cves.
func (*ScanController) GetVulnerabilitySummary ¶
func (h *ScanController) GetVulnerabilitySummary(c *gin.Context)
GetVulnerabilitySummary handles GET /analytics/vulnerabilities/summary.
func (*ScanController) GetVulnerabilityTrends ¶
func (h *ScanController) GetVulnerabilityTrends(c *gin.Context)
GetVulnerabilityTrends handles GET /analytics/vulnerabilities/trends.
func (*ScanController) HealthCheck ¶
func (h *ScanController) HealthCheck(c *gin.Context)
HealthCheck handles GET /health.
func (*ScanController) ListAllScans ¶
func (h *ScanController) ListAllScans(c *gin.Context)
ListAllScans handles GET /scans/all.
func (*ScanController) ListScans ¶
func (h *ScanController) ListScans(c *gin.Context)
ListScans handles GET /scans?tag=<tag> or GET /scans?image=<name>[&severity=<level>].
type ScanResponseDTO ¶
type ScanResponseDTO struct {
ID string `json:"ID"`
ImageName string `json:"ImageName"`
ImageTag string `json:"ImageTag"`
ImageDigest string `json:"ImageDigest"`
ScanResult TrivyReportResponseDTO `json:"ScanResult"`
CreatedAt time.Time `json:"CreatedAt"`
VulnCritical int `json:"VulnCritical"`
VulnHigh int `json:"VulnHigh"`
VulnMedium int `json:"VulnMedium"`
VulnLow int `json:"VulnLow"`
VulnUnknown int `json:"VulnUnknown"`
}
ScanResponseDTO is the API response DTO for one scan.
type ScanVulnerabilitiesResponseDTO ¶
type ScanVulnerabilitiesResponseDTO struct {
ScanID string `json:"ScanID"`
ImageName string `json:"ImageName"`
ImageTag string `json:"ImageTag"`
Severity string `json:"Severity,omitempty"`
Pkg string `json:"Pkg,omitempty"`
Count int `json:"Count"`
Items []ScanVulnerabilityItemDTO `json:"Items"`
}
ScanVulnerabilitiesResponseDTO is the API response DTO for GET /scans/:id/vulnerabilities.
type ScanVulnerabilityDetailDTO ¶ added in v0.0.2
type ScanVulnerabilityDetailDTO struct {
VulnerabilityID string `json:"VulnerabilityID"`
PkgName string `json:"PkgName"`
PkgVersion string `json:"PkgVersion,omitempty"`
CurrentVersion string `json:"CurrentVersion,omitempty"`
FixedVersion string `json:"FixedVersion,omitempty"`
Severity string `json:"Severity"`
Title string `json:"Title,omitempty"`
}
ScanVulnerabilityDetailDTO is one vulnerability detail returned by GET /scans/:id/vulnerabilities.
type ScanVulnerabilityItemDTO ¶
type ScanVulnerabilityItemDTO struct {
Target string `json:"Target"`
Class string `json:"Class,omitempty"`
Type string `json:"Type,omitempty"`
Vulnerability ScanVulnerabilityDetailDTO `json:"Vulnerability"`
}
ScanVulnerabilityItemDTO is one vulnerability item in a scan vulnerability response.
type ScansListResponseDTO ¶
type ScansListResponseDTO struct {
Image string `json:"Image,omitempty"`
Tag string `json:"Tag,omitempty"`
Severity string `json:"Severity,omitempty"`
Count int `json:"Count"`
Limit int `json:"Limit,omitempty"`
Offset int `json:"Offset,omitempty"`
Items []ScanResponseDTO `json:"Items"`
}
ScansListResponseDTO is the API response DTO for scan lists.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps the HTTP server and its dependencies.
type SeverityCountDTO ¶
SeverityCountDTO is one aggregate severity bucket for analytics.
type TopCVEDTO ¶
type TopCVEDTO struct {
CVEID string `json:"CVEID"`
Severity string `json:"Severity"`
Title string `json:"Title,omitempty"`
ImageCount int64 `json:"ImageCount"`
Fixable bool `json:"Fixable"`
}
TopCVEDTO is a CVE aggregated across latest scans.
type TopCVEsResponseDTO ¶
type TopCVEsResponseDTO struct {
Image string `json:"Image,omitempty"`
Severity string `json:"Severity,omitempty"`
Limit int `json:"Limit"`
From *time.Time `json:"From,omitempty"`
To *time.Time `json:"To,omitempty"`
Count int `json:"Count"`
CVEs []TopCVEDTO `json:"CVEs"`
}
TopCVEsResponseDTO is the API response DTO for top CVE analytics.
type TrivyMetadataDTO ¶
type TrivyMetadataDTO struct {
ImageID string `json:"ImageID,omitempty"`
RepoTags []string `json:"RepoTags,omitempty"`
RepoDigests []string `json:"RepoDigests,omitempty"`
}
TrivyMetadataDTO represents image metadata included by Trivy.
type TrivyMetadataResponseDTO ¶ added in v0.0.2
type TrivyMetadataResponseDTO struct {
ImageID string `json:"ImageID,omitempty"`
RepoTags []string `json:"RepoTags,omitempty"`
RepoDigests []string `json:"RepoDigests,omitempty"`
}
TrivyMetadataResponseDTO represents image metadata in scan_result responses.
type TrivyReportDTO ¶
type TrivyReportDTO struct {
ArtifactName string `json:"ArtifactName,omitempty"`
ArtifactType string `json:"ArtifactType,omitempty"`
Metadata TrivyMetadataDTO `json:"Metadata,omitempty"`
Results []TrivyResultDTO `json:"Results,omitempty"`
}
TrivyReportDTO represents the request payload accepted by POST /scans.
type TrivyReportResponseDTO ¶ added in v0.0.2
type TrivyReportResponseDTO struct {
ArtifactName string `json:"ArtifactName,omitempty"`
ArtifactType string `json:"ArtifactType,omitempty"`
Metadata TrivyMetadataResponseDTO `json:"Metadata,omitempty"`
Results []TrivyResultResponseDTO `json:"Results,omitempty"`
}
TrivyReportResponseDTO represents scan_result in GET scan responses.
type TrivyResultDTO ¶
type TrivyResultDTO struct {
Target string `json:"Target,omitempty"`
Class string `json:"Class,omitempty"`
Type string `json:"Type,omitempty"`
Vulnerabilities []TrivyVulnerabilityDTO `json:"Vulnerabilities,omitempty"`
}
TrivyResultDTO represents one Trivy result section.
type TrivyResultResponseDTO ¶ added in v0.0.2
type TrivyResultResponseDTO struct {
Target string `json:"Target,omitempty"`
Class string `json:"Class,omitempty"`
Type string `json:"Type,omitempty"`
Vulnerabilities []TrivyVulnerabilityResponseDTO `json:"Vulnerabilities,omitempty"`
}
TrivyResultResponseDTO represents one Trivy result section in scan_result responses.
type TrivyVulnerabilityDTO ¶
type TrivyVulnerabilityDTO struct {
VulnerabilityID string `json:"VulnerabilityID"`
PkgName string `json:"PkgName"`
PkgVersion string `json:"PkgVersion,omitempty"`
FixedVersion string `json:"FixedVersion,omitempty"`
Severity string `json:"Severity"`
Title string `json:"Title,omitempty"`
}
TrivyVulnerabilityDTO represents one vulnerability item in a Trivy report.
type TrivyVulnerabilityResponseDTO ¶ added in v0.0.2
type TrivyVulnerabilityResponseDTO struct {
VulnerabilityID string `json:"VulnerabilityID"`
PkgName string `json:"PkgName"`
PkgVersion string `json:"PkgVersion,omitempty"`
FixedVersion string `json:"FixedVersion,omitempty"`
Severity string `json:"Severity"`
Title string `json:"Title,omitempty"`
}
TrivyVulnerabilityResponseDTO represents one vulnerability in scan_result responses.
type VulnerabilitySummaryResponseDTO ¶
type VulnerabilitySummaryResponseDTO struct {
Image string `json:"Image,omitempty"`
From *time.Time `json:"From,omitempty"`
To *time.Time `json:"To,omitempty"`
TotalScans int64 `json:"TotalScans"`
TotalVulnerabilities int64 `json:"TotalVulnerabilities"`
SeverityCounts []SeverityCountDTO `json:"SeverityCounts"`
TopCVEs []TopCVEDTO `json:"TopCVEs,omitempty"`
}
VulnerabilitySummaryResponseDTO is the API response DTO for summary analytics.
type VulnerabilityTrendPointDTO ¶
type VulnerabilityTrendPointDTO struct {
Bucket time.Time `json:"Bucket"`
Severity string `json:"Severity"`
Count int64 `json:"Count"`
}
VulnerabilityTrendPointDTO is one bucketed vulnerability count.
type VulnerabilityTrendsResponseDTO ¶
type VulnerabilityTrendsResponseDTO struct {
Image string `json:"Image,omitempty"`
Interval string `json:"Interval"`
From *time.Time `json:"From,omitempty"`
To *time.Time `json:"To,omitempty"`
Count int `json:"Count"`
Points []VulnerabilityTrendPointDTO `json:"Points"`
}
VulnerabilityTrendsResponseDTO is the API response DTO for trends analytics.