|
1 | 1 | # github-security-jira |
2 | | -Github Action for integrating Security Alerts with JIRA |
| 2 | +GitHub Action for mapping security alerts to Jira tickets. |
| 3 | + |
| 4 | + |
| 5 | +## Setup |
| 6 | + |
| 7 | +You need the following pieces set up to sync alerts with Jira: |
| 8 | + |
| 9 | +1. Two repo secrets containing a GitHub access token and a Jira API token, respectively. |
| 10 | +2. A workflow file which runs the action on a schedule, continually creating new tickets when necessary. |
| 11 | + |
| 12 | + |
| 13 | +### Repo secrets |
| 14 | +The `reload/github-security-jira` action requires you to [create two encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets#creating-encrypted-secrets) in the repo: |
| 15 | + |
| 16 | +1. A secret called `GitHubSecurityToken` which should contain a [Personal Access Token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) for the GitHub user under which this action should be executed. The token must include the `public_repo` scope if checking only public repos, or the `repo` scope for use on private repos. Also, the user must have [access to security alerts in the repo](https://help.github.com/en/github/managing-security-vulnerabilities/managing-alerts-for-vulnerable-dependencies-in-your-organization). |
| 17 | +2. A secret called `JiraApiToken` containing an [API Token](https://confluence.atlassian.com/cloud/api-tokens-938839638.html) for the Jira user that should be used to create tickets. |
| 18 | + |
| 19 | + |
| 20 | +### Workflow file setup |
| 21 | +The [GitHub workflow file](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/configuring-a-workflow#creating-a-workflow-file) should reside in any repo where you want to sync security alerts with Jira. |
| 22 | + |
| 23 | +It has some required and some optional settings, which are passed to the action as environment variables: |
| 24 | + |
| 25 | +- `GH_SECURITY_TOKEN`: A reference to the repo secret `GitHubSecurityToken` (**REQUIRED**) |
| 26 | +- `JIRA_TOKEN`: A reference to the repo secret `JiraApiToken` (**REQUIRED**) |
| 27 | +- `JIRA_HOST`: The endpoint for your Jira instance, e.g. https://foo.atlassian.net (**REQUIRED**) |
| 28 | +- `JIRA_USER`: The ID of the Jira user which is associated with the 'JiraApiToken' secret, eg ' [email protected]' ( **REQUIRED **) |
| 29 | +- `JIRA_PROJECT`: The project key for the Jira project where issues should be created, eg `TEST` or `ABC`. (**REQUIRED**) |
| 30 | +- `JIRA_ISSUE_TYPE`: Type of issue to create, e.g. `Security`. Defaults to `Bug`. (*Optional*) |
| 31 | +- `JIRA_WATCHERS`: Jira users to add as watchers to tickets. Use the [YAML block scalar literal style indicator with stripping chomping indicator](https://yaml-multiline.info/) (pipe and dash: `|-`) to add multiple watchers. (*Optional*) |
| 32 | +- `JIRA_RESTRICTED_GROUP`: If set, the action will add a restricted comment to the ticket, viewable by only this Jira group. (*Optional*) |
| 33 | +- `JIRA_RESTRICTED_COMMENT`: The comment to post. Use the YAML multiline operator for adding linebreaks to the comment. (*Optional, but required if group is set*) |
| 34 | + |
| 35 | +Here is an example setup which runs this action every 15 mins. |
| 36 | + |
| 37 | +```yaml |
| 38 | +name: GitHub Security Alerts for Jira |
| 39 | + |
| 40 | +on: |
| 41 | + schedule: |
| 42 | + - cron: '*/15 * * * *' |
| 43 | + |
| 44 | +jobs: |
| 45 | + syncSecurityAlerts: |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - name: "Sync security alerts to Jira issues" |
| 49 | + |
| 50 | + env: |
| 51 | + GH_SECURITY_TOKEN: ${{ secrets.GitHubSecurityToken }} |
| 52 | + JIRA_TOKEN: ${{ secrets.JiraApiToken }} |
| 53 | + JIRA_HOST: https://foo.atlassian.net |
| 54 | + |
| 55 | + JIRA_PROJECT: ABC |
| 56 | + JIRA_ISSUE_TYPE: Security |
| 57 | + JIRA_WATCHERS: |- |
| 58 | + |
| 59 | + |
| 60 | + JIRA_RESTRICTED_GROUP: Developers |
| 61 | + JIRA_RESTRICTED_COMMENT: |- |
| 62 | + Remember to evaluate severity here and set ticket priority. |
| 63 | + Check out the guide [in our wiki|https://foo.atlassian.net/wiki/]! |
| 64 | +``` |
| 65 | +
|
| 66 | +
|
| 67 | +## Local development |
| 68 | +
|
| 69 | +Copy `docker-composer.override.example.yml` to `docker-composer.override.yml` and edit according to your settings. |
| 70 | + |
| 71 | +After that, you can execute the Symfony console app like so: |
| 72 | + |
| 73 | +``` |
| 74 | +docker-compose run --rm ghsec-jira --verbose --dry-run |
| 75 | +``` |
| 76 | + |
| 77 | +Remove the `--dry-run` option to actually create issues in Jira. |
0 commit comments