Documentation
¶
Overview ¶
Package scan manages the scan process to image scanning service
Index ¶
- func Cleanup()
- func GenerateLayersAndFileData(image *image.Image) ([]layers.Layer, error)
- type AnalysisPayload
- type Bom
- type Handler
- func (h *Handler) AttachData(bom *Bom, layers []layers.Layer, buildStep, namespace, imageID string)
- func (h Handler) GetImageAnalysisStatus(digest, operationID string) (StatusResponse, error)
- func (h Handler) GetImageVulnerability(digest, imageID, cliVersion string) (*image.ScannedImage, error)
- func (h Handler) GetImagesScanResultsFromBackendByImageID(imageId, cliVersion string) (*image.ScannedImage, error)
- func (h Handler) GetResponseFromScanAPI(digest, operationID string) (*image.ScannedImage, error)
- func (h Handler) HealthCheck() error
- func (h Handler) PutBomAndLayersToAnalysisAPI(operationID string, opts Option) (Status, error)
- func (h *Handler) Scan(operationID string, opts Option) (*image.ScannedImage, error)
- type Option
- type RegistryHandler
- type Scanner
- type Status
- type StatusResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cleanup ¶ added in v1.7.2
func Cleanup()
Cleanup performs a full cleanup of temporary files related to the image pull and scan process It should be called after all image processing is done since instances of stereoscope/pkg/image.Image will be broken afterwards
func GenerateLayersAndFileData ¶ added in v1.7.2
GenerateLayersAndFileData reads the input image and calculates: - metadata for all layers (including empty ones) in the image - interesting files per layer with an flag whether they are in the squashed image or not
Types ¶
type AnalysisPayload ¶ added in v1.7.2
type AnalysisPayload struct { SBOM *bom.JSONDocument `json:"sbom"` Layers []layers.Layer `json:"layers"` BuildStep string `json:"build_step"` Namespace string `json:"namespace"` ForceScan bool `json:"force_scan"` ImageID string `json:"image_id"` Meta struct { SyftVersion string `json:"syft_version"` CliVersion string `json:"cli_version"` } `json:"metadata"` }
AnalysisPayload is the payload used for uploading sbom to image scanning service.
func NewAnalysisPayload ¶ added in v1.7.2
func NewAnalysisPayload(sbom *bom.JSONDocument, layers []layers.Layer, buildStep, namespace string, forceScan bool, syftVersion, cliVersion string) AnalysisPayload
func (AnalysisPayload) Footer ¶ added in v1.7.2
func (payload AnalysisPayload) Footer() string
func (AnalysisPayload) Header ¶ added in v1.7.2
func (payload AnalysisPayload) Header() []string
func (AnalysisPayload) Rows ¶ added in v1.7.2
func (payload AnalysisPayload) Rows() [][]string
func (AnalysisPayload) Title ¶ added in v1.7.2
func (payload AnalysisPayload) Title() string
type Bom ¶
type Bom struct { // FullTag is the full tag of the bom FullTag string // ManifestDigest is the sha256 of this image manifest json ManifestDigest string // Packages enumerates the packages in the bill of materials Packages bom.JSONDocument }
Bom contains the full bill of materials for an image, along with some additional helpful metadata.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler has all the fields for sending request to scanning service.
func NewScanHandler ¶
func NewScanHandler(saasTmpl, orgKey, apiID, apiKey string, bom *Bom, layers []layers.Layer) *Handler
NewScanHandler will create a handler for scan cmd.
func (*Handler) AttachData ¶ added in v1.6.3
AttachData will attach sbom, layers & policy to the handler.
func (Handler) GetImageAnalysisStatus ¶
func (h Handler) GetImageAnalysisStatus(digest, operationID string) (StatusResponse, error)
GetImageAnalysisStatus will fetch the current analysis result of an image.
func (Handler) GetImageVulnerability ¶
func (h Handler) GetImageVulnerability(digest, imageID, cliVersion string) (*image.ScannedImage, error)
GetImageVulnerability will fetch the vulnerability result via image digest.
func (Handler) GetImagesScanResultsFromBackendByImageID ¶ added in v1.7.2
func (h Handler) GetImagesScanResultsFromBackendByImageID(imageId, cliVersion string) (*image.ScannedImage, error)
GetImagesScanResultsFromBackendByImageID return scan image data if existed.
func (Handler) GetResponseFromScanAPI ¶
func (h Handler) GetResponseFromScanAPI(digest, operationID string) (*image.ScannedImage, error)
GetResponseFromScanAPI will call the status API from image scanning service periodically, once the status is "FINISHED", it will fetch the real result from vuln API.
func (Handler) HealthCheck ¶
HealthCheck will check the health of the service backend.
func (Handler) PutBomAndLayersToAnalysisAPI ¶ added in v1.6.3
PutBomAndLayersToAnalysisAPI will call the PUT API and upload sbom to image scanning service.
type Option ¶
type Option struct { // ForceScan is the option whether to force scan an image no matter it is scanned or not. ForceScan bool // BypassDockerDaemon is whether not to use docker daemon to pull the image BypassDockerDaemon bool // UseDockerDaemon deprecated. UseDockerDaemon bool // Credential is the auth string used for login to registry, format: USERNAME[:PASSWORD] Credential string // ShouldCleanup is whether to delete the docker image pulled by docker ShouldCleanup bool // FullTag is the tag set to override in the image FullTag string // Timeout is the duration (second) for the scan process Timeout int DockerInsecureSkipTLSVerify bool }
Option is the option used for image related cmd.
type RegistryHandler ¶
type RegistryHandler struct{}
RegistryHandler coordinates with OCI registry APIs in order to retrieve container images as needed.
func NewRegistryHandler ¶
func NewRegistryHandler() RegistryHandler
NewRegistryHandler constructs a new RegistryHandler instance.
func (*RegistryHandler) LoadImage ¶ added in v1.7.2
LoadImage parses the provided input and attempts to load an image from it If successful, the first returned parameter will be populated and ready to use in scanning methods Sharing the returned image for reading is expected, shared writing is not supported
type Scanner ¶ added in v1.7.2
type Scanner struct{}
func NewScanner ¶ added in v1.7.2
func NewScanner() *Scanner
NewScanner creates a new Scanner that captures all supported scan operations under one interface
func (*Scanner) ExtractDataFromImage ¶ added in v1.7.2
type StatusResponse ¶ added in v1.7.2
type StatusResponse struct {
OperationStatus Status `json:"operation_status"`
}