{"record":{"id":"e547183f5d357b7e","repo":"crowdsecurity/crowdsec","slug":"while-find-appsec-tests-config-w","errorCode":null,"errorMessage":"while find appsec-tests config: %w","messagePattern":"while find appsec-tests config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/hubtest/coverage.go","lineNumber":46,"sourceCode":"\t\treturn nil, errors.New(\"no appsec rules in hub index\")\n\t}\n\n\t// populate from hub, iterate in alphabetical order\n\tpkeys := maptools.SortedKeys(h.HubIndex.GetItemMap(cwhub.APPSEC_RULES))\n\tcoverage := make([]Coverage, len(pkeys))\n\n\tfor i, name := range pkeys {\n\t\tcoverage[i] = Coverage{\n\t\t\tName:       name,\n\t\t\tTestsCount: 0,\n\t\t\tPresentIn:  make(map[string]bool),\n\t\t}\n\t}\n\n\t// parser the expressions a-la-oneagain\n\tappsecTestConfigs, err := filepath.Glob(filepath.Join(hubDir, \".appsec-tests\", \"*\", \"config.yaml\"))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"while find appsec-tests config: %w\", err)\n\t}\n\n\tfor _, appsecTestConfigPath := range appsecTestConfigs {\n\t\tconfigFileData := &HubTestItemConfig{}\n\n\t\tyamlFile, err := os.ReadFile(appsecTestConfigPath)\n\t\tif err != nil {\n\t\t\tlog.Printf(\"unable to open appsec test config file '%s': %s\", appsecTestConfigPath, err)\n\t\t\tcontinue\n\t\t}\n\n\t\terr = yaml.Unmarshal(yamlFile, configFileData)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"parsing: %w\", err)\n\t\t}\n\n\t\tfor _, appsecRulesFile := range configFileData.AppsecRules {\n\t\t\tappsecRuleData := &appsec_rule.CustomRule{}","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/coverage.go#L28-L64","documentation":"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).","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nh.GetAppsecCoverage(\"\")\n// after\nh.GetAppsecCoverage(\"/etc/crowdsec/hub\") // valid hub checkout","handlingStrategy":"validation","validationCode":"st, err := os.Stat(filepath.Join(hubDir, \".appsec-tests\"))\nif err != nil {\n\treturn fmt.Errorf(\"no .appsec-tests under %s: %w\", hubDir, err)\n}\nif !st.IsDir() {\n\treturn fmt.Errorf(\"%s/.appsec-tests is not a directory\", hubDir)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["glob","paths","hub-test"],"backgroundTag":"file-not-found","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}