Skip to content

Commit 1c1bbfb

Browse files
Merge pull request #45 from Br3nd3n/do-not-stop-on-failed-comment
Fix for minor issues after production testing 🔥
2 parents ef53d55 + 221678b commit 1c1bbfb

File tree

5 files changed

+41
-21
lines changed

5 files changed

+41
-21
lines changed

dist/index.js

+20-10
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ async function createReviewComments(secretKey, scanId) {
283283
path: finding.file,
284284
line: finding.end_line,
285285
start_line: finding.start_line,
286-
body: `${finding.title}\n${finding.description}\n**Remediation:** ${finding.remediation}\n**Details**: [View details](https://app.aikido.dev/featurebranch/scan/${scanId})`
286+
body: `${finding.title}\n${finding.description}\n**Remediation:** ${finding.remediation}\n**Aikido Security:**: [View details](https://app.aikido.dev/featurebranch/scan/${scanId}?groupId=${findingResponse.group_id})`
287287
}));
288288
if (findings.length > 0) {
289289
await (0, postReviewComment_1.postFindingsAsReviewComments)(findings);
@@ -485,15 +485,25 @@ const postFindingsAsReviewComments = async (findings) => {
485485
existingFinding = comment;
486486
}
487487
if (typeof existingFinding === 'undefined') {
488-
await octokit.rest.pulls.createReviewComment({
489-
...context.repo,
490-
pull_number: pullRequestNumber,
491-
commit_id: finding.commit_id,
492-
path: finding.path,
493-
body: finding.body,
494-
line: finding.line,
495-
...(finding.start_line != finding.line) && { start_line: finding.start_line }
496-
});
488+
try {
489+
await octokit.rest.pulls.createReviewComment({
490+
...context.repo,
491+
pull_number: pullRequestNumber,
492+
commit_id: finding.commit_id,
493+
path: finding.path,
494+
body: finding.body,
495+
line: finding.line,
496+
...(finding.start_line != finding.line) && { start_line: finding.start_line }
497+
});
498+
}
499+
catch (error) {
500+
if (error instanceof Error) {
501+
core.info(`unable to post scan status comment due to error: ${error.message}. Tried posting ${JSON.stringify(finding)}`);
502+
}
503+
else {
504+
core.info(`unable to post scan status comment due to unknown error`);
505+
}
506+
}
497507
}
498508
}
499509
};

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api.ts

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type GetScanStatusResponse =
2525

2626
export type GetScanFindingsResponse =
2727
{
28+
group_id: number,
2829
start_commit_id?: string,
2930
end_commit_id: string,
3031
introduced_sast_issues: [

src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ async function createReviewComments(secretKey: string, scanId: number): Promise<
204204
path: finding.file,
205205
line: finding.end_line,
206206
start_line: finding.start_line,
207-
body: `${finding.title}\n${finding.description}\n**Remediation:** ${finding.remediation}\n**Details**: [View details](https://app.aikido.dev/featurebranch/scan/${scanId})`
207+
body: `${finding.title}\n${finding.description}\n**Remediation:** ${finding.remediation}\n**Aikido Security:**: [View details](https://app.aikido.dev/featurebranch/scan/${scanId}?groupId=${findingResponse.group_id})`
208208
}
209209
))
210210

src/postReviewComment.ts

+18-9
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,24 @@ export const postFindingsAsReviewComments = async (findings: TFinding[]): Promis
6666
}
6767

6868
if (typeof existingFinding === 'undefined') {
69-
await octokit.rest.pulls.createReviewComment({
70-
...context.repo,
71-
pull_number: pullRequestNumber,
72-
commit_id: finding.commit_id,
73-
path: finding.path,
74-
body: finding.body,
75-
line: finding.line,
76-
...(finding.start_line != finding.line) && { start_line: finding.start_line }
77-
});
69+
try {
70+
await octokit.rest.pulls.createReviewComment({
71+
...context.repo,
72+
pull_number: pullRequestNumber,
73+
commit_id: finding.commit_id,
74+
path: finding.path,
75+
body: finding.body,
76+
line: finding.line,
77+
...(finding.start_line != finding.line) && { start_line: finding.start_line }
78+
});
79+
} catch (error) {
80+
if (error instanceof Error) {
81+
core.info(`unable to post scan status comment due to error: ${error.message}. Tried posting ${JSON.stringify(finding)}`);
82+
} else {
83+
core.info(`unable to post scan status comment due to unknown error`);
84+
}
85+
}
86+
7887
}
7988
}
8089
};

0 commit comments

Comments
 (0)