crowdsecurity/crowdsec · warning
while find appsec-tests config: %w
Error message
while find appsec-tests config: %w
What it means
GetAppsecCoverage globs <hubDir>/.appsec-tests/*/config.yaml to discover appsec test configs and wraps filepath.Glob failures. Glob only errors on malformed patterns or inaccessible top-level paths, so this indicates a bad hubDir or an unreadable path component rather than 'no tests found' (that yields an empty slice, no error).
Source
Thrown at pkg/hubtest/coverage.go:46
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)
}
for _, appsecTestConfigPath := range appsecTestConfigs {
configFileData := &HubTestItemConfig{}
yamlFile, err := os.ReadFile(appsecTestConfigPath)
if err != nil {
log.Printf("unable to open appsec test config file '%s': %s", appsecTestConfigPath, err)
continue
}
err = yaml.Unmarshal(yamlFile, configFileData)
if err != nil {
return nil, fmt.Errorf("parsing: %w", err)
}
for _, appsecRulesFile := range configFileData.AppsecRules {
appsecRuleData := &appsec_rule.CustomRule{}View on GitHub (pinned to 909b515798)
Solutions
- Verify hubDir exists and is accessible, and contains a .appsec-tests directory
- Escape or remove glob metacharacters ([, *, ?) from hubDir
- Check directory permissions for the user running coverage collection
Example fix
// before
h.GetAppsecCoverage("")
// after
h.GetAppsecCoverage("/etc/crowdsec/hub") // valid hub checkout Defensive patterns
Strategy: validation
Validate before calling
st, err := os.Stat(filepath.Join(hubDir, ".appsec-tests"))
if err != nil {
return fmt.Errorf("no .appsec-tests under %s: %w", hubDir, err)
}
if !st.IsDir() {
return fmt.Errorf("%s/.appsec-tests is not a directory", hubDir)
} Prevention
- Pass a real, accessible hub checkout directory to GetAppsecCoverage
- Avoid glob metacharacters in hubDir values
- Verify read permissions on the hub tree before running coverage collection
When it happens
Trigger: GetAppsecCoverage called with a hubDir whose join with .appsec-tests/*/config.yaml produces an invalid glob pattern or triggers an underlying filesystem error (e.g. EACCES on hubDir/.appsec-tests on some systems).
Common situations: hubDir pointing to a non-existent or permission-restricted hub checkout; hubDir path containing glob metacharacters that form a bad pattern; running as a user without access to the hub directory.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- plugins are enabled, but config_paths.plugin_dir is not defi
- please provide a data directory with the 'data_dir' directiv
- while globbing acquis_dir: %w
- failed to get absolute path of %q: %w
- can't get absolute path of '%s': %w
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/e547183f5d357b7e.
Report an issue: GitHub.