From b0cf02236bf8c17fcbf065c0c730a3063b0c53b5 Mon Sep 17 00:00:00 2001 From: lauri nomme Date: Mon, 22 Nov 2021 20:28:59 +0200 Subject: [PATCH] Fix paging boundaries (cherry picked from commit 9f2d9d2e4efa9997d65831fea1f9edf707cc8ce5) --- index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index a8fd1e5..4e06c1a 100755 --- a/index.js +++ b/index.js @@ -237,6 +237,8 @@ function logError(context, error){ { const pageSize = 500; + const maxResults = 10000; + const maxPage = maxResults / pageSize; let page = 1; let nbResults; @@ -259,11 +261,13 @@ function logError(context, error){ logError("getting rules", error); return null; } - } while (nbResults === pageSize); + } while (nbResults === pageSize && page <= maxPage); } { const pageSize = 500; + const maxResults = 10000; + const maxPage = maxResults / pageSize; let page = 1; let nbResults; /** Get all statuses except "REVIEWED". @@ -306,7 +310,7 @@ function logError(context, error){ logError("getting issues", error); return null; } - } while (nbResults === pageSize); + } while (nbResults === pageSize && page <= maxPage); let hSeverity = ""; if (version >= "8.1" && !data.noSecurityHotspot) { @@ -326,7 +330,7 @@ function logError(context, error){ logError("getting hotspots list", error); return null; } - } while (nbResults === pageSize); + } while (nbResults === pageSize && page <= maxPage); // 2) Getting hotspots details with hotspots/show for (let hotspotKey of data.hotspotKeys){