Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/hello #49

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Test action
on:
pull_request:
branches:
- '*'
branches: [ "main" ]
merge_group:
types: [checks_requested]


jobs:
test:
Expand Down
22 changes: 12 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const STATUS_TIMED_OUT = 'TIMED_OUT';
const ALLOWED_POST_SCAN_STATUS_OPTIONS = ['on', 'off', 'only_if_new_findings'];
const ALLOWED_POST_REVIEW_COMMENTS_OPTIONS = ['on', 'off'];
async function run() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
try {
const secretKey = core.getInput('secret-key');
const fromSeverity = core.getInput('minimum-severity');
Expand All @@ -158,6 +158,7 @@ async function run() {
core.setFailed(`Invalid property value for post-scan-status-comment. Allowed values are: ${ALLOWED_POST_SCAN_STATUS_OPTIONS.join(', ')}`);
return;
}
console.log(`testerken 22222`);
postReviewComments = (0, transformPostFindingsAsReviewComment_1.transformPostFindingsAsReviewComment)(postReviewComments);
if (!ALLOWED_POST_REVIEW_COMMENTS_OPTIONS.includes(postReviewComments)) {
core.setOutput('ouput', STATUS_FAILED);
Expand All @@ -168,13 +169,14 @@ async function run() {
version: '1.0.5',
branch_name: ((_c = (_b = (_a = github.context.payload) === null || _a === void 0 ? void 0 : _a.pull_request) === null || _b === void 0 ? void 0 : _b.head) === null || _c === void 0 ? void 0 : _c.ref) || ((_d = github.context.payload) === null || _d === void 0 ? void 0 : _d.ref),
repository_id: (_e = github.context.payload.repository) === null || _e === void 0 ? void 0 : _e.node_id,
base_commit_id: ((_h = (_g = (_f = github.context.payload) === null || _f === void 0 ? void 0 : _f.pull_request) === null || _g === void 0 ? void 0 : _g.base) === null || _h === void 0 ? void 0 : _h.sha) || ((_j = github.context.payload) === null || _j === void 0 ? void 0 : _j.before),
head_commit_id: ((_m = (_l = (_k = github.context.payload) === null || _k === void 0 ? void 0 : _k.pull_request) === null || _l === void 0 ? void 0 : _l.head) === null || _m === void 0 ? void 0 : _m.sha) || ((_o = github.context.payload) === null || _o === void 0 ? void 0 : _o.after),
author: ((_r = (_q = (_p = github.context.payload) === null || _p === void 0 ? void 0 : _p.pull_request) === null || _q === void 0 ? void 0 : _q.user) === null || _r === void 0 ? void 0 : _r.login) ||
((_u = (_t = (_s = github.context.payload) === null || _s === void 0 ? void 0 : _s.head_commit) === null || _t === void 0 ? void 0 : _t.author) === null || _u === void 0 ? void 0 : _u.username),
base_commit_id: ((_h = (_g = (_f = github.context.payload) === null || _f === void 0 ? void 0 : _f.pull_request) === null || _g === void 0 ? void 0 : _g.base) === null || _h === void 0 ? void 0 : _h.sha) || ((_j = github.context.payload) === null || _j === void 0 ? void 0 : _j.before) || ((_l = (_k = github.context.payload) === null || _k === void 0 ? void 0 : _k.merge_group) === null || _l === void 0 ? void 0 : _l.base_sha),
head_commit_id: ((_p = (_o = (_m = github.context.payload) === null || _m === void 0 ? void 0 : _m.pull_request) === null || _o === void 0 ? void 0 : _o.head) === null || _p === void 0 ? void 0 : _p.sha) || ((_q = github.context.payload) === null || _q === void 0 ? void 0 : _q.after) || ((_s = (_r = github.context.payload) === null || _r === void 0 ? void 0 : _r.merge_group) === null || _s === void 0 ? void 0 : _s.head_sha),
author: ((_v = (_u = (_t = github.context.payload) === null || _t === void 0 ? void 0 : _t.pull_request) === null || _u === void 0 ? void 0 : _u.user) === null || _v === void 0 ? void 0 : _v.login) ||
((_y = (_x = (_w = github.context.payload) === null || _w === void 0 ? void 0 : _w.head_commit) === null || _x === void 0 ? void 0 : _x.author) === null || _y === void 0 ? void 0 : _y.username) ||
((_2 = (_1 = (_0 = (_z = github.context.payload) === null || _z === void 0 ? void 0 : _z.merge_group) === null || _0 === void 0 ? void 0 : _0.head_commit) === null || _1 === void 0 ? void 0 : _1.author) === null || _2 === void 0 ? void 0 : _2.name),
pull_request_metadata: {
title: (_w = (_v = github.context.payload) === null || _v === void 0 ? void 0 : _v.pull_request) === null || _w === void 0 ? void 0 : _w.title,
url: (_y = (_x = github.context.payload) === null || _x === void 0 ? void 0 : _x.pull_request) === null || _y === void 0 ? void 0 : _y.html_url,
title: (_4 = (_3 = github.context.payload) === null || _3 === void 0 ? void 0 : _3.pull_request) === null || _4 === void 0 ? void 0 : _4.title,
url: (_6 = (_5 = github.context.payload) === null || _5 === void 0 ? void 0 : _5.pull_request) === null || _6 === void 0 ? void 0 : _6.html_url,
},
// user config
fail_on_dependency_scan: failOnDependencyScan,
Expand All @@ -187,7 +189,7 @@ async function run() {
core.info(`starting a scan with secret key: "${redactedToken}"`);
}
else {
const isLikelyDependabotPr = ((_z = startScanPayload.branch_name) !== null && _z !== void 0 ? _z : '').starts_with('dependabot/');
const isLikelyDependabotPr = ((_7 = startScanPayload.branch_name) !== null && _7 !== void 0 ? _7 : '').starts_with('dependabot/');
if (isLikelyDependabotPr) {
core.info(`it looks like the action is running on a dependabot PR, this means that secret variables are not available in this context and thus we can not start a scan. Please see: https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/`);
core.setOutput('outcome', STATUS_SUCCEEDED);
Expand Down Expand Up @@ -230,10 +232,10 @@ async function run() {
moreDetailsText = ` More details at ${result.diff_url}`;
}
const shouldPostComment = (postScanStatusAsComment === 'on' || postScanStatusAsComment === 'only_if_new_findings');
if (shouldPostComment && !!((_0 = result.outcome) === null || _0 === void 0 ? void 0 : _0.human_readable_message)) {
if (shouldPostComment && !!((_8 = result.outcome) === null || _8 === void 0 ? void 0 : _8.human_readable_message)) {
try {
const options = { onlyIfNewFindings: postScanStatusAsComment === 'only_if_new_findings', hasNewFindings: !!result.gate_passed };
await (0, postMessage_1.postScanStatusMessage)((_1 = result.outcome) === null || _1 === void 0 ? void 0 : _1.human_readable_message, options);
await (0, postMessage_1.postScanStatusMessage)((_9 = result.outcome) === null || _9 === void 0 ? void 0 : _9.human_readable_message, options);
}
catch (error) {
if (error instanceof Error) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ async function run(): Promise<void> {
return;
}

console.log(`testerken 22222`)

postReviewComments = transformPostFindingsAsReviewComment(postReviewComments);
if (!ALLOWED_POST_REVIEW_COMMENTS_OPTIONS.includes(postReviewComments)) {
core.setOutput('ouput', STATUS_FAILED);
Expand All @@ -51,11 +53,12 @@ async function run(): Promise<void> {
version: '1.0.5',
branch_name: github.context.payload?.pull_request?.head?.ref || github.context.payload?.ref,
repository_id: github.context.payload.repository?.node_id,
base_commit_id: github.context.payload?.pull_request?.base?.sha || github.context.payload?.before,
head_commit_id: github.context.payload?.pull_request?.head?.sha || github.context.payload?.after,
base_commit_id: github.context.payload?.pull_request?.base?.sha || github.context.payload?.before || github.context.payload?.merge_group?.base_sha,
head_commit_id: github.context.payload?.pull_request?.head?.sha || github.context.payload?.after || github.context.payload?.merge_group?.head_sha,
author:
github.context.payload?.pull_request?.user?.login ||
github.context.payload?.head_commit?.author?.username,
github.context.payload?.head_commit?.author?.username ||
github.context.payload?.merge_group?.head_commit?.author?.name,
pull_request_metadata: {
title: github.context.payload?.pull_request?.title,
url: github.context.payload?.pull_request?.html_url,
Expand Down
Loading