-
Notifications
You must be signed in to change notification settings - Fork 0
Trivy Scanning tool pilot implementation #72
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
Merged
Merged
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
8beba93
Terraform Static Check - PILOT update
tmikula-dev adf4ccc
Bug fix.
tmikula-dev e494f58
Adding medium severity for TRIVY.
tmikula-dev b461698
Typo.
tmikula-dev 6cefa72
Typos.
tmikula-dev c972f06
Bug.
tmikula-dev cc3a615
New way to Trivy test changes made in the the project.
tmikula-dev c65866f
Pseudo change
tmikula-dev 98725d9
worklofw update.
tmikula-dev 12dabcc
worklofw update.
tmikula-dev e4c09ff
Change.
tmikula-dev 10053c1
Python workflow bug fix.
tmikula-dev 0e6e234
Current implementation with automatic midnight scan.
tmikula-dev e682bd7
Black check.
tmikula-dev 53b38da
Terraform pseudo change.
tmikula-dev dc1d167
New mvp version of the scan.
tmikula-dev b657be8
Permission bug fix.
tmikula-dev 99c4124
Formating fix.
tmikula-dev 1fb029b
Upgrading the python logic to handle the errors.
tmikula-dev 64e0ec6
Debug.
tmikula-dev 4ae6449
Debug.
tmikula-dev be6f94e
Summary table formatting.
tmikula-dev 55b671a
Bug fix.
tmikula-dev 4456c25
Bug fix.
tmikula-dev ac4df24
Formatting touch.
tmikula-dev 2813ae7
Updated TODO comments with following issue link
tmikula-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # TODO: Trivy scan for Dockerfile will be enabled in the following implementation phases | ||
| #name: Docker Check | ||
| # | ||
| #on: | ||
| # pull_request: | ||
| # types: [ opened, synchronize, reopened ] | ||
| # push: | ||
| # branches: [ master ] | ||
| # workflow_dispatch: | ||
| # | ||
| #concurrency: | ||
| # group: static-docker-check-${{ github.ref }} | ||
| # cancel-in-progress: true | ||
| # | ||
| #permissions: | ||
| # contents: read | ||
| # security-events: write | ||
| # | ||
| #jobs: | ||
| # detect: | ||
| # name: Docker Changes Detection | ||
| # runs-on: ubuntu-latest | ||
| # outputs: | ||
| # docker_changed: ${{ steps.changes.outputs.docker_changed }} | ||
| # steps: | ||
| # - name: Checkout repository | ||
| # uses: actions/checkout@v5 | ||
| # with: | ||
| # persist-credentials: false | ||
| # fetch-depth: 0 | ||
| # | ||
| # - name: Check if docker file changed | ||
| # id: changes | ||
| # shell: bash | ||
| # run: | | ||
| # if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
| # RANGE="${{ github.event.pull_request.base.sha }}...${{ github.sha }}" | ||
| # else | ||
| # RANGE="${{ github.sha }}~1...${{ github.sha }}" | ||
| # fi | ||
| # if git diff --name-only "$RANGE" | grep -qE '^Dockerfile$'; then | ||
| # echo "docker_changed=true" >> "$GITHUB_OUTPUT" | ||
| # else | ||
| # echo "docker_changed=false" >> "$GITHUB_OUTPUT" | ||
| # fi | ||
| # | ||
| # trivy-docker: | ||
| # name: Trivy Security Scan | ||
| # needs: detect | ||
| # if: needs.detect.outputs.docker_changed == 'true' | ||
| # runs-on: ubuntu-latest | ||
| # steps: | ||
| # - name: Checkout repository | ||
| # uses: actions/checkout@v5 | ||
| # with: | ||
| # persist-credentials: false | ||
| # fetch-depth: 0 | ||
| # | ||
| # - name: Setup Trivy | ||
| # uses: aquasecurity/[email protected] | ||
| # | ||
| # - name: Trivy security scan | ||
| # run: | | ||
| # trivy config Dockerfile \ | ||
| # --format sarif \ | ||
| # --output $GITHUB_WORKSPACE/trivy_dockerfile.sarif | ||
| # | ||
| # - name: Upload Dockerfile SARIF | ||
| # uses: github/codeql-action/upload-sarif@v4 | ||
| # with: | ||
| # sarif_file: ${{ github.workspace }}/trivy_dockerfile.sarif | ||
| # | ||
| # noop: | ||
| # name: No Operation | ||
| # needs: detect | ||
| # if: needs.detect.outputs.docker_changed != 'true' | ||
| # runs-on: ubuntu-latest | ||
| # steps: | ||
| # - run: echo "No changes in the Dockerfile — passing." | ||
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| name: Python Check | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [ opened, synchronize, reopened ] | ||
| push: | ||
| branches: [ master ] | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: static-python-check-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
|
|
||
| jobs: | ||
| detect: | ||
| name: Python Changes Detection | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| python_changed: ${{ steps.changes.outputs.python_changed }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Check if Python files changed | ||
| id: changes | ||
| shell: bash | ||
| run: | | ||
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
| RANGE="${{ github.event.pull_request.base.sha }}...${{ github.sha }}" | ||
| else | ||
| RANGE="${{ github.sha }}~1...${{ github.sha }}" | ||
| fi | ||
| if git diff --name-only "$RANGE" -- '*.py' | grep -q .; then | ||
| echo "python_changed=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "python_changed=false" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| pylint-analysis: | ||
| name: Pylint Static Code Analysis | ||
| needs: detect | ||
| if: needs.detect.outputs.python_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.13' | ||
| cache: 'pip' | ||
|
|
||
| - name: Install dependencies | ||
| run: pip install -r requirements.txt | ||
|
|
||
| - name: Analyze code with Pylint | ||
| id: analyze-code | ||
| run: | | ||
| pylint_score=$(pylint $(git ls-files '*.py')| grep 'rated at' | awk '{print $7}' | cut -d'/' -f1) | ||
| echo "PYLINT_SCORE=$pylint_score" >> $GITHUB_ENV | ||
|
|
||
| - name: Check Pylint score | ||
| run: | | ||
| if (( $(echo "$PYLINT_SCORE < 9.5" | bc -l) )); then | ||
| echo "Failure: Pylint score is below 9.5 (project score: $PYLINT_SCORE)." | ||
| exit 1 | ||
| else | ||
| echo "Success: Pylint score is above 9.5 (project score: $PYLINT_SCORE)." | ||
| fi | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| black-check: | ||
| name: Black Format Check | ||
| needs: detect | ||
| if: needs.detect.outputs.python_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.13' | ||
| cache: 'pip' | ||
|
|
||
| - name: Install dependencies | ||
| run: pip install -r requirements.txt | ||
|
|
||
| - name: Check code format with Black | ||
| id: check-format | ||
| run: black --check $(git ls-files '*.py') | ||
|
|
||
| pytest-test: | ||
| name: Pytest Unit Tests with Coverage | ||
| needs: detect | ||
| if: needs.detect.outputs.python_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.13' | ||
| cache: 'pip' | ||
|
|
||
| - name: Install Python dependencies | ||
| run: pip install -r requirements.txt | ||
|
|
||
| - name: Check code coverage with Pytest | ||
| run: pytest --cov=. -v tests/ --cov-fail-under=80 | ||
|
|
||
| mypy-check: | ||
| name: Mypy Type Check | ||
| needs: detect | ||
| if: needs.detect.outputs.python_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| persist-credentials: false | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: '3.13' | ||
| cache: 'pip' | ||
|
|
||
| - name: Install dependencies | ||
| run: pip install -r requirements.txt | ||
|
|
||
| - name: Check types with Mypy | ||
| id: check-types | ||
| run: mypy . | ||
|
|
||
| noop: | ||
| name: No Operation | ||
| needs: detect | ||
| if: needs.detect.outputs.python_changed != 'true' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - run: echo "No changes in the *.py files — passing." | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.