Skip to content

Commit

Permalink
Added sonatype_scan.yaml which will execute Sonatype SCA scan on comm…
Browse files Browse the repository at this point in the history
…its to the project and save an SBOM as an output artifact. Security and license issues can be reviewed within the Sonatype Dashboard: https://finos.sonatype.app/
  • Loading branch information
acpcreation authored and Alexander Plattel committed Oct 29, 2024
1 parent 8e39896 commit 7526acf
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/sonatype_scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright 2023 Amazon.com, Inc. or its affiliates.

Check failure on line 1 in .github/workflows/sonatype_scan.yaml

View workflow job for this annotation

GitHub Actions / checkov

CKV2_GHA_1: "Ensure top-level permissions are not set to write-all"

Check failure

Code scanning / checkov

Ensure top-level permissions are not set to write-all Error

Ensure top-level permissions are not set to write-all
# SPDX-License-Identifier: Apache-2.0
# Licensed under the Apache License, Version 2.0 https://aws.amazon.com/apache-2-0/

name: Sonatype SCA Scanning
on:
push:
branches: [main]
pull_request:
branches: [main]

env:
SonatypeUrl: "https://finos.sonatype.app/platform/"
SonatypeAppId: "htc-grid"
SonatypeScanTarget: "."
ExcludeDirectory: "**/docs/ **/.*'"

jobs:
build:
if: github.repository_owner == 'finos'
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip' # caching pip dependencies

- name: Download Python Libraries
run : |
projRoot=`pwd`
list=$(find "." -name 'requirements.txt')
for i in $list; do
echo ""
echo "Found requirements.txt at: $i"
j="${i/'requirements.txt'/}" # Remove 'requirements.txt' from path
cd $j
# Remove local dependencies
sed -i '/dist/d' requirements.txt
sed -i '/backports.zoneinfo/d' requirements.txt
cat requirements.txt
echo ""
mkdir pip-modules
pip install -r requirements.txt
# pip freeze > pip-modules/requirements.txt
pip download -r requirements.txt -d pip-modules
cd $projRoot # Return to project root
done
###########################
## Sonatype SCA Scanning ##
###########################
- name: Sonatype Lifecycle SCA Scan
id: evaluate
uses: sonatype/actions/evaluate@v1
with:
iq-server-url: ${{ env.SonatypeUrl }}
username: ${{ secrets.SONATYPE_SCANNER_USERNAME }}
password: ${{ secrets.SONATYPE_SCANNER_PASSWORD }}
application-id: ${{ env.SonatypeAppId }}
stage: "build"
scan-targets: ${{ env.SonatypeScanTarget }}
module-exclude: ${{ env.ExcludeDirectory }}

- name: Save Sonatype SBOM
uses: sonatype/actions/fetch-sbom@v1
if: always() && steps.evaluate.outputs.scan-id
with:
iq-server-url: ${{ env.SonatypeUrl }}
username: ${{ secrets.SONATYPE_SCANNER_USERNAME }}
password: ${{ secrets.SONATYPE_SCANNER_PASSWORD }}
application-id: ${{ env.SonatypeAppId }}
scan-id: ${{ steps.evaluate.outputs.scan-id }}
sbom-standard: spdx
sbom-version: 2.3
artifact-name: ${{ env.SonatypeAppId }}-bom

0 comments on commit 7526acf

Please sign in to comment.