metric

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessComplexity

type AccessComplexity int

AccessComplexity is metric type for Base Metrics

const (
	AccessComplexityUnknown AccessComplexity = iota
	AccessComplexityHigh
	AccessComplexityMedium
	AccessComplexityLow
)

Constant of AccessComplexity result

func GetAccessComplexity

func GetAccessComplexity(s string) AccessComplexity

GetAccessComplexity returns result of AccessComplexity metric

func (AccessComplexity) IsUnknown

func (ac AccessComplexity) IsUnknown() bool

IsUnknown returns false if undefined result value of metric

func (AccessComplexity) String

func (ac AccessComplexity) String() string

func (AccessComplexity) Value

func (ac AccessComplexity) Value() float64

Value returns value of AccessComplexity metric

type AccessVector

type AccessVector int

AccessVector is metric type for Base Metrics

const (
	AccessVectorUnknown AccessVector = iota
	AccessVectorLocal
	AccessVectorAdjacent
	AccessVectorNetwork
)

Constant of AccessVector result

func GetAccessVector

func GetAccessVector(s string) AccessVector

GetAccessVector returns result of AccessVector metric

func (AccessVector) IsUnknown

func (av AccessVector) IsUnknown() bool

IsUnknown returns false if undefined result value of metric

func (AccessVector) String

func (av AccessVector) String() string

func (AccessVector) Value

func (av AccessVector) Value() float64

Value returns value of AccessVector metric

type Authentication

type Authentication int

Authentication is metric type for Base Metrics

const (
	AuthenticationUnknown Authentication = iota
	AuthenticationNone
	AuthenticationSingle
	AuthenticationMultiple
)

Constant of Authentication result

func GetAuthentication

func GetAuthentication(s string) Authentication

GetAuthentication returns result of Authentication metric

func (Authentication) IsUnknown

func (av Authentication) IsUnknown() bool

IsUnknown returns false if undefined result value of metric

func (Authentication) String

func (av Authentication) String() string

func (Authentication) Value

func (av Authentication) Value() float64

Value returns value of Authentication metric

type AvailabilityImpact

type AvailabilityImpact int

AvailabilityImpact is metric type for Base Metrics

const (
	AvailabilityImpactUnknown AvailabilityImpact = iota
	AvailabilityImpactNone
	AvailabilityImpactPartial
	AvailabilityImpactComplete
)

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 Temporal 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) IsDefined

func (ar AvailabilityRequirement) IsDefined() bool

IsDefined returns false if undefined result value of metric

func (AvailabilityRequirement) IsValid

func (ar AvailabilityRequirement) IsValid() bool

IsValid returns false if invalid 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 {
	AV AccessVector
	AC AccessComplexity
	Au Authentication
	C  ConfidentialityImpact
	I  IntegrityImpact
	A  AvailabilityImpact
	// contains filtered or unexported fields
}

Base is Base Metrics for CVSSv2

func NewBase

func NewBase() *Base

NewMetrics returns Metrics instance

func (*Base) Decode

func (m *Base) Decode(vector string) (*Base, error)

Decode returns Metrics instance by CVSSv2 vector

Example
package main

import (
	"fmt"

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

func main() {
	m, err := metric.NewBase().Decode("AV:N/AC:L/Au:N/C:N/I:N/A:C") //CVE-2002-0392
	if err != nil {
		return
	}
	fmt.Println("Score =", m.Score())
	fmt.Println("Severity =", m.Severity())
}
Output:

Score = 7.8
Severity = High

func (*Base) Encode

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

Encode returns CVSSv2 vector string

func (*Base) GetError

func (m *Base) GetError() error

GetError returns error instance if unknown metric

func (*Base) Score

func (m *Base) Score() float64

Score returns score of Base metrics

func (*Base) Severity

func (m *Base) Severity() Severity

GetSeverity returns severity by score of Base metrics

func (*Base) String

func (m *Base) String() string

String is stringer method.

type CollateralDamagePotential

type CollateralDamagePotential int

CollateralDamagePotential is metric type for Temporal Metrics

const (
	CollateralDamagePotentialInvalid CollateralDamagePotential = iota
	CollateralDamagePotentialNotDefined
	CollateralDamagePotentialNon
	CollateralDamagePotentialLow
	CollateralDamagePotentialLowMedium
	CollateralDamagePotentialMediumHigh
	CollateralDamagePotentialHigh
)

Constant of CollateralDamagePotential result

func GetCollateralDamagePotential

func GetCollateralDamagePotential(s string) CollateralDamagePotential

GetCollateralDamagePotential returns result of CollateralDamagePotential metric

func (CollateralDamagePotential) IsDefined

func (cdp CollateralDamagePotential) IsDefined() bool

IsDefined returns false if undefined result value of metric

func (CollateralDamagePotential) IsValid

func (cdp CollateralDamagePotential) IsValid() bool

IsValid returns false if invalid result value of metric

func (CollateralDamagePotential) String

func (cdp CollateralDamagePotential) String() string

func (CollateralDamagePotential) Value

func (cdp CollateralDamagePotential) Value() float64

Value returns value of CollateralDamagePotential metric

type ConfidentialityImpact

type ConfidentialityImpact int

ConfidentialityImpact is metric type for Base Metrics

const (
	ConfidentialityImpactUnknown ConfidentialityImpact = iota
	ConfidentialityImpactNone
	ConfidentialityImpactPartial
	ConfidentialityImpactComplete
)

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 Temporal Metrics

const (
	ConfidentialityRequirementInvalid ConfidentialityRequirement = iota
	ConfidentialityRequirementNotDefined
	ConfidentialityRequirementLow
	ConfidentialityRequirementMedium
	ConfidentialityRequirementHigh
)

Constant of ConfidentialityRequirement result

func GetConfidentialityRequirement

func GetConfidentialityRequirement(s string) ConfidentialityRequirement

GetConfidentialityRequirement returns result of ConfidentialityRequirement metric

func (ConfidentialityRequirement) IsDefined

func (cr ConfidentialityRequirement) IsDefined() bool

IsDefined returns false if undefined result value of metric

func (ConfidentialityRequirement) IsValid

func (cr ConfidentialityRequirement) IsValid() bool

IsValid returns false if invalid result value of metric

func (ConfidentialityRequirement) String

func (cr ConfidentialityRequirement) String() string

func (ConfidentialityRequirement) Value

Value returns value of ConfidentialityRequirement metric

type Environmental

type Environmental struct {
	*Temporal
	CDP CollateralDamagePotential
	TD  TargetDistribution
	CR  ConfidentialityRequirement
	IR  IntegrityRequirement
	AR  AvailabilityRequirement
	// contains filtered or unexported fields
}

Environmental is Environmental Metrics for CVSSv2

func NewEnvironmental

func NewEnvironmental() *Environmental

NewBase returns Environmental Metrics instance

func (*Environmental) BaseMetrics

func (m *Environmental) BaseMetrics() *Base

BaseMetrics returns Base metrics in Environmental metrics instance

func (*Environmental) Decode

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

Decode returns Metrics instance by CVSSv2 vector

Example
package main

import (
	"fmt"

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

func main() {
	m, err := metric.NewEnvironmental().Decode("AV:N/AC:L/Au:N/C:N/I:N/A:C/E:F/RL:OF/RC:C/CDP:H/TD:H/CR:M/IR:M/AR:H") //CVE-2002-0392
	if err != nil {
		return
	}
	fmt.Println("Score =", m.Score())
	fmt.Println("Severity =", m.Severity())
}
Output:

Score = 9.2
Severity = High

func (*Environmental) Encode

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

Encode returns CVSSv2 vector string

func (*Environmental) GetError

func (m *Environmental) GetError() error

GetError returns error instance if undefined metric

func (*Environmental) IsEmpty added in v1.6.2

func (m *Environmental) IsEmpty() bool

IsEmpty returns true if all elements of Temporal Metrics are empty.

func (*Environmental) Score

func (m *Environmental) Score() float64

Score returns score of Environmental metrics

func (*Environmental) Severity

func (m *Environmental) Severity() Severity

Severity returns severity by score of Environmental metrics

func (*Environmental) String

func (m *Environmental) String() string

String is stringer method.

func (*Environmental) TemporalMetrics

func (m *Environmental) TemporalMetrics() *Temporal

TemporalMetrics returns Temporal metrics in Environmental metrics instance

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) IsDefined

func (ai Exploitability) IsDefined() bool

IsDefined returns false if undefined result value of metric

func (Exploitability) IsValid

func (ai Exploitability) IsValid() bool

IsValid returns false if invalid result value of metric

func (Exploitability) String

func (ai Exploitability) String() string

func (Exploitability) Value

func (ai 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
	IntegrityImpactPartial
	IntegrityImpactComplete
)

Constant of IntegrityImpact result

func GetIntegrityImpact

func GetIntegrityImpact(s string) IntegrityImpact

GetIntegrityImpact returns result of IntegrityImpact metric

func (IntegrityImpact) IsUnknown

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 Temporal Metrics

const (
	IntegrityRequirementInvalid IntegrityRequirement = iota
	IntegrityRequirementNotDefined
	IntegrityRequirementLow
	IntegrityRequirementMedium
	IntegrityRequirementHigh
)

Constant of IntegrityRequirement result

func GetIntegrityRequirement

func GetIntegrityRequirement(s string) IntegrityRequirement

GetIntegrityRequirement returns result of IntegrityRequirement metric

func (IntegrityRequirement) IsDefined

func (ir IntegrityRequirement) IsDefined() bool

IsDefined returns false if undefined result value of metric

func (IntegrityRequirement) IsValid

func (ir IntegrityRequirement) IsValid() bool

IsValid returns false if invalid result value of metric

func (IntegrityRequirement) String

func (ir IntegrityRequirement) String() string

func (IntegrityRequirement) Value

func (ir IntegrityRequirement) Value() float64

Value returns value of IntegrityRequirement 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) IsDefined

func (ai RemediationLevel) IsDefined() bool

IsDefined returns false if undefined result value of metric

func (RemediationLevel) IsValid

func (ai RemediationLevel) IsValid() bool

IsValid returns false if invalid result value of metric

func (RemediationLevel) String

func (ai RemediationLevel) String() string

func (RemediationLevel) Value

func (ai 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
	ReportConfidenceUnconfirmed
	ReportConfidenceUncorroborated
	ReportConfidenceConfirmed
)

Constant of ReportConfidence result

func GetReportConfidence

func GetReportConfidence(s string) ReportConfidence

GetReportConfidence returns result of ReportConfidence metric

func (ReportConfidence) IsDefined

func (ai ReportConfidence) IsDefined() bool

IsDefined returns false if undefined result value of metric

func (ReportConfidence) IsValid

func (ai ReportConfidence) IsValid() bool

IsValid returns false if invalid result value of metric

func (ReportConfidence) String

func (ai ReportConfidence) String() string

func (ReportConfidence) Value

func (ai ReportConfidence) Value() float64

Value returns value of ReportConfidence metric

type Severity

type Severity int

Severity is severity for Base Metrics

const (
	SeverityUnknown Severity = iota
	SeverityLow
	SeverityMedium
	SeverityHigh
)

Constant of severity

func (Severity) String

func (sv Severity) String() string

type TargetDistribution

type TargetDistribution int

TargetDistribution is metric type for Temporal Metrics

const (
	TargetDistributionInvalid TargetDistribution = iota
	TargetDistributionNotDefined
	TargetDistributionNon
	TargetDistributionLow
	TargetDistributionMedium
	TargetDistributionHigh
)

Constant of TargetDistribution result

func GetTargetDistribution

func GetTargetDistribution(s string) TargetDistribution

GetTargetDistribution returns result of TargetDistribution metric

func (TargetDistribution) IsDefined

func (td TargetDistribution) IsDefined() bool

IsDefined returns false if undefined result value of metric

func (TargetDistribution) IsValid

func (td TargetDistribution) IsValid() bool

IsValid returns false if invalid result value of metric

func (TargetDistribution) String

func (td TargetDistribution) String() string

func (TargetDistribution) Value

func (td TargetDistribution) Value() float64

Value returns value of TargetDistribution metric

type Temporal

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

Temporal is Temporal Metrics for CVSSv2

func NewTemporal

func NewTemporal() *Temporal

NewTemporal returns Temporal Metrics instance

func (*Temporal) BaseMetrics

func (m *Temporal) BaseMetrics() *Base

BaseMetrics returns Base metrics in Temporal metrics instance

func (*Temporal) Decode

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

Decode returns Metrics instance by CVSSv2 vector

Example
package main

import (
	"fmt"

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

func main() {
	m, err := metric.NewTemporal().Decode("AV:N/AC:L/Au:N/C:N/I:N/A:C/E:F/RL:OF/RC:C") //CVE-2002-0392
	if err != nil {
		return
	}
	fmt.Println("Score =", m.Score())
	fmt.Println("Severity =", m.Severity())
}
Output:

Score = 6.4
Severity = Medium

func (*Temporal) Encode

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

Encode returns CVSSv2 vector string

func (*Temporal) GetError

func (m *Temporal) GetError() error

GetError returns error instance if undefined metric

func (*Temporal) IsEmpty added in v1.6.2

func (m *Temporal) IsEmpty() bool

IsEmpty returns true if all elements of Temporal Metrics are empty.

func (*Temporal) Score

func (m *Temporal) Score() float64

Score returns score of Temporal metrics

func (*Temporal) Severity

func (m *Temporal) Severity() Severity

GetSeverity returns severity by score of Base metrics

func (*Temporal) String

func (m *Temporal) String() string

String is stringer method.

Jump to

Keyboard shortcuts

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