File tree Expand file tree Collapse file tree 15 files changed +71
-44
lines changed Expand file tree Collapse file tree 15 files changed +71
-44
lines changed Original file line number Diff line number Diff line change 7878 - name : Check for uncommitted changes
7979 run : |
8080 git diff --exit-code || (echo 'Unstaged changes detected. \
81- Run `make check-all ` and use `git add` to address it.' && exit 1)
81+ Run `make check` and use `git add` to address it.' && exit 1)
8282
8383 spellcheck :
8484 name : Run spell check
@@ -241,6 +241,7 @@ jobs:
241241 run : |
242242 touch frontend/.env
243243 echo "VITE_API_URL=${{ secrets.VITE_API_URL }}" >> frontend/.env
244+ echo "VITE_CSRF_URL=${{ secrets.VITE_CSRF_URL }}" >> frontend/.env
244245 echo "VITE_ENVIRONMENT=${{ secrets.VITE_ENVIRONMENT }}" >> frontend/.env
245246 echo "VITE_GRAPHQL_URL=${{ secrets.VITE_GRAPHQL_URL }}" >> frontend/.env
246247 echo "VITE_IDX_URL=${{ secrets.VITE_IDX_URL }}" >> frontend/.env
@@ -404,6 +405,7 @@ jobs:
404405 run : |
405406 touch frontend/.env
406407 echo "VITE_API_URL=${{ secrets.VITE_API_URL }}" >> frontend/.env
408+ echo "VITE_CSRF_URL=${{ secrets.VITE_CSRF_URL }}" >> frontend/.env
407409 echo "VITE_ENVIRONMENT=${{ secrets.VITE_ENVIRONMENT }}" >> frontend/.env
408410 echo "VITE_GRAPHQL_URL=${{ secrets.VITE_GRAPHQL_URL }}" >> frontend/.env
409411 echo "VITE_IDX_URL=${{ secrets.VITE_IDX_URL }}" >> frontend/.env
Original file line number Diff line number Diff line change 4949 - name : Check for uncommitted changes
5050 run : |
5151 git diff --exit-code || (echo 'Unstaged changes detected. \
52- Run `make check-all ` and use `git add` to address it.' && exit 1)
52+ Run `make check` and use `git add` to address it.' && exit 1)
5353
5454 code-ql :
5555 name : CodeQL
Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ Please follow these contribution guidelines for OWASP Schema-related changes:
234234Nest enforces code quality standards to ensure consistency and maintainability. You can run automated checks locally before pushing your changes:
235235
236236```bash
237- make check-all
237+ make check
238238```
239239
240240This command runs linters and other static analysis tools for both the frontend and backend.
@@ -245,7 +245,7 @@ This command runs linters and other static analysis tools for both the frontend
245245Our CI/CD pipelines automatically run tests against every Pull Request. You can run tests locally before submitting a PR:
246246
247247` ` ` bash
248- make test-all
248+ make test
249249` ` `
250250
251251This command runs tests and checks that coverage threshold requirements are satisfied for both backend and frontend.
@@ -286,7 +286,7 @@ git checkout -b feature/my-feature-name
286286- Run the code quality checks and tests:
287287
288288 ```bash
289- make check-test-all
289+ make check-test
290290 ```
291291
292292- Write meaningful commit messages:
Original file line number Diff line number Diff line change @@ -7,17 +7,22 @@ include schema/Makefile
77build :
88 @docker compose build
99
10- check-all : \
10+ clean : \
11+ clean-backend \
12+ clean-frontend \
13+ clean-schema
14+
15+ check : \
1116 check-backend \
1217 check-frontend \
1318 check-spelling
1419
1520check-backend : \
1621 pre-commit
1722
18- check-test-all : \
19- check-all \
20- test-all
23+ check-test : \
24+ check \
25+ test
2126
2227check-test-backend : \
2328 pre-commit \
@@ -33,7 +38,7 @@ pre-commit:
3338run :
3439 @COMPOSE_BAKE=true docker compose -f docker/docker-compose-local.yaml up --build --remove-orphans
3540
36- test-all : \
41+ test : \
3742 test-nest-app \
3843 test-schema
3944
Original file line number Diff line number Diff line change 1+ clean-backend :
2+ @rm -rf frontend/.cache
3+ @rm -rf frontend/.local
4+ @rm -rf frontend/.venv
5+
16exec-backend-command :
27 @docker exec -i nest-backend $(CMD )
38
File renamed without changes.
Original file line number Diff line number Diff line change 1313from rest_framework import routers
1414
1515from apps .core .api .algolia import algolia_search
16- from apps .core .api .csrf_token import get_csrf_token
16+ from apps .core .api .csrf import get_csrf_token
1717from apps .github .api .urls import router as github_router
1818from apps .owasp .api .urls import router as owasp_router
1919from apps .slack .apps import SlackConfig
2323router .registry .extend (owasp_router .registry )
2424
2525urlpatterns = [
26+ path ("csrf/" , get_csrf_token ),
2627 path ("idx/" , csrf_protect (algolia_search )),
2728 path ("graphql/" , csrf_protect (GraphQLView .as_view (graphiql = settings .DEBUG ))),
28- path ("csrf/" , get_csrf_token ),
2929 path ("api/v1/" , include (router .urls )),
3030 path ("a/" , admin .site .urls ),
3131]
Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ check-frontend: \
33 format-frontend-code \
44 lint-frontend-code
55
6+ clean-frontend :
7+ @rm -rf frontend/.pnpm-store
8+ @rm -rf frontend/node_modules
9+
610exec-frontend-command :
711 @docker exec -t nest-frontend $(CMD )
812
@@ -19,8 +23,8 @@ shell-frontend:
1923 @CMD=" /bin/sh" $(MAKE ) exec-frontend-command-it
2024
2125test-frontend : \
22- test-frontend-e2e \
23- test-frontend-unit
26+ test-frontend-unit \
27+ test-frontend-e2e
2428
2529test-frontend-e2e :
2630 @DOCKER_BUILDKIT=1 docker build \
Original file line number Diff line number Diff line change 11import { getCsrfToken } from 'utils/utility'
22
3- jest . mock ( 'api/getCsrfToken ' , ( ) => ( {
4- getInitialCsrfToken : jest . fn ( ( ) => Promise . resolve ( 'abc123' ) ) ,
3+ jest . mock ( 'api/fetchCsrfToken ' , ( ) => ( {
4+ fetchCsrfToken : jest . fn ( ( ) => Promise . resolve ( 'abc123' ) ) ,
55} ) )
66
77describe ( 'utility tests' , ( ) => {
Original file line number Diff line number Diff line change 1+ import { CSRF_URL } from 'utils/credentials'
2+ import { AppError } from 'wrappers/ErrorWrapper'
3+
4+ export const fetchCsrfToken = async ( ) : Promise < string > => {
5+ try {
6+ const response = await fetch ( CSRF_URL , {
7+ credentials : 'include' ,
8+ method : 'GET' ,
9+ } )
10+
11+ if ( ! response . ok ) {
12+ const message = `Failed to fetch CSRF token: ${ response . status } ${ response . statusText } `
13+ throw new AppError ( response . status , message )
14+ }
15+
16+ const data = await response . json ( )
17+
18+ if ( ! data ?. csrftoken ) {
19+ throw new AppError ( 500 , 'CSRF token missing in response' )
20+ }
21+
22+ return data . csrftoken
23+ } catch ( error ) {
24+ if ( error instanceof AppError ) {
25+ throw error
26+ }
27+
28+ const message = error ?. message || 'Unexpected error while fetching CSRF token'
29+ throw new AppError ( 500 , message )
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments