model

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoGitRepo = errors.New("No git repo found")

Functions

func NewInspectError

func NewInspectError(language Language, message string) error

func WithInspectorTask

func WithInspectorTask(ctx context.Context, scanDir string) context.Context

func WithScanTask

func WithScanTask(ctx context.Context, task *ScanTask) context.Context

Types

type Contributor

type Contributor struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

type Dependency

type Dependency struct {
	Name         string       `json:"name"`
	Version      string       `json:"version"`
	Dependencies []Dependency `json:"dependencies,omitempty"`
}

type FileHash

type FileHash struct {
	Hash []string `json:"hash"`
	Path string   `json:"path"`
}

type GitInfo

type GitInfo struct {
	RemoteName     string    `json:"remote_name"`
	RemoteURL      string    `json:"remote_url"`
	HeadCommitHash string    `json:"head_commit_hash"`
	HeadRefName    string    `json:"head_ref_name"`
	ProjectName    string    `json:"project_name"`
	CommitMsg      string    `json:"commit_msg"`
	Committer      string    `json:"committer"`
	CommitterEmail string    `json:"committer_email"`
	CommitTime     time.Time `json:"commit_time"`
}

type InspectError

type InspectError struct {
	Language string `json:"language"`
	Message  string `json:"message"`
}

func (InspectError) Error

func (i InspectError) Error() string

type InspectorTask

type InspectorTask struct {
	*ScanTask
	ScanDir string
}

func UseInspectorTask

func UseInspectorTask(ctx context.Context) *InspectorTask

func (*InspectorTask) AddModule

func (i *InspectorTask) AddModule(module Module)

type Language

type Language string
const (
	Cxx        Language = "C/C++"
	Ruby       Language = "Ruby"
	ObjectiveC Language = "Objective-C"
	PHP        Language = "PHP"
	Go         Language = "Go"
	Java       Language = "Java"
	JavaScript Language = "JavaScript"
	Python     Language = "Python"
)

type LicenseLevel

type LicenseLevel string
const (
	LicenseLevelLow    LicenseLevel = "Low"
	LicenseLevelMedium LicenseLevel = "Medium"
	LicenseLevelHigh   LicenseLevel = "High"
)

type Module

type Module struct {
	PackageManager PackageManagerType `json:"package_manager"`
	Language       Language           `json:"language"`
	PackageFile    string             `json:"package_file"`
	Name           string             `json:"name"`
	Version        string             `json:"version"`
	FilePath       string             `json:"relative_path"`
	Dependencies   []Dependency       `json:"dependencies,omitempty"`
	RuntimeInfo    interface{}        `json:"runtime_info,omitempty"`
	UUID           uuid.UUID          `json:"uuid"`
}

type PackageManagerType

type PackageManagerType string
const (
	PMMaven     PackageManagerType = "maven"
	PMGoMod     PackageManagerType = "gomod"
	PMNpm       PackageManagerType = "npm"
	PMGradle    PackageManagerType = "gradle"
	PMYarn      PackageManagerType = "yarn"
	PMPython    PackageManagerType = "python"
	PMPip       PackageManagerType = "pip"
	PMComposer  PackageManagerType = "composer"
	PMBundler   PackageManagerType = "bundler"
	PMCocoaPods PackageManagerType = "cocoapods"
	PMPoetry    PackageManagerType = "poetry"
)

type ProjectType

type ProjectType string
const (
	ProjectTypeLocal ProjectType = "Local"
	ProjectTypeGit   ProjectType = "Git"
)

type ScanTask

type ScanTask struct {
	TaskId            string
	ProjectDir        string
	ProjectName       string
	Kind              TaskKind
	ProjectType       ProjectType
	ProjectId         string
	StartTime         time.Time
	GitInfo           *GitInfo
	TaskType          TaskType
	ContributorList   []Contributor
	TotalContributors int
	Modules           []Module
	ScanResult        *TaskScanResponse
	EnableDeepScan    bool
	FileHashes        []FileHash
}

func CreateScanTask

func CreateScanTask(projectDir string, taskKind TaskKind, taskType TaskType) *ScanTask

func UseScanTask

func UseScanTask(ctx context.Context) *ScanTask

func (*ScanTask) UI

func (s *ScanTask) UI() display.UI

type SuggestLevel

type SuggestLevel string
const (
	SuggestLevelOptional        SuggestLevel = "Optional"
	SuggestLevelRecommend       SuggestLevel = "Recommend"
	SuggestLevelStrongRecommend SuggestLevel = "StrongRecommend"
)

type TaskKind

type TaskKind string
const (
	TaskKindNormal  TaskKind = "Normal"
	TaskKindBinary  TaskKind = "Binary"
	TaskKindIotScan TaskKind = "IotScan"
)

type TaskScanResponse

type TaskScanResponse struct {
	Complete          bool `json:"complete"`
	DependenciesCount int  `json:"dependencies_count"`
	IssuesCompsCount  int  `json:"issues_comps_count"`
	Modules           []struct {
		ModuleId       int    `json:"module_id"`
		Language       string `json:"language"`
		PackageManager string `json:"package_manager"`
		Comps          []struct {
			MinFixedInfo []struct {
				Name       string `json:"name"`
				OldVersion string `json:"old_version"`
				NewVersion string `json:"new_version"`
			} `json:"min_fixed_info,omitempty"`
			IsDirectDependency bool   `json:"is_direct_dependency"`
			CompId             int    `json:"comp_id"`
			CompName           string `json:"comp_name"`
			CompVersion        string `json:"comp_version"`
			MinFixedVersion    string `json:"min_fixed_version"`
			License            *struct {
				Level LicenseLevel `json:"level"`
				Spdx  string       `json:"spdx"`
			} `json:"license,omitempty"`
			Solutions []struct {
				Compatibility *int   `json:"compatibility,omitempty"`
				Description   string `json:"description"`
				Type          string `json:"type,omitempty"`
			} `json:"solutions,omitempty"`
			Vuls    []VoVulnInfo `json:"vuls"`
			FixType string       `json:"fix_type"`
		} `json:"comps"`
	} `json:"modules"`
	TaskId string `json:"task_id"`
	Status string `json:"status"`
}

type TaskType

type TaskType int
const (
	TaskTypeIdea TaskType = iota + 1
	TaskTypeCli
	TaskTypeJenkins
)

func (TaskType) MarshalJSON

func (t TaskType) MarshalJSON() ([]byte, error)

func (TaskType) String

func (t TaskType) String() string

func (TaskType) UI

func (t TaskType) UI() display.UI

type VoVulnInfo

type VoVulnInfo struct {
	CveId           string        `json:"cve_id"`
	Description     string        `json:"description"`
	Level           VulnLevelType `json:"level"`
	Influence       int           `json:"influence"`
	Poc             bool          `json:"poc"`
	PublishTime     int           `json:"publish_time"`
	AffectedVersion string        `json:"affected_version"`
	MinFixedVersion string        `json:"min_fixed_version"`
	References      []struct {
		Name string `json:"name"`
		Url  string `json:"url"`
	} `json:"references"`
	Solutions []struct {
		Type          string `json:"type"`
		Description   string `json:"description"`
		Compatibility int    `json:"compatibility"`
	} `json:"solutions"`
	SuggestLevel SuggestLevel `json:"suggest_level"`
	VulnNo       string       `json:"vuln_no"`
	VulnPath     []string     `json:"vuln_path"`
	Title        string       `json:"title"`
}

type VulnLevelType

type VulnLevelType string
const (
	VulnLevelCritical VulnLevelType = "Critical"
	VulnLevelHigh     VulnLevelType = "High"
	VulnLevelMedium   VulnLevelType = "Medium"
	VulnLevelLow      VulnLevelType = "Low"
)

Jump to

Keyboard shortcuts

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