test

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

Tests

The purpose of this docs is to describe KICS' tests

Getting Started

There are several ways to execute the E2E tests.

TLDR

This command will execute all go tests:

make test-race-cover

This will run a shorter test suite without the queries tests.

make test-short

If you want to generate a HTML coverage report:

make test-coverage-report

Documentation

Index

Constants

View Source
const ValidUUIDRegex = `(?i)^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$`

ValidUUIDRegex is a constant representing a regular expression rule to validate UUID string

Variables

View Source
var ComplexSummaryMock = model.Summary{
	Counters: model.Counters{
		ScannedFiles:           2,
		ParsedFiles:            2,
		FailedToScanFiles:      0,
		TotalQueries:           2,
		FailedToExecuteQueries: 0,
	},
	Queries: []model.VulnerableQuery{
		queryHigh,
		queryMedium,
	},
	SeveritySummary: model.SeveritySummary{
		ScanID: "console",
		SeverityCounters: map[model.Severity]int{
			model.SeverityInfo:   0,
			model.SeverityLow:    0,
			model.SeverityMedium: 1,
			model.SeverityHigh:   2,
		},
		TotalCounter: 3,
	},
}

ComplexSummaryMock a summary with more results to be used without running kics scan

View Source
var SummaryMock = model.Summary{
	Counters: model.Counters{
		ScannedFiles:           1,
		ParsedFiles:            1,
		FailedToScanFiles:      0,
		TotalQueries:           1,
		FailedToExecuteQueries: 0,
	},
	Queries: []model.VulnerableQuery{
		queryHigh,
	},
	SeveritySummary: model.SeveritySummary{
		ScanID: "console",
		SeverityCounters: map[model.Severity]int{
			model.SeverityInfo:   0,
			model.SeverityLow:    0,
			model.SeverityMedium: 0,
			model.SeverityHigh:   2,
		},
		TotalCounter: 2,
	},
}

SummaryMock a summary to be used without running kics scan

Functions

func CaptureCommandOutput

func CaptureCommandOutput(cmd *cobra.Command, args []string) (string, error)

CaptureCommandOutput set cobra command args, if necessary, then capture the output

func CaptureOutput

func CaptureOutput(funcToExec execute) (string, error)

CaptureOutput changes default stdout to intercept into a buffer, converts it to string and returns it

func ChangeCurrentDir

func ChangeCurrentDir(desiredDir string) error

ChangeCurrentDir gets current working directory and changes to its parent until finds the desired directory or fail

func GetCurrentDirName

func GetCurrentDirName(path string) string

GetCurrentDirName returns current working directory

func MapToStringSlice added in v1.2.0

func MapToStringSlice(stringKeyMap map[string]string) []string

MapToStringSlice extract slice of keys from a map[string]string

func StringifyStruct added in v1.1.3

func StringifyStruct(v interface{}) (string, error)

StringifyStruct stringify struct for pretty print

Types

This section is empty.

Jump to

Keyboard shortcuts

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