Fully autonomous AI Agents system capable of performing complex penetration testing tasks
Go ai-agentsai-security-toolanthropicautonomous-agentsgolanggptgraphqlmulti-agent-systemoffensive-securityopen-sourceopenaipenetration-testingpenetration-testing-toolsreactsecurity-automationsecurity-testingsecurity-toolsself-hosted
fix(csum): prevent out-of-range errors in recent section determination
Dmitry Ng9cd52b102a8b
diff --git a/backend/pkg/csum/chain_summary.go b/backend/pkg/csum/chain_summary.goindex a05e6dce..bf9e1c78 100644--- a/backend/pkg/csum/chain_summary.go+++ b/backend/pkg/csum/chain_summary.go@@ -653,8 +653,10 @@ func determineRecentSectionsToKeep(ast *cast.ChainAST, keepQASections int, maxSeconst bufferSpace = 1000effectiveMaxBytes := maxBytes - bufferSpace- // Keep the most recent sections- for i := totalSections - 1; i >= totalSections-keepQASections; i-- {+ // Keep the most recent sections; clamp lower bound to 0 to avoid out-of-range+ // when keepQASections exceeds the number of available sections.+ recentFloor := max(0, totalSections-keepQASections)+ for i := totalSections - 1; i >= recentFloor; i-- {sectionSize := ast.Sections[i].Size()currentSize += sectionSizekeepCount++@@ -666,7 +668,7 @@ func determineRecentSectionsToKeep(ast *cast.ChainAST, keepQASections int, maxSe}// Start from most recent sections (end of array) and work backwards- for i := totalSections - keepQASections - 1; i >= 0; i-- {+ for i := recentFloor - 1; i >= 0; i-- {// Stop if we've reached max sections to keepif keepCount >= maxSections {break