Skip to content

Commit d1ac4b2

Browse files
authored
Merge pull request #130 from mailjet/refine-client
refactor: Modernize SDK architecture, harden security, and enable O(1) routing
2 parents 2bce502 + e41beb1 commit d1ac4b2

50 files changed

Lines changed: 5327 additions & 1026 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codeql.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: CodeQL
2+
on:
3+
push: { branches: [main] }
4+
pull_request: { branches: [main] }
5+
schedule: [{ cron: "37 3 * * 0" }] # weekly full scan
6+
7+
jobs:
8+
analyze:
9+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
10+
runs-on: ubuntu-latest
11+
permissions:
12+
security-events: write
13+
contents: read
14+
actions: read
15+
steps:
16+
- uses: actions/checkout@v6
17+
- uses: github/codeql-action/init@v3
18+
with:
19+
languages: python
20+
queries: security-extended,security-and-quality
21+
- uses: github/codeql-action/analyze@v3
22+
with:
23+
category: "/language:python"

.github/workflows/commit_checks.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
channels: defaults
4747
show-channel-urls: true
4848
environment-file: environment.yaml
49-
cache: 'pip' # Drastically speeds up CI by caching pip dependencies
5049

5150
- name: Install dependencies and package
5251
run: |
@@ -60,7 +59,7 @@ jobs:
6059
- name: Install test dependencies
6160
run: |
6261
python -m pip install --upgrade pip
63-
pip install pytest
62+
pip install pytest hypothesis responses
6463
6564
- name: Run unit tests
66-
run: pytest tests/unit/ -v
65+
run: pytest tests/unit/ -v -m "not property_heavy"

.github/workflows/publish.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,25 @@ jobs:
3434

3535
- name: Extract version
3636
id: get_version
37+
# Use an intermediate environment variable to avoid shell injection
38+
env:
39+
EVENT_NAME: ${{ github.event_name }}
40+
RELEASE_TAG: ${{ github.event.release.tag_name }}
41+
REF_NAME: ${{ github.ref_name }}
3742
run: |
3843
# Get clean version from the tag or release
39-
if [[ "${{ github.event_name }}" == "release" ]]; then
44+
if [[ "$EVENT_NAME" == "release" ]]; then
4045
# For releases, get the version from the release tag
41-
TAG_NAME="${{ github.event.release.tag_name }}"
46+
TAG_NAME="$RELEASE_TAG"
4247
else
4348
# For tags, get version from the tag
44-
TAG_NAME="${{ github.ref_name }}"
49+
TAG_NAME="$REF_NAME"
4550
fi
4651
4752
# Remove 'v' prefix
4853
VERSION=$(echo $TAG_NAME | sed 's/^v//')
4954
50-
# Check if this is a stable version (no rc, alpha, beta, dev, etc.)
55+
# Check if this is a stable version
5156
if [[ $TAG_NAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
5257
echo "IS_STABLE=true" >> $GITHUB_ENV
5358
else

.github/workflows/security.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Security
2+
3+
on:
4+
push: { branches: [main] }
5+
pull_request:
6+
schedule: [{ cron: "0 5 * * *" }] # Daily security sweep
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
static-analysis:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v6
16+
- uses: actions/setup-python@v6
17+
with:
18+
python-version: "3.13"
19+
cache: 'pip'
20+
- run: pip install ruff bandit mypy pip-audit
21+
# Fast checks
22+
- run: ruff check .
23+
- run: bandit -c pyproject.toml -r mailjet_rest
24+
- run: mypy --strict mailjet_rest
25+
26+
semgrep:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v6
30+
- uses: returntocorp/semgrep-action@v1
31+
with:
32+
config: >-
33+
p/python
34+
p/owasp-top-ten
35+
p/supply-chain
36+
p/command-injection
37+
p/insecure-transport
38+
error: true # Fails CI if issues found
39+
40+
pip-audit:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- uses: actions/checkout@v6
44+
- uses: actions/setup-python@v6
45+
with: { python-version: "3.13" }
46+
- run: pip install pip-audit
47+
- run: pip-audit --strict
48+
49+
osv-scan:
50+
permissions:
51+
actions: read
52+
security-events: write # For Security Tab
53+
contents: read
54+
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@v2.3.8"
55+
with:
56+
# Explicit root scanning
57+
scan-args: |-
58+
--recursive
59+
./

0 commit comments

Comments
 (0)