Skip to content

Commit 818ac3a

Browse files
authored
Chore/update pre commit config (#14)
* fix: update deprecated actions, add Docker support, and publish as gitsafe-cli * security: replace manual CTR implementation with proper cryptography library - Remove insecure manual CTR mode using ECB cipher - Implement proper AES-256-CTR using cryptography library modes.CTR() - Fix potential counter overflow and nonce reuse vulnerabilities - Maintain backward compatibility with existing encrypted files - All tests pass (110/110) Fixes: Use of broken/weak cryptographic algorithm in crypto.py * chore: update pre-commit config with modern Python tooling - Update to latest hook versions (pre-commit-hooks v4.6.0, Black 24.8.0) - Add Ruff, MyPy, and Bandit for comprehensive code quality checks - Configure all tools to match project's pyproject.toml settings - All hooks tested and passing --------- Co-authored-by: Hernan Monserrat <16483541+hemonserrat@users.noreply.github.com>
1 parent 120bff1 commit 818ac3a

22 files changed

Lines changed: 114 additions & 73 deletions

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ tests/
9393
CONTRIBUTING.md
9494
TESTING.md
9595
.safety-project.ini
96-
pytest.ini
96+
pytest.ini

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ updates:
4040
include: "scope"
4141
labels:
4242
- "dependencies"
43-
- "github-actions"
43+
- "github-actions"

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@ jobs:
119119
with:
120120
name: security-reports
121121
path: |
122-
bandit-report.json
122+
bandit-report.json

.github/workflows/dependencies.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
run: |
2929
# Update main requirements
3030
pip-compile --upgrade requirements.in || echo "No requirements.in found, skipping main requirements update"
31-
31+
3232
# Update test requirements
3333
pip-compile --upgrade requirements-test.in || echo "No requirements-test.in found, skipping test requirements update"
3434
@@ -48,18 +48,18 @@ jobs:
4848
title: 'chore: automated dependency updates'
4949
body: |
5050
## Automated Dependency Updates
51-
51+
5252
This PR contains automated updates to project dependencies.
53-
53+
5454
### Changes
5555
- Updated Python package dependencies to latest compatible versions
5656
- Ran security checks on updated dependencies
57-
57+
5858
### Review Checklist
5959
- [ ] All tests pass
6060
- [ ] No new security vulnerabilities introduced
6161
- [ ] Breaking changes are documented
62-
62+
6363
**Note**: This PR was created automatically by the dependency update workflow.
6464
branch: automated/dependency-updates
6565
delete-branch: true
@@ -79,4 +79,4 @@ jobs:
7979
run: gh pr merge --auto --merge "$PR_URL"
8080
env:
8181
PR_URL: ${{github.event.pull_request.html_url}}
82-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
82+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/release.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- uses: actions/checkout@v4
1919

2020
- name: Set up Python
21-
uses: actions/setup-python@v4
21+
uses: actions/setup-python@v5
2222
with:
2323
python-version: '3.11'
2424

@@ -38,7 +38,7 @@ jobs:
3838
- uses: actions/checkout@v4
3939

4040
- name: Set up Python
41-
uses: actions/setup-python@v4
41+
uses: actions/setup-python@v5
4242
with:
4343
python-version: '3.11'
4444

@@ -113,7 +113,7 @@ jobs:
113113
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-')
114114
environment:
115115
name: pypi
116-
url: https://pypi.org/p/git-safe
116+
url: https://pypi.org/p/gitsafe-cli
117117
permissions:
118118
id-token: write
119119
steps:
@@ -125,16 +125,14 @@ jobs:
125125

126126
- name: Publish to PyPI
127127
uses: pypa/gh-action-pypi-publish@release/v1
128-
with:
129-
password: ${{ secrets.PYPI_API_TOKEN }}
130128

131129
publish-test-pypi:
132130
needs: [test, build]
133131
runs-on: ubuntu-latest
134132
if: contains(github.ref, '-') || github.event_name == 'workflow_dispatch'
135133
environment:
136134
name: testpypi
137-
url: https://test.pypi.org/p/git-safe
135+
url: https://test.pypi.org/p/gitsafe-cli
138136
permissions:
139137
id-token: write
140138
steps:
@@ -147,7 +145,6 @@ jobs:
147145
- name: Publish to Test PyPI
148146
uses: pypa/gh-action-pypi-publish@release/v1
149147
with:
150-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
151148
repository-url: https://test.pypi.org/legacy/
152149

153150
docker:
@@ -183,4 +180,14 @@ jobs:
183180
push: true
184181
tags: ${{ steps.meta.outputs.tags }}
185182
labels: ${{ steps.meta.outputs.labels }}
186-
platforms: linux/amd64,linux/arm64
183+
platforms: linux/amd64,linux/arm64
184+
185+
- name: Update Docker Hub Description
186+
uses: peter-evans/dockerhub-description@v4
187+
with:
188+
username: ${{ secrets.DOCKER_USERNAME }}
189+
password: ${{ secrets.DOCKERHUB_TOKEN }}
190+
repository: ${{ secrets.DOCKER_USERNAME }}/git-safe
191+
short-description: "Effortless file encryption for your git repos—pattern-matched, secure, and keyfile-flexible."
192+
readme-filepath: ./README.md
193+
enable-url-completion: true

.github/workflows/security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,4 @@ jobs:
125125
name: crypto-analysis-reports
126126
path: |
127127
bandit-crypto-report.json
128-
semgrep-report.json
128+
semgrep-report.json

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,4 @@ secrets.txt
276276
.pre-commit-config.yaml.bak
277277

278278
# Ruff cache
279-
.ruff_cache/
279+
.ruff_cache/

.pre-commit-config.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.6.0
4+
hooks:
5+
- id: check-yaml
6+
- id: check-toml
7+
- id: check-json
8+
- id: end-of-file-fixer
9+
- id: trailing-whitespace
10+
- id: check-merge-conflict
11+
- id: check-added-large-files
12+
- id: check-case-conflict
13+
- id: check-docstring-first
14+
- id: debug-statements
15+
- id: name-tests-test
16+
args: ['--pytest-test-first']
17+
18+
- repo: https://github.com/psf/black
19+
rev: 24.8.0
20+
hooks:
21+
- id: black
22+
args: ['--line-length=120']
23+
24+
- repo: https://github.com/astral-sh/ruff-pre-commit
25+
rev: v0.6.8
26+
hooks:
27+
- id: ruff
28+
args: [--fix, --exit-non-zero-on-fix]
29+
- id: ruff-format
30+
31+
- repo: https://github.com/pre-commit/mirrors-mypy
32+
rev: v1.11.2
33+
hooks:
34+
- id: mypy
35+
additional_dependencies: [types-cryptography, types-setuptools]
36+
args: [--ignore-missing-imports, --no-strict-optional, --disable-error-code=no-any-return]
37+
38+
- repo: https://github.com/PyCQA/bandit
39+
rev: 1.7.10
40+
hooks:
41+
- id: bandit
42+
args: ['-c', 'pyproject.toml', '--severity-level', 'medium']
43+
additional_dependencies: ['bandit[toml]']

.safety-project.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
id = git-safe
33
url = /codebases/git-safe/findings
44
name = git-safe
5-

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,4 +307,4 @@ Contributors are recognized in:
307307
- Release notes for significant contributions
308308
- Special thanks in documentation updates
309309

310-
Thank you for contributing to git-safe! 🔒
310+
Thank you for contributing to git-safe! 🔒

0 commit comments

Comments
 (0)