filters

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Predicate

type Predicate func(tests *models.SubCategory, params string) *models.SubCategory

Predicate filter audit tests cmd criteria

var Basic Predicate = func(tests *models.SubCategory, params string) *models.SubCategory {
	return tests
}

Basic filter by specific audit tests as set in command

var ExcludeAudit Predicate = func(tests *models.SubCategory, params string) *models.SubCategory {
	sat := make([]*models.AuditBench, 0)
	spt := utils.GetAuditTestsList("e", params)

	for _, sp := range spt {
		if strings.HasPrefix(tests.Name, sp) {
			return &models.SubCategory{Name: tests.Name, AuditTests: []*models.AuditBench{}}
		}
	}
	for _, at := range tests.AuditTests {
		var skipTest bool
		for _, sp := range spt {
			if strings.HasPrefix(at.Name, sp) {
				skipTest = true
			}
		}
		if skipTest {
			continue
		}
		sat = append(sat, at)
	}
	return &models.SubCategory{Name: tests.Name, AuditTests: sat}
}

ExcludeAudit audit test from been executed

var IncludeAudit Predicate = func(tests *models.SubCategory, params string) *models.SubCategory {
	sat := make([]*models.AuditBench, 0)
	spt := utils.GetAuditTestsList("i", params)

	for _, sp := range spt {
		if strings.HasPrefix(tests.Name, sp) {
			return tests
		}
	}

	for _, at := range tests.AuditTests {
		for _, sp := range spt {
			if strings.HasPrefix(at.Name, sp) {
				sat = append(sat, at)
			}
		}
	}
	if len(sat) == 0 {
		return &models.SubCategory{Name: tests.Name, AuditTests: make([]*models.AuditBench, 0)}
	}
	return &models.SubCategory{Name: tests.Name, AuditTests: sat}
}

IncludeAudit include audit tests , only included tests will be executed

var NodeAudit Predicate = func(tests *models.SubCategory, params string) *models.SubCategory {
	sat := make([]*models.AuditBench, 0)
	spt := utils.GetAuditTestsList("n", params)

	for _, at := range tests.AuditTests {
		for _, sp := range spt {
			if strings.ToLower(at.ProfileApplicability) == sp {
				sat = append(sat, at)
			}
		}
	}
	if len(sat) == 0 {
		return &models.SubCategory{Name: tests.Name, AuditTests: make([]*models.AuditBench, 0)}
	}
	return &models.SubCategory{Name: tests.Name, AuditTests: sat}
}

NodeAudit audit test from been executed

Jump to

Keyboard shortcuts

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