Skip to content

Commit 9a5d3bb

Browse files
committed
Merge branch 'main' into feature/iac-scaffolding
2 parents 8acec84 + 93d19eb commit 9a5d3bb

File tree

194 files changed

+7644
-5353
lines changed

Some content is hidden

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

194 files changed

+7644
-5353
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
__pycache__
21
.ash_history
32
.bash_history
43
.cache
@@ -17,6 +16,7 @@ __pycache__
1716
.vscode
1817
*.log
1918
*.pem
19+
**/__pycache__
2020
backend/data
2121
backend/staticfiles
2222
build
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check PR linked issue and assignee
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
9+
permissions:
10+
contents: read
11+
issues: write
12+
pull-requests: write
13+
14+
jobs:
15+
check-pr-issue:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v5
20+
21+
- name: Check PR linked issue and assignee
22+
uses: arkid15r/check-pr-issue-action@a3635191c798f111aae577759b579dc37bb13e02
23+
with:
24+
close_pr_on_failure: 'false'
25+
github_token: ${{ secrets.GITHUB_TOKEN }}
26+
no_assignee_message: 'Test: The linked issue must be assigned to the PR author.'
27+
no_issue_message: 'Test: This PR must be linked to an issue.'
28+
require_assignee: 'true'

.github/workflows/run-ci-cd.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ jobs:
7171
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
7272

7373
- name: Install pnpm
74-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda
74+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061
7575
with:
7676
version: 10
7777
run_install: true
7878

7979
- name: Set up Node
80-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
80+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903
8181
with:
8282
node-version: 22
8383
cache: 'pnpm'
@@ -557,13 +557,13 @@ jobs:
557557
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
558558

559559
- name: Install pnpm
560-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda
560+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061
561561
with:
562562
run_install: true
563563
version: 10
564564

565565
- name: Set up Node
566-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
566+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903
567567
with:
568568
cache-dependency-path: frontend/pnpm-lock.yaml
569569
cache: 'pnpm'

.github/workflows/run-code-ql.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ jobs:
3131
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
3232

3333
- name: Initialize CodeQL
34-
uses: github/codeql-action/init@3599b3baa15b485a2e49ef411a7a4bb2452e7f93
34+
uses: github/codeql-action/init@f443b600d91635bebf5b0d9ebc620189c0d6fba5
3535
with:
3636
languages: ${{ matrix.language }}
3737

3838
- name: Install pnpm
39-
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda
39+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061
4040
with:
4141
version: 10
4242
run_install: false
4343

4444
- name: Set up Node
4545
if: matrix.language == 'javascript-typescript'
46-
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444
46+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903
4747
with:
4848
node-version: 22
4949
cache: 'pnpm'
@@ -55,6 +55,6 @@ jobs:
5555
run: pnpm install --frozen-lockfile
5656

5757
- name: Perform CodeQL analysis
58-
uses: github/codeql-action/analyze@3599b3baa15b485a2e49ef411a7a4bb2452e7f93
58+
uses: github/codeql-action/analyze@f443b600d91635bebf5b0d9ebc620189c0d6fba5
5959
with:
6060
category: /language:${{ matrix.language }}

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
exclude: (.github|pnpm-lock.yaml)
1111

1212
- repo: https://github.com/astral-sh/ruff-pre-commit
13-
rev: v0.13.2
13+
rev: v0.14.0
1414
hooks:
1515
- id: ruff
1616
args:
@@ -83,7 +83,7 @@ repos:
8383
exclude: pnpm-lock.yaml
8484

8585
- repo: https://github.com/tox-dev/pyproject-fmt
86-
rev: v2.7.0
86+
rev: v2.11.0
8787
hooks:
8888
- id: pyproject-fmt
8989

LEARN.md

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

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
# [OWASP Nest](https://nest.owasp.org/)
99

10-
[![OWASP](https://img.shields.io/badge/OWASP-Incubator-blue?style=for-the-badge)](https://owasp.org/www-project-nest/) [![OWASP](https://img.shields.io/badge/OWASP-Code-blue?style=for-the-badge)](https://owasp.org/www-project-nest/) [![project-nest](https://img.shields.io/badge/OWASP-%23project--nest-blue?logo=slack&logoColor=white&style=for-the-badge)](https://owasp.slack.com/messages/project-nest)
10+
[![OWASP](https://img.shields.io/badge/Lab-blue?&label=owasp%20level&style=for-the-badge)](https://owasp.org/www-project-nest/) [![OWASP](https://img.shields.io/badge/Code-blue?label=OWASP%20Type&style=for-the-badge)](https://owasp.org/www-project-nest/) [![project-nest](https://img.shields.io/badge/%23project--nest-blue?label=OWASP%20Slack&logoColor=white&style=for-the-badge)](https://owasp.slack.com/messages/project-nest)
1111

12-
[![License](https://img.shields.io/github/license/owasp/nest?color=41BE4A&label=License&style=for-the-badge)](https://github.com/OWASP/Nest/blob/main/LICENSE) [![Last Commit](https://img.shields.io/github/last-commit/owasp/nest/main?style=for-the-badge&label=Last%20commit)](https://github.com/OWASP/Nest/commits/main/) [![Contributors](https://img.shields.io/github/contributors/owasp/nest?style=for-the-badge&label=Contributors)](https://github.com/OWASP/Nest/graphs/contributors)
12+
[![License](https://img.shields.io/github/license/owasp/nest?color=blue&label=License&style=for-the-badge)](https://github.com/OWASP/Nest/blob/main/LICENSE) [![Last Commit](https://img.shields.io/github/last-commit/owasp/nest/main?color=blue&style=for-the-badge&label=Last%20commit)](https://github.com/OWASP/Nest/commits/main/) [![Contributors](https://img.shields.io/github/contributors/owasp/nest?style=for-the-badge&label=Contributors&color=blue)](https://github.com/OWASP/Nest/graphs/contributors)
1313

14-
[![CI/CD](https://img.shields.io/github/actions/workflow/status/owasp/nest/run-ci-cd.yaml?branch=main&label=Build&style=for-the-badge)](https://github.com/owasp/nest/actions/workflows/run-ci-cd.yaml?query=branch%3Amain) [![CodeQL](https://img.shields.io/github/actions/workflow/status/owasp/nest/run-code-ql.yaml?branch=main&label=CodeQL&style=for-the-badge)](https://github.com/owasp/nest/actions/workflows/run-code-ql.yaml?query=branch%3Amain) [![Sonarqube](https://img.shields.io/sonar/quality_gate/OWASP_Nest?server=https://sonarcloud.io&style=for-the-badge&label=Sonarqube)](https://sonarcloud.io/summary/new_code?id=OWASP_Nest&branch=main)
14+
[![CI/CD](https://img.shields.io/github/actions/workflow/status/owasp/nest/run-ci-cd.yaml?branch=main&color=blue&label=Build&style=for-the-badge)](https://github.com/owasp/nest/actions/workflows/run-ci-cd.yaml?query=branch%3Amain) [![CodeQL](https://img.shields.io/github/actions/workflow/status/owasp/nest/run-code-ql.yaml?branch=main&color=blue&label=CodeQL&style=for-the-badge)](https://github.com/owasp/nest/actions/workflows/run-code-ql.yaml?query=branch%3Amain) [![Sonarqube](https://img.shields.io/sonar/quality_gate/OWASP_Nest?color=blue&server=https://sonarcloud.io&style=for-the-badge&label=Sonarqube)](https://sonarcloud.io/summary/new_code?id=OWASP_Nest&branch=main)
1515

1616
[![Issues](https://img.shields.io/github/issues/owasp/nest?color=blue&style=for-the-badge&label=Issues)](https://github.com/OWASP/Nest/issues) [![Pull Requests](https://img.shields.io/github/issues-pr/owasp/nest?color=blue&style=for-the-badge&label=Pull%20Requests)](https://github.com/OWASP/Nest/pulls)
1717

backend/apps/api/decorators/__init__.py

Whitespace-only changes.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""Decorator for API Cache."""
2+
3+
from functools import wraps
4+
from http import HTTPStatus
5+
6+
from django.conf import settings
7+
from django.core.cache import cache
8+
from django.http import HttpRequest
9+
10+
11+
def generate_key(
12+
request: HttpRequest,
13+
prefix: str,
14+
):
15+
"""Generate a cache key for a request."""
16+
return f"{prefix}:{request.get_full_path()}"
17+
18+
19+
def cache_response(
20+
ttl: int | None = None,
21+
prefix: str | None = None,
22+
):
23+
"""Cache API responses for GET and HEAD requests.
24+
25+
Args:
26+
ttl (int): The time-to-live for the cache entry in seconds.
27+
prefix (str): A prefix for the cache key.
28+
29+
"""
30+
if ttl is None:
31+
ttl = settings.API_CACHE_TIME_SECONDS
32+
33+
if prefix is None:
34+
prefix = settings.API_CACHE_PREFIX
35+
36+
def decorator(view_func):
37+
@wraps(view_func)
38+
def _wrapper(request, *args, **kwargs):
39+
if request.method not in ("GET", "HEAD"):
40+
return view_func(request, *args, **kwargs)
41+
42+
cache_key = generate_key(
43+
request=request,
44+
prefix=prefix,
45+
)
46+
if response := cache.get(cache_key):
47+
return response
48+
49+
response = view_func(request, *args, **kwargs)
50+
if response.status_code == HTTPStatus.OK:
51+
cache.set(cache_key, response, timeout=ttl)
52+
return response
53+
54+
return _wrapper
55+
56+
return decorator

backend/apps/api/rest/v0/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
from django.conf import settings
44
from ninja import NinjaAPI, Swagger
5+
from ninja.pagination import RouterPaginated
56
from ninja.throttling import AuthRateThrottle
67

78
from apps.api.rest.auth.api_key import ApiKey as ApiKey
9+
from apps.api.rest.v0.chapter import router as chapter_router
810
from apps.api.rest.v0.committee import router as committee_router
911
from apps.api.rest.v0.event import router as event_router
1012
from apps.api.rest.v0.issue import router as issue_router
@@ -15,8 +17,6 @@
1517
from apps.api.rest.v0.repository import router as repository_router
1618
from apps.api.rest.v0.sponsor import router as sponsor_router
1719

18-
from .chapter import router as chapter_router
19-
2020
ROUTERS = {
2121
# Chapters.
2222
"/chapters": chapter_router,
@@ -42,11 +42,12 @@
4242

4343
api_settings = {
4444
"auth": ApiKey(), # The `api_key` param name is based on the ApiKey class name.
45+
"default_router": RouterPaginated(),
4546
"description": "Open Worldwide Application Security Project API",
4647
"docs": Swagger(settings={"persistAuthorization": True}),
4748
"throttle": [AuthRateThrottle("10/s")],
4849
"title": "OWASP Nest",
49-
"version": "0.2.3",
50+
"version": "0.2.4",
5051
}
5152

5253
api_settings_customization = {}

0 commit comments

Comments
 (0)