{"record":{"id":"16b783879ea3584e","repo":"crowdsecurity/crowdsec","slug":"invalid-item-name-s","errorCode":null,"errorMessage":"invalid item name %s","messagePattern":"invalid item name (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cwhub/hub.go","lineNumber":193,"sourceCode":"}\n\n// GetItemMap returns the map of items for a given type.\nfunc (h *Hub) GetItemMap(itemType string) map[string]*Item {\n\treturn h.items[itemType]\n}\n\n// GetItem returns an item from hub based on its type and full name (author/name).\nfunc (h *Hub) GetItem(itemType string, itemName string) *Item {\n\treturn h.GetItemMap(itemType)[itemName]\n}\n\n// GetItemFQ returns an item from hub based on its type and name (type:author/name).\nfunc (h *Hub) GetItemFQ(itemFQName string) (*Item, error) {\n\t// type and name are separated by a colon\n\tparts := strings.Split(itemFQName, \":\")\n\n\tif len(parts) != 2 {\n\t\treturn nil, fmt.Errorf(\"invalid item name %s\", itemFQName)\n\t}\n\n\tm := h.GetItemMap(parts[0])\n\tif m == nil {\n\t\treturn nil, fmt.Errorf(\"invalid item type %s\", parts[0])\n\t}\n\n\ti := m[parts[1]]\n\tif i == nil {\n\t\treturn nil, fmt.Errorf(\"item %s:%s not found\", parts[0], parts[1])\n\t}\n\n\treturn i, nil\n}\n\n// GetItemsByType returns a slice of all the items of a given type, installed or not, optionally sorted by case-insensitive name.\n// A non-existent type will silently return an empty slice.\nfunc (h *Hub) GetItemsByType(itemType string, sorted bool) []*Item {","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/cwhub/hub.go#L175-L211","documentation":"Hub.GetItemFQ expects a fully-qualified item name in the form \"type:name\" (e.g. \"collections:crowdsecurity/linux\"), split on ':'. If the string doesn't contain exactly one colon producing two parts, the name is rejected before any lookup.","triggerScenarios":"Calling GetItemFQ with a bare name like \"linux\", a name with multiple colons like \"collections:auth:linux\", or an empty string; also hit indirectly via whyTainted when callers pass unqualified names.","commonSituations":"Passing `cscli`-style short names to hub APIs; copy-pasting an FQ name with an extra colon; programmatic lookups that forgot to prepend the item type.","solutions":["Pass the full \"type:name\" string, e.g. GetItemFQ(\"collections:crowdsecurity/linux\")","Strip or validate user input before calling GetItemFQ","Use GetItemMap(type) directly when you already know the type"],"exampleFix":"// before\nitem, err := hub.GetItemFQ(\"crowdsecurity/linux\")\n// after\nitem, err := hub.GetItemFQ(\"collections:crowdsecurity/linux\")","handlingStrategy":"validation","validationCode":"func isFQName(s string) bool {\n    parts := strings.Split(s, \":\")\n    return len(parts) == 2 && parts[0] != \"\" && parts[1] != \"\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build FQ names with fmt.Sprintf(\"%s:%s\", type, name) instead of concatenating raw input","Validate CLI input with the same split check before calling GetItemFQ","Prefer GetItemMap when the type is known at compile time"],"tags":["hub","api","naming"],"backgroundTag":"invalid-argument-format","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}