Skip to content

Commit

Permalink
changed to use badge service urls
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin selbekk committed Nov 13, 2023
1 parent dc109ab commit 779bb0a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 39 deletions.
34 changes: 18 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ permissions:
pages: read
id-token: write

on:
workflow_dispatch:
pull_request:
on:
workflow_dispatch:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -19,8 +19,8 @@ jobs:
- name: Checkout Azure compliance action
uses: actions/checkout@v4
with:
repository: Omegapoint/cydig-azure-compliance-action
path: azure-compliance-action
repository: Omegapoint/cydig-azure-compliance-action
path: azure-compliance-action
- name: Checkout compliance action
uses: actions/checkout@v4
with:
Expand All @@ -47,14 +47,14 @@ jobs:
cd upload-action
npm run test
- name: Run azure compliance tests
run : |
run: |
cd azure-compliance-action
npm run test
- name: Run compliance tests
run : |
run: |
cd compliance-action
npm run test
- name: Build Upload action
run: |
cd upload-action
Expand All @@ -68,31 +68,33 @@ jobs:
cd compliance-action
npm run build
- name: 'Az CLI login'
- name: "Az CLI login"
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID_DEV }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_DEV }}
- name: 'Run Azure Compliance Controls'
- name: "Run Azure Compliance Controls"
uses: ./azure-compliance-action
with:
subscription: ${{ secrets.AZURE_SUBSCRIPTION_ID_DEV }}
cydigConfigPath: ${{ github.workspace }}/azure-compliance-action/src/cydigConfig.json
- name: 'Run Compliance Controls'
- name: "Run Compliance Controls"
uses: ./compliance-action
with:
cydigConfigPath: ${{ github.workspace }}/compliance-action/src/cydigConfig.json
PAT-token: ${{ secrets.MY_GITHUB_PAT }}

- name: Set dev func URL
run: |
echo "urlUpdate=${{ secrets.URL_UPLOAD_DEV }}" >> $GITHUB_ENV
echo "updateKey=${{ secrets.CYDIG_API_KEY_DEV }}" >> $GITHUB_ENV
- name: 'Run Upload Action'
echo "urlDashboard=${{ secrets.URL_DASHBOARD_DEV }}" >> $GITHUB_ENV
echo "urlBadgeService=${{ secrets.URL_BADGE_SERVICE_DEV }}" >> $GITHUB_ENV
echo "accessKeyBadgeService=${{ secrets.ACCESS_KEY_BADGES_DEV }}" >> $GITHUB_ENV
- name: "Run Upload Action"
uses: ./upload-action
with:
cydigConfigPath: ${{ github.workspace }}/upload-action/src/cydigConfig.json
cydigConfigPath: ${{ github.workspace }}/upload-action/src/cydigConfig.json
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID_DEV }}

2 changes: 1 addition & 1 deletion src/lib/BodyBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class BodyBuilder {
.setPentestDate(pentestDate)
.build();

urls = UrlBuilder.createUrl(
urls = new UrlBuilder().createUrl(
// eslint-disable-line
teamName,
teamProjectName,
Expand Down
46 changes: 24 additions & 22 deletions src/lib/UrlBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@

export class UrlBuilder {
static createUrl(
export class UrlBuilder {

private urlDashboard: string;
private urlBadgeService: string;
private accessKeyBadgeService: string;
private source: string;

constructor() {

this.urlDashboard = process.env?.urlDashboard ? process.env?.urlDashboard : 'https://cydig.omegapoint.cloud/';

this.urlBadgeService = process.env?.urlBadgeService ? process.env?.urlBadgeService : 'https://func-cydig-badge-service-prod.azurewebsites.net/api';

if (!process.env?.accessKeyBadgeService) {
throw new Error('Could not find environment variable accessKeyBadgeService');
}
this.accessKeyBadgeService = process.env.accessKeyBadgeService;
this.source = 'GitHub';

}
public createUrl(
teamName: string,
teamProjectName: string,
codeRepositoryName: string,
subscriptionId: string,
states: object
): string {

//Please update the url if there are any changes to the infrastructure.
const urlDashboard: string = "https://cydig.omegapoint.cloud/";
//Please update the func url if there are any changes to the infrastructure.
const readFunctionURL: string = 'https://func-cydig-comp-state-prod.azurewebsites.net/api/ReadToReadme?code=';
//Please update the url if there are any changes to the infrastructure.
const readToReadMeKeyAcessKey: string = 'xaEvCDsaK01y2Z6SBivwOKndN4o915lpOTt1VkmULgsxgsjkml7u1DOhgULzmAPX';
const source: string = 'GitHub';

let urls: string = '';
let encodedURL: string;
Expand All @@ -24,29 +35,20 @@ export class UrlBuilder {
//OP Dashboard
encodedURL = encodeURIComponent('OP Compliance Dashboard-click here-blue');
singleBadgeURL = '[![' + 'OP Compliance Dashboard' + '](https://img.shields.io/badge/' + encodedURL + ')]';
redirectLink = '(' + urlDashboard + encodeURIComponent(teamName.toLowerCase()) + ')';
redirectLink = '(' + this.urlDashboard + encodeURIComponent(teamName.toLowerCase()) + ')';
urls = urls + singleBadgeURL + redirectLink + '<br/>' + '<br/>' + '\n';

//timestamp
encodedURL = encodeURIComponent(
`${readFunctionURL}/teams/${teamName}/sources/${source}/projects/${teamProjectName}/repositories/${codeRepositoryName}/controls/timestamp?code=${badgeAccessKey}`
`${this.urlBadgeService}/teams/${teamName}/sources/${this.source}/projects/${teamProjectName}/repositories/${codeRepositoryName}/controls/timestamp?code=${this.accessKeyBadgeService}`
);
singleBadgeURL = '![' + 'Timestamp' + '](https://img.shields.io/endpoint?url=' + encodedURL + ')';
urls = urls + singleBadgeURL + '<br/>' + '<br/>' + '\n';

for (const state of Object.keys(states)) {
redirectLink = '';
encodedURL = encodeURIComponent(
readFunctionURL +
readToReadMeKeyAcessKey +
'&teamName=' +
encodeURIComponent(teamName) +
'&teamProjectName=' +
encodeURIComponent(teamProjectName) +
'&codeRepositoryName=' +
encodeURIComponent(codeRepositoryName) +
'&stateType=' +
state
`${this.urlBadgeService}/teams/${teamName}/sources/${this.source}/projects/${teamProjectName}/repositories/${codeRepositoryName}/controls/${state}?code=${this.accessKeyBadgeService}`
);
singleBadgeURL = '[![' + state + '](https://img.shields.io/endpoint?url=' + encodedURL + ')]';

Expand Down

0 comments on commit 779bb0a

Please sign in to comment.