Skip to content

Commit

Permalink
Added logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanbokvad committed Sep 8, 2023
1 parent db49222 commit b71be3d
Showing 1 changed file with 60 additions and 47 deletions.
107 changes: 60 additions & 47 deletions src/Pentest/PentestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,70 @@ import * as core from '@actions/core';
import * as github from '@actions/github';

export class PentestService {
public static async getStateOfPentest(pentestDate: {
date: string;
boardsTag: string;
}): Promise<void> {
console.log('Running Pentest Controls');

if(!pentestDate.date || pentestDate.date === "date-of-pentest"){
core.warning("Pentest Date is not set!");
return;
}
core.setOutput("pentestDate", pentestDate.date);

console.log("Pentest Date is set", pentestDate.date);
public static async getStateOfPentest(pentestDate: { date: string; boardsTag: string }): Promise<void> {
console.log('Running Pentest Controls');

// const token = core.getInput('repo-token');
// console.log("Got the token");
if (!pentestDate.date || pentestDate.date === 'date-of-pentest') {
core.warning('Pentest Date is not set!');
return;
}
core.setOutput('pentestDate', pentestDate.date);

// const octokit = github.getOctokit(token);
// console.log("octoKit authenticated");
console.log('Pentest Date is set', pentestDate.date);

// const { owner, repo } = github.context.repo;
// console.log(`Owner: ${owner}`);
// console.log(`Repo: ${repo}`);
const token = core.getInput('repo-token');
console.log('Got the token');

// console.log("Going to get branch protection");
// await octokit.rest.projects.listCards({
// owner: owner,
// repo: repo,
// column_id: 123456789,
const octokit = github.getOctokit(token);
console.log('octoKit authenticated');

// }).then((response) => {
// console.log("Got the cards");
// const projectCards = response.data;
// const customLabelCards = projectCards.filter((card) => {
// return card.note?.includes(pentestDate.boardsTag);
// });

const { owner, repo } = github.context.repo;
console.log(`Owner: ${owner}`);
console.log(`Repo: ${repo}`);

// }).catch((error) => {
// core.warning("Error getting cards!");
// core.warning("Error: ", error.message);
console.log('Going to get branch protection');
await octokit.rest.projects
.listCards({
owner: owner,
repo: repo,
column_id: 123456789,
})
.then(async (response) => {
console.log('Got the cards');
const projectCards = response.data;
// const customLabelCards = projectCards.filter((card) => {
// return card.note?.includes(pentestDate.boardsTag);
// });
// owner: owner,
// repo: repo,
// branch: 'main',
// }).then((response) => {
// console.log("Got the branch protection");
// console.log(response.data);
// }).catch((error) => {
// core.warning("Error getting branch protection!");
// core.warning("Error: ", error.message);
// });
}
}

const customLabelCards = [];
console.log('projectCards', projectCards);
for (const card of projectCards) {
// Get the associated issue or pull request for the card
console.log('card', card);
const contentResponse = await octokit.request(card.content_url);
console.log('contentResponse', contentResponse);
if (contentResponse.data.labels.some((label: any) => label.name === pentestDate.boardsTag)) {
customLabelCards.push(card);
}
}

console.log('customLabelCards', customLabelCards);
return customLabelCards;
})
.catch((error) => {
core.warning('Error getting cards!');
core.warning('Error: ', error.message);
});

// owner: owner,
// repo: repo,
// branch: 'main',
// }).then((response) => {
// console.log("Got the branch protection");
// console.log(response.data);
// }).catch((error) => {
// core.warning("Error getting branch protection!");
// core.warning("Error: ", error.message);
// });
}
}

0 comments on commit b71be3d

Please sign in to comment.