Skip to content
This repository was archived by the owner on Oct 30, 2023. It is now read-only.

Commit 7b132be

Browse files
authored
Merge pull request #52 from ossf/improve/JLL/pre-commit-hooks
2 parents 869c16a + 6baeab0 commit 7b132be

Some content is hidden

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

77 files changed

+426
-185
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,3 @@ RUN cd /opt && \
2525
# [Optional] Uncomment this section to install additional OS packages.
2626
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
2727
# && apt-get -y install --no-install-recommends <your-package-list-here>
28-
29-
30-

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@
5656
},
5757
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
5858
"remoteUser": "vscode"
59-
}
59+
}

.devcontainer/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414
NODE_VERSION: "lts/*"
1515

1616
volumes:
17-
- ..:/workspace:cached
17+
- ..:/workspace:cached
1818
init: true
1919

2020
# Overrides default command so things don't shut down after the process ends.

.github/workflows/azure-container-webapp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ env:
3535

3636
on:
3737
push:
38-
branches: [ "main" ]
38+
branches: [ main ]
3939
pull_request:
4040
workflow_dispatch:
4141

.github/workflows/ci.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
name: CI
22
on:
33
push:
4-
branches: main
4+
branches: [ main ]
55
pull_request:
66
workflow_dispatch:
77

88
jobs:
9+
pre-commit-check:
10+
runs-on: ubuntu-latest
11+
name: "Run the pre-commit hooks"
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-python@v2
15+
with:
16+
python-version: 3.9
17+
- uses: pre-commit/[email protected]
18+
919
test:
1020
runs-on: ubuntu-latest
1121
name: test (Python ${{ matrix.python-version }})

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/omega-triage-portal.iml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.pre-commit-config.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
exclude: '.idea'
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v4.4.0
5+
hooks:
6+
- id: trailing-whitespace
7+
- id: end-of-file-fixer
8+
- id: check-yaml
9+
- id: debug-statements
10+
- id: name-tests-test
11+
- id: requirements-txt-fixer
12+
- repo: https://github.com/asottile/add-trailing-comma
13+
rev: v2.4.0
14+
hooks:
15+
- id: add-trailing-comma
16+
args: [--py36-plus]
17+
- repo: https://github.com/asottile/pyupgrade
18+
rev: v3.3.1
19+
hooks:
20+
- id: pyupgrade
21+
args: [--py38-plus]
22+
- repo: https://github.com/iamthefij/docker-pre-commit
23+
rev: v3.0.1
24+
hooks:
25+
- id: docker-compose-check
26+
- repo: https://github.com/pryorda/dockerfilelint-precommit-hooks
27+
rev: v0.1.0
28+
hooks:
29+
- id: dockerfilelint
30+
- repo: https://github.com/python-jsonschema/check-jsonschema
31+
rev: 0.22.0
32+
hooks:
33+
- id: check-github-workflows
34+
- id: check-dependabot

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
"django": true
1717
}
1818
]
19-
}
19+
}

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@
3939
},
4040
"editor.bracketPairColorization.enabled": true,
4141
"html.format.templating": true
42-
}
42+
}

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@
9090
},
9191
},
9292
]
93-
}
93+
}

CONTRIBUTING.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Contributing
2+
3+
## Getting Started
4+
5+
Please read the [README](./README.md) for more information about the project.
6+
7+
## Pre-Commit Hooks
8+
9+
### Installing
10+
11+
This project uses `pre-commit` to run a series of checks before each commit.
12+
If you don't already have `pre-commit` installed, you can install globally with:
13+
14+
```bash
15+
pip install pre-commit
16+
```
17+
Alternatively, you can use homebrew on macOS:
18+
19+
```bash
20+
brew install pre-commit
21+
```
22+
23+
Then, to install the pre-commit hooks, run:
24+
25+
```bash
26+
pre-commit install
27+
```
28+
29+
### Executing
30+
31+
The pre-commit hooks will run automatically before each commit.
32+
However, many of the hooks can be used to automatically fix issues as well.
33+
To run the pre-commit hooks manually and resolve easily fixed issues, run:
34+
35+
```bash
36+
pre-commit run --all-files
37+
```

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,3 @@ TBD
6161
## Security
6262

6363
See [SECURITY.md](https://github.com/ossf/omega-triage-portal/blob/main/SECURITY.md).
64-

docker-entrypoint-initdb.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ psql -v ON_ERROR_STOP=1 --username "$DATABASE_USER" --dbname "$DATABASE_NAME" <<
55
CREATE USER triage_user;
66
CREATE DATABASE triage;
77
GRANT ALL PRIVILEGES ON DATABASE triage_user TO triage_user;
8-
EOSQL
8+
EOSQL

src/.env-template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ CACHE_REDIS_PASSWORD=''
2121

2222
#APPINSIGHTS_IKEY = ''
2323

24-
OSSGADGET_PATH="/opt/OSSGadget"
24+
OSSGADGET_PATH="/opt/OSSGadget"

src/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN cd /opt && \
2323
mv OSSGadget_linux_${OSSGADGET_VERSION} OSSGadget
2424

2525

26-
RUN apk update && apk add gcc \
26+
RUN apk update && apk add --no-cache gcc \
2727
libc-dev \
2828
postgresql-dev \
2929
musl-dev \

src/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_env_variable(var_name, optional=False):
1717
if optional:
1818
return False
1919
raise ImproperlyConfigured(
20-
f"Error: You must set the {var_name} environment variable."
20+
f"Error: You must set the {var_name} environment variable.",
2121
) from ex
2222

2323

src/core/settings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
dotenv.load_dotenv(os.path.join(BASE_DIR, ".env-template"))
1616
except Exception as ex:
1717
raise ImproperlyConfigured(
18-
"A .env-template file was not found. Environment variables are not set."
18+
"A .env-template file was not found. Environment variables are not set.",
1919
) from ex
2020

2121
SECRET_KEY = os.getenv("SECRET_KEY")
@@ -92,7 +92,7 @@
9292
"HOST": os.getenv("DATABASE_HOST"),
9393
"PORT": os.getenv("DATABASE_PORT"),
9494
"OPTIONS": {"options": "-c statement_timeout=5000"},
95-
}
95+
},
9696
}
9797

9898

@@ -146,7 +146,7 @@
146146
"TIMEOUT": DEFAULT_CACHE_TIMEOUT,
147147
"PASSWORD": os.getenv("CACHE_REDIS_PASSWORD"),
148148
},
149-
}
149+
},
150150
}
151151
else:
152152
CACHES = {
@@ -237,5 +237,5 @@
237237
"default": {
238238
"provider": "triage.util.content_managers.file_manager.FileManager",
239239
"args": {"root_path": "/home/vscode/omega-fs"},
240-
}
240+
},
241241
}

src/manage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def main():
1414
raise ImportError(
1515
"Couldn't import Django. Are you sure it's installed and "
1616
"available on your PYTHONPATH environment variable? Did you "
17-
"forget to activate a virtual environment?"
17+
"forget to activate a virtual environment?",
1818
) from exc
1919
execute_from_command_line(sys.argv)
2020

src/pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,5 +545,3 @@ ignored-argument-names = "_.*|^ignored_|^unused_"
545545
# List of qualified module names which can have objects that can redefine
546546
# builtins.
547547
redefining-builtins-modules = ["six.moves", "past.builtins", "future.builtins", "builtins", "io"]
548-
549-

src/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ azure-core==1.26.1
44
azure-storage-blob==12.14.1
55
bandit==1.7.5
66
black==22.10.0
7-
cryptography==39.0.1
7+
celery==5.2.7
88
certifi==2022.12.7
99
cffi==1.15.1
10-
celery==5.2.7
1110
charset-normalizer<3,>=2
1211
click==8.1.3
1312
cryptography==39.0.1
13+
cryptography==39.0.1
1414
data==0.4
1515
Deprecated==1.2.13
1616
dill==0.3.6
@@ -53,8 +53,8 @@ pylint-django==2.5.3
5353
pylint-flask==0.6
5454
pylint-plugin-utils==0.7
5555
pyparsing==3.0.9
56-
python-magic==0.4.27
5756
python-dotenv==1.0.0
57+
python-magic==0.4.27
5858
pytz==2022.6
5959
PyYAML==6.0
6060
redis==4.5.4

src/triage/apps.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""This module configures application-level settings for the Triage Portal."""
32

43
import logging

src/triage/migrations/0001_initial.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ class Migration(migrations.Migration):
3737
(
3838
"package_url",
3939
models.CharField(
40-
blank=True, db_index=True, max_length=1024, null=True
40+
blank=True,
41+
db_index=True,
42+
max_length=1024,
43+
null=True,
4144
),
4245
),
4346
("metadata", models.JSONField(null=True)),
@@ -83,7 +86,10 @@ class Migration(migrations.Migration):
8386
(
8487
"package_url",
8588
models.CharField(
86-
blank=True, db_index=True, max_length=1024, null=True
89+
blank=True,
90+
db_index=True,
91+
max_length=1024,
92+
null=True,
8793
),
8894
),
8995
("metadata", models.JSONField(null=True)),
@@ -98,7 +104,8 @@ class Migration(migrations.Migration):
98104
(
99105
"project",
100106
models.ForeignKey(
101-
on_delete=django.db.models.deletion.CASCADE, to="triage.project"
107+
on_delete=django.db.models.deletion.CASCADE,
108+
to="triage.project",
102109
),
103110
),
104111
(
@@ -144,7 +151,9 @@ class Migration(migrations.Migration):
144151
(
145152
"type",
146153
models.CharField(
147-
choices=[("PY", "Python Function")], default="PY", max_length=2
154+
choices=[("PY", "Python Function")],
155+
default="PY",
156+
max_length=2,
148157
),
149158
),
150159
],
@@ -246,7 +255,8 @@ class Migration(migrations.Migration):
246255
(
247256
"tool",
248257
models.ForeignKey(
249-
on_delete=django.db.models.deletion.CASCADE, to="triage.tool"
258+
on_delete=django.db.models.deletion.CASCADE,
259+
to="triage.tool",
250260
),
251261
),
252262
(
@@ -413,7 +423,8 @@ class Migration(migrations.Migration):
413423
(
414424
"scan",
415425
models.ForeignKey(
416-
on_delete=django.db.models.deletion.CASCADE, to="triage.scan"
426+
on_delete=django.db.models.deletion.CASCADE,
427+
to="triage.scan",
417428
),
418429
),
419430
(

src/triage/migrations/0003_auto_20211127_0020.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class Migration(migrations.Migration):
6565
(
6666
"tool",
6767
models.ForeignKey(
68-
on_delete=django.db.models.deletion.CASCADE, to="triage.tool"
68+
on_delete=django.db.models.deletion.CASCADE,
69+
to="triage.tool",
6970
),
7071
),
7172
],

src/triage/migrations/0012_filecontent_remove_finding_file_path_file_and_more.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ class Migration(migrations.Migration):
2828
(
2929
"content_type",
3030
models.CharField(
31-
blank=True, db_index=True, max_length=64, null=True
31+
blank=True,
32+
db_index=True,
33+
max_length=64,
34+
null=True,
3235
),
3336
),
3437
("data", models.BinaryField(blank=True, null=True)),

0 commit comments

Comments
 (0)