Skip to content

Commit

Permalink
update inventory workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-akto committed Oct 6, 2023
1 parent d294e7a commit 921c4ae
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions .github/scripts/akto-inventory.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 921c4ae

Please sign in to comment.