metric

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: Apache-2.0 Imports: 4 Imported by: 18

Documentation

Index

Examples

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type AttackComplexity

type AttackComplexity int

AttackComplexity is metric type for Base Metrics

const (
	AttackComplexityUnknown AttackComplexity = iota
	// AttackComplexityNotDefined
	AttackComplexityHigh
	AttackComplexityLow
)

Constant of AttackComplexity result

func GetAttackComplexity

func GetAttackComplexity(s string) AttackComplexity

GetAttackComplexity returns result of AttackComplexity metric

func (AttackComplexity) IsUnknown

func (ac AttackComplexity) IsUnknown() bool

IsUnknown returns false if unknown result value of metric

func (AttackComplexity) String

func (ac AttackComplexity) String() string

func (AttackComplexity) Value

func (ac AttackComplexity) Value() float64

Value returns value of AttackComplexity metric

type AttackVector

type AttackVector int

AttackVector is metric type for Base Metrics

const (
	AttackVectorUnknown AttackVector = iota
	AttackVectorPhysical
	AttackVectorLocal
	AttackVectorAdjacent
	AttackVectorNetwork
)

Constant of AttackVector result

func GetAttackVector

func GetAttackVector(s string) AttackVector

GetAttackVector returns result of AttackVector metric

func (AttackVector) IsUnknown

func (av AttackVector) IsUnknown() bool

IsUnknown returns false if unknouwn result value of metric

func (AttackVector) String

func (av AttackVector) String() string

func (AttackVector) Value

func (av AttackVector) Value() float64

Value returns value of AttackVector metric

type AvailabilityImpact

type AvailabilityImpact int

AvailabilityImpact is metric type for Base Metrics

const (
	AvailabilityImpactUnknown AvailabilityImpact = iota
	AvailabilityImpactNone
	AvailabilityImpactLow
	AvailabilityImpactHigh
)

Constant of AvailabilityImpact result

func GetAvailabilityImpact

func GetAvailabilityImpact(s string) AvailabilityImpact

GetAvailabilityImpact returns result of AvailabilityImpact metric

func (AvailabilityImpact) IsUnknown

func (ai AvailabilityImpact) IsUnknown() bool

IsUnknown returns false if undefined result value of metric

func (AvailabilityImpact) String

func (ai AvailabilityImpact) String() string

func (AvailabilityImpact) Value

func (ai AvailabilityImpact) Value() float64

Value returns value of AvailabilityImpact metric

type AvailabilityRequirement

type AvailabilityRequirement int

AvailabilityRequirement is metric type for Base Metrics

const (
	AvailabilityRequirementInvalid AvailabilityRequirement = iota
	AvailabilityRequirementNotDefined
	AvailabilityRequirementLow
	AvailabilityRequirementMedium
	AvailabilityRequirementHigh
)

Constant of AvailabilityRequirement result

func GetAvailabilityRequirement

func GetAvailabilityRequirement(s string) AvailabilityRequirement

GetAvailabilityRequirement returns result of AvailabilityRequirement metric

func (AvailabilityRequirement) IsValid added in v1.4.0

func (ar AvailabilityRequirement) IsValid() bool

IsDefined returns false if undefined result value of metric

func (AvailabilityRequirement) String

func (ar AvailabilityRequirement) String() string

func (AvailabilityRequirement) Value

func (ar AvailabilityRequirement) Value() float64

Value returns value of AvailabilityRequirement metric

type Base

type Base struct {
	Ver Version
	AV  AttackVector
	AC  AttackComplexity
	PR  PrivilegesRequired
	UI  UserInteraction
	S   Scope
	C   ConfidentialityImpact
	I   IntegrityImpact
	A   AvailabilityImpact
	// contains filtered or unexported fields
}

Base is Base Metrics for CVSSv3

func NewBase

func NewBase() *Base

NewBase returns Base Metrics instance

func (*Base) BaseMetrics added in v1.2.0

func (bm *Base) BaseMetrics() *Base

func (*Base) Decode

func (bm *Base) Decode(vector string) (*Base, error)
Example
package main

import (
	"fmt"

	"github.com/goark/go-cvss/v3/metric"
)

func main() {
	m, err := metric.NewBase().Decode("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N") //CVE-2015-8252
	if err != nil {
		return
	}
	fmt.Println("Score =", m.Score())
	fmt.Println("Severity =", m.Severity())
	//Output
	//Score = 7.5
	//Severity = High
}
Output:

func (*Base) Encode

func (bm *Base) Encode() (string, error)

Encode returns CVSSv3 vector string

func (*Base) GetError

func (bm *Base) GetError() error

GetError returns error instance if undefined metric

func (*Base) Score

func (bm *Base) Score() float64

Score returns score of Base metrics

func (*Base) Severity

func (bm *Base) Severity() Severity

Severity returns severity by score of Base metrics

type ConfidentialityImpact

type ConfidentialityImpact int

ConfidentialityImpact is metric type for Base Metrics

const (
	ConfidentialityImpactUnknown ConfidentialityImpact = iota
	ConfidentialityImpactNone
	ConfidentialityImpactLow
	ConfidentialityImpactHigh
)

Constant of ConfidentialityImpact result

func GetConfidentialityImpact

func GetConfidentialityImpact(s string) ConfidentialityImpact

GetConfidentialityImpact returns result of ConfidentialityImpact metric

func (ConfidentialityImpact) IsUnknown

func (ci ConfidentialityImpact) IsUnknown() bool

IsUnknown returns false if undefined result value of metric

func (ConfidentialityImpact) String

func (ci ConfidentialityImpact) String() string

func (ConfidentialityImpact) Value

func (ci ConfidentialityImpact) Value() float64

Value returns value of ConfidentialityImpact metric

type ConfidentialityRequirement

type ConfidentialityRequirement int

ConfidentialityRequirement is metric type for Base Metrics

const (
	ConfidentialityRequirementInvalid ConfidentialityRequirement = iota
	ConfidentialityRequirementNotDefined
	ConfidentialityRequirementLow
	ConfidentialityRequirementMedium
	ConfidentialityRequirementHigh
)

Constant of ConfidentialityRequirement result

func GetConfidentialityRequirement

func GetConfidentialityRequirement(s string) ConfidentialityRequirement

GetConfidentialityRequirement returns result of ConfidentalityRequirement metric

func (ConfidentialityRequirement) IsValid added in v1.4.0

func (cr ConfidentialityRequirement) IsValid() bool

IsDefined returns false if undefined result value of metric

func (ConfidentialityRequirement) String

func (cr ConfidentialityRequirement) String() string

func (ConfidentialityRequirement) Value

Value returns value of ConfidentialityRequirement metric

type Environmental

Base is Environmental Metrics for CVSSv3

func NewEnvironmental

func NewEnvironmental() *Environmental

NewBase returns Base Metrics instance

func (*Environmental) BaseMetrics

func (em *Environmental) BaseMetrics() *Base

BaseMetrics returns Base metrics in Environmental metrics instance

func (*Environmental) Decode

func (em *Environmental) Decode(vector string) (*Environmental, error)

func (*Environmental) Encode

func (em *Environmental) Encode() (string, error)

Encode returns CVSSv3 vector string

func (*Environmental) GetError

func (em *Environmental) GetError() error

GetError returns error instance if undefined metric

func (*Environmental) Score

func (em *Environmental) Score() float64

func (*Environmental) Severity

func (em *Environmental) Severity() Severity

Severity returns severity by score of Environmental metrics

func (*Environmental) TemporalMetrics

func (em *Environmental) TemporalMetrics() *Temporal

type Exploitability

type Exploitability int

Exploitability is metric type for Temporal Metrics

const (
	ExploitabilityInvalid Exploitability = iota
	ExploitabilityNotDefined
	ExploitabilityUnproven
	ExploitabilityProofOfConcept
	ExploitabilityFunctional
	ExploitabilityHigh
)

Constant of Exploitability result

func GetExploitability

func GetExploitability(s string) Exploitability

GetExploitability returns result of Exploitability metric

func (Exploitability) IsValid added in v1.4.0

func (ex Exploitability) IsValid() bool

IsDefined returns false if undefined result value of metric

func (Exploitability) String

func (ex Exploitability) String() string

func (Exploitability) Value

func (ex Exploitability) Value() float64

Value returns value of Exploitability metric

type IntegrityImpact

type IntegrityImpact int

IntegrityImpact is metric type for Base Metrics

const (
	IntegrityImpactUnknown IntegrityImpact = iota
	IntegrityImpactNone
	IntegrityImpactLow
	IntegrityImpactHigh
)

Constant of IntegrityImpact result

func GetIntegrityImpact

func GetIntegrityImpact(s string) IntegrityImpact

GetIntegrityImpact returns result of IntegrityImpact metric

func (IntegrityImpact) IsUnknown added in v1.4.0

func (ii IntegrityImpact) IsUnknown() bool

IsUnKnown returns false if undefined result value of metric

func (IntegrityImpact) String

func (ii IntegrityImpact) String() string

func (IntegrityImpact) Value

func (ii IntegrityImpact) Value() float64

Value returns value of IntegrityImpact metric

type IntegrityRequirement

type IntegrityRequirement int

IntegrityRequirement is metric type for Base Metrics

const (
	IntegrityRequirementInvalid IntegrityRequirement = iota
	IntegrityRequirementNotDefined
	IntegrityRequirementLow
	IntegrityRequirementMedium
	IntegrityRequirementHigh
)

Constant of IntegrityRequirement result

func GetIntegrityRequirement

func GetIntegrityRequirement(s string) IntegrityRequirement

GetIntegrityRequirement returns result of ConfidentalityRequirement metric

func (IntegrityRequirement) IsValid added in v1.4.0

func (ir IntegrityRequirement) IsValid() bool

IsDefined returns false if undefined result value of metric

func (IntegrityRequirement) String

func (ir IntegrityRequirement) String() string

func (IntegrityRequirement) Value

func (ir IntegrityRequirement) Value() float64

Value returns value of AttackVector metric

type Metrics added in v1.2.0

type Metrics interface {
	// BaseMetrics returns the base type for any given metrics type.
	BaseMetrics() *Base
}

type ModifiedAttackComplexity

type ModifiedAttackComplexity int

ModifiedAttackComplexity is metric type for Base Metrics

const (
	ModifiedAttackComplexityInvalid ModifiedAttackComplexity = iota
	ModifiedAttackComplexityNotDefined
	ModifiedAttackComplexityHigh
	ModifiedAttackComplexityLow
)

Constant of ModifiedAttackComplexity result

func GetModifiedAttackComplexity

func GetModifiedAttackComplexity(s string) ModifiedAttackComplexity

GetModifiedAttackComplexity returns result of ModifiedAttackComplexity metric

func (ModifiedAttackComplexity) IsValid added in v1.4.0

func (mac ModifiedAttackComplexity) IsValid() bool

IsDefined returns false if undefined result value of metric

func (ModifiedAttackComplexity) String

func (mac ModifiedAttackComplexity) String() string

func (ModifiedAttackComplexity) Value

Value returns value of ModifiedAttackComplexity metric

type ModifiedAttackVector

type ModifiedAttackVector int

ModifiedAttackVector is metric type for Base Metrics

const (
	ModifiedAttackVectorInvalid ModifiedAttackVector = iota
	ModifiedAttackVectorNotDefined
	ModifiedAttackVectorPhysical
	ModifiedAttackVectorLocal
	ModifiedAttackVectorAdjacent
	ModifiedAttackVectorNetwork
)

Constant of ModifiedAttackVector result

func GetModifiedAttackVector

func GetModifiedAttackVector(s string) ModifiedAttackVector

GetModifiedAttackVector returns result of ModifiedAttackVector metric

func (ModifiedAttackVector) IsValid added in v1.4.0

func (mav ModifiedAttackVector) IsValid() bool

IsDefined returns false if undefined result value of metric

func (ModifiedAttackVector) String

func (mav ModifiedAttackVector) String() string

func (ModifiedAttackVector) Value

Value returns value of ModifiedAttackVector metric

type ModifiedAvailabilityImpact

type ModifiedAvailabilityImpact int

ModifiedAvailabilityImpact is metric type for Base Metrics

const (
	ModifiedAvailabilityInvalid ModifiedAvailabilityImpact = iota
	ModifiedAvailabilityImpactNotDefined
	ModifiedAvailabilityImpactNone
	ModifiedAvailabilityImpactLow
	ModifiedAvailabilityImpactHigh
)

Constant of ModifiedAvailabilityImpact result

func GetModifiedAvailabilityImpact

func GetModifiedAvailabilityImpact(s string) ModifiedAvailabilityImpact

GetModifiedAvailabilityImpact returns result of ModifiedAvailabilityImpact metric

func (ModifiedAvailabilityImpact) IsValid added in v1.4.0

func (mai ModifiedAvailabilityImpact) IsValid() bool

IsDefined returns false if undefined result value of metric

func (ModifiedAvailabilityImpact) String

func (mai ModifiedAvailabilityImpact) String() string

func (ModifiedAvailabilityImpact) Value

Value returns value of ModifiedAvailabilityImpact metric

type ModifiedConfidentialityImpact

type ModifiedConfidentialityImpact int

ModifiedConfidentialityImpact is metric type for Base Metrics

const (
	ModifiedConfidentialityImpactInvalid ModifiedConfidentialityImpact = iota
	ModifiedConfidentialityImpactNotDefined
	ModifiedConfidentialityImpactNone
	ModifiedConfidentialityImpactLow
	ModifiedConfidentialityImpactHigh
)

Constant of ModifiedConfidentialityImpact result

func GetModifiedConfidentialityImpact

func GetModifiedConfidentialityImpact(s string) ModifiedConfidentialityImpact

GetModifiedConfidentialityImpact returns result of ModifiedConfidentialityImpact metric

func (ModifiedConfidentialityImpact) IsValid added in v1.4.0

func (mci ModifiedConfidentialityImpact) IsValid() bool

IsDefined returns false if undefined result value of metric

func (ModifiedConfidentialityImpact) String

func (ModifiedConfidentialityImpact) Value

Value returns value of ModifiedConfidentialityImpact metric

type ModifiedIntegrityImpact

type ModifiedIntegrityImpact int

ModifiedIntegrityImpact is metric type for Base Metrics

const (
	ModifiedIntegrityImpactInvalid ModifiedIntegrityImpact = iota
	ModifiedIntegrityImpactNotDefined
	ModifiedIntegrityImpactNone
	ModifiedIntegrityImpactLow
	ModifiedIntegrityImpactHigh
)

Constant of ModifiedIntegrityImpact result

func GetModifiedIntegrityImpact

func GetModifiedIntegrityImpact(s string) ModifiedIntegrityImpact

GetModifiedIntegrityImpact returns result of ModifiedIntegrityImpact metric

func (ModifiedIntegrityImpact) IsValid added in v1.4.0

func (mii ModifiedIntegrityImpact) IsValid() bool

IsDefined returns false if undefined result value of metric

func (ModifiedIntegrityImpact) String

func (mii ModifiedIntegrityImpact) String() string

func (ModifiedIntegrityImpact) Value

Value returns value of ModifiedIntegrityImpact metric

type ModifiedPrivilegesRequired

type ModifiedPrivilegesRequired int

ModifiedPrivilegesRequired is metric type for Base Metrics

const (
	ModifiedPrivilegesRequiredInvalid ModifiedPrivilegesRequired = iota
	ModifiedPrivilegesRequiredNotDefined
	ModifiedPrivilegesRequiredHigh
	ModifiedPrivilegesRequiredLow
	ModifiedPrivilegesRequiredNone
)

Constant of ModifiedPrivilegesRequired result

func GetModifiedPrivilegesRequired

func GetModifiedPrivilegesRequired(s string) ModifiedPrivilegesRequired

GetModifiedPrivilegesRequired returns result of ModifiedPrivilegesRequired metric

func (ModifiedPrivilegesRequired) IsValid added in v1.4.0

func (mpr ModifiedPrivilegesRequired) IsValid() bool

IsDefined returns false if undefined result value of metric

func (ModifiedPrivilegesRequired) String

func (mpr ModifiedPrivilegesRequired) String() string

func (ModifiedPrivilegesRequired) Value

Value returns value of ModifiedPrivilegesRequired metric

type ModifiedScope

type ModifiedScope int

ModifiedScope is metric type for Base Metrics

const (
	ModifiedScopeInvalid ModifiedScope = iota
	ModifiedScopeNotDefined
	ModifiedScopeUnchanged
	ModifiedScopeChanged
)

Constant of ModifiedScope result

func GetModifiedScope

func GetModifiedScope(s string) ModifiedScope

GetModifiedScope returns result of ModifiedScope metric

func (ModifiedScope) IsValid added in v1.4.0

func (msc ModifiedScope) IsValid() bool

IsDefined returns false if undefined result value of metric

func (ModifiedScope) String

func (msc ModifiedScope) String() string

type ModifiedUserInteraction

type ModifiedUserInteraction int

ModifiedUserInteraction is metric type for Base Metrics

const (
	ModifiedUserInteractionInvalid ModifiedUserInteraction = iota
	ModifiedUserInteractionNotDefined
	ModifiedUserInteractionRequired
	ModifiedUserInteractionNone
)

Constant of ModifiedUserInteraction result

func GetModifiedUserInteraction

func GetModifiedUserInteraction(s string) ModifiedUserInteraction

GetModifiedUserInteraction returns result of ModifiedUserInteraction metric

func (ModifiedUserInteraction) IsValid added in v1.4.0

func (mui ModifiedUserInteraction) IsValid() bool

IsDefined returns false if undefined result value of metric

func (ModifiedUserInteraction) String

func (mui ModifiedUserInteraction) String() string

func (ModifiedUserInteraction) Value

Value returns value of ModifiedUserInteraction metric

type PrivilegesRequired

type PrivilegesRequired int

PrivilegesRequired is metric type for Base Metrics

const (
	PrivilegesRequiredUnknown PrivilegesRequired = iota
	PrivilegesRequiredHigh
	PrivilegesRequiredLow
	PrivilegesRequiredNone
)

Constant of PrivilegesRequired result

func GetPrivilegesRequired

func GetPrivilegesRequired(s string) PrivilegesRequired

GetPrivilegesRequired returns result of PrivilegesRequired metric

func (PrivilegesRequired) IsUnknown

func (pr PrivilegesRequired) IsUnknown() bool

IsUnknown returns false if undefined result value of metric

func (PrivilegesRequired) String

func (pr PrivilegesRequired) String() string

func (PrivilegesRequired) Value

func (pr PrivilegesRequired) Value(s Scope) float64

Value returns value of PrivilegesRequired metric

type RemediationLevel

type RemediationLevel int

RemediationLevel is metric type for Temporal Metrics

const (
	RemediationLevelInvalid RemediationLevel = iota
	RemediationLevelNotDefined
	RemediationLevelOfficialFix
	RemediationLevelTemporaryFix
	RemediationLevelWorkaround
	RemediationLevelUnavailable
)

Constant of RemediationLevel result

func GetRemediationLevel

func GetRemediationLevel(s string) RemediationLevel

GetRemediationLevel returns result of RemediationLevel metric

func (RemediationLevel) IsValid added in v1.4.0

func (rl RemediationLevel) IsValid() bool

IsDefined returns false if undefined result value of metric

func (RemediationLevel) String

func (rl RemediationLevel) String() string

func (RemediationLevel) Value

func (rl RemediationLevel) Value() float64

Value returns value of RemediationLevel metric

type ReportConfidence

type ReportConfidence int

ReportConfidence is metric type for Temporal Metrics

const (
	ReportConfidenceInvalid ReportConfidence = iota
	ReportConfidenceNotDefined
	ReportConfidenceUnknown
	ReportConfidenceReasonable
	ReportConfidenceConfirmed
)

Constant of ReportConfidence result

func GetReportConfidence

func GetReportConfidence(s string) ReportConfidence

GetReportConfidence returns result of ReportConfidence metric

func (ReportConfidence) IsValid added in v1.4.0

func (rc ReportConfidence) IsValid() bool

IsDefined returns false if undefined result value of metric

func (ReportConfidence) String

func (rc ReportConfidence) String() string

func (ReportConfidence) Value

func (rc ReportConfidence) Value() float64

Value returns value of ReportConfidence metric

type Scope

type Scope int

Scope is metric type for Base Metrics

const (
	ScopeUnknown Scope = iota
	ScopeUnchanged
	ScopeChanged
)

Constant of Scope result

func GetScope

func GetScope(s string) Scope

GetScope returns result of Scope metric

func (Scope) IsUnknown

func (sc Scope) IsUnknown() bool

IsUnknown returns false if undefined result value of metric

func (Scope) String

func (sc Scope) String() string

type Severity

type Severity int

Severity is severity for Base Metrics

const (
	SeverityUnknown Severity = iota
	SeverityNone
	SeverityLow
	SeverityMedium
	SeverityHigh
	SeverityCritical
)

Constant of severity

func (Severity) String

func (sv Severity) String() string

type Temporal

type Temporal struct {
	*Base
	E  Exploitability
	RL RemediationLevel
	RC ReportConfidence
	// contains filtered or unexported fields
}

Base is Temporal Metrics for CVSSv3

func NewTemporal

func NewTemporal() *Temporal

NewBase returns Base Metrics instance

func (*Temporal) BaseMetrics

func (tm *Temporal) BaseMetrics() *Base

BaseMetrics returns Base metrics in Temporal metrics instance

func (*Temporal) Decode

func (tm *Temporal) Decode(vector string) (*Temporal, error)

func (*Temporal) Encode

func (tm *Temporal) Encode() (string, error)

Encode returns CVSSv3 vector string

func (*Temporal) GetError

func (tm *Temporal) GetError() error

GetError returns error instance if undefined metric

func (*Temporal) Score

func (tm *Temporal) Score() float64

Score returns score of Temporal metrics

func (*Temporal) Severity

func (tm *Temporal) Severity() Severity

Severity returns severity by score of Temporal metrics

type UserInteraction

type UserInteraction int

UserInteraction is metric type for Base Metrics

const (
	UserInteractionUnknown UserInteraction = iota
	UserInteractionRequired
	UserInteractionNone
)

Constant of UserInteraction result

func GetUserInteraction

func GetUserInteraction(s string) UserInteraction

GetUserInteraction returns result of UserInteraction metric

func (UserInteraction) IsUnknown

func (ui UserInteraction) IsUnknown() bool

IsUnknown returns false if undefined result value of metric

func (UserInteraction) String

func (ui UserInteraction) String() string

func (UserInteraction) Value

func (ui UserInteraction) Value() float64

Value returns value of UserInteraction metric

type Version

type Version int

Version is error number for CVSS

const (
	VUnknown Version = iota //unknown version
	V3_0                    //v3.0
	V3_1                    //v3.1
)

func GetVersion

func GetVersion(vec string) (Version, error)

GetVersion returns Version number from string

func (Version) String

func (n Version) String() string

String is Stringer method

Jump to

Keyboard shortcuts

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