Skip to content

Commit 1109e49

Browse files
authored
add semgrep (#141)
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
1 parent 92991f0 commit 1109e49

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

.github/workflows/semgrep.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Semgrep
2+
3+
on:
4+
pull_request: {}
5+
push:
6+
branches:
7+
- master
8+
- '201[7-9][0-1][0-9]'
9+
- '202[0-9][0-1][0-9]'
10+
11+
jobs:
12+
semgrep:
13+
if: github.repository_owner == 'sonic-net'
14+
name: Semgrep
15+
runs-on: ubuntu-latest
16+
container:
17+
image: returntocorp/semgrep
18+
steps:
19+
- uses: actions/checkout@v3
20+
- run: semgrep ci
21+
env:
22+
SEMGREP_RULES: p/default

azure-pipelines.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,6 @@ pr:
1414
- master
1515

1616
stages:
17-
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
18-
- stage: Analysis
19-
dependsOn: []
20-
jobs:
21-
- job:
22-
displayName: "Semgrep"
23-
pool:
24-
vmImage: ubuntu-latest
25-
steps:
26-
- script: |
27-
set -ex
28-
target_branch=origin/$(System.PullRequest.TargetBranch)
29-
files_changed=$(git --no-pager diff $target_branch..HEAD --name-only --diff-filter=d)
30-
python -m pip install --upgrade pip
31-
pip install semgrep
32-
semgrep --config "p/default" --error $files_changed
33-
displayName: 'Run Semgrep'
34-
3517
- stage: Build
3618
jobs:
3719
- job:

0 commit comments

Comments
 (0)