{"record":{"id":"365ab7bffb5e77b4","repo":"kgretzky/evilginx2","slug":"index-out-of-bounds-d","errorCode":null,"errorMessage":"index out of bounds: %d","messagePattern":"index out of bounds: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/config.go","lineNumber":693,"sourceCode":"\t\t}\n\t\tc.cfg.Set(CFG_SITE_DOMAINS, c.siteDomains)\n\t\tc.cfg.Set(CFG_SITES_ENABLED, sites_enabled)\n\t\tc.cfg.Set(CFG_SITES_HIDDEN, sites_hidden)\n\t\tc.cfg.WriteConfig()*/\n}\n\nfunc (c *Config) AddLure(site string, l *Lure) {\n\tc.lures = append(c.lures, l)\n\tc.lureIds = append(c.lureIds, GenRandomToken())\n\tc.cfg.Set(CFG_LURES, c.lures)\n\tc.cfg.WriteConfig()\n}\n\nfunc (c *Config) SetLure(index int, l *Lure) error {\n\tif index >= 0 && index < len(c.lures) {\n\t\tc.lures[index] = l\n\t} else {\n\t\treturn fmt.Errorf(\"index out of bounds: %d\", index)\n\t}\n\tc.cfg.Set(CFG_LURES, c.lures)\n\tc.cfg.WriteConfig()\n\treturn nil\n}\n\nfunc (c *Config) DeleteLure(index int) error {\n\tif index >= 0 && index < len(c.lures) {\n\t\tc.lures = append(c.lures[:index], c.lures[index+1:]...)\n\t\tc.lureIds = append(c.lureIds[:index], c.lureIds[index+1:]...)\n\t} else {\n\t\treturn fmt.Errorf(\"index out of bounds: %d\", index)\n\t}\n\tc.cfg.Set(CFG_LURES, c.lures)\n\tc.cfg.WriteConfig()\n\treturn nil\n}\n","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/kgretzky/evilginx2/blob/4c0988a1d9db4d172a185e979a38bfd0efdb5830/core/config.go#L675-L711","documentation":"SetLure rejects the index argument because it falls outside the valid range [0, len(c.lures)). This is a validation guard against out-of-range lure indices supplied by callers (e.g., from user CLI input); the lure at that index cannot be replaced and the config is left unchanged.","triggerScenarios":"Calling cfg.SetLure(index, lure) where index is negative or >= the number of lures currently loaded in config.","commonSituations":"Storing lure indexes across config reloads (a lure deleted by another session shifts indexes); using 1-based numbering from a CLI; appending a new lure by passing len(c.lures) instead of using a create method.","solutions":["Verify the index is within 0..len(c.lures)-1 before calling (use GetLures/length check)","Refresh the lure list and recompute the index after any add/delete","Use index 0..N-1 numbering, not the CLI's 1-based lure numbering"],"exampleFix":"// before\ncfg.SetLure(idx, lure)\n// after\nlures := cfg.GetLures()\nif idx >= 0 && idx < len(lures) {\n    cfg.SetLure(idx, lure)\n}","handlingStrategy":"validation","validationCode":"func validLureIndex(cfg *core.Config, i int) bool {\n    return i >= 0 && i < len(cfg.GetLures())\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.SetLure(i, lure); err != nil {\n    return fmt.Errorf(\"lure index %d invalid, refresh list: %w\", i, err)\n}","preventionTips":["Re-list lures before every index-based mutation","Never cache lure indexes across reloads","Convert 1-based CLI numbers to 0-based"],"tags":["config","lure","index-out-of-range","go"],"backgroundTag":"index-out-of-bounds","analyzedSha":"4c0988a1d9db4d172a185e979a38bfd0efdb5830","analyzedAt":"2026-09-05T19:23:07.238Z","contentChangedAt":"2026-09-05T19:23:07.238Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}