From 51186947f497c12934be6d5d6b23c8ab3de61c61 Mon Sep 17 00:00:00 2001 From: ShiftLeft Date: Tue, 18 Aug 2020 00:17:00 -0700 Subject: [PATCH] adding ShiftLeft action workflow config --- .github/workflows/shiftleft.yml | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/shiftleft.yml diff --git a/.github/workflows/shiftleft.yml b/.github/workflows/shiftleft.yml new file mode 100644 index 0000000..a8e1afc --- /dev/null +++ b/.github/workflows/shiftleft.yml @@ -0,0 +1,41 @@ +--- +# This workflow integrates ShiftLeft NG SAST with GitHub +# Visit https://docs.shiftleft.io for help +name: ShiftLeft + +on: + pull_request: + workflow_dispatch: + +jobs: + NextGen-Static-Analysis: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '^1.14' + - name: Build + run: | + go build ./... + - name: Download ShiftLeft CLI + run: | + curl https://cdn.shiftleft.io/download/sl > ${GITHUB_WORKSPACE}/sl && chmod a+rx ${GITHUB_WORKSPACE}/sl + - name: Extract branch name + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + id: extract_branch + - name: NextGen Static Analysis + run: | + ${GITHUB_WORKSPACE}/sl --version + ${GITHUB_WORKSPACE}/sl analyze --app go-api-example --tag branch=${{ github.head_ref || steps.extract_branch.outputs.branch }} --go --cpg $(pwd) + env: + SHIFTLEFT_ACCESS_TOKEN: ${{ secrets.SHIFTLEFT_ACCESS_TOKEN }} + + - name: Create status check + run: | + URL="https://www.shiftleft.io/violationlist/go-api-example?apps=go-api-example&isApp=1" + GH_CHECK_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/check-runs" + 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\": \"go-api-example\", \"details_url\": \"${URL}\", \"status\": \"completed\", \"conclusion\": \"action_required\", \"output\": {\"title\": \"ShiftLeft NextGen Static Analysis Findings\", \"summary\": \"Visit ${URL} for the findings\"}}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}