Skip to content

Commit 0e74bbb

Browse files
committed
made changes to work with secure-workflows
1 parent 261f2a0 commit 0e74bbb

File tree

3 files changed

+51
-26
lines changed

3 files changed

+51
-26
lines changed

kbanalysis/dist/src/index.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8331,8 +8331,8 @@ try {
83318331
if (event === "workflow_dispatch" || event === "schedule") {
83328332
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`[!] Launched by ${event}`);
83338333
const label = "knowledge-base";
8334-
const owner = "h0x0er";
8335-
const repo = "kb_setup";
8334+
const owner = "step-security";
8335+
const repo = "secure-workflows";
83368336
let issues = [];
83378337
const resp = await client.rest.issues.listForRepo({ owner: owner, repo: repo, labels: label, state: "open", per_page: 100 });
83388338
const status = resp.status;
@@ -8528,8 +8528,8 @@ __webpack_handle_async_dependencies__();
85288528

85298529

85308530
async function handleKBIssue(octokit, owner, repo, issue) {
8531-
const storage_issue = 86;
8532-
const comment_id = 1306827650; // TODO: change this id
8531+
const storage_issue = 1380;
8532+
const comment_id = 1308209074;
85338533
let comment = await prepareComment(octokit, owner, repo, issue);
85348534
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Analysis For ${issue}:\n ${comment}`);
85358535
let resp = await octokit.rest.issues.getComment({
@@ -8551,7 +8551,12 @@ async function handleKBIssue(octokit, owner, repo, issue) {
85518551
}
85528552
else {
85538553
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`[!] Added ${issue.title} in tracking comment.`);
8554-
let resp3 = await octokit.rest.issues.update({ owner: owner, repo: repo, issue_number: issue.number, state: "closed" });
8554+
let resp3 = await octokit.rest.issues.update({
8555+
owner: owner,
8556+
repo: repo,
8557+
issue_number: issue.number,
8558+
state: "closed",
8559+
});
85558560
if (resp3.status === 200) {
85568561
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`[!] Closed Issue ${issue.number}`);
85578562
}
@@ -8566,7 +8571,7 @@ async function handleKBIssue(octokit, owner, repo, issue) {
85668571
}
85678572
function createIssueCommentBody(data) {
85688573
let output = [];
8569-
output.push(`\n- [ ] ${data.title}`);
8574+
output.push(`\n- [ ] ${data.title.substring(5)}`);
85708575
let new_body = data.body.split("\n");
85718576
output.push(" <details>");
85728577
output.push(" <summary>Analysis</summary>\n");
@@ -8587,8 +8592,17 @@ async function prepareComment(client, owner, repo, issue) {
85878592
let body = resp.data[0].body;
85888593
return createIssueCommentBody({ title: issue.title, body: body });
85898594
}
8595+
else {
8596+
return createIssueCommentBody({
8597+
title: issue.title,
8598+
body: "no analysis found",
8599+
});
8600+
}
85908601
}
8591-
return createIssueCommentBody({ title: issue.title, body: "no analysis" });
8602+
return createIssueCommentBody({
8603+
title: issue.title,
8604+
body: "unable to fetch analysis",
8605+
});
85928606
}
85938607

85948608

kbanalysis/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ try{
2121
core.info(`[!] Launched by ${event}`)
2222

2323
const label = "knowledge-base";
24-
const owner = "h0x0er"
25-
const repo = "kb_setup"
24+
const owner = "step-security"
25+
const repo = "secure-workflows"
2626
let issues = [];
2727
const resp = await client.rest.issues.listForRepo({owner:owner, repo:repo, labels: label, state: "open", per_page:100});
2828
const status = resp.status;

kbanalysis/src/issues-util.ts

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ import { Api } from "@octokit/plugin-rest-endpoint-methods/dist-types/types";
33
import * as core from "@actions/core";
44
import { exit } from "process";
55

6-
76
export async function handleKBIssue(
87
octokit: Octokit & Api,
98
owner,
109
repo,
1110
issue: { title: string; number: number }
1211
) {
13-
const storage_issue = 86;
14-
const comment_id = 1306827650; // TODO: change this id
12+
const storage_issue = 1380;
13+
const comment_id = 1308209074;
1514
let comment = await prepareComment(octokit, owner, repo, issue);
1615
core.info(`Analysis For ${issue}:\n ${comment}`);
1716

@@ -31,27 +30,31 @@ export async function handleKBIssue(
3130
comment_id: comment_id,
3231
body: new_body,
3332
});
34-
if(resp2.status !== 200){
35-
core.info(`[X] Unable to add: ${issue.number} in the tracking comment`)
36-
}else{
37-
core.info(`[!] Added ${issue.title} in tracking comment.`)
38-
let resp3 = await octokit.rest.issues.update({owner:owner, repo:repo, issue_number: issue.number, state:"closed"})
39-
if(resp3.status === 200){
40-
core.info(`[!] Closed Issue ${issue.number}`)
41-
}else{
42-
core.info(`[X] Unable to close issue ${issue.number}`)
43-
}
44-
33+
if (resp2.status !== 200) {
34+
core.info(`[X] Unable to add: ${issue.number} in the tracking comment`);
35+
} else {
36+
core.info(`[!] Added ${issue.title} in tracking comment.`);
37+
let resp3 = await octokit.rest.issues.update({
38+
owner: owner,
39+
repo: repo,
40+
issue_number: issue.number,
41+
state: "closed",
42+
});
43+
if (resp3.status === 200) {
44+
core.info(`[!] Closed Issue ${issue.number}`);
45+
} else {
46+
core.info(`[X] Unable to close issue ${issue.number}`);
47+
}
4548
}
4649
exit(0);
4750
}
48-
core.info(`[X] Unable to handle: ${issue.title} `)
51+
core.info(`[X] Unable to handle: ${issue.title} `);
4952
exit(0);
5053
}
5154

5255
function createIssueCommentBody(data: { title: string; body: string }) {
5356
let output = [];
54-
output.push(`\n- [ ] ${data.title}`);
57+
output.push(`\n- [ ] ${data.title.substring(5)}`);
5558
let new_body = data.body.split("\n");
5659
output.push(" <details>");
5760
output.push(" <summary>Analysis</summary>\n");
@@ -78,8 +81,16 @@ async function prepareComment(
7881
if (resp.data.length > 0) {
7982
let body = resp.data[0].body;
8083
return createIssueCommentBody({ title: issue.title, body: body });
84+
} else {
85+
return createIssueCommentBody({
86+
title: issue.title,
87+
body: "no analysis found",
88+
});
8189
}
8290
}
8391

84-
return createIssueCommentBody({ title: issue.title, body: "no analysis" });
92+
return createIssueCommentBody({
93+
title: issue.title,
94+
body: "unable to fetch analysis",
95+
});
8596
}

0 commit comments

Comments
 (0)