Skip to content

Commit

Permalink
Merge pull request #38 from snyk-tech-services/fix/addOption_setPassI…
Browse files Browse the repository at this point in the history
…fNoBaselineFlag

fix:add setPassIfNoBaselineFlag option
  • Loading branch information
mathild3r authored Jul 9, 2021
2 parents b430c45 + 47ce832 commit 738a155
Show file tree
Hide file tree
Showing 7 changed files with 1,071 additions and 88 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ export SNYK_DEBUG=true
<GH_PR_NUMBER>
<LINK_TO_CI_JOB - optional>
<keepHistory - optional>
<setPassIfNoBaselineFlag - optional>
```

#### No baseline
In case of an unmonitored project, it is possible to force the snyk-delta result so snyk-prevent-gh-commit-status will not fail.
If some vulnerabilities are found comment listing the vulnerabilities will still be the post on the PR.

148 changes: 74 additions & 74 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/lib/github/commitStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ghDetails, ghCommitStatusState, ghCommitStatus } from "./types"



export const sendCommitStatus = async (snykDeltaBinaryResult: number, snykProjectDetails: snykProjectDetails, ghDetails: ghDetails ): Promise<ghCommitStatus> => {
export const sendCommitStatus = async (snykDeltaBinaryResult: number, snykProjectDetails: snykProjectDetails, ghDetails: ghDetails, issueFoundNoBaseline: boolean ): Promise<ghCommitStatus> => {

let data: ghCommitStatus = {
state: ghCommitStatusState.pending,
Expand All @@ -20,11 +20,14 @@ export const sendCommitStatus = async (snykDeltaBinaryResult: number, snykProjec
data.target_url = `https://app.snyk.io/org/${snykProjectDetails.orgName}/project/${snykProjectDetails.projectID}`
}


switch (snykDeltaBinaryResult) {
case 0:
data.state = ghCommitStatusState.success;
data.description = 'No new issue found';
if (issueFoundNoBaseline)
{
data.description = 'Skipping check - New issue(s) found for unmonitored project';
}
break;
case 1:
data.state = ghCommitStatusState.failure;
Expand Down
9 changes: 8 additions & 1 deletion src/lib/github/prComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ const formatPRComment = (snykDeltaResults: SnykDeltaOutput, commitNb: string): s
let vulnerabilityLine = '';
let licenseLine = '';

allIssuesToDisplay = `### ******* Vulnerabilities report for commit number ${commitNb} *******\n`
if (snykDeltaResults.passIfNoBaseline)
{
allIssuesToDisplay = `### ******* INFORMATION ONLY *******\n`
allIssuesToDisplay += `#### project is unmonitored (no baseline) ####\n`
allIssuesToDisplay += `see https://github.com/snyk-tech-services/snyk-prevent-gh-commit-status#additional-option---debug for more information\n`
}

allIssuesToDisplay += `### ******* Vulnerabilities report for commit number ${commitNb} *******\n`

if (newVulns.length + newLicenseIssues.length > 1) {
allIssuesToDisplay += 'New Issues Introduced!\n';
Expand Down
Loading

0 comments on commit 738a155

Please sign in to comment.