Skip to content

Commit

Permalink
add semgrep (#141)
Browse files Browse the repository at this point in the history
Make Semgrep CI same practice with other SONiC repositories

**Why I did it**
[Semgrep](https://github.com/returntocorp/semgrep) is a static analysis tool to find security vulnerabilities.
When opening a PR or commtting to PR, Semgrep performs a diff-aware scanning, which scans changed files in PRs.
When merging PR, Semgrep performs a full scan on master branch and report all findings.

Ref: - [Supported Language](https://semgrep.dev/docs/supported-languages/#language-maturity) - [Semgrep Rules](https://registry.semgrep.dev/rule)

**How I did it**
Integrate Semgrep into this repository by committing a job configuration file
  • Loading branch information
maipbui authored Jun 19, 2023
1 parent 92991f0 commit 1109e49
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Semgrep

on:
pull_request: {}
push:
branches:
- master
- '201[7-9][0-1][0-9]'
- '202[0-9][0-1][0-9]'

jobs:
semgrep:
if: github.repository_owner == 'sonic-net'
name: Semgrep
runs-on: ubuntu-latest
container:
image: returntocorp/semgrep
steps:
- uses: actions/checkout@v3
- run: semgrep ci
env:
SEMGREP_RULES: p/default
18 changes: 0 additions & 18 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,6 @@ pr:
- master

stages:
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- stage: Analysis
dependsOn: []
jobs:
- job:
displayName: "Semgrep"
pool:
vmImage: ubuntu-latest
steps:
- script: |
set -ex
target_branch=origin/$(System.PullRequest.TargetBranch)
files_changed=$(git --no-pager diff $target_branch..HEAD --name-only --diff-filter=d)
python -m pip install --upgrade pip
pip install semgrep
semgrep --config "p/default" --error $files_changed
displayName: 'Run Semgrep'
- stage: Build
jobs:
- job:
Expand Down

0 comments on commit 1109e49

Please sign in to comment.