crowdsecurity/crowdsec · error
no appsec rules in hub index
Error message
no appsec rules in hub index
What it means
GetAppsecCoverage in pkg/hubtest/coverage.go returns this error when the hub index contains zero items of type APPSEC_RULES. Coverage enumeration cannot proceed without at least one appsec rule item to iterate over.
Source
Thrown at pkg/hubtest/coverage.go:28
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
"github.com/crowdsecurity/go-cs-lib/maptools"
"github.com/crowdsecurity/crowdsec/pkg/appsec/appsec_rule"
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
)
type Coverage struct {
Name string
TestsCount int
PresentIn map[string]bool // poorman's set
}
func (h *HubTest) GetAppsecCoverage(hubDir string) ([]Coverage, error) {
if len(h.HubIndex.GetItemMap(cwhub.APPSEC_RULES)) == 0 {
return nil, errors.New("no appsec rules in hub index")
}
// populate from hub, iterate in alphabetical order
pkeys := maptools.SortedKeys(h.HubIndex.GetItemMap(cwhub.APPSEC_RULES))
coverage := make([]Coverage, len(pkeys))
for i, name := range pkeys {
coverage[i] = Coverage{
Name: name,
TestsCount: 0,
PresentIn: make(map[string]bool),
}
}
// parser the expressions a-la-oneagain
appsecTestConfigs, err := filepath.Glob(filepath.Join(hubDir, ".appsec-tests", "*", "config.yaml"))
if err != nil {
return nil, fmt.Errorf("while find appsec-tests config: %w", err)View on GitHub (pinned to 909b515798)
Solutions
- Run 'cscli hub update' to refresh the hub index so appsec rules are present
- Verify the hub directory contains an index.json with appsec-rules entries
- Skip appsec coverage when testing against a legacy hub without appsec rules
Defensive patterns
Strategy: validation
Validate before calling
if len(h.HubIndex.GetItemMap(cwhub.APPSEC_RULES)) == 0 { skipAppsecCoverage = true } Try / catch
coverage, err := h.GetAppsecCoverage(hubDir)
if err != nil { log.Warn(err); return } Prevention
- Run 'cscli hub update' before hub test/coverage tooling
- Verify the hub index contains appsec-rules entries
- Skip appsec coverage gracefully on legacy hubs
When it happens
Trigger: Calling HubTest.GetAppsecCoverage(hubDir) after loading an index with no appsec-rules entries — e.g. an old hub index file predating appsec rules, or hub not updated.
Common situations: Running hub test/coverage tooling against a stale local hub clone; hub index not updated (cscli hub update) on an installation from before the appsec feature existed.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- no parsers in hub index
- no scenarios in hub index
- ErrNucleiTemplateFail
- no appsec_config provided
- source is nil or not an IP
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/42fcb5ee6ae74de7.
Report an issue: GitHub.