|
1 | | -# coverage-report-artifacts |
2 | | -This is a github action which can make coverage report after the running unit tests in python. |
| 1 | + |
| 2 | + |
| 3 | +<p align="center"> |
| 4 | + <a href="https://github.com/marketplace/actions/bandit-report-artifacts"> |
| 5 | + <img width="150px" src="./assets/logo.png"> |
| 6 | + </a> |
| 7 | +</p> |
| 8 | + |
| 9 | +<h1 align="center"> |
| 10 | + Github action which can make security check reports after the running [bandit](https://pypi.org/project/bandit/). |
| 11 | +</h1> |
| 12 | + |
| 13 | +<p align="center"> |
| 14 | + This <a href="https://github.com/features/actions">GitHub Action</a> will deploy your Django project to <a href="https://aws.amazon.com/elasticbeanstalk/">AWS Elastic beanstalk</a>. |
| 15 | +</p> |
| 16 | + |
| 17 | +<p align="center"> |
| 18 | + <img src="./assets/screenshot_new.png"> |
| 19 | +</p> |
| 20 | +<p align="center"> |
| 21 | + <img src="./assets/screenshot.png"> |
| 22 | +</p> |
| 23 | + |
| 24 | +## Usage |
| 25 | + |
| 26 | +```yml |
| 27 | +name: Security check - Bandit |
| 28 | + |
| 29 | +on: push |
| 30 | + |
| 31 | +jobs: |
| 32 | + build: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + strategy: |
| 35 | + matrix: |
| 36 | + os: [ ubuntu-latest, macos-latest ] |
| 37 | + python-version: [ '2.7.17', '3.6.10' ] |
| 38 | + name: Python ${{ matrix.python-version }} ${{ matrix.os }} |
| 39 | + |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v2 |
| 42 | + |
| 43 | + - name: Security check - Bandit |
| 44 | + uses: ./ |
| 45 | + with: |
| 46 | + python_version: ${{ matrix.python-version }} |
| 47 | + project_path: . |
| 48 | + ignore_failure: true |
| 49 | + |
| 50 | + - name: Security check report artifacts |
| 51 | + uses: actions/upload-artifact@v1 |
| 52 | + # if: failure() |
| 53 | + with: |
| 54 | + name: Security report |
| 55 | + path: output/security_report.txt |
| 56 | +``` |
| 57 | +
|
| 58 | +
|
| 59 | +### Getting Started :airplane: |
| 60 | +
|
| 61 | +You can include the action in your workflow to trigger on any event that [GitHub actions supports](https://help.github.com/en/articles/events-that-trigger-workflows). If the remote branch that you wish to deploy to doesn't already exist the action will create it for you. Your workflow will also need to include the `actions/checkout` step before this workflow runs in order for the deployment to work. |
| 62 | + |
| 63 | + |
| 64 | +If you'd like to make it so the workflow only triggers on push events to specific branches then you can modify the `on` section. |
| 65 | + |
| 66 | +```yml |
| 67 | +on: |
| 68 | + push: |
| 69 | + branches: |
| 70 | + - master |
| 71 | +``` |
| 72 | + |
| 73 | +### Configuration 📁 |
| 74 | + |
| 75 | +The `with` portion of the workflow **must** be configured before the action will work. You can add these in the `with` section found in the examples above. Any `secrets` must be referenced using the bracket syntax and stored in the GitHub repositories `Settings/Secrets` menu. You can learn more about setting environment variables with GitHub actions [here](https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepsenv). |
| 76 | + |
| 77 | +#### Required Setup |
| 78 | + |
| 79 | +One of the following deployment options must be configured. |
| 80 | + |
| 81 | +| Key | Value Information | Type | Required | Default | |
| 82 | +| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -------- | |
| 83 | +| `PYTHON_VERSION` | You should provide your python version.' | `with` | **Yes** | 3.6.10 | |
| 84 | +| `PROJECT_PATH` | To provide you python location at which this security check needed to be done. | `with` | **No** | "." | |
| 85 | +| `IGNORE_FAILURE` | This is to ignore the security failures and pass the check. | `with` | **No** | false | |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | + |
| 90 | +### Artifacts 📁 |
| 91 | + |
| 92 | +You can get the bandit security checks reports for you python project. [learn more about artifacts](https://help.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts). |
| 93 | + |
| 94 | +#### Bandit report (security checks report) 👮♂️ |
| 95 | + |
| 96 | +The following is an bandit report for a django project. [learn more about bandit](https://pypi.org/project/bandit/). |
| 97 | + |
| 98 | +```txt |
| 99 | +Run started:2020-03-22 18:12:42.386731 |
| 100 | +
|
| 101 | +Test results: |
| 102 | +>> Issue: [B105:hardcoded_password_string] Possible hardcoded password: '(2h1-*yec9^6xz6y920vco%zdd+!7m6j6$!gi@)3amkbduup%d' |
| 103 | + Severity: Low Confidence: Medium |
| 104 | + Location: ./sample_project/settings.py:25 |
| 105 | + More Info: https://bandit.readthedocs.io/en/latest/plugins/b105_hardcoded_password_string.html |
| 106 | +24 # SECURITY WARNING: keep the secret key used in production secret! |
| 107 | +25 SECRET_KEY = "(2h1-*yec9^6xz6y920vco%zdd+!7m6j6$!gi@)3amkbduup%d" |
| 108 | +26 |
| 109 | +27 # SECURITY WARNING: don't run with debug turned on in production! |
| 110 | +28 DEBUG = True |
| 111 | +
|
| 112 | +-------------------------------------------------- |
| 113 | +
|
| 114 | +Test results: |
| 115 | + No issues identified. |
| 116 | +
|
| 117 | +Code scanned: |
| 118 | + Total lines of code: 138 |
| 119 | + Total lines skipped (#nosec): 0 |
| 120 | +
|
| 121 | +Run metrics: |
| 122 | + Total issues (by severity): |
| 123 | + Undefined: 0.0 |
| 124 | + Low: 0.0 |
| 125 | + Medium: 0.0 |
| 126 | + High: 0.0 |
| 127 | + Total issues (by confidence): |
| 128 | + Undefined: 0.0 |
| 129 | + Low: 0.0 |
| 130 | + Medium: 0.0 |
| 131 | + High: 0.0 |
| 132 | +Files skipped (0): |
| 133 | +``` |
| 134 | +This can be achieved by add the following to your job |
| 135 | + |
| 136 | +```yml |
| 137 | + - name: Security check report artifacts |
| 138 | + uses: actions/upload-artifact@v1 |
| 139 | + # if: failure() |
| 140 | + with: |
| 141 | + name: Security report |
| 142 | + path: output/security_report.txt |
| 143 | +``` |
| 144 | + |
| 145 | +### License 👨🏻💻 |
| 146 | + |
| 147 | +The Dockerfile and associated scripts and documentation in this project are released under the [MIT License](LICENSE). |
| 148 | + |
| 149 | +Container images built with this project include third party materials. As with all Docker images, these likely also contain other software which may be under other licenses. It is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within. |
0 commit comments