Skip to content

Commit 1c3742b

Browse files
author
ShiftLeft
committed
adding ShiftLeft GitHub action
1 parent 6ab2f49 commit 1c3742b

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/shiftleft.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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-Analysis:
12+
runs-on: ubuntu-20.04
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Download ShiftLeft CLI
16+
run: |
17+
curl https://cdn.shiftleft.io/download/sl > ${GITHUB_WORKSPACE}/sl && chmod a+rx ${GITHUB_WORKSPACE}/sl
18+
- name: Extract branch name
19+
shell: bash
20+
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
21+
id: extract_branch
22+
- name: NextGen Static Analysis
23+
run: |
24+
pip install --upgrade setuptools wheel
25+
pip install -r requirements.txt
26+
${GITHUB_WORKSPACE}/sl analyze --strict --wait --app shiftleft-python-demo --tag branch=${{ github.head_ref || steps.extract_branch.outputs.branch }} --python $(pwd)
27+
env:
28+
SHIFTLEFT_ACCESS_TOKEN: ${{ secrets.SHIFTLEFT_ACCESS_TOKEN }}
29+
30+
if:
31+
${{ hashFiles('requirements.txt') != '' }}
32+
- name: Legacy Static Analysis
33+
run: |
34+
echo "Please update your `shiftleft-python-demo` fork!"
35+
${GITHUB_WORKSPACE}/sl analyze --strict --wait --no-cpg --app shiftleft-python-demo --tag branch=${{ github.head_ref || steps.extract_branch.outputs.branch }} --python $(pwd)
36+
env:
37+
SHIFTLEFT_ACCESS_TOKEN: ${{ secrets.SHIFTLEFT_ACCESS_TOKEN }}
38+
39+
if:
40+
${{ hashFiles('requirements.txt') == '' }}
41+
Build-Rules:
42+
runs-on: ubuntu-latest
43+
needs: NextGen-Static-Analysis
44+
steps:
45+
- uses: actions/checkout@v2
46+
- name: Download ShiftLeft CLI
47+
run: |
48+
curl https://cdn.shiftleft.io/download/sl > ${GITHUB_WORKSPACE}/sl && chmod a+rx ${GITHUB_WORKSPACE}/sl
49+
- name: Validate Build Rules
50+
run: |
51+
${GITHUB_WORKSPACE}/sl check-analysis --app shiftleft-python-demo \
52+
--branch "${{ github.head_ref || steps.extract_branch.outputs.branch }}" \
53+
--report \
54+
--github-pr-number=${{github.event.number}} \
55+
--github-pr-user=${{ github.repository_owner }} \
56+
--github-pr-repo=${{ github.event.repository.name }} \
57+
--github-token=${{ secrets.GITHUB_TOKEN }}
58+
env:
59+
SHIFTLEFT_ACCESS_TOKEN: ${{ secrets.SHIFTLEFT_ACCESS_TOKEN }}
60+
61+

0 commit comments

Comments
 (0)