Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

/** @david-backslash @yoli-backslash
2 changes: 1 addition & 1 deletion .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
git add dist/
git commit -m "Build: Update dist/ directory"
git push
fi
fi
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
prScan: true
disablePrComments: false
githubToken: ${{ secrets.GITHUB_TOKEN }}
localExport: true
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
Expand Down
28 changes: 20 additions & 8 deletions dist/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", { value: true });
const core = require("@actions/core");
const github = require("@actions/github");
const process = require("process");
const fs_1 = require("fs");
const crypto_1 = require("crypto");
const fs_1 = require("fs");
const process = require("process");
const child_process_1 = require("child_process");
const util_1 = require("./util");
const cliRunnerFileName = 'run-cli.sh';
Expand Down Expand Up @@ -42,6 +42,7 @@ function run() {
const isOnPremise = core.getBooleanInput('isOnPremise');
const disablePrComments = core.getBooleanInput('disablePrComments');
const pushToDashboard = core.getBooleanInput('pushToDashboard');
const localExport = core.getBooleanInput('localExport');
const githubToken = core.getInput('githubToken');
const cloneUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}.git`;
const provider = isOnPremise ? 'github-enterprise-on-premise' : 'github';
Expand All @@ -50,10 +51,6 @@ function run() {
if (repositoryName === undefined || analyzedBranch === undefined) {
return core.setFailed('Repo or branch not defined');
}
let githubExtraInput = '';
if (!disablePrComments) {
githubExtraInput = `--providerPrNumber=${github.context.issue.number} --providerAccessToken=${githubToken}`;
}
yield (0, util_1.downloadFile)(S3CLIUrl, cliRunnerFileName);
yield (0, util_1.downloadFile)(S3CLIShaUrl, cliShaFileName);
const generatedHash = (0, crypto_1.createHash)('sha256').update((0, fs_1.readFileSync)(cliRunnerFileName)).digest('hex').replace(' ', '').replace('\n', '').replace('\r', '');
Expand All @@ -62,8 +59,23 @@ function run() {
return core.setFailed(`Checksum failed, got ${fetchedHash} but expected ${generatedHash}`);
}
console.log(`Cli sha matches`);
const commonArgs = `--authToken=${authToken} ${ignoreBlock ? `--warnOnly` : ''} --deltaScan=${prScan} --analyzedBranch="${analyzedBranch}" --repositoryCloneUrl=${cloneUrl} --provider=${provider} --gitProviderOrganization=${organization} ${baselineBranch && `--baselineBranch="${baselineBranch}" `} ${githubExtraInput} --outputPath=${outputPath}`;
const runCommand = `bash ${cliRunnerFileName} analyze ${commonArgs} ${pushToDashboard ? `--pushToDashboard` : ''}`;
let analyzeArgs = `--authToken=${authToken} --deltaScan=${prScan} --analyzedBranch="${analyzedBranch}" --repositoryCloneUrl=${cloneUrl} --provider=${provider} --gitProviderOrganization=${organization} --outputPath=${outputPath}`;
if (!disablePrComments) {
analyzeArgs += ` --providerPrNumber=${github.context.issue.number} --providerAccessToken=${githubToken}`;
}
if (baselineBranch) {
analyzeArgs += ` --baselineBranch="${baselineBranch}"`;
}
if (ignoreBlock) {
analyzeArgs += ` --warnOnly`;
}
if (localExport) {
analyzeArgs += ` --outputPath=Backslash-scan-results/`;
}
if (pushToDashboard) {
analyzeArgs += ` --pushToDashboard`;
}
const runCommand = `bash ${cliRunnerFileName} analyze ${analyzeArgs}`;
core.debug(`pushToDashboard: ${pushToDashboard}`);
core.debug(`Running this command: ${runCommand}`);
const child = (0, child_process_1.spawn)('bash', ['-c', runCommand], { stdio: ['inherit', 'pipe', 'pipe'] });
Expand Down
28 changes: 20 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __nccwpck_require__(8167);
const github = __nccwpck_require__(3459);
const process = __nccwpck_require__(932);
const fs_1 = __nccwpck_require__(9896);
const crypto_1 = __nccwpck_require__(6982);
const fs_1 = __nccwpck_require__(9896);
const process = __nccwpck_require__(932);
const child_process_1 = __nccwpck_require__(5317);
const util_1 = __nccwpck_require__(9507);
const cliRunnerFileName = 'run-cli.sh';
Expand Down Expand Up @@ -49,6 +49,7 @@ function run() {
const isOnPremise = core.getBooleanInput('isOnPremise');
const disablePrComments = core.getBooleanInput('disablePrComments');
const pushToDashboard = core.getBooleanInput('pushToDashboard');
const localExport = core.getBooleanInput('localExport');
const githubToken = core.getInput('githubToken');
const cloneUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}.git`;
const provider = isOnPremise ? 'github-enterprise-on-premise' : 'github';
Expand All @@ -57,10 +58,6 @@ function run() {
if (repositoryName === undefined || analyzedBranch === undefined) {
return core.setFailed('Repo or branch not defined');
}
let githubExtraInput = '';
if (!disablePrComments) {
githubExtraInput = `--providerPrNumber=${github.context.issue.number} --providerAccessToken=${githubToken}`;
}
yield (0, util_1.downloadFile)(S3CLIUrl, cliRunnerFileName);
yield (0, util_1.downloadFile)(S3CLIShaUrl, cliShaFileName);
const generatedHash = (0, crypto_1.createHash)('sha256').update((0, fs_1.readFileSync)(cliRunnerFileName)).digest('hex').replace(' ', '').replace('\n', '').replace('\r', '');
Expand All @@ -69,8 +66,23 @@ function run() {
return core.setFailed(`Checksum failed, got ${fetchedHash} but expected ${generatedHash}`);
}
console.log(`Cli sha matches`);
const commonArgs = `--authToken=${authToken} ${ignoreBlock ? `--warnOnly` : ''} --deltaScan=${prScan} --analyzedBranch="${analyzedBranch}" --repositoryCloneUrl=${cloneUrl} --provider=${provider} --gitProviderOrganization=${organization} ${baselineBranch && `--baselineBranch="${baselineBranch}" `} ${githubExtraInput} --outputPath=${outputPath}`;
const runCommand = `bash ${cliRunnerFileName} analyze ${commonArgs} ${pushToDashboard ? `--pushToDashboard` : ''}`;
let analyzeArgs = `--authToken=${authToken} --deltaScan=${prScan} --analyzedBranch="${analyzedBranch}" --repositoryCloneUrl=${cloneUrl} --provider=${provider} --gitProviderOrganization=${organization} --outputPath=${outputPath}`;
if (!disablePrComments) {
analyzeArgs += ` --providerPrNumber=${github.context.issue.number} --providerAccessToken=${githubToken}`;
}
if (baselineBranch) {
analyzeArgs += ` --baselineBranch="${baselineBranch}"`;
}
if (ignoreBlock) {
analyzeArgs += ` --warnOnly`;
}
if (localExport) {
analyzeArgs += ` --outputPath=Backslash-scan-results/`;
}
if (pushToDashboard) {
analyzeArgs += ` --pushToDashboard`;
}
const runCommand = `bash ${cliRunnerFileName} analyze ${analyzeArgs}`;
core.debug(`pushToDashboard: ${pushToDashboard}`);
core.debug(`Running this command: ${runCommand}`);
const child = (0, child_process_1.spawn)('bash', ['-c', runCommand], { stdio: ['inherit', 'pipe', 'pipe'] });
Expand Down
38 changes: 27 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import { createHash } from 'crypto';
import { readFileSync } from 'fs';
import * as process from 'process';
import { readFileSync } from 'fs'
import { createHash } from 'crypto'

import { spawn } from 'child_process';
import { downloadFile } from './util';
Expand Down Expand Up @@ -39,9 +39,10 @@ async function run() {
const isOnPremise: boolean = core.getBooleanInput('isOnPremise');
const disablePrComments: boolean = core.getBooleanInput('disablePrComments');
const pushToDashboard: boolean = core.getBooleanInput('pushToDashboard');
const localExport: boolean = core.getBooleanInput('localExport');
const githubToken = core.getInput('githubToken')
const cloneUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}.git`

const provider = isOnPremise ? 'github-enterprise-on-premise' : 'github'

const repositoryName = github.context.payload.repository.name
Expand All @@ -52,11 +53,6 @@ async function run() {
return core.setFailed('Repo or branch not defined')
}

let githubExtraInput = ''
if(!disablePrComments){
githubExtraInput = `--providerPrNumber=${github.context.issue.number} --providerAccessToken=${githubToken}`
}

await downloadFile(S3CLIUrl, cliRunnerFileName)
await downloadFile(S3CLIShaUrl, cliShaFileName)

Expand All @@ -68,10 +64,30 @@ async function run() {
}
console.log(`Cli sha matches`);

const commonArgs = `--authToken=${authToken} ${ignoreBlock ? `--warnOnly`: ''} --deltaScan=${prScan} --analyzedBranch="${analyzedBranch}" --repositoryCloneUrl=${cloneUrl} --provider=${provider} --gitProviderOrganization=${organization} ${baselineBranch && `--baselineBranch="${baselineBranch}" `} ${githubExtraInput} --outputPath=${outputPath}`
let analyzeArgs = `--authToken=${authToken} --deltaScan=${prScan} --analyzedBranch="${analyzedBranch}" --repositoryCloneUrl=${cloneUrl} --provider=${provider} --gitProviderOrganization=${organization} --outputPath=${outputPath}`

if(!disablePrComments){
analyzeArgs += ` --providerPrNumber=${github.context.issue.number} --providerAccessToken=${githubToken}`
}

if (baselineBranch) {
analyzeArgs += ` --baselineBranch="${baselineBranch}"`
}

if (ignoreBlock) {
analyzeArgs += ` --warnOnly`
}

if (localExport) {
analyzeArgs += ` --outputPath=Backslash-scan-results/`
}

if (pushToDashboard) {
analyzeArgs += ` --pushToDashboard`
}

const runCommand = `bash ${cliRunnerFileName} analyze ${analyzeArgs}`

const runCommand = `bash ${cliRunnerFileName} analyze ${commonArgs} ${pushToDashboard ? `--pushToDashboard` : ''}`

core.debug(`pushToDashboard: ${pushToDashboard}`)
core.debug(`Running this command: ${runCommand}`)

Expand Down
Loading