From 7d09afe4bbf170dcd39bc0bd389ea1673cb7f5b0 Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Tue, 3 Oct 2023 09:47:44 +0530 Subject: [PATCH 01/16] initial changes --- .github/scripts/akto-inventory.sh | 20 ++++++++++++++++++++ .github/workflows/akto-inventory.yaml | 15 +++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 .github/scripts/akto-inventory.sh create mode 100644 .github/workflows/akto-inventory.yaml diff --git a/.github/scripts/akto-inventory.sh b/.github/scripts/akto-inventory.sh new file mode 100644 index 0000000000..d8712ce5fe --- /dev/null +++ b/.github/scripts/akto-inventory.sh @@ -0,0 +1,20 @@ +#! /bin/sh + +#sudo apt-get install jq -y + +# Akto Variables +AKTO_DASHBOARD_URL=$AKTO_DASHBOARD_URL +AKTO_API_KEY=$AKTO_API_KEY + +response=$(curl -s "$AKTO_DASHBOARD_URL/api/generateOpenApiFile" \ + --header 'content-type: application/json' \ + --header "X-API-KEY: $AKTO_API_KEY" \ + --data "{ + \"apiCollectionId\": \"-1753579810\" + }") + +open_api_string=$(echo "$response" | jq -r '.openAPIString') +echo $open_api_string > test.json +jq 'del(.paths[] | .[] | .get.responses["200"].headers)' test.json > output.json + + diff --git a/.github/workflows/akto-inventory.yaml b/.github/workflows/akto-inventory.yaml new file mode 100644 index 0000000000..2bf6702941 --- /dev/null +++ b/.github/workflows/akto-inventory.yaml @@ -0,0 +1,15 @@ +name: Akto Inventory + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check for Akto test completion + env: + AKTO_DASHBOARD_URL: https://flash.staging.akto.io + AKTO_API_KEY: ${{secrets.AKTO_API_KEY}} + run: bash ./.github/scripts/akto-cicd.sh \ No newline at end of file From a244c26fd594c4fd52919fbdaedd6f2b43b38fbb Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Fri, 6 Oct 2023 09:54:55 +0530 Subject: [PATCH 02/16] add akto inventory script and workflow --- .github/scripts/akto-inventory.js | 95 +++++++++++++++++++++++++++ .github/scripts/akto-inventory.sh | 20 ------ .github/workflows/akto-inventory.yaml | 12 +++- 3 files changed, 105 insertions(+), 22 deletions(-) create mode 100644 .github/scripts/akto-inventory.js delete mode 100644 .github/scripts/akto-inventory.sh diff --git a/.github/scripts/akto-inventory.js b/.github/scripts/akto-inventory.js new file mode 100644 index 0000000000..1e3b2f5057 --- /dev/null +++ b/.github/scripts/akto-inventory.js @@ -0,0 +1,95 @@ +const axios = require("axios") +const fs = require("fs") +const { Readable } = require('stream'); + +const AKTO_DASHBOARD_URL = process.env.AKTO_DASHBOARD_URL +const AKTO_API_KEY = process.env.AKTO_API_KEY + +const headers = { + 'X-API-KEY': AKTO_API_KEY, +} + +function processOpenAPIfile(openAPIObject) { + // Modify the headers in the openAPIString object + for (const path in openAPIObject.paths) { + + if (!path.startsWith("/api")) { + delete openAPIObject.paths[path] + continue + } + + const pathInfo = openAPIObject.paths[path]; + for (const method in pathInfo) { + if (method === "description" || method === 'parameters') { + continue + } + const operation = pathInfo[method]; + if (operation.parameters) { + // Remove existing headers + operation.parameters = operation.parameters.filter(param => param.in !== 'header'); + } + // Add new headers + operation.parameters = operation.parameters || []; + operation.parameters.push( + { + name: 'X-API-KEY', + in: 'header', + schema: { + type: 'string', + example: 'your-api-key', + }, + }, + { + name: 'content-type', + in: 'header', + schema: { + type: 'string', + example: 'application/json', + }, + } + ); + + } + } + + return openAPIObject +} + +async function saveOpenAPIfile(openAPIObject) { + // Convert the JSON object to a JSON string + const jsonString = JSON.stringify(openAPIObject, null, 2); + + // Specify the file path where you want to save the JSON + const filePath = './akto_open_api.json'; + + // Write the JSON string to the file + fs.writeFile(filePath, jsonString, 'utf8', (err) => { + if (err) { + console.error(`Error writing file: ${err}`); + } else { + console.log(`JSON object saved to ${filePath}`); + } + }); + +} + +async function main() { + + const data = { + apiCollectionId: "-1753579810" + } + + try { + const generateOpenApiFileResponse = await axios.post(`${AKTO_DASHBOARD_URL}/api/generateOpenApiFile`, { ...data }, { headers }) + + if (generateOpenApiFileResponse.status === 200) { + const openAPIObject = JSON.parse(generateOpenApiFileResponse.data.openAPIString) + const processedOpenAPIObject = processOpenAPIfile(openAPIObject) + saveOpenAPIfile(processedOpenAPIObject) + } + } catch (error) { + console.error('Error:', error.message); + } +} + +main() \ No newline at end of file diff --git a/.github/scripts/akto-inventory.sh b/.github/scripts/akto-inventory.sh deleted file mode 100644 index d8712ce5fe..0000000000 --- a/.github/scripts/akto-inventory.sh +++ /dev/null @@ -1,20 +0,0 @@ -#! /bin/sh - -#sudo apt-get install jq -y - -# Akto Variables -AKTO_DASHBOARD_URL=$AKTO_DASHBOARD_URL -AKTO_API_KEY=$AKTO_API_KEY - -response=$(curl -s "$AKTO_DASHBOARD_URL/api/generateOpenApiFile" \ - --header 'content-type: application/json' \ - --header "X-API-KEY: $AKTO_API_KEY" \ - --data "{ - \"apiCollectionId\": \"-1753579810\" - }") - -open_api_string=$(echo "$response" | jq -r '.openAPIString') -echo $open_api_string > test.json -jq 'del(.paths[] | .[] | .get.responses["200"].headers)' test.json > output.json - - diff --git a/.github/workflows/akto-inventory.yaml b/.github/workflows/akto-inventory.yaml index 2bf6702941..87022747c6 100644 --- a/.github/workflows/akto-inventory.yaml +++ b/.github/workflows/akto-inventory.yaml @@ -8,8 +8,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Check for Akto test completion + - name: Generate Akto OpenAPI specication file + working-directory: ./.github/scripts env: AKTO_DASHBOARD_URL: https://flash.staging.akto.io AKTO_API_KEY: ${{secrets.AKTO_API_KEY}} - run: bash ./.github/scripts/akto-cicd.sh \ No newline at end of file + run: | + npm install axios + node akto-inventory.js + - name: Archive open_api spec + uses: actions/upload-artifact@v3 + with: + name: Akto OpenAPI Specication + path: ./.github/scripts/akto_open_api.json \ No newline at end of file From 69c5912928499a5874857b00a1c221fbe449ab73 Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Fri, 6 Oct 2023 09:59:06 +0530 Subject: [PATCH 03/16] add push trigger for testing --- .github/workflows/akto-inventory.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/akto-inventory.yaml b/.github/workflows/akto-inventory.yaml index 87022747c6..819731c7f4 100644 --- a/.github/workflows/akto-inventory.yaml +++ b/.github/workflows/akto-inventory.yaml @@ -1,6 +1,9 @@ name: Akto Inventory on: + push: + branches: [ flash-inventory-swagger ] + workflow_dispatch: jobs: From 92cf7303229095c953dee9753bb52c0946491a97 Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Fri, 6 Oct 2023 10:05:27 +0530 Subject: [PATCH 04/16] remove push trigger --- .github/workflows/akto-inventory.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/akto-inventory.yaml b/.github/workflows/akto-inventory.yaml index 819731c7f4..87022747c6 100644 --- a/.github/workflows/akto-inventory.yaml +++ b/.github/workflows/akto-inventory.yaml @@ -1,9 +1,6 @@ name: Akto Inventory on: - push: - branches: [ flash-inventory-swagger ] - workflow_dispatch: jobs: From 5fddf226fe9423019b90edff34a056a76936b3b5 Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Fri, 6 Oct 2023 12:42:58 +0530 Subject: [PATCH 05/16] fix typo --- .github/workflows/akto-inventory.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/akto-inventory.yaml b/.github/workflows/akto-inventory.yaml index 87022747c6..d8d4730f19 100644 --- a/.github/workflows/akto-inventory.yaml +++ b/.github/workflows/akto-inventory.yaml @@ -19,5 +19,5 @@ jobs: - name: Archive open_api spec uses: actions/upload-artifact@v3 with: - name: Akto OpenAPI Specication + name: Akto OpenAPI Specification path: ./.github/scripts/akto_open_api.json \ No newline at end of file From ca72c62f0f86290bc87ddea5185c9554e273429a Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Fri, 6 Oct 2023 16:23:28 +0530 Subject: [PATCH 06/16] update --- .github/workflows/akto-inventory.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/akto-inventory.yaml b/.github/workflows/akto-inventory.yaml index d8d4730f19..51390690fc 100644 --- a/.github/workflows/akto-inventory.yaml +++ b/.github/workflows/akto-inventory.yaml @@ -1,6 +1,8 @@ name: Akto Inventory on: + push: + branches: [ flash-inventory-swagger ] workflow_dispatch: jobs: @@ -20,4 +22,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: Akto OpenAPI Specification - path: ./.github/scripts/akto_open_api.json \ No newline at end of file + path: ./.github/scripts/akto_open_api.json + - name: Generate Akto swagger report + run: | + ls From 1a4286ee411cf92ab29ec11b88d7a17465a61ba7 Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Fri, 6 Oct 2023 17:01:16 +0530 Subject: [PATCH 07/16] update --- .github/scripts/akto-inventory.js | 28 ++++++++++++++++++++++++++- .github/workflows/akto-inventory.yaml | 7 ++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/scripts/akto-inventory.js b/.github/scripts/akto-inventory.js index 1e3b2f5057..4e7e181e22 100644 --- a/.github/scripts/akto-inventory.js +++ b/.github/scripts/akto-inventory.js @@ -1,6 +1,5 @@ const axios = require("axios") const fs = require("fs") -const { Readable } = require('stream'); const AKTO_DASHBOARD_URL = process.env.AKTO_DASHBOARD_URL const AKTO_API_KEY = process.env.AKTO_API_KEY @@ -9,6 +8,10 @@ const headers = { 'X-API-KEY': AKTO_API_KEY, } +function logGithubStepSummary(message) { + fs.appendFileSync(GITHUB_STEP_SUMMARY, `${message}\n`); +} + function processOpenAPIfile(openAPIObject) { // Modify the headers in the openAPIString object for (const path in openAPIObject.paths) { @@ -73,6 +76,26 @@ async function saveOpenAPIfile(openAPIObject) { } +function generateAktoEndpointsSummary(processedOpenAPIObject) { + let sourceAktoEndpoints + + const sourceData = fs.readFileSync("./polaris-output.txt", 'utf8') + sourceAktoEndpoints = sourceData.split('\n') + + const openAPIAktoEndpoints = Object.keys(processedOpenAPIObject.paths) + + logGithubStepSummary(`Akto endpoints count (source): ${sourceAktoEndpoints.length}`) + logGithubStepSummary(`Akto endpoints count (OpenAPI file): ${openAPIAktoEndpoints.length}`) + logGithubStepSummary(`#### Endpoints missing in OpenAPI file`) + + sourceAktoEndpoints.forEach(sourceEndpoint => { + if (!openAPIAktoEndpoints.includes(sourceEndpoint)) { + logGithubStepSummary(`| ${sourceEndpoint} |`) + } + }); + +} + async function main() { const data = { @@ -86,6 +109,9 @@ async function main() { const openAPIObject = JSON.parse(generateOpenApiFileResponse.data.openAPIString) const processedOpenAPIObject = processOpenAPIfile(openAPIObject) saveOpenAPIfile(processedOpenAPIObject) + + logGithubStepSummary("### Akto inventory summary") + generateAktoEndpointsSummary(processedOpenAPIObject) } } catch (error) { console.error('Error:', error.message); diff --git a/.github/workflows/akto-inventory.yaml b/.github/workflows/akto-inventory.yaml index 51390690fc..ed1fad474f 100644 --- a/.github/workflows/akto-inventory.yaml +++ b/.github/workflows/akto-inventory.yaml @@ -10,6 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Generate akto endpoints from source code + working-directory: ./apps/dashboard/web/polaris_web/web/src + run: | + grep -r --include "*.js" "api/" . | awk -F"'" '/url:/ {print $2} > ./.github/scripts/polaris-output.txt - name: Generate Akto OpenAPI specication file working-directory: ./.github/scripts env: @@ -23,6 +27,3 @@ jobs: with: name: Akto OpenAPI Specification path: ./.github/scripts/akto_open_api.json - - name: Generate Akto swagger report - run: | - ls From 4df18db429c971286cec307c127564f378cc8495 Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Fri, 6 Oct 2023 17:04:51 +0530 Subject: [PATCH 08/16] update --- .github/workflows/akto-inventory.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/akto-inventory.yaml b/.github/workflows/akto-inventory.yaml index ed1fad474f..f31fb4f57a 100644 --- a/.github/workflows/akto-inventory.yaml +++ b/.github/workflows/akto-inventory.yaml @@ -13,7 +13,7 @@ jobs: - name: Generate akto endpoints from source code working-directory: ./apps/dashboard/web/polaris_web/web/src run: | - grep -r --include "*.js" "api/" . | awk -F"'" '/url:/ {print $2} > ./.github/scripts/polaris-output.txt + grep -r --include "*.js" "api/" . | awk -F"'" '/url:/ {print $2}' > ./.github/scripts/polaris-output.txt - name: Generate Akto OpenAPI specication file working-directory: ./.github/scripts env: From c37c4c0bf4d4b1263a4744d24eaa718b2e93088e Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Fri, 6 Oct 2023 17:06:56 +0530 Subject: [PATCH 09/16] update --- .github/scripts/akto-inventory.js | 2 +- .github/workflows/akto-inventory.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/akto-inventory.js b/.github/scripts/akto-inventory.js index 4e7e181e22..5620f0581b 100644 --- a/.github/scripts/akto-inventory.js +++ b/.github/scripts/akto-inventory.js @@ -79,7 +79,7 @@ async function saveOpenAPIfile(openAPIObject) { function generateAktoEndpointsSummary(processedOpenAPIObject) { let sourceAktoEndpoints - const sourceData = fs.readFileSync("./polaris-output.txt", 'utf8') + const sourceData = fs.readFileSync("../../apps/dashboard/web/polaris_web/web/src", 'utf8') sourceAktoEndpoints = sourceData.split('\n') const openAPIAktoEndpoints = Object.keys(processedOpenAPIObject.paths) diff --git a/.github/workflows/akto-inventory.yaml b/.github/workflows/akto-inventory.yaml index f31fb4f57a..5965722108 100644 --- a/.github/workflows/akto-inventory.yaml +++ b/.github/workflows/akto-inventory.yaml @@ -13,7 +13,7 @@ jobs: - name: Generate akto endpoints from source code working-directory: ./apps/dashboard/web/polaris_web/web/src run: | - grep -r --include "*.js" "api/" . | awk -F"'" '/url:/ {print $2}' > ./.github/scripts/polaris-output.txt + grep -r --include "*.js" "api/" . | awk -F"'" '/url:/ {print $2}' > ./polaris-output.txt - name: Generate Akto OpenAPI specication file working-directory: ./.github/scripts env: From d294e7a02f5bc45afcbb6b2033ad8579de2c4d9b Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Fri, 6 Oct 2023 17:08:05 +0530 Subject: [PATCH 10/16] update --- .github/scripts/akto-inventory.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/scripts/akto-inventory.js b/.github/scripts/akto-inventory.js index 5620f0581b..974f54ddb1 100644 --- a/.github/scripts/akto-inventory.js +++ b/.github/scripts/akto-inventory.js @@ -3,6 +3,7 @@ const fs = require("fs") const AKTO_DASHBOARD_URL = process.env.AKTO_DASHBOARD_URL const AKTO_API_KEY = process.env.AKTO_API_KEY +const GITHUB_STEP_SUMMARY = process.env.GITHUB_STEP_SUMMARY const headers = { 'X-API-KEY': AKTO_API_KEY, From 921c4aea9f5ea5344d9a731bfc9d6e0f33305680 Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Fri, 6 Oct 2023 17:23:49 +0530 Subject: [PATCH 11/16] update inventory workflow --- .github/scripts/akto-inventory.js | 42 ++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/.github/scripts/akto-inventory.js b/.github/scripts/akto-inventory.js index 974f54ddb1..959f22562f 100644 --- a/.github/scripts/akto-inventory.js +++ b/.github/scripts/akto-inventory.js @@ -1,5 +1,6 @@ const axios = require("axios") const fs = require("fs") +const { exec } = require("child_process"); const AKTO_DASHBOARD_URL = process.env.AKTO_DASHBOARD_URL const AKTO_API_KEY = process.env.AKTO_API_KEY @@ -78,23 +79,34 @@ async function saveOpenAPIfile(openAPIObject) { } function generateAktoEndpointsSummary(processedOpenAPIObject) { - let sourceAktoEndpoints - - const sourceData = fs.readFileSync("../../apps/dashboard/web/polaris_web/web/src", 'utf8') - sourceAktoEndpoints = sourceData.split('\n') - - const openAPIAktoEndpoints = Object.keys(processedOpenAPIObject.paths) - - logGithubStepSummary(`Akto endpoints count (source): ${sourceAktoEndpoints.length}`) - logGithubStepSummary(`Akto endpoints count (OpenAPI file): ${openAPIAktoEndpoints.length}`) - logGithubStepSummary(`#### Endpoints missing in OpenAPI file`) - - sourceAktoEndpoints.forEach(sourceEndpoint => { - if (!openAPIAktoEndpoints.includes(sourceEndpoint)) { - logGithubStepSummary(`| ${sourceEndpoint} |`) + let sourceAktoEndpoints + + exec('cd ../../apps/dashboard/web/polaris_web/web/src; grep -r --include "*.js" "api/" . | awk -F"\'" \'/url:/ {print $2}\'', (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; } - }); + if (stderr) { + console.log(`stderr: ${stderr}`); + return; + } + + sourceAktoEndpoints = stdout.split('\n') + sourceAktoEndpoints.pop() + sourceAktoEndpoints.forEach(endpoint => console.log(endpoint)) + const openAPIAktoEndpoints = Object.keys(processedOpenAPIObject.paths) + + logGithubStepSummary(`Akto endpoints count (source): ${sourceAktoEndpoints.length}`) + logGithubStepSummary(`Akto endpoints count (OpenAPI file): ${openAPIAktoEndpoints.length}`) + logGithubStepSummary(`#### Endpoints missing in OpenAPI file`) + + sourceAktoEndpoints.forEach(sourceEndpoint => { + if (!openAPIAktoEndpoints.includes(sourceEndpoint)) { + logGithubStepSummary(`| ${sourceEndpoint} |`) + } + }); + }); } async function main() { From 7cfec86b456fb09d5bda7db051ae1984478fd413 Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Fri, 6 Oct 2023 17:25:42 +0530 Subject: [PATCH 12/16] update inventory workflow --- .github/scripts/akto-inventory.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/scripts/akto-inventory.js b/.github/scripts/akto-inventory.js index 959f22562f..f82062bb4b 100644 --- a/.github/scripts/akto-inventory.js +++ b/.github/scripts/akto-inventory.js @@ -101,9 +101,12 @@ function generateAktoEndpointsSummary(processedOpenAPIObject) { logGithubStepSummary(`Akto endpoints count (OpenAPI file): ${openAPIAktoEndpoints.length}`) logGithubStepSummary(`#### Endpoints missing in OpenAPI file`) + let counter = 1 + sourceAktoEndpoints.forEach(sourceEndpoint => { if (!openAPIAktoEndpoints.includes(sourceEndpoint)) { - logGithubStepSummary(`| ${sourceEndpoint} |`) + logGithubStepSummary(`${counter} | ${sourceEndpoint} |`) + counter += 1 } }); }); From 091e9d55aa7e9e2146c53f30fe2b4d48ec4f9d8f Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Fri, 6 Oct 2023 17:27:45 +0530 Subject: [PATCH 13/16] update inventory workflow --- .github/scripts/akto-inventory.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/scripts/akto-inventory.js b/.github/scripts/akto-inventory.js index f82062bb4b..d3fd43db96 100644 --- a/.github/scripts/akto-inventory.js +++ b/.github/scripts/akto-inventory.js @@ -102,10 +102,12 @@ function generateAktoEndpointsSummary(processedOpenAPIObject) { logGithubStepSummary(`#### Endpoints missing in OpenAPI file`) let counter = 1 + logGithubStepSummary("S.No | Endpoint ") + logGithubStepSummary("--- | --- ") sourceAktoEndpoints.forEach(sourceEndpoint => { if (!openAPIAktoEndpoints.includes(sourceEndpoint)) { - logGithubStepSummary(`${counter} | ${sourceEndpoint} |`) + logGithubStepSummary(`${counter} | ${sourceEndpoint} `) counter += 1 } }); From 7617871a4ff4d8bca3ca574c6abc94a9208d7fde Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Sat, 7 Oct 2023 12:02:46 +0530 Subject: [PATCH 14/16] fix missing endpoints count --- .github/scripts/akto-inventory.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/scripts/akto-inventory.js b/.github/scripts/akto-inventory.js index d3fd43db96..a9cdbf8d5e 100644 --- a/.github/scripts/akto-inventory.js +++ b/.github/scripts/akto-inventory.js @@ -78,6 +78,14 @@ async function saveOpenAPIfile(openAPIObject) { } +function addSlash(endpoints) { + endpoints.forEach((endpoint, index) => { + if (!endpoint.startsWith("/")) { + endpoints[index] = "/" + endpoint + } + }) +} + function generateAktoEndpointsSummary(processedOpenAPIObject) { let sourceAktoEndpoints @@ -93,9 +101,11 @@ function generateAktoEndpointsSummary(processedOpenAPIObject) { sourceAktoEndpoints = stdout.split('\n') sourceAktoEndpoints.pop() - sourceAktoEndpoints.forEach(endpoint => console.log(endpoint)) - + const openAPIAktoEndpoints = Object.keys(processedOpenAPIObject.paths) + + addSlash(sourceAktoEndpoints) + addSlash(openAPIAktoEndpoints) logGithubStepSummary(`Akto endpoints count (source): ${sourceAktoEndpoints.length}`) logGithubStepSummary(`Akto endpoints count (OpenAPI file): ${openAPIAktoEndpoints.length}`) @@ -111,6 +121,8 @@ function generateAktoEndpointsSummary(processedOpenAPIObject) { counter += 1 } }); + + logGithubStepSummary(`Total missing: ${counter}`) }); } From 84b2c3e38f17bbcc883100d6ae421bcca91ca8f2 Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Sat, 7 Oct 2023 12:03:09 +0530 Subject: [PATCH 15/16] fix missing endpoints count --- .github/workflows/akto-inventory.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/akto-inventory.yaml b/.github/workflows/akto-inventory.yaml index 5965722108..5446f8767f 100644 --- a/.github/workflows/akto-inventory.yaml +++ b/.github/workflows/akto-inventory.yaml @@ -10,10 +10,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Generate akto endpoints from source code - working-directory: ./apps/dashboard/web/polaris_web/web/src - run: | - grep -r --include "*.js" "api/" . | awk -F"'" '/url:/ {print $2}' > ./polaris-output.txt - name: Generate Akto OpenAPI specication file working-directory: ./.github/scripts env: From 5bd37688c3cb695a8dd8adaec2df402968600f7f Mon Sep 17 00:00:00 2001 From: Oren Saldanha Date: Sat, 7 Oct 2023 12:07:08 +0530 Subject: [PATCH 16/16] fix missing endpoints count --- .github/scripts/akto-inventory.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/scripts/akto-inventory.js b/.github/scripts/akto-inventory.js index a9cdbf8d5e..f7044f4c77 100644 --- a/.github/scripts/akto-inventory.js +++ b/.github/scripts/akto-inventory.js @@ -122,7 +122,8 @@ function generateAktoEndpointsSummary(processedOpenAPIObject) { } }); - logGithubStepSummary(`Total missing: ${counter}`) + logGithubStepSummary("
") + logGithubStepSummary(`Total missing: ${counter - 1}`) }); }