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

Add workflow app support #35

Closed
wants to merge 183 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
183 commits
Select commit Hold shift + click to select a range
a0d29c1
add gitignor
julz0815 Jun 13, 2022
7a7b9aa
new action name
julz0815 Jun 13, 2022
1490c6f
commit
julz0815 Oct 1, 2022
0ecd2ae
updates
julz0815 Oct 1, 2022
7ddefd3
updates
julz0815 Oct 1, 2022
2735d93
updates
julz0815 Oct 1, 2022
dc6e9d2
updates
julz0815 Oct 1, 2022
40aa788
updates
julz0815 Oct 1, 2022
d14f631
updates
julz0815 Oct 1, 2022
da0dec8
updates
julz0815 Oct 1, 2022
3dbcbf8
updates
julz0815 Oct 1, 2022
51b4a37
updates
julz0815 Oct 1, 2022
a8dabfd
updates
julz0815 Oct 1, 2022
5e14a58
updates
julz0815 Oct 1, 2022
7ab4859
updates
julz0815 Oct 1, 2022
aa044f6
updates
julz0815 Oct 1, 2022
3112721
updates
julz0815 Oct 1, 2022
aad1114
updates
julz0815 Oct 1, 2022
ee794d5
updates
julz0815 Oct 1, 2022
0a367ed
updates
julz0815 Oct 1, 2022
c6b415f
updates
julz0815 Oct 1, 2022
3ac9458
updates
julz0815 Oct 1, 2022
2d5ddb1
updates
julz0815 Oct 1, 2022
940aa90
upsates
julz0815 Oct 1, 2022
c501f6b
updates
julz0815 Oct 1, 2022
f580211
updates
julz0815 Oct 1, 2022
ec9f497
updates
julz0815 Oct 1, 2022
cb72217
updates
julz0815 Oct 1, 2022
64f5612
update
julz0815 Oct 1, 2022
b80cd6b
updates
julz0815 Oct 1, 2022
d3496fd
updates
julz0815 Oct 1, 2022
46ac69b
updates
julz0815 Oct 1, 2022
3278b8a
update
julz0815 Oct 1, 2022
62b6cf3
update
julz0815 Oct 1, 2022
83d3472
updates
julz0815 Oct 1, 2022
638e795
updates
julz0815 Oct 1, 2022
f2327ac
uodates
julz0815 Oct 1, 2022
15c5a52
updates
julz0815 Oct 1, 2022
9ee9d5d
updates
julz0815 Oct 1, 2022
e331914
update
julz0815 Oct 1, 2022
c0f92dd
updates
julz0815 Oct 1, 2022
8aad6eb
updates
julz0815 Oct 1, 2022
b0a52f1
updates
julz0815 Oct 1, 2022
3ce765d
updates
julz0815 Oct 1, 2022
bd06178
updates
julz0815 Oct 1, 2022
e183657
updates
julz0815 Oct 1, 2022
4bd37b7
updates
julz0815 Oct 1, 2022
2af7653
updates
julz0815 Oct 1, 2022
6a19edd
updates
julz0815 Oct 1, 2022
34235ed
updates
julz0815 Oct 1, 2022
7840156
updates
julz0815 Oct 1, 2022
3a195f1
updates
julz0815 Oct 1, 2022
108ee18
updates
julz0815 Oct 1, 2022
83f6084
updates
julz0815 Oct 2, 2022
8570527
updates
julz0815 Oct 2, 2022
389fcfc
updates
julz0815 Oct 2, 2022
2f33f7c
updates
julz0815 Oct 2, 2022
4c88537
updates
julz0815 Oct 3, 2022
d09f124
updates
julz0815 Oct 3, 2022
29710c0
updates
julz0815 Oct 3, 2022
df8d978
updates
julz0815 Oct 3, 2022
43b282d
updates
julz0815 Oct 3, 2022
8964754
updates
julz0815 Oct 3, 2022
87d08d5
updates
julz0815 Oct 3, 2022
c66373a
updates
julz0815 Oct 3, 2022
1626976
updates
julz0815 Oct 3, 2022
1c228f3
updates
julz0815 Oct 3, 2022
846a159
updates
julz0815 Oct 3, 2022
b996d8a
updates
julz0815 Oct 3, 2022
70d577c
updates
julz0815 Oct 3, 2022
d99709b
updates
julz0815 Oct 3, 2022
59d9c96
updates
julz0815 Oct 3, 2022
20b9d98
updates
julz0815 Oct 3, 2022
29cbab5
pipeline scan flaws
julz0815 Oct 9, 2022
0989a6a
pipeline flaws
julz0815 Oct 9, 2022
0f281e3
pipeline scan flaws
julz0815 Oct 9, 2022
a3f4567
pipeline flaws
julz0815 Oct 9, 2022
58e52b5
pipeline flaws
julz0815 Oct 9, 2022
95150fc
pipeline flaws
julz0815 Oct 9, 2022
8ef7d80
pipeline flaws
julz0815 Oct 9, 2022
60e4119
pipeline flaws
julz0815 Oct 10, 2022
50ee270
pipeline flaws
julz0815 Oct 10, 2022
5a13e7d
pipeline flaws
julz0815 Oct 10, 2022
7556abf
pipeline flaws
julz0815 Oct 10, 2022
e57b1b0
pipeline flaws
julz0815 Oct 10, 2022
b1d16fb
pipeline flaws
julz0815 Oct 10, 2022
670c1fa
pipeline flaws
julz0815 Oct 10, 2022
1fe31e5
pipeline flaws
julz0815 Oct 10, 2022
07dd62e
pipeline flaws
julz0815 Oct 10, 2022
efd1685
pipeline flaws
julz0815 Oct 10, 2022
0c49a6c
pipeline flaws
julz0815 Oct 10, 2022
9065a91
pipeline flaws
julz0815 Oct 10, 2022
9cddbe9
pipeline flaws
julz0815 Oct 10, 2022
0692af3
pipeline flaws
julz0815 Oct 10, 2022
a996578
pipeline flaws
julz0815 Oct 10, 2022
c123f3a
pipeline flaws
julz0815 Oct 10, 2022
233b909
pipeline flaws
julz0815 Oct 10, 2022
0a41988
pipeline falws
julz0815 Oct 10, 2022
d0eb33a
pipeline flaws
julz0815 Oct 10, 2022
d1df8ba
pipeline flaws
julz0815 Oct 10, 2022
85bde2a
pipeline flaws
julz0815 Oct 10, 2022
8753386
pipeline flaws
julz0815 Oct 10, 2022
ffee038
pipeline flaws
julz0815 Oct 10, 2022
57db1b0
pipeline flaws
julz0815 Oct 10, 2022
2908936
pipeline flaws
julz0815 Oct 10, 2022
7843ccd
pipeline flaws
julz0815 Oct 10, 2022
8ca06b9
pipeline flaws
julz0815 Oct 10, 2022
bea3bda
pipeline flaws
julz0815 Oct 10, 2022
89fb5df
pipeline flaws
julz0815 Oct 10, 2022
c71e1be
pipeline flaws
julz0815 Oct 10, 2022
9b88d96
fixed source_base_path
julz0815 Oct 11, 2022
0151580
Merge branch 'main' into main
julz0815 Oct 30, 2022
fd16651
Merge pull request #1 from julz0815/main
julz0815 Oct 30, 2022
bb1e714
new functions
julz0815 Oct 30, 2022
21e87d1
minor readme changes
julz0815 Oct 30, 2022
8ccf9ae
adding break pipeline support
julz0815 Nov 14, 2022
1f7b127
add break pipeline support
julz0815 Nov 14, 2022
47b3fd7
add break pipeline support
julz0815 Nov 14, 2022
7ce16c8
add break pipeline support
julz0815 Nov 14, 2022
15c9e56
add break pipeline support
julz0815 Nov 14, 2022
34f54a2
add break pipeline support
julz0815 Nov 14, 2022
addc545
add break pipeline support
julz0815 Nov 14, 2022
8658244
update npm modules
julz0815 Nov 14, 2022
8cd01d9
add break pipeline support
julz0815 Nov 14, 2022
f0b5a4e
add break pipeline support
julz0815 Nov 14, 2022
f4c3547
add break build support and readme update
julz0815 Nov 14, 2022
1666101
update the readme
julz0815 Nov 14, 2022
766d839
readme updates
julz0815 Nov 14, 2022
4994203
Delete .DS_Store
julz0815 Nov 14, 2022
e2d55d9
Delete Archive.zip
julz0815 Nov 14, 2022
1e71e17
Update readme.md
tjarrettveracode Nov 14, 2022
1cc3d1a
typo fix
tjarrettveracode Nov 14, 2022
fe7a9fb
delete
julz0815 Nov 14, 2022
16029c6
enabled debug
julz0815 Jun 7, 2023
313cd5c
update action.yml
julz0815 Jun 7, 2023
1a2cbc9
debug
julz0815 Jun 7, 2023
dafe5c1
debug
julz0815 Jun 7, 2023
417eb4e
enable debug
julz0815 Jun 7, 2023
11256a2
debug
julz0815 Jun 7, 2023
aed8bdf
enabled debug
julz0815 Jun 7, 2023
55cdd2e
debug
julz0815 Jun 7, 2023
e81310f
debug
julz0815 Jun 7, 2023
493af6e
debug
julz0815 Jun 8, 2023
b40e940
debug
julz0815 Jun 8, 2023
5d90531
debug
julz0815 Jun 8, 2023
a298d16
devug
julz0815 Jun 8, 2023
bb41955
debug
julz0815 Jun 8, 2023
b3bcac9
debug
julz0815 Jun 8, 2023
55285c5
commit
julz0815 Jun 11, 2023
0dec97a
debug
julz0815 Jun 11, 2023
78b3deb
debug
julz0815 Jun 11, 2023
d33939c
fix PR identification
julz0815 Jun 11, 2023
8d94267
Merge pull request #3 from veracode/fixPRidentification
julz0815 Jun 11, 2023
c7e584a
Switch from token to Bearer because that is compatible with all token…
Sep 14, 2023
fb4606f
Add documentation on permissions required.
Sep 14, 2023
4923f83
Use new name in package.json and increase to v1.1.0
Sep 14, 2023
a765503
npm upgrade
Sep 14, 2023
a19d513
Merge pull request #4 from relaxnow/permissions
julz0815 Sep 15, 2023
9cff79e
Merge pull request #5 from relaxnow/npm-update
julz0815 Sep 15, 2023
2af7541
Add 'Get Assistance' comment after flaw import
Oct 13, 2023
0b85c51
Fix pipeline flaw details
Oct 13, 2023
f44104e
Fix variable reference
Oct 13, 2023
15ab359
Fix mailto link
Oct 13, 2023
59a2ab6
Merge pull request #7 from relaxnow/feature/get-assistance
julz0815 Oct 14, 2023
6e68718
Create SECURITY.md
mtawadrousv Nov 16, 2023
b12c73e
Merge pull request #8 from veracode/mtawadrousv-patch-1
tjarrettveracode Nov 16, 2023
ae05023
Create nigthlySecurityScan.yml
julz0815 Nov 19, 2023
1c2d878
update example file
julz0815 Nov 19, 2023
8eec3c2
updte workflow
julz0815 Nov 20, 2023
b3bc050
Update action.yml
julz0815 Feb 10, 2024
6a8dfa3
Merge pull request #10 from veracode/julz0815-patch-3
julz0815 Feb 10, 2024
c94511e
gitignor
julz0815 Feb 12, 2024
ecf9821
add workflow support
julz0815 Feb 12, 2024
67e7e47
more debug info
julz0815 Feb 12, 2024
9f4e847
more debugging
julz0815 Feb 12, 2024
eaa1d91
more debugging
julz0815 Feb 12, 2024
8582640
add vars
julz0815 Feb 12, 2024
f50013b
disable PR for workflow app
julz0815 Feb 12, 2024
d970097
disable comment
julz0815 Feb 12, 2024
3cdfda1
diable comment
julz0815 Feb 12, 2024
5a900b9
disable comment
julz0815 Feb 12, 2024
69609d3
move comment to a different place
julz0815 Feb 12, 2024
7dffa1a
updating the link
julz0815 Feb 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
47 changes: 47 additions & 0 deletions .github/workflows/nigthlySecurityScan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Veracode Security Scan

on:
pull_request:
branches:
- main
schedule:
- cron: 0 4 * * *
workflow_dispatch:

jobs:
veracode-sca-task:
runs-on: ubuntu-latest
name: Veracode SCA scan

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run Veracode SCA
env:
SRCCLR_API_TOKEN: ${{ secrets.SRCCLR_API_TOKEN }}
uses: veracode/veracode-sca@v2.1.9

veracode-sast-task:
runs-on: ubuntu-latest
name: Veracode SAST policy scan

steps:
- name: Checkout
uses: actions/checkout@v3
- name: create new package-lock.json
run: npm install
- name: ZIP source folder
run: zip -r app.zip *.js package-lock.json -x node_modules -x doc -x test -x helpers -x .vscode
- name: Run Veracode Policy scan
uses: veracode/veracode-uploadandscan-action@0.2.6
with:
appname: 'GitHub Flaws to Issues Action'
createprofile: true
filepath: 'app.zip'
scantimeout: 30
vid: '${{ secrets.API_ID }}'
vkey: '${{ secrets.API_KEY }}'




5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@

# helper test output
helpers/flaws*
Archive.zip
package-lock.json
.DS_Store
Archive.zip
.DS_Store
140 changes: 101 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ Note that when Issues are added, a tag is inserted into the Issue title. The ta
For a Policy or Sandbox scan, this is done with the Findings REST API call, see [Findings REST API](https://help.veracode.com/r/c_findings_v2_intro).

Note that when Issues are added, a tag is inserted into the Issue title. The tag is of the form `[VID:<flaw_number>]`. This tag is used to prevent duplicate issues from getting created.


## Pull request decoration
This action now supports pull request decoration. Once an issue is generated and the job runs on a PR, the issue will automatically be linked to the PR. This is done for easy review and an easy approval process.

## Fail the build upon findings
As this job needs to run after a Veracode pipeline/sandbox/policy scan, the scan job cannot fail the pipeline upon findings as otherwiese the following job, this flaws-to-issues job, won't be started. In order to still fail the pipeline this action now includes and option to fail the pipeline upon findings. Make sure you pass the correct pipelins-scan results or download the correct sandbox/policy scan results (most probably all unmitigated, policy relevant findings) to fail the pipeline.

---

## Inputs
Expand All @@ -22,15 +28,75 @@ Note that when Issues are added, a tag is inserted into the Issue title. The ta
|Default value | `"filtered_results.json"`|
--- | ---

### `github-token`

**Required** GitHub token needed to access the repo. Normally, when run in a Workflow, use the `{{ secrets.GITHUB-TOKEN }}` that is created by GitHub. See [here](https://docs.github.com/en/actions/reference/authentication-in-a-workflow) for further information.

### `wait-time`

**Optional** GitHub (at least the free/public version) has a rate limiter to prevent a user from adding Issues too quickly. This value is used to insert a small delay between each new issue created so as to not trip the rate limiter. This value sets the number of seconds between each issue. See [here](https://docs.github.com/en/rest/guides/best-practices-for-integrators#dealing-with-rate-limits) for additional information.
| Default value | `"2"` |
--- | ---

### `source_base_path_1`, `source_base_path_2`, `source_base_path_3`

**Optional** In some compilations, the path representation is not the same as the repository root folder. In order to add the ability to navigate back from the scanning issue to the file in the repository, a base path to the source is required. The input format is regex base (`"[search pattern]:[replace with pattern]"`).
| Default value | `""` |
--- | ---

Example:
```yml
source-base-path-1: "^com/veracode:src/main/java/com/veracode"
source-base-path-2: "^WEB-INF:src/main/webapp/WEB-INF"
```

### `fail_build`

**Optional** If a previous task run and was set to `fail_build: false` as you need to run this `flaws-to-issues` action after the scan is finished but you still need to fail the pipeline based on findings from a Veracode scan, this option is require to be set to `true`.
| Default value | `""` |
--- | ---

---

## Permissions

If you get an error like:

```
Failure at Error: Error 404 creating VeracodeFlaw label "VeracodeFlaw: Very High": Not Found
```
Or:
```
Failure at Error: Error 403 creating VeracodeFlaw label "VeracodeFlaw: Very High": Resource not accessible by integration
```

It is likely that something is wrong with the permissions for the token provided to the action (GitHub API responds with 403 or 404 if there are permission issues).

### GITHUB_TOKEN

This action requires `issues: write` of all (new) Personal Access Tokens, including the automatically generated `GITHUB_TOKEN`.

If you do not add anything to the YAML, by default the `GITHUB_TOKEN` will be used and it will not be given "write" rights to "issues".

You can [change the default permissions](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#setting-the-permissions-of-the-github_token-for-your-repository), but this would apply to all workflows in your repository and we generally don't recommend this

To follow the Principle of Least Privilege we recommend only granting the permission to the job in the job configuration by including [job.<job_id>.permissions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idpermissions):

```
permissions:
issues: write
```


### Your own token

You can specify your own token with the `github-token` argument:
```
with:
github-token: ${{ secrets.MY_TOKEN }}
```

If this is a Classic token this token must have the `repo` scope.
[You can check this with curl](https://stackoverflow.com/a/70588035).

If this is a new 'fine-grained, repository-scoped token' you will need to ensure that for the given repository it says "Read and Write access to issues".
[You can check that here](https://github.com/settings/tokens?type=beta)

## Example usage

Expand All @@ -39,48 +105,43 @@ Note that when Issues are added, a tag is inserted into the Issue title. The ta
```yaml
. . .
# This first step is assumed to exist already in your Workflow
scan:
runs-on: ubuntu-latest
container:
image: veracode/pipeline-scan:latest
options: --user root
steps:
- name: get archive
uses: actions/download-artifact@v2
with:
name: scan-target
path: /tmp

- name: scan
run: |
java -jar /opt/veracode/pipeline-scan.jar \
-vid ${{ secrets.VERACODE_API_ID }} \
-vkey ${{ secrets.VERACODE_API_KEY }} \
--file /tmp/upload.zip \
--fail_on_severity="Very High,High" \
continue-on-error: true

- name: save filtered results file
uses: actions/upload-artifact@v2
with:
name: filtered-results
path: filtered_results.json
pipeline_scan:
needs: build
runs-on: ubuntu-latest
name: pipeline scan
steps:
- name: checkout repo
uses: actions/checkout@v3

- name: get archive
uses: actions/download-artifact@v3
with:
name: verademo.war
- name: pipeline-scan action step
id: pipeline-scan
uses: veracode/Veracode-pipeline-scan-action@pipeline-scan-beta-v0.0.4
with:
vid: ${{ secrets.VID }}
vkey: ${{ secrets.VKEY }}
file: "verademo.war"
fail_build: false

# This step will import the flaws from the step above
import-issues:
needs: scan
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: get scan results
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: filtered-results

- name: import flaws as issues
uses: buzzcode/veracode-flaws-to-issues@v1
uses: veracode/veracode-flaws-to-issues@v2.1.19
with:
scan-results-json: 'filtered_results.json'
github-token: ${{ secrets.GITHUB_TOKEN }}
```

### Policy/Sandbox scan
Expand Down Expand Up @@ -111,7 +172,7 @@ Note that when Issues are added, a tag is inserted into the Issue title. The ta
http --auth-type veracode_hmac GET "https://api.veracode.com/appsec/v2/applications/${guid}/findings?scan_type=STATIC&violates_policy=True&size=${total_flaws}" > policy_flaws.json

- name: save results file
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: policy-flaws
path: /tmp/policy_flaws.json
Expand All @@ -120,16 +181,17 @@ Note that when Issues are added, a tag is inserted into the Issue title. The ta
import-policy-flaws:
needs: get-policy-flaws
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: get flaw file
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: policy-flaws
path: /tmp

- name: import flaws as issues
uses: buzzcode/veracode-flaws-to-issues@v1
uses: veracode/veracode-flaws-to-issues@v2.1.19
with:
scan-results-json: '/tmp/policy_flaws.json'
github-token: ${{ secrets.GITHUB_TOKEN }}
```
```
19 changes: 19 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Our Commitment to Security

Veracode was founded on the idea that companies should be able to access technology that allows them to scan their software for vulnerabilities so that they can identify them, fix them and improve their security. Since that time, we have created new technologies and services to enable our customers to scan for flaws in along the entire software development lifecycle, seeing results in seconds or minutes, to allow them to code securely while also remaining on schedule with continuous release cycles.

Veracode envisions a world where the software fueling our economic growth and solving society's greatest challenges is developed secure from the start.

We value transparency in the security industry and openness with sharing information that could improve security for every organization. Veracode is committed to engaging the research community in a professional, positive and agreeable manner that protects our company and our customers.

As such, we encourage and welcome anyone who believes he or she has identified a vulnerability to contact us with security concerns or pertinent information to the integrity, functionality or confidentiality of our software.

The terms below apply to any website, application or service distributed by or hosted by Veracode, Inc.

Please use the email address [**security-alerts@veracode.com**](mailto:security-alerts@veracode.com?subject=Responsible%20Disclosure%20Notice&body=URL(s)/Application(s)%20Impacted:%0A%0ASuspected%20Vulnerability%20Details:%0A%0ADescription%20of%20how%20the%20Vulnerability%20was%20found:%0A%0AContact%20Information:%0A%0AAny%20other%20relevant%20information:%0A%0A) to alert us to:

- Vulnerabilities or breaches in our software or environments which threaten the confidentiality, integrity or availability of our data, software, or services, or our customers’ data
- Applications that mimic, mislabel, misdirect, or "copycat" Veracode, or phishing attacks even if they do not originate from Veracode sources
- Written or verbal discussion, activities, or data in any public forum which you believe constitutes a threat to Veracode, our employees or our customers

For more, please refer to our [**Responsible Disclosure Policy**](https://www.veracode.com/legal-privacy/responsible-disclosure-policy)
18 changes: 13 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Veracode scan results to GitHub issues'
name: 'Veracode scan results to GitHub issues Action'
description: 'Import the results of a Veracode scan as Issues for a repo'
inputs:
scan-results-json:
Expand All @@ -7,6 +7,7 @@ inputs:
default: 'filtered_results.json'
github-token:
description: 'GitHub token to access the repo'
default: ${{ github.token }}
required: true
wait-time:
description: 'Delay (in seconds) between entering Issues into GitHub (due to rate limiting)'
Expand All @@ -21,9 +22,16 @@ inputs:
source_base_path_3:
description: 'Rewrite 3'
required: false
commit-hash:
description: 'Commit Hash'
repo_owner:
description: 'repo owner'
required: false
fail_build:
description: fail pipeline upon findings (true | false)
required: false
debug:
description: enable debug logging
required: false

runs:
using: 'node12'
main: 'index.js'
using: 'node20'
main: 'index.js'
23 changes: 23 additions & 0 deletions importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

const fs = require('fs');
const core = require('@actions/core');
const processPipelineFlaws = require('./pipeline').processPipelineFlaws;
const processPolicyFlaws = require('./policy').processPolicyFlaws;
const label = require('./label');
Expand All @@ -21,6 +22,10 @@ async function importFlaws(options) {
const source_base_path_2 = options.source_base_path_2;
const source_base_path_3 = options.source_base_path_3;
const commit_hash = options.commit_hash;
const fail_build = options.fail_build;
const isPR = options.isPR
const debug = options.debug
var internal_flaw_count = 0
var flawData;

// basic sanity checking
Expand Down Expand Up @@ -61,18 +66,36 @@ async function importFlaws(options) {

label.buildSeverityXref(); // TODO: cleanup, merge into label init?


// process the flaws
if(scanType == 'pipeline') {
await processPipelineFlaws(options, flawData)
.then (count => {
internal_flaw_count = count
console.log(`Done. ${count} flaws processed.`);
})
} else {
if ( debug == "true" ){
core.info('#### DEBUG START ####')
core.info('importer.js')
console.log("isPr?: "+isPR)
core.info('#### DEBUG END ####')
}
await processPolicyFlaws(options, flawData)
.then (count => {
console.log(`Done. ${count} flaws processed.`);
internal_flaw_count = count
})
}

// add break build functionality
if ( fail_build == "true" ){
if ( internal_flaw_count > 0 ){
console.log('There are Veracode flaws found that require the build to fail, please review generated GitHub issues')
core.setFailed('There are Veracode flaws found that require the build to fail, please review generated GitHub issues')
}
}
}


module.exports = { importFlaws };
Loading
Loading