Skip to content

Commit 018e52f

Browse files
authored
Merge pull request #1 from arunmecheri/demo-branch-1
Add GitHub Action: ShiftLeft NextGen Static Analysis
2 parents 1551f22 + 703a983 commit 018e52f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

.github/workflows/shiftleft.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
# This workflow integrates ShiftLeft NG SAST with GitHub
3+
# Visit https://docs.shiftleft.io for help
4+
name: ShiftLeft
5+
6+
on:
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
NextGen-Static-Analyis:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
# We are building this application with Java 11
16+
- name: Setup Java JDK
17+
uses: actions/setup-java@v1.3.0
18+
with:
19+
java-version: 11.0.x
20+
- name: Package with maven
21+
run: mvn compile package
22+
- name: Download ShiftLeft CLI
23+
run: |
24+
curl https://cdn.shiftleft.io/download/sl > ${GITHUB_WORKSPACE}/sl && chmod a+rx ${GITHUB_WORKSPACE}/sl
25+
# ShiftLeft requires Java 1.8. Post the package step override the version
26+
- name: Setup Java JDK
27+
uses: actions/setup-java@v1.3.0
28+
with:
29+
java-version: 1.8
30+
- name: Extract branch name
31+
shell: bash
32+
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
33+
id: extract_branch
34+
- name: NextGen Static Analysis
35+
run: ${GITHUB_WORKSPACE}/sl analyze --app shiftleft-java-demo --tag branch=${{ github.head_ref || steps.extract_branch.outputs.branch }} --java --cpg target/hello-shiftleft-0.0.1.jar
36+
env:
37+
SHIFTLEFT_ACCESS_TOKEN: ${{ secrets.SHIFTLEFT_ACCESS_TOKEN }}
38+
39+
- name: Create status check
40+
run: |
41+
URL="https://www.shiftleft.io/violationlist/shiftleft-java-demo?apps=shiftleft-java-demo&isApp=1"
42+
GH_CHECK_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/check-runs"
43+
curl -XPOST $GH_CHECK_URL -H "Authorization: Token ${GITHUB_TOKEN}" -H "accept: application/vnd.github.antiope-preview+json" -H "Content-Type: application/json" -d "{\"name\": \"ShiftLeft NextGen Static Analysis\", \"head_sha\": \"${GITHUB_REF}\", \"external_id\": \"shiftleft-java-demo\", \"details_url\": \"${URL}\", \"status\": \"completed\", \"conclusion\": \"action_required\", \"output\": {\"title\": \"ShiftLeft NextGen Static Analysis Findings\", \"summary\": \"Visit ${URL} for the findings\"}}"
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)