model

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoGitRemoteFound = errors.New("No git remote found")
View Source
var ErrNoGitRepo = errors.New("No git repo found")
View Source
var Logger = zap.NewNop()

Functions

func GenerateIdeaErrorOutput added in v1.7.0

func GenerateIdeaErrorOutput(e error) string

func GenerateIdeaOutput added in v1.7.0

func GenerateIdeaOutput(c context.Context) string

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

func WrapIdeaErr added in v1.7.0

func WrapIdeaErr(e error, ideaCode IdeaErrCode) error

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 IdeaErrCode added in v1.7.0

type IdeaErrCode int
const (
	IdeaSucceed IdeaErrCode = iota + 100
	IdeaUnknownErr
	IdeaInspectErr
	IdeaEngineScanFailed
	IdeaServerRequestFailed
	IdeaTokenInvalid
	IdeaApiTimeout
	IdeaScanDirInvalid
	IdeaLogFileCreateFailed
)

func GetIdeaErrCode added in v1.7.0

func GetIdeaErrCode(e error) IdeaErrCode

func (IdeaErrCode) Error added in v1.7.0

func (code IdeaErrCode) Error() string

func (IdeaErrCode) String added in v1.7.0

func (code IdeaErrCode) String() string

func (*IdeaErrCode) UnmarshalText added in v1.7.0

func (code *IdeaErrCode) UnmarshalText(data []byte) error

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"
	DotNet     Language = "DotNet"
)

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"
	PmNuget     PackageManagerType = "nuget"
	PmConan     PackageManagerType = "conan"
)

type PluginComp added in v1.7.0

type PluginComp struct {
	CompName           string               `json:"comp_name"`
	ShowLevel          int                  `json:"show_level"`
	MinFixedVersion    string               `json:"min_fixed_version"`
	DisposePlan        PluginCompFixList    `json:"dispose_plan"`
	Vulns              []VoVulnInfo         `json:"vulns"`
	Version            string               `json:"version"`
	License            *PluginCompLicense   `json:"license,omitempty"`
	Solutions          []PluginCompSolution `json:"solutions,omitempty"`
	IsDirectDependency bool                 `json:"is_direct_dependency"`
	Language           string               `json:"language"`
	FixType            string               `json:"fix_type"`
	CompSecScore       int                  `json:"comp_sec_score"`
}

type PluginCompFix added in v1.7.0

type PluginCompFix struct {
	OldVersion      string `json:"old_version"`
	NewVersion      string `json:"new_version"`
	CompName        string `json:"comp_name"`
	UpdateSecScore  int    `json:"update_sec_score"`
	CompatibleScore int    `json:"compatible_score"`
}

type PluginCompFixList added in v1.7.0

type PluginCompFixList []PluginCompFix

func (PluginCompFixList) Len added in v1.7.3

func (l PluginCompFixList) Len() int

func (PluginCompFixList) Less added in v1.7.3

func (l PluginCompFixList) Less(i, j int) bool

func (PluginCompFixList) MarshalJSON added in v1.7.0

func (l PluginCompFixList) MarshalJSON() ([]byte, error)

func (PluginCompFixList) Swap added in v1.7.3

func (l PluginCompFixList) Swap(i, j int)

func (PluginCompFixList) Uniq added in v1.7.3

func (l PluginCompFixList) Uniq() (rs PluginCompFixList)

type PluginCompLicense added in v1.7.0

type PluginCompLicense struct {
	Level LicenseLevel `json:"level"`
	Spdx  string       `json:"spdx"`
}

type PluginCompSolution added in v1.7.0

type PluginCompSolution struct {
	Compatibility *int   `json:"compatibility,omitempty"`
	Description   string `json:"description"`
	Type          string `json:"type,omitempty"`
}

type PluginOutput added in v1.7.0

type PluginOutput struct {
	ProjectName      string       `json:"project_name"`
	Username         string       `json:"username"`
	ErrCode          IdeaErrCode  `json:"err_code"`
	IssuesCount      int          `json:"issues_count,omitempty"`
	Comps            []PluginComp `json:"comps,omitempty"`
	ProjectScore     int          `json:"project_score"`
	SurpassScore     string       `json:"surpass_score"`
	IssuesLevelCount struct {
		Critical int `json:"critical,omitempty"`
		High     int `json:"high,omitempty"`
		Medium   int `json:"medium,omitempty"`
		Low      int `json:"low,omitempty"`
	} `json:"issues_level_count,omitempty"`
	TaskId            string         `json:"task_id,omitempty"`
	TotalContributors int            `json:"total_contributors"`
	ProjectId         string         `json:"project_id"`
	InspectErrors     []InspectError `json:"inspect_errors,omitempty"`
	DependenciesCount int            `json:"dependencies_count"`
	InspectReportUrl  string         `json:"inspect_report_url"`
}

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
	Username          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"`
	ProjectScore      int  `json:"project_score"`
	SurpassScore      int  `json:"surpass_score"`
	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"`
				SecurityScore      int    `json:"security_score"`
				CompatibilityScore int    `json:"compatibility_score"`
			} `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"`
			CompSecScore int          `json:"comp_sec_score"`
		} `json:"comps"`
	} `json:"modules"`
	TaskId           string `json:"task_id"`
	Status           string `json:"status"`
	InspectReportUrl string `json:"inspect_report_url"`
}

func (TaskScanResponse) ReportURL added in v1.7.9

func (t TaskScanResponse) ReportURL() string

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