Increasing security posture of HTC Grid by enforcing and fixing relevant encryption, authentication and RBAC issues #98
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | |
# SPDX-License-Identifier: Apache-2.0 | |
# Licensed under the Apache License, Version 2.0 https://aws.amazon.com/apache-2-0/ | |
name: Test-Bandit | |
on: [push, pull_request] | |
permissions: | |
contents: read | |
jobs: | |
bandit: | |
permissions: | |
contents: read # for actions/checkout to fetch code | |
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results | |
runs-on: ubuntu-latest | |
env: | |
NEW_BRANCH: new_branch | |
MAIN_BRANCH: main_branch | |
NEW_BRANCH_REPORT_FILE: new_branch_bandit_report_file.sarif | |
MAIN_BRANCH_REPORT_FILE: main_branch_bandit_report_file.sarif | |
DIFF_REPORTS_FILE: diff_bandit_reports.txt | |
steps: | |
- name: Checkout the new branch | |
uses: actions/checkout@v3 | |
with: | |
path: ${{ env.NEW_BRANCH }} | |
- name: Checkout the main branch | |
uses: actions/checkout@v3 | |
with: | |
repository: awslabs/aws-htc-grid | |
path: ${{ env.MAIN_BRANCH }} | |
- name: Install bandit | |
run: |- | |
pip3 install bandit bandit-sarif-formatter | |
- name: Run bandit on the new branch | |
run: |- | |
bandit --configfile ${{ env.NEW_BRANCH }}/.github/workflows/bandit.conf \ | |
--format sarif --exit-zero --recursive \ | |
--output ${{ env.NEW_BRANCH_REPORT_FILE }} ${{ env.NEW_BRANCH }}/ | |
- name: Run bandit on the main branch | |
run: |- | |
bandit --configfile ${{ env.NEW_BRANCH }}/.github/workflows/bandit.conf \ | |
--format sarif --exit-zero --recursive \ | |
--output ${{ env.MAIN_BRANCH_REPORT_FILE }} ${{ env.MAIN_BRANCH }}/ | |
- name: Upload bandit scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v2 | |
if: success() || failure() | |
with: | |
sarif_file: "${{ env.NEW_BRANCH_REPORT_FILE }}" | |
- name: Save report results for the new branch | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.NEW_BRANCH_REPORT_FILE }} | |
path: ${{ env.NEW_BRANCH_REPORT_FILE }} | |
- name: Save report results for the main branch | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.MAIN_BRANCH_REPORT_FILE }} | |
path: ${{ env.MAIN_BRANCH_REPORT_FILE }} | |
- name: Generate the diff of reports between main and the new branch | |
run: |- | |
diff ${{ env.NEW_BRANCH_REPORT_FILE }} ${{ env.MAIN_BRANCH_REPORT_FILE }} >> ${{ env.DIFF_REPORTS_FILE }} || true | |
- name: Save diff reports | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.DIFF_REPORTS_FILE }} | |
path: ${{ env.DIFF_REPORTS_FILE }} | |
- name: Verify that the number of errors in the new branch does not exceed the number of existing errors in the main branch | |
run: |- | |
if [ "$(wc -l < ${{ env.NEW_BRANCH_REPORT_FILE }} )" -gt "$(wc -l < ${{ env.MAIN_BRANCH_REPORT_FILE }} )" ]; then \ | |
echo "Warning: New branch has more errors!" | |
exit 1 | |
fi |