From 2c329cc580cf57dcda26d06c8d7491d16e995438 Mon Sep 17 00:00:00 2001 From: Johanna Ahlskog Date: Thu, 14 Sep 2023 14:02:35 +0200 Subject: [PATCH] added proper console logs to pipeline --- src/Pentest/PentestService.ts | 6 ++---- .../BranchProtectionService.ts | 19 ++++++++++--------- src/index.ts | 5 ++++- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/Pentest/PentestService.ts b/src/Pentest/PentestService.ts index 83ed6e6e..3cad70bf 100644 --- a/src/Pentest/PentestService.ts +++ b/src/Pentest/PentestService.ts @@ -1,17 +1,15 @@ import * as core from '@actions/core'; -import * as github from '@actions/github'; +//import * as github from '@actions/github'; export class PentestService { public static async getStateOfPentest(pentestDate: { date: string; boardsTag: string }): Promise { - console.log('Running Pentest Controls'); - if (!pentestDate.date || pentestDate.date === 'date-of-pentest') { core.warning('Pentest Date is not set!'); return; } core.exportVariable('pentestDate', pentestDate.date); - console.log('Pentest Date is set', pentestDate.date); + //console.log('Pentest Date is set', pentestDate.date); // const token = core.getInput('repo-token'); // console.log('Got the token'); diff --git a/src/branchprotection/BranchProtectionService.ts b/src/branchprotection/BranchProtectionService.ts index dab26733..50c189c8 100644 --- a/src/branchprotection/BranchProtectionService.ts +++ b/src/branchprotection/BranchProtectionService.ts @@ -2,18 +2,18 @@ import * as core from '@actions/core'; import * as github from '@actions/github'; export class BranchProtectionService { public static async getStateOfBranchProtection(): Promise { - console.log('Custom task is working!'); + console.log('\n Running branch protection control'); const token = core.getInput('repo-token'); - console.log('Got the token'); + //console.log('Got the token'); const octokit = github.getOctokit(token); - console.log('octoKit authenticated'); + //console.log('octoKit authenticated'); const { owner, repo } = github.context.repo; - console.log(`Owner: ${owner}`); - console.log(`Repo: ${repo}`); + //console.log(`Owner: ${owner}`); + //console.log(`Repo: ${repo}`); - console.log('Going to get branch protection'); + //console.log('Going to get branch protection'); await octokit.rest.repos .getBranchProtection({ owner: owner, @@ -21,12 +21,13 @@ export class BranchProtectionService { branch: 'main', }) .then((response) => { - console.log('Got the branch protection'); + //console.log('Got the branch protection'); console.log(response.data); }) .catch((error) => { - core.warning('Error getting branch protection!'); - console.log('Error: ', error.message); + console.log('Branch protections is not enabled for repository:' + repo) + //core.warning('Error getting branch protection!'); + //console.log('Error: ', error.message); }); } } diff --git a/src/index.ts b/src/index.ts index c1ebab53..91881076 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ import * as github from '@actions/github'; import { BranchProtectionService } from './branchprotection/BranchProtectionService'; import { CyDigConfig } from './types/CyDigConfig'; import { getContentOfFile } from './helpfunctions/JsonService'; -import { PentestService } from './Pentest/PentestService'; +import { PentestService } from './pentest/PentestService'; import { ThreatModelingService } from './threatmodeling/ThreatModelingService'; /** * The main function for the action. @@ -11,8 +11,11 @@ import { ThreatModelingService } from './threatmodeling/ThreatModelingService'; */ export async function run(): Promise { try { + console.log('\n Running controls on your repository') const cydigConfig: CyDigConfig = getContentOfFile(core.getInput('cydigConfigPath')); await BranchProtectionService.getStateOfBranchProtection(); + + console.log('\n Running controls on your boards'); await PentestService.getStateOfPentest(cydigConfig.pentest); await ThreatModelingService.getStateOfThreatModeling(cydigConfig.threatModeling); } catch (error) {