Skip to content

Commit 7327c77

Browse files
Add security workflows: pre-commit hooks, dependency review, CodeQL for Python
1 parent 9401e9b commit 7327c77

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

.github/workflows/codeql.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# CodeQL Analysis for Python
2+
name: CodeQL
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
schedule:
10+
# Run every Monday at 9:00 AM UTC
11+
- cron: '0 9 * * 1'
12+
13+
permissions:
14+
actions: read
15+
contents: read
16+
security-events: write
17+
18+
jobs:
19+
analyze:
20+
name: Analyze Python
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.11'
31+
32+
- name: Initialize CodeQL
33+
uses: github/codeql-action/init@v3
34+
with:
35+
languages: python
36+
queries: +security-extended,security-and-quality
37+
38+
- name: Autobuild
39+
uses: github/codeql-action/autobuild@v3
40+
41+
- name: Perform CodeQL Analysis
42+
uses: github/codeql-action/analyze@v3
43+
with:
44+
category: "/language:python"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Dependency Review - blocks PRs that introduce known-vulnerable dependencies
2+
name: Dependency Review
3+
4+
on:
5+
pull_request:
6+
branches: [main]
7+
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
12+
jobs:
13+
dependency-review:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Dependency Review
20+
uses: actions/dependency-review-action@v4
21+
with:
22+
fail-on-severity: high
23+
comment-summary-in-pr: always
24+
deny-licenses: GPL-3.0, AGPL-3.0

.pre-commit-config.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Pre-commit hooks for Agent365-python
2+
# Install: pip install pre-commit && pre-commit install
3+
# Run manually: pre-commit run --all-files
4+
5+
repos:
6+
# Gitleaks - detect secrets in code
7+
- repo: https://github.com/gitleaks/gitleaks
8+
rev: v8.18.4
9+
hooks:
10+
- id: gitleaks
11+
12+
# Whitespace fixes
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v4.6.0
15+
hooks:
16+
- id: trailing-whitespace
17+
args: [--markdown-linebreak-ext=md]
18+
- id: end-of-file-fixer
19+
- id: mixed-line-ending
20+
args: [--fix=lf]
21+
- id: check-merge-conflict
22+
- id: check-yaml
23+
args: [--allow-multiple-documents]
24+
- id: check-json
25+
- id: check-toml
26+
- id: check-ast
27+
28+
# Python specific
29+
- repo: https://github.com/psf/black
30+
rev: 24.4.2
31+
hooks:
32+
- id: black
33+
language_version: python3
34+
35+
- repo: https://github.com/pycqa/isort
36+
rev: 5.13.2
37+
hooks:
38+
- id: isort
39+
args: ["--profile", "black"]
40+
41+
- repo: https://github.com/pycqa/flake8
42+
rev: 7.0.0
43+
hooks:
44+
- id: flake8
45+
args: [--max-line-length=120]

0 commit comments

Comments
 (0)