hubtest

package
v1.5.6-rc9 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParserAssertFileName = "parser.assert"
	ParserResultFileName = "parser-dump.yaml"

	ScenarioAssertFileName = "scenario.assert"
	ScenarioResultFileName = "bucket-dump.yaml"

	BucketPourResultFileName = "bucketpour-dump.yaml"

	TestBouncerApiKey = "this_is_a_bad_password"

	DefaultNucleiTarget = "http://127.0.0.1:7822/"
	DefaultAppsecHost   = "127.0.0.1:4241"
)
View Source
const (
	TemplateNucleiFile = `` /* 429-byte string literal not displayed */

)

Variables

View Source
var ErrNucleiTemplateFail = errors.New("nuclei template failed")

Functions

func Copy

func Copy(src string, dst string) error

func CopyDir

func CopyDir(src string, dest string) error

func DumpTree

func DumpTree(parserResults ParserResults, bucketPour BucketPourInfo, opts DumpOpts)

func Escape

func Escape(val string) string

func IsAlive added in v1.6.0

func IsAlive(target string) (bool, error)

Types

type AssertFail

type AssertFail struct {
	File       string
	Line       int
	Expression string
	Debug      map[string]string
}

type BucketPourInfo

type BucketPourInfo map[string][]types.Event

func LoadBucketPourDump

func LoadBucketPourDump(filepath string) (*BucketPourInfo, error)

type BucketResults

type BucketResults []types.Event

func LoadScenarioDump

func LoadScenarioDump(filepath string) (*BucketResults, error)

func (BucketResults) Len

func (b BucketResults) Len() int

func (BucketResults) Less

func (b BucketResults) Less(i, j int) bool

func (BucketResults) Swap

func (b BucketResults) Swap(i, j int)

type Coverage added in v1.6.0

type Coverage struct {
	Name       string
	TestsCount int
	PresentIn  map[string]bool //poorman's set
}

type DumpOpts

type DumpOpts struct {
	Details          bool
	SkipOk           bool
	ShowNotOkParsers bool
}

type HubTest

type HubTest struct {
	CrowdSecPath              string
	CscliPath                 string
	HubPath                   string
	HubTestPath               string //generic parser/scenario tests .tests
	HubAppsecTestPath         string //dir specific to appsec tests .appsec-tests
	HubIndexFile              string
	TemplateConfigPath        string
	TemplateProfilePath       string
	TemplateSimulationPath    string
	TemplateAcquisPath        string
	TemplateAppsecProfilePath string
	NucleiTargetHost          string
	AppSecHost                string

	HubIndex *cwhub.Hub
	Tests    []*HubTestItem
}

func NewHubTest

func NewHubTest(hubPath string, crowdsecPath string, cscliPath string, isAppsecTest bool) (HubTest, error)

func (*HubTest) GetAppsecCoverage added in v1.6.0

func (h *HubTest) GetAppsecCoverage() ([]Coverage, error)

func (*HubTest) GetParsersCoverage

func (h *HubTest) GetParsersCoverage() ([]Coverage, error)

func (*HubTest) GetScenariosCoverage

func (h *HubTest) GetScenariosCoverage() ([]Coverage, error)

func (*HubTest) LoadAllTests

func (h *HubTest) LoadAllTests() error

func (*HubTest) LoadTestItem

func (h *HubTest) LoadTestItem(name string) (*HubTestItem, error)

type HubTestItem

type HubTestItem struct {
	Name string
	Path string

	CrowdSecPath string
	CscliPath    string

	RuntimePath               string
	RuntimeHubPath            string
	RuntimeDataPath           string
	RuntimePatternsPath       string
	RuntimeConfigFilePath     string
	RuntimeProfileFilePath    string
	RuntimeSimulationFilePath string
	RuntimeAcquisFilePath     string
	RuntimeHubConfig          *csconfig.LocalHubCfg

	ResultsPath          string
	ParserResultFile     string
	ScenarioResultFile   string
	BucketPourResultFile string

	HubPath                   string
	HubTestPath               string
	HubIndexFile              string
	TemplateConfigPath        string
	TemplateProfilePath       string
	TemplateSimulationPath    string
	TemplateAcquisPath        string
	TemplateAppsecProfilePath string
	HubIndex                  *cwhub.Hub

	Config *HubTestItemConfig

	Success    bool
	ErrorsList []string

	AutoGen        bool
	ParserAssert   *ParserAssert
	ScenarioAssert *ScenarioAssert

	CustomItemsLocation []string

	NucleiTargetHost string
	AppSecHost       string
}

func NewTest

func NewTest(name string, hubTest *HubTest) (*HubTestItem, error)

func (*HubTestItem) Clean

func (t *HubTestItem) Clean() error

func (*HubTestItem) InstallHub

func (t *HubTestItem) InstallHub() error

func (*HubTestItem) Run

func (t *HubTestItem) Run() error

func (*HubTestItem) RunWithLogFile added in v1.6.0

func (t *HubTestItem) RunWithLogFile() error

func (*HubTestItem) RunWithNucleiTemplate added in v1.6.0

func (t *HubTestItem) RunWithNucleiTemplate() error

type HubTestItemConfig

type HubTestItemConfig struct {
	Parsers               []string            `yaml:"parsers,omitempty"`
	Scenarios             []string            `yaml:"scenarios,omitempty"`
	PostOverflows         []string            `yaml:"postoverflows,omitempty"`
	AppsecRules           []string            `yaml:"appsec-rules,omitempty"`
	NucleiTemplate        string              `yaml:"nuclei_template,omitempty"`
	ExpectedNucleiFailure bool                `yaml:"expect_failure,omitempty"`
	LogFile               string              `yaml:"log_file,omitempty"`
	LogType               string              `yaml:"log_type,omitempty"`
	Labels                map[string]string   `yaml:"labels,omitempty"`
	IgnoreParsers         bool                `yaml:"ignore_parsers,omitempty"`   // if we test a scenario, we don't want to assert on Parser
	OverrideStatics       []parser.ExtraField `yaml:"override_statics,omitempty"` //Allow to override statics. Executed before s00
}

type NucleiConfig added in v1.6.0

type NucleiConfig struct {
	Path           string   `yaml:"nuclei_path"`
	OutputDir      string   `yaml:"output_dir"`
	CmdLineOptions []string `yaml:"cmdline_options"`
}

func (*NucleiConfig) RunNucleiTemplate added in v1.6.0

func (nc *NucleiConfig) RunNucleiTemplate(testName string, templatePath string, target string) error

type ParserAssert

type ParserAssert struct {
	File              string
	AutoGenAssert     bool
	AutoGenAssertData string
	NbAssert          int
	Fails             []AssertFail
	Success           bool
	TestData          *ParserResults
}

func NewParserAssert

func NewParserAssert(file string) *ParserAssert

func (*ParserAssert) AssertFile

func (p *ParserAssert) AssertFile(testFile string) error

func (*ParserAssert) AutoGenFromFile

func (p *ParserAssert) AutoGenFromFile(filename string) (string, error)

func (*ParserAssert) AutoGenParserAssert

func (p *ParserAssert) AutoGenParserAssert() string

func (*ParserAssert) EvalExpression

func (p *ParserAssert) EvalExpression(expression string) (string, error)

func (*ParserAssert) LoadTest

func (p *ParserAssert) LoadTest(filename string) error

func (*ParserAssert) Run

func (p *ParserAssert) Run(assert string) (bool, error)

func (*ParserAssert) RunExpression

func (p *ParserAssert) RunExpression(expression string) (interface{}, error)

type ParserResult

type ParserResult struct {
	Evt     types.Event
	Success bool
}

type ParserResults

type ParserResults map[string]map[string][]ParserResult

func LoadParserDump

func LoadParserDump(filepath string) (*ParserResults, error)

type ScenarioAssert

type ScenarioAssert struct {
	File              string
	AutoGenAssert     bool
	AutoGenAssertData string
	NbAssert          int
	Fails             []AssertFail
	Success           bool
	TestData          *BucketResults
	PourData          *BucketPourInfo
}

func NewScenarioAssert

func NewScenarioAssert(file string) *ScenarioAssert

func (*ScenarioAssert) AssertFile

func (s *ScenarioAssert) AssertFile(testFile string) error

func (*ScenarioAssert) AutoGenFromFile

func (s *ScenarioAssert) AutoGenFromFile(filename string) (string, error)

func (*ScenarioAssert) AutoGenScenarioAssert

func (s *ScenarioAssert) AutoGenScenarioAssert() string

func (*ScenarioAssert) EvalExpression

func (s *ScenarioAssert) EvalExpression(expression string) (string, error)

func (*ScenarioAssert) LoadTest

func (s *ScenarioAssert) LoadTest(filename string, bucketpour string) error

func (*ScenarioAssert) Run

func (s *ScenarioAssert) Run(assert string) (bool, error)

func (*ScenarioAssert) RunExpression

func (s *ScenarioAssert) RunExpression(expression string) (interface{}, error)

Jump to

Keyboard shortcuts

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