Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-akto committed Oct 6, 2023
1 parent ca72c62 commit 1a4286e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
28 changes: 27 additions & 1 deletion .github/scripts/akto-inventory.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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 = {
Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/akto-inventory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -23,6 +27,3 @@ jobs:
with:
name: Akto OpenAPI Specification
path: ./.github/scripts/akto_open_api.json
- name: Generate Akto swagger report
run: |
ls

0 comments on commit 1a4286e

Please sign in to comment.