Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adds semgrep pre-commit and CI action #51

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ name: CI
on:
push:
pull_request:
branches: main
branches:
- main

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
Expand Down Expand Up @@ -36,11 +37,14 @@ jobs:

- name: Set up poetry and install
uses: ./.github/actions/setup-poetry

- name: Pre-commit install
run: make pre-commit

- name: Run checks
- name: Run linting checks
run: make lint

- name: Run bandit
- name: Run security checks
run: make security-check

- name: Check dependencies
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Code Coverage Check

on:
pull_request:
branches: main
branches:
- main

jobs:
test:
Expand Down
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/returntocorp/semgrep
rev: v1.42.0
hooks:
- id: semgrep
name: Semgrep Python
types: [python]
args: ["--config", "p/python", "--error", --metrics=off]
- id: semgrep
name: Semgrep Bandit
types: [python]
exclude: "^tests/.+$"
args: ["--config", "p/bandit", "--error", --metrics=off]
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ TESTS := tests
all: develop lint test
.PHONY: all

develop:
develop: pre-commit
@poetry install
@poetry shell
.PHONY: develop

pre-commit:
@poetry run pre-commit install

lint:
@poetry lock --check
@poetry run isort --profile=black --lines-after-imports=2 \
Expand Down Expand Up @@ -38,7 +41,7 @@ dep-cve-check:
.PHONY: dep-cve-check

security-check:
@poetry run bandit -r $(PYMODULE)
@poetry run pre-commit run semgrep --all-files
.PHONY: security-check

build: clean-build
Expand Down
Loading
Loading