db

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculatePercentage

func CalculatePercentage[A Number, B Number](first A, second B) float64

func Round

func Round(n float64) float64

Types

type Case

type Case struct {
	Payloads     []string
	Encoders     []string
	Placeholders []*Placeholder
	Type         string

	Set            string
	Name           string
	IsTruePositive bool
}

func LoadTestCases

func LoadTestCases(cfg *config.Config) (testCases []*Case, err error)

func (*Case) Hash added in v0.4.12

func (p *Case) Hash() []byte

type DB

type DB struct {
	sync.Mutex

	NumberOfTests uint
	Hash          string

	IsGrpcAvailable    bool
	IsGraphQLAvailable bool
	// contains filtered or unexported fields
}

func NewDB

func NewDB(tests []*Case) (*DB, error)

func (*DB) AddToScannedPaths

func (db *DB) AddToScannedPaths(method string, path string)

func (*DB) ExportPayloads

func (db *DB) ExportPayloads(payloadsExportFile string) error

func (*DB) GetStatistics

func (db *DB) GetStatistics(ignoreUnresolved, nonBlockedAsPassed bool) *Statistics

func (*DB) GetTestCases

func (db *DB) GetTestCases() []*Case

func (*DB) UpdateBlockedTests

func (db *DB) UpdateBlockedTests(t *Info)

func (*DB) UpdateFailedTests

func (db *DB) UpdateFailedTests(t *Info)

func (*DB) UpdateNaTests

func (db *DB) UpdateNaTests(t *Info, ignoreUnresolved, nonBlockedAsPassed, isTruePositive bool)

func (*DB) UpdatePassedTests

func (db *DB) UpdatePassedTests(t *Info)

type FailedDetails

type FailedDetails struct {
	Payload     string   `json:"payload" validate:"required"`
	TestCase    string   `json:"test_case" validate:"required,printascii"`
	TestSet     string   `json:"test_set" validate:"required,printascii"`
	Encoder     string   `json:"encoder" validate:"required,printascii"`
	Placeholder string   `json:"placeholder" validate:"required,printascii"`
	Reason      []string `json:"reason" validate:"omitempty,dive,required"`
	Type        string   `json:"type" validate:"omitempty"`
}

type Float

type Float interface {
	float32 | float64
}

type Info

type Info struct {
	Payload            string
	Encoder            string
	Placeholder        string
	Set                string
	Case               string
	ResponseStatusCode int
	AdditionalInfo     []string
	Type               string
}

type Integer

type Integer interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64
}

type Number

type Number interface {
	Integer | Float
}

type Path

type Path struct {
	Method string `json:"method" validate:"required,printascii,max=32"`
	Path   string `json:"path" validate:"required,printascii,max=1024"`
}

type Placeholder added in v0.4.4

type Placeholder struct {
	Name   string
	Config placeholder.PlaceholderConfig
}

func (*Placeholder) Hash added in v0.4.12

func (p *Placeholder) Hash() []byte

type RequestStats added in v0.5.4

type RequestStats struct {
	AllRequestsNumber        int
	BlockedRequestsNumber    int
	BypassedRequestsNumber   int
	UnresolvedRequestsNumber int
	FailedRequestsNumber     int
	ResolvedRequestsNumber   int
}

type ScannedPaths

type ScannedPaths []*Path

func (ScannedPaths) Len

func (sp ScannedPaths) Len() int

func (ScannedPaths) Less

func (sp ScannedPaths) Less(i, j int) bool

func (ScannedPaths) Sort

func (sp ScannedPaths) Sort()

func (ScannedPaths) Swap

func (sp ScannedPaths) Swap(i, j int)

type Score added in v0.5.3

type Score struct {
	TruePositive float64
	TrueNegative float64
	Average      float64
}

type Statistics

type Statistics struct {
	IsGrpcAvailable    bool
	IsGraphQLAvailable bool

	Paths ScannedPaths

	TestCasesFingerprint string

	TruePositiveTests TestsSummary
	TrueNegativeTests TestsSummary

	Score struct {
		ApiSec  Score
		AppSec  Score
		Average float64
	}
}

type SummaryTableRow

type SummaryTableRow struct {
	TestSet    string  `json:"test_set" validate:"required,printascii,max=256"`
	TestCase   string  `json:"test_case" validate:"required,printascii,max=256"`
	Percentage float64 `json:"percentage" validate:"min=0,max=100"`
	Sent       int     `json:"sent" validate:"min=0"`
	Blocked    int     `json:"blocked" validate:"min=0"`
	Bypassed   int     `json:"bypassed" validate:"min=0"`
	Unresolved int     `json:"unresolved" validate:"min=0"`
	Failed     int     `json:"failed" validate:"min=0"`
}

type TestDetails

type TestDetails struct {
	Payload            string
	TestCase           string
	TestSet            string
	Encoder            string
	Placeholder        string
	ResponseStatusCode int
	AdditionalInfo     []string
	Type               string
}

type TestsSummary added in v0.5.3

type TestsSummary struct {
	SummaryTable []*SummaryTableRow
	Blocked      []*TestDetails
	Bypasses     []*TestDetails
	Unresolved   []*TestDetails
	Failed       []*FailedDetails

	ReqStats       RequestStats
	ApiSecReqStats RequestStats
	AppSecReqStats RequestStats

	UnresolvedRequestsPercentage       float64
	ResolvedBlockedRequestsPercentage  float64
	ResolvedBypassedRequestsPercentage float64
	FailedRequestsPercentage           float64
}

Jump to

Keyboard shortcuts

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