utils

package
v1.4.9 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckLine

func CheckLine(t *testing.T, expec, want string, line int)

CheckLine executes assertions to validate the content of two JSON files

func Contains

func Contains(list []string, searchTerm string) bool

Contains returns if a string list contains an especific term

func FileCheck

func FileCheck(t *testing.T, actualPayloadName, expectPayloadName, location string)

FileCheck executes assertions to validate file content length

func GetKICSBinaryPath

func GetKICSBinaryPath(path string) []string

GetKICSBinaryPath gets the kics binary complete path

func HTMLValidation

func HTMLValidation(t *testing.T, file string)

HTMLValidation executes many asserts to validate the HTML Report

func JSONSchemaCompare added in v1.4.9

func JSONSchemaCompare(t *testing.T, schema, report gojsonschema.JSONLoader)

JSONSchemaCompare executes schema assertions to validate the content of a JSON file

func JSONSchemaValidationFromData added in v1.4.9

func JSONSchemaValidationFromData(t *testing.T, data []byte, schema string)

JSONSchemaValidationFromData loads a json data and validates it against a schema

func JSONSchemaValidationFromFile added in v1.4.9

func JSONSchemaValidationFromFile(t *testing.T, file, schema string)

JSONSchemaValidationFromFile loads a json file and validates it against a schema

func PrepareExpected

func PrepareExpected(path, folder string) ([]string, error)

PrepareExpected prepares the files for validation tests

func ReadFixture

func ReadFixture(testName, folder string) (string, error)

ReadFixture reads a file based on a provided path and filename

func XMLToJSON added in v1.4.9

func XMLToJSON(t *testing.T, filename, model string) []byte

XMLToJSON - converts XML to JSON Structure

Types

type CmdOutput

type CmdOutput struct {
	Output []string
	Status int
}

CmdOutput stores the structure of kics output

func RunCommand

func RunCommand(args []string, useMock bool) (*CmdOutput, error)

RunCommand executes the kics in a terminal

type CycloneSchema added in v1.4.9

type CycloneSchema struct {
	XMLName      xml.Name `xml:"bom"`
	XMLNS        string   `xml:"xmlns,attr"`
	XMLNSV       string   `xml:"v,attr"`
	SerialNumber string   `xml:"serialNumber,attr"`
	Version      string   `xml:"version,attr"`
	Metadata     struct {
		Timestamp string `xml:"timestamp"`
		Tools     []struct {
			Vendor  string `xml:"vendor"`
			Name    string `xml:"name"`
			Version string `xml:"version"`
		} `xml:"tools>tool"`
	} `xml:"metadata"`
	Components struct {
		Components []struct {
			Type    string `xml:"type,attr"`
			BomRef  string `xml:"bom-ref,attr"`
			Name    string `xml:"name"`
			Version string `xml:"version"`
			Hashes  []struct {
				Alg     string `xml:"alg,attr"`
				Content string `xml:",chardata"`
			} `xml:"hashes>hash"`
			Purl            string `xml:"purl"`
			Vulnerabilities []struct {
				Ref    string `xml:"ref,attr"`
				ID     string `xml:"id"`
				Source struct {
					Name string `xml:"name"`
					URL  string `xml:"url"`
				} `xml:"source"`
				Ratings []struct {
					Severity string `xml:"severity"`
					Method   string `xml:"method"`
				} `xml:"ratings>rating"`
				Description     string `xml:"description"`
				Recommendations []struct {
					Recommendation string `xml:"Recommendation"`
				} `xml:"recommendations>recommendation"`
			} `xml:"vulnerabilities>vulnerability"`
		} `xml:"component"`
	} `xml:"components"`
}

CycloneSchema is the struct used to unmarshal the cyclonedx xml

Jump to

Keyboard shortcuts

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