Skip to content

Commit 61be288

Browse files
committed
Integrate SSDLC tooling (Ruff, pip-audit, Trivy, Hadolint), update CONTRIBUTING.rst, and remove obsolete MANIFEST.in
1 parent 82bf36c commit 61be288

8 files changed

Lines changed: 51 additions & 34 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,31 @@ jobs:
3131
run: |
3232
python -m pip install --upgrade pip
3333
python -m pip install tox tox-gh-actions
34-
- name: Lint
34+
- name: Security & Linting
3535
if: matrix.python-version == '3.10'
3636
run: |
37-
tox -e flake8
37+
tox -e ruff
38+
tox -e pip-audit
3839
tox -e mypy
3940
- name: Tests
4041
run: tox
42+
43+
docker-security:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
- name: Run Hadolint
48+
uses: hadolint/hadolint-action@v3.1.0
49+
with:
50+
dockerfile: Dockerfile
51+
- name: Build Docker Image
52+
run: docker build -t snappass:local .
53+
- name: Run Trivy vulnerability scanner
54+
uses: aquasecurity/trivy-action@master
55+
with:
56+
image-ref: 'snappass:local'
57+
format: 'table'
58+
exit-code: '1'
59+
ignore-unfixed: true
60+
vuln-type: 'os,library'
61+
severity: 'CRITICAL,HIGH'

CONTRIBUTING.rst

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,12 @@ Here's how to set up ``snappass`` for local development.
7070

7171
$ git clone git@github.com:your_name_here/snappass.git
7272

73-
3. Install your local copy into a ``virtualenv``. Assuming you have
74-
``virtualenvwrapper`` installed, this is how you set up your fork for local
75-
development::
73+
3. Install your local copy into a ``virtualenv``. It is recommended to use standard ``venv``::
7674

77-
$ mkvirtualenv snappass
75+
$ python -m venv venv
76+
$ source venv/bin/activate
7877
$ cd snappass/
79-
$ python setup.py develop
78+
$ pip install -e .
8079
$ make dev
8180

8281
4. Create a branch for local development::
@@ -92,29 +91,19 @@ Here's how to set up ``snappass`` for local development.
9291

9392
You now have a running instance on localhost:5000/
9493

95-
6. Please add some tests to tests.py and run tests::
94+
6. Please add some tests to tests.py. When you're done making changes, check that your changes pass all tests and security linters (Ruff, Pip-Audit, etc.)::
9695

9796
$ make test
9897

99-
7. When you're done making changes, check that your changes pass the tests and
100-
flake8::
98+
(Tox will automatically run all linting, security scans, and tests with coverage output.)
10199

102-
$ flake8 snappass tests.py setup.py
103-
$ tox
104-
105-
8. Check that the test coverage hasn't dropped::
106-
107-
$ coverage run --source snappass tests.py
108-
$ coverage report -m
109-
$ coverage html
110-
111-
9. Commit your changes and push your branch to GitHub::
100+
7. Commit your changes and push your branch to GitHub::
112101

113102
$ git add .
114103
$ git commit -m "Your detailed description of your changes."
115104
$ git push origin name-of-your-bugfix-or-feature
116105

117-
10. Submit a pull request through the GitHub website.
106+
8. Submit a pull request through the GitHub website.
118107

119108
Pull Request Guidelines
120109
-----------------------

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ RUN groupadd -r snappass && \
88

99
WORKDIR $APP_DIR
1010

11-
COPY ["pyproject.toml", "requirements.txt", "MANIFEST.in", "README.rst", "AUTHORS.rst", "LICENSE", "$APP_DIR/"]
11+
COPY ["pyproject.toml", "requirements.txt", "README.rst", "AUTHORS.rst", "LICENSE", "$APP_DIR/"]
1212
COPY ["./snappass", "$APP_DIR/snappass"]
1313

1414
RUN pip install -r requirements.txt

MANIFEST.in

Lines changed: 0 additions & 4 deletions
This file was deleted.

dev-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
coverage==7.6.0
22
fakeredis==2.25.1
3-
flake8==7.1.1
3+
ruff==0.6.2
4+
pip-audit==2.7.3
45
freezegun==1.5.1
56
pytest==8.3.2
67
pytest-cov==5.0.0

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ Homepage = "https://github.com/pinterest/snappass"
2727

2828
[project.scripts]
2929
snappass = "snappass.main:main"
30+
31+
[tool.ruff.lint]
32+
select = ["E", "F", "S"]
33+
34+
[tool.ruff.lint.per-file-ignores]
35+
"tests.py" = ["S105", "S101"]

snappass/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def get_locale() -> typing.Optional[str]:
4848
redis_client = FakeStrictRedis(version=(6, 2), protocol=2) # type: ignore
4949
elif os.environ.get('REDIS_URL'):
5050
redis_url = os.environ.get('REDIS_URL')
51-
assert redis_url is not None
51+
if not redis_url:
52+
raise ValueError("REDIS_URL is empty")
5253
redis_client = redis.StrictRedis.from_url(redis_url)
5354
else:
5455
redis_host = os.environ.get('REDIS_HOST', 'localhost')
@@ -336,7 +337,7 @@ def health_check() -> typing.Dict[typing.Any, typing.Any]:
336337

337338
@check_redis_alive
338339
def main() -> None:
339-
app.run(host=os.environ.get('SNAPPASS_BIND_ADDRESS', '0.0.0.0'),
340+
app.run(host=os.environ.get('SNAPPASS_BIND_ADDRESS', '0.0.0.0'), # noqa: S104
340341
port=int(os.environ.get('SNAPPASS_PORT', 5000)))
341342

342343

tox.ini

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py310, py314, py315, flake8, mypy
2+
envlist = py310, py314, py315, ruff, pip-audit, mypy
33
skip_missing_interpreters = true
44

55
[testenv]
@@ -11,15 +11,18 @@ commands =
1111
pip install -r dev-requirements.txt
1212
pytest --cov=snappass --cov-report=term-missing tests.py
1313

14-
[testenv:flake8]
14+
[testenv:ruff]
1515
commands =
1616
pip install -r dev-requirements.txt
17-
flake8
17+
ruff check .
18+
19+
[testenv:pip-audit]
20+
commands =
21+
pip install -r dev-requirements.txt
22+
pip-audit -r requirements.txt
1823

1924
[testenv:mypy]
2025
commands =
2126
pip install -r dev-requirements.txt
2227
mypy snappass
2328

24-
[flake8]
25-
exclude = .tox, .git, __pycache__, .venv, venv, myenv, env

0 commit comments

Comments
 (0)