scan

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppFileName = "apps_pkg"

	WPVerFileSuffix = "wp-includes/version.php"
)
View Source
const ImageWorkingPath = "/tmp/images"

Variables

This section is empty.

Functions

func CollectImageFileMap

func CollectImageFileMap(rootPath string, fmap map[string]string) (int, error)

CollectImageFileMap creates a virtual file map for a image to save real copy efforts

func CreateImagePath

func CreateImagePath(uid string) string

Get an unique image folder under /tmp, return "" if can not allocate a good folder

func DownloadFromUrl

func DownloadFromUrl(url, fileName string) error

--

func GetAwsFuncPackages

func GetAwsFuncPackages(fileName string) ([]*share.ScanAppPackage, error)

func NormalizeImageCmd

func NormalizeImageCmd(cmd string) string

func ParseImageCmds

func ParseImageCmds(cmds []string) (bool, bool, bool)

func ParseImageName

func ParseImageName(image string) (string, string, string, error)

Not a strict parsing, if the input is wrong, we just cannot get the image.

func ParseRegistryURI

func ParseRegistryURI(ur string) (string, error)

func ScanErrorToStr

func ScanErrorToStr(e share.ScanErrorCode) string

func SelectiveFilesFromPath

func SelectiveFilesFromPath(rootPath string, maxFileSize int64, selected func(string) bool) (map[string]string, error)

SelectiveFilesFromPath the specified files and folders store them in a map indexed by file paths

Types

type AppPackage

type AppPackage struct {
	AppName    string `json:"app_name"`
	ModuleName string `json:"module_name"`
	Version    string `json:"version"`
	FileName   string `json:"file_name"`
}

type ImageInfo

type ImageInfo struct {
	Layers    []string
	ID        string
	Digest    string
	Author    string
	Signed    bool
	RunAsRoot bool
	Envs      []string
	Cmds      []string
	Labels    map[string]string
	Sizes     map[string]int64
	RepoTags  []string
}

type ImageManifest

type ImageManifest struct {
	Config   string   `json:"Config"`
	RepoTags []string `json:"RepoTags"`
	Layers   []string `json:"Layers"`
}

type LayerFiles

type LayerFiles struct {
	Size int64
	Pkgs map[string][]byte
	Apps map[string][]AppPackage
}

type LayerMetadata

type LayerMetadata struct {
	ID              string    `json:"id"`
	Parent          string    `json:"parent"`
	Created         time.Time `json:"created"`
	Container       string    `json:"container"`
	ContainerConfig struct {
		Hostname   string            `json:"Hostname"`
		Domainname string            `json:"Domainname"`
		User       string            `json:"User"`
		Env        []string          `json:"Env"`
		Cmd        []string          `json:"Cmd"`
		Labels     map[string]string `json:"Labels"`
	} `json:"container_config"`
	Config struct {
		Hostname    string            `json:"Hostname"`
		Domainname  string            `json:"Domainname"`
		User        string            `json:"User"`
		Env         []string          `json:"Env"`
		Cmd         []string          `json:"Cmd"`
		ArgsEscaped bool              `json:"ArgsEscaped"`
		Image       string            `json:"Image"`
		WorkingDir  string            `json:"WorkingDir"`
		Labels      map[string]string `json:"Labels"`
	} `json:"config"`
	Architecture string `json:"architecture"`
	Os           string `json:"os"`
}

type RegClient

type RegClient struct {
	*registry.Registry
}

func NewRegClient

func NewRegClient(url, username, password, proxy string, trace httptrace.HTTPTrace) *RegClient

func (*RegClient) Alive

func (rc *RegClient) Alive() (uint, error)

func (*RegClient) DownloadRemoteImage

func (rc *RegClient) DownloadRemoteImage(ctx context.Context, name, imgPath string, layers []string, sizes map[string]int64) (map[string]*LayerFiles, share.ScanErrorCode)

this function will be called at scanner side

func (*RegClient) GetImageInfo

func (rc *RegClient) GetImageInfo(ctx context.Context, name, tag string) (*ImageInfo, share.ScanErrorCode)

type ScanApps

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

func NewScanApps

func NewScanApps(v2 bool) *ScanApps

func (*ScanApps) DerivePkg

func (s *ScanApps) DerivePkg(data map[string][]byte) []AppPackage

type ScanUtil

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

func NewScanUtil

func NewScanUtil(sys *system.SystemTools) *ScanUtil

Scan normally doesn't require contaiener runtime socket, except for local image scan

func (*ScanUtil) GetLocalImageMeta

func (s *ScanUtil) GetLocalImageMeta(ctx context.Context, repository, tag, rtSock string) (*container.ImageMeta, share.ScanErrorCode)

func (*ScanUtil) GetRunningPackages

func (s *ScanUtil) GetRunningPackages(id string, objType share.ScanObjectType, pid int, kernel string) ([]byte, share.ScanErrorCode)

func (*ScanUtil) LoadLocalImage

func (s *ScanUtil) LoadLocalImage(ctx context.Context, repository, tag, rtSock, imgPath string) (*ImageInfo, map[string]*LayerFiles, share.ScanErrorCode)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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