From e7b5e8dce7093e9f408b9aad3944c51b2bb7b5f5 Mon Sep 17 00:00:00 2001 From: davidvader Date: Mon, 30 Oct 2023 12:10:17 -0500 Subject: [PATCH] enhance: use constant for complexity limit --- api/build/graph.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/api/build/graph.go b/api/build/graph.go index 01cf36ca4..899331da8 100644 --- a/api/build/graph.go +++ b/api/build/graph.go @@ -79,9 +79,10 @@ type stg struct { const ( // clusters determine graph orientation - BuiltInCluster = 2 - PipelineCluster = 1 - ServiceCluster = 0 + BuiltInCluster = 2 + PipelineCluster = 1 + ServiceCluster = 0 + GraphComplexityLimit = 1000 ) // swagger:operation GET /api/v1/repos/{org}/{repo}/builds/{build}/graph builds GetBuildGraph @@ -496,10 +497,8 @@ func GetBuildGraph(c *gin.Context) { } } - // for loop over edges, and collapse same parent edge - // todo: move this check above the processing ? - if len(nodes) > 5000 { - c.JSON(http.StatusInternalServerError, "too many nodes on this graph") + if len(nodes) > GraphComplexityLimit || len(nodes) > GraphComplexityLimit { + c.JSON(http.StatusInternalServerError, "too many nodes or edges on this graph") return }