models

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2017 License: GPL-3.0 Imports: 7 Imported by: 74

Documentation

Index

Constants

View Source
const (
	// CpeNameMatchStr is a String representation of CpeNameMatch
	CpeNameMatchStr = "CpeNameMatch"

	// YumUpdateSecurityMatchStr is a String representation of YumUpdateSecurityMatch
	YumUpdateSecurityMatchStr = "YumUpdateSecurityMatch"

	// PkgAuditMatchStr is a String representation of PkgAuditMatch
	PkgAuditMatchStr = "PkgAuditMatch"

	// OvalMatchStr is a String representation of OvalMatch
	OvalMatchStr = "OvalMatch"

	// ChangelogExactMatchStr is a String representation of ChangelogExactMatch
	ChangelogExactMatchStr = "ChangelogExactMatch"

	// ChangelogLenientMatchStr is a String representation of ChangelogLenientMatch
	ChangelogLenientMatchStr = "ChangelogLenientMatch"

	// FailedToGetChangelog is a String representation of FailedToGetChangelog
	FailedToGetChangelog = "FailedToGetChangelog"

	// FailedToFindVersionInChangelog is a String representation of FailedToFindVersionInChangelog
	FailedToFindVersionInChangelog = "FailedToFindVersionInChangelog"
)
View Source
const JSONVersion = 3

JSONVersion is JSON Version

Variables

View Source
var (
	// CpeNameMatch is a ranking how confident the CVE-ID was deteted correctly
	CpeNameMatch = Confidence{100, CpeNameMatchStr}

	// YumUpdateSecurityMatch is a ranking how confident the CVE-ID was deteted correctly
	YumUpdateSecurityMatch = Confidence{100, YumUpdateSecurityMatchStr}

	// PkgAuditMatch is a ranking how confident the CVE-ID was deteted correctly
	PkgAuditMatch = Confidence{100, PkgAuditMatchStr}

	// OvalMatch is a ranking how confident the CVE-ID was deteted correctly
	OvalMatch = Confidence{100, OvalMatchStr}

	// ChangelogExactMatch is a ranking how confident the CVE-ID was deteted correctly
	ChangelogExactMatch = Confidence{95, ChangelogExactMatchStr}

	// ChangelogLenientMatch is a ranking how confident the CVE-ID was deteted correctly
	ChangelogLenientMatch = Confidence{50, ChangelogLenientMatchStr}
)
View Source
var AllCveContetTypes = CveContentTypes{NVD, JVN, RedHat, Debian, Ubuntu}

AllCveContetTypes has all of CveContentTypes

Functions

This section is empty.

Types

type Changelog added in v0.3.0

type Changelog struct {
	Contents string
	Method   DetectionMethod
}

Changelog has contents of changelog and how to get it. Method: models.detectionMethodStr

type Confidence added in v0.3.0

type Confidence struct {
	Score           int
	DetectionMethod DetectionMethod
}

Confidence is a ranking how confident the CVE-ID was deteted correctly Score: 0 - 100

func (Confidence) String added in v0.3.0

func (c Confidence) String() string

type Container added in v0.1.4

type Container struct {
	ContainerID string
	Name        string
	Image       string
	Type        string
}

Container has Container information

type Cpe added in v0.4.0

type Cpe struct {
	CpeName string
}

Cpe is Common Platform Enumeration

type CveContent added in v0.4.0

type CveContent struct {
	Type         CveContentType
	CveID        string
	Title        string
	Summary      string
	Severity     string
	Cvss2Score   float64
	Cvss2Vector  string
	Cvss3Score   float64
	Cvss3Vector  string
	SourceLink   string
	Cpes         []Cpe
	References   References
	CweID        string
	Published    time.Time
	LastModified time.Time
}

CveContent has abstraction of various vulnerability information

func ConvertJvnToModel added in v0.4.0

func ConvertJvnToModel(cveID string, jvn cvedict.Jvn) *CveContent

ConvertJvnToModel convert JVN to CveContent

func ConvertNvdToModel added in v0.4.0

func ConvertNvdToModel(cveID string, nvd cvedict.Nvd) *CveContent

ConvertNvdToModel convert NVD to CveContent

func (CveContent) Empty added in v0.4.0

func (c CveContent) Empty() bool

Empty checks the content is empty

type CveContentCpes added in v0.4.0

type CveContentCpes struct {
	Type  CveContentType
	Value []Cpe
}

CveContentCpes has CveContentType and Value

type CveContentCvss added in v0.4.0

type CveContentCvss struct {
	Type  CveContentType
	Value Cvss
}

CveContentCvss has CveContentType and Cvss2

type CveContentRefs added in v0.4.0

type CveContentRefs struct {
	Type  CveContentType
	Value []Reference
}

CveContentRefs has CveContentType and Cpes

type CveContentStr added in v0.4.0

type CveContentStr struct {
	Type  CveContentType
	Value string
}

CveContentStr has CveContentType and Value

type CveContentType added in v0.4.0

type CveContentType string

CveContentType is a source of CVE information

const (
	// NVD is NVD
	NVD CveContentType = "nvd"

	// JVN is JVN
	JVN CveContentType = "jvn"

	// RedHat is RedHat
	RedHat CveContentType = "redhat"

	// Debian is Debian
	Debian CveContentType = "debian"

	// Ubuntu is Ubuntu
	Ubuntu CveContentType = "ubuntu"

	// Oracle is Oracle Linux
	Oracle CveContentType = "oracle"

	// SUSE is SUSE Linux
	SUSE CveContentType = "suse"

	// Unknown is Unknown
	Unknown CveContentType = "unknown"
)

func NewCveContentType added in v0.4.0

func NewCveContentType(name string) CveContentType

NewCveContentType create CveContentType

type CveContentTypes added in v0.4.0

type CveContentTypes []CveContentType

CveContentTypes has slide of CveContentType

func (CveContentTypes) Except added in v0.4.0

func (c CveContentTypes) Except(excepts ...CveContentType) (excepted CveContentTypes)

Except returns CveContentTypes except for given args

type CveContents added in v0.4.0

type CveContents map[CveContentType]CveContent

CveContents has CveContent

func NewCveContents added in v0.4.0

func NewCveContents(conts ...CveContent) CveContents

NewCveContents create CveContents

func (CveContents) Cpes added in v0.4.0

func (v CveContents) Cpes(myFamily string) (values []CveContentCpes)

Cpes returns affected CPEs of this Vulnerability

func (CveContents) CweIDs added in v0.4.0

func (v CveContents) CweIDs(myFamily string) (values []CveContentStr)

CweIDs returns related CweIDs of the vulnerability

func (CveContents) Except added in v0.4.0

func (v CveContents) Except(exceptCtypes ...CveContentType) (values CveContents)

Except returns CveContents except given keys for enumeration

func (CveContents) References added in v0.4.0

func (v CveContents) References(myFamily string) (values []CveContentRefs)

References returns References

func (v CveContents) SourceLinks(lang, myFamily, cveID string) (values []CveContentStr)

SourceLinks returns link of source

type Cvss added in v0.4.0

type Cvss struct {
	Type                 CvssType
	Score                float64
	CalculatedBySeverity bool
	Vector               string
	Severity             string
}

Cvss has CVSS Score

func (Cvss) Format added in v0.4.0

func (c Cvss) Format() string

Format CVSS Score and Vector

type CvssType added in v0.4.0

type CvssType string

CvssType Represent the type of CVSS

const (
	// CVSS2 means CVSS vesion2
	CVSS2 CvssType = "2"

	// CVSS3 means CVSS vesion3
	CVSS3 CvssType = "3"
)

type DetectionMethod added in v0.4.0

type DetectionMethod string

DetectionMethod indicates - How to detect the CveID - How to get the changelog difference between installed and candidate version

type DistroAdvisory

type DistroAdvisory struct {
	AdvisoryID  string
	Severity    string
	Issued      time.Time
	Updated     time.Time
	Description string
}

DistroAdvisory has Amazon Linux, RHEL, FreeBSD Security Advisory information.

func (DistroAdvisory) Format added in v0.4.0

func (p DistroAdvisory) Format() string

Format the distro advisory information

type Kernel added in v0.4.0

type Kernel struct {
	Release        string
	Version        string
	RebootRequired bool
}

Kernel has the Release, version and whether need restart

type Package added in v0.4.0

type Package struct {
	Name       string
	Version    string
	Release    string
	NewVersion string
	NewRelease string
	Arch       string
	Repository string
	Changelog  Changelog
}

Package has installed binary packages.

func (Package) FormatChangelog added in v0.4.0

func (p Package) FormatChangelog() string

FormatChangelog formats the changelog

func (Package) FormatNewVer added in v0.4.0

func (p Package) FormatNewVer() string

FormatNewVer returns package version-release

func (Package) FormatVer added in v0.4.0

func (p Package) FormatVer() string

FormatVer returns package version-release

func (Package) FormatVersionFromTo added in v0.4.0

func (p Package) FormatVersionFromTo(notFixedYet bool) string

FormatVersionFromTo formats installed and new package version

type PackageStatus added in v0.4.0

type PackageStatus struct {
	Name        string
	NotFixedYet bool
}

PackageStatus has name and other status abount the package

type PackageStatuses added in v0.4.0

type PackageStatuses []PackageStatus

PackageStatuses is a list of PackageStatus

func (PackageStatuses) Sort added in v0.4.0

func (p PackageStatuses) Sort()

Sort by Name

type Packages added in v0.4.0

type Packages map[string]Package

Packages is Map of Package { "package-name": Package }

func NewPackages added in v0.4.0

func NewPackages(packs ...Package) Packages

NewPackages create Packages

func (Packages) FindOne added in v0.4.0

func (ps Packages) FindOne(f func(Package) bool) (string, Package, bool)

FindOne search a element by name-newver-newrel-arch

func (Packages) FormatUpdatablePacksSummary added in v0.4.0

func (ps Packages) FormatUpdatablePacksSummary() string

FormatUpdatablePacksSummary returns a summary of updatable packages

func (Packages) Merge added in v0.4.0

func (ps Packages) Merge(other Packages) Packages

Merge returns merged map (immutable)

func (Packages) MergeNewVersion added in v0.4.0

func (ps Packages) MergeNewVersion(as Packages)

MergeNewVersion merges candidate version information to the receiver struct

type Platform added in v0.1.5

type Platform struct {
	Name       string // aws or azure or gcp or other...
	InstanceID string
}

Platform has platform information

type Reference added in v0.4.0

type Reference struct {
	Source string
	Link   string
	RefID  string
}

Reference has a related link of the CVE

type References added in v0.4.0

type References []Reference

References is a slice of Reference

type ScanResult

type ScanResult struct {
	ScannedAt   time.Time
	ReportedAt  time.Time
	JSONVersion int
	Lang        string
	ServerUUID  string
	ServerName  string // TOML Section key
	Family      string
	Release     string
	Container   Container
	Platform    Platform

	// Scanned Vulns by SSH scan + CPE + OVAL
	ScannedCves VulnInfos

	RunningKernel Kernel
	Packages      Packages
	SrcPackages   SrcPackages

	Errors   []string
	Optional [][]interface{}

	Config struct {
		Scan   config.Config
		Report config.Config
	}
}

ScanResult has the result of scanned CVE information.

func (ScanResult) FilterByCvssOver added in v0.2.0

func (r ScanResult) FilterByCvssOver(over float64) ScanResult

FilterByCvssOver is filter function.

func (ScanResult) FilterIgnoreCves added in v0.4.0

func (r ScanResult) FilterIgnoreCves(cveIDs []string) ScanResult

FilterIgnoreCves is filter function.

func (ScanResult) FilterUnfixed added in v0.4.1

func (r ScanResult) FilterUnfixed() ScanResult

FilterUnfixed is filter function.

func (ScanResult) FormatServerName added in v0.3.0

func (r ScanResult) FormatServerName() (name string)

FormatServerName returns server and container name

func (ScanResult) FormatTextReportHeadedr added in v0.4.0

func (r ScanResult) FormatTextReportHeadedr() string

FormatTextReportHeadedr returns header of text report

func (ScanResult) ReportFileName added in v0.2.0

func (r ScanResult) ReportFileName() (name string)

ReportFileName returns the filename on localhost without extention

func (ScanResult) ReportKeyName added in v0.2.0

func (r ScanResult) ReportKeyName() (name string)

ReportKeyName returns the name of key on S3, Azure-Blob without extention

func (ScanResult) ServerInfo added in v0.1.4

func (r ScanResult) ServerInfo() string

ServerInfo returns server name one line

func (ScanResult) ServerInfoTui added in v0.1.4

func (r ScanResult) ServerInfoTui() string

ServerInfoTui returns server infromation for TUI sidebar

type ScanResults

type ScanResults []ScanResult

ScanResults is a slide of ScanResult

type SrcPackage added in v0.4.1

type SrcPackage struct {
	Name        string
	Version     string
	BinaryNames []string
}

SrcPackage has installed source package information. Debian based Linux has both of package and source information in dpkg. OVAL database often includes a source version (Not a binary version), so it is also needed to capture source version for OVAL version comparison. https://github.com/future-architect/vuls/issues/504

func (*SrcPackage) AddBinaryName added in v0.4.1

func (s *SrcPackage) AddBinaryName(name string)

AddBinaryName add the name if not exists

type SrcPackages added in v0.4.1

type SrcPackages map[string]SrcPackage

SrcPackages is Map of SrcPackage { "package-name": SrcPackage }

type VulnInfo added in v0.2.0

type VulnInfo struct {
	CveID            string
	Confidence       Confidence
	AffectedPackages PackageStatuses
	DistroAdvisories []DistroAdvisory // for Aamazon, RHEL, FreeBSD
	CpeNames         []string
	CveContents      CveContents
}

VulnInfo has a vulnerability information and unsecure packages

func (VulnInfo) Cvss2CalcURL added in v0.4.0

func (v VulnInfo) Cvss2CalcURL() string

Cvss2CalcURL returns CVSS v2 caluclator's URL

func (VulnInfo) Cvss2Scores added in v0.4.0

func (v VulnInfo) Cvss2Scores() (values []CveContentCvss)

Cvss2Scores returns CVSS V2 Scores

func (VulnInfo) Cvss3CalcURL added in v0.4.0

func (v VulnInfo) Cvss3CalcURL() string

Cvss3CalcURL returns CVSS v3 caluclator's URL

func (VulnInfo) Cvss3Scores added in v0.4.0

func (v VulnInfo) Cvss3Scores() (values []CveContentCvss)

Cvss3Scores returns CVSS V3 Score

func (VulnInfo) FormatMaxCvssScore added in v0.4.0

func (v VulnInfo) FormatMaxCvssScore() string

FormatMaxCvssScore returns Max CVSS Score

func (VulnInfo) MaxCvss2Score added in v0.4.0

func (v VulnInfo) MaxCvss2Score() CveContentCvss

MaxCvss2Score returns Max CVSS V2 Score

func (VulnInfo) MaxCvss3Score added in v0.4.0

func (v VulnInfo) MaxCvss3Score() CveContentCvss

MaxCvss3Score returns Max CVSS V3 Score

func (VulnInfo) MaxCvssScore added in v0.4.0

func (v VulnInfo) MaxCvssScore() CveContentCvss

MaxCvssScore returns max CVSS Score If there is no CVSS Score, return Severity as a numerical value.

func (*VulnInfo) NilToEmpty added in v0.4.0

func (v *VulnInfo) NilToEmpty() *VulnInfo

NilToEmpty set nil slice or map fields to empty to avoid null in JSON

func (VulnInfo) Summaries added in v0.4.0

func (v VulnInfo) Summaries(lang, myFamily string) (values []CveContentStr)

Summaries returns summaries

func (VulnInfo) Titles added in v0.4.0

func (v VulnInfo) Titles(lang, myFamily string) (values []CveContentStr)

Titles returns tilte (TUI)

func (v VulnInfo) VendorLinks(family string) map[string]string

VendorLinks returns links of vendor support's URL

type VulnInfos added in v0.2.0

type VulnInfos map[string]VulnInfo

VulnInfos has a map of VulnInfo Key: CveID

func (VulnInfos) CountGroupBySeverity added in v0.4.0

func (v VulnInfos) CountGroupBySeverity() map[string]int

CountGroupBySeverity summarize the number of CVEs group by CVSSv2 Severity

func (VulnInfos) Find added in v0.4.0

func (v VulnInfos) Find(f func(VulnInfo) bool) VulnInfos

Find elements that matches the function passed in argument

func (VulnInfos) FindScoredVulns added in v0.4.0

func (v VulnInfos) FindScoredVulns() VulnInfos

FindScoredVulns return scored vulnerabilities

func (VulnInfos) FormatCveSummary added in v0.4.0

func (v VulnInfos) FormatCveSummary() string

FormatCveSummary summarize the number of CVEs group by CVSSv2 Severity

func (VulnInfos) ToSortedSlice added in v0.4.0

func (v VulnInfos) ToSortedSlice() (sorted []VulnInfo)

ToSortedSlice returns slice of VulnInfos that is sorted by Score, CVE-ID

Jump to

Keyboard shortcuts

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