diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..a543ce4 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ + +/** @david-backslash @yoli-backslash diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index d5160f5..70e27d7 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -43,4 +43,4 @@ jobs: git add dist/ git commit -m "Build: Update dist/ directory" git push - fi \ No newline at end of file + fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11128d1..1f7508c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ jobs: prScan: true disablePrComments: false githubToken: ${{ secrets.GITHUB_TOKEN }} + localExport: true - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} with: diff --git a/dist/build/index.js b/dist/build/index.js index db3efcd..fa8191a 100644 --- a/dist/build/index.js +++ b/dist/build/index.js @@ -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'; @@ -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'; @@ -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', ''); @@ -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'] }); diff --git a/dist/index.js b/dist/index.js index 5d7fdd0..de46362 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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'; @@ -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'; @@ -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', ''); @@ -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'] }); diff --git a/src/index.ts b/src/index.ts index acea604..65c3955 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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'; @@ -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 @@ -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) @@ -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}`)