add sast ci #4
Workflow file for this run
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
| name: SAST | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: '45 6 * * *' | |
| jobs: | |
| buildmavenDepTree: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '11' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: Set temporary version for Maven | |
| run: | | |
| mvn -q versions:set -DnewVersion=0.0.0-ci -DgenerateBackupPoms=false -Dmaven.test.skip=true || echo "No version bump needed" | |
| - name: Generate dependency tree | |
| run: | | |
| find . -name "pom.xml" | while read pom; do | |
| dir=$(dirname "$pom") | |
| echo "Processing $dir" | |
| ( | |
| cd "$dir" || exit 1 | |
| echo "Running in $(pwd)" | |
| if ! timeout 300s mvn -q dependency:tree -DoutputFile=maven_dep_tree.txt -Dmaven.test.skip=true 2> error.log; then | |
| echo "Failed in $dir" | |
| echo "-------- ERROR LOG START ($dir) --------" | |
| cat error.log | |
| echo "-------- ERROR LOG END ($dir) --------" | |
| fi | |
| ) | |
| done | |
| - name: Create zip with all dependency trees | |
| run: find . -type f -name 'maven_dep_tree.txt' -exec zip -r deptree.zip {} + | |
| - name: Upload zip | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: deptree | |
| path: deptree.zip | |
| sast: | |
| needs: buildmavenDepTree | |
| name: sast | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| env: | |
| SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} | |
| container: | |
| image: semgrep/semgrep | |
| if: (github.actor != 'dependabot[bot]') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download Maven Dependencies | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: deptree | |
| - name: Extract zip and run Semgrep | |
| run: | | |
| unzip -o deptree.zip | |
| semgrep ci > /dev/null 2>&1 || exit $? |