Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurswag committed Oct 14, 2024
2 parents 1fe2ddc + 4eb2085 commit 2261e12
Show file tree
Hide file tree
Showing 81 changed files with 8,721 additions and 1,747 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/frontend-linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install pnpm
working-directory: ${{env.working-directory}}
run: |
npm install -g pnpm &&
npm --version &&
npm list -g --depth 0
- name: Install prettier
working-directory: ${{env.working-directory}}
run: npm install --save-dev prettier
run: pnpm add --save-dev prettier
- name: Run prettier
working-directory: ${{env.working-directory}}
run: npx prettier --check .
run: pnpm exec prettier --check .
# NOTE: The following will be uncommented once the codebase is cleaned up
# - name: Install latest npm
# working-directory: ${{env.working-directory}}
# run: |
# npm install -g npm &&
# npm --version &&
# npm list -g --depth 0
# - name: Install dependencies
# working-directory: ${{env.working-directory}}
# run: npm ci
# run: pnpm i --frozen-lockfile
# - name: Run prettier check & eslint
# working-directory: ${{env.working-directory}}
# run: npm run lint
# run: pnpm run lint
# - name: Run svelte-check
# working-directory: ${{env.working-directory}}
# run: npm run check
# run: pnpm run check
2 changes: 1 addition & 1 deletion .github/workflows/frontend-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install latest npm
- name: Install latest pnpm
working-directory: ${{env.working-directory}}
run: |
npm install -g pnpm &&
Expand Down
41 changes: 17 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ and run the starter script
> If you're getting warnings or errors about image's platform not matching host platform, raise an issue with the details and we'll add it shortly after. You can also use `docker-compose-build.sh` instead (see below) to build for your specific architecture.
> [!CAUTION]
> Don't use the `main` branch code directly for production as it's the merge upstream and can have breaking changes during our development. Either use the `tags` for stable versions or prebuilt images.
> Don't use the `main` branch code directly for production as it's the merge upstream and can have breaking changes during our development. Either use the `tags` for stable versions or prebuilt images.
## End-user Documentation

Expand Down Expand Up @@ -167,7 +167,6 @@ Check out the online documentation on <https://intuitem.gitbook.io/ciso-assistan

<br/>


> [!NOTE]
> `*` These frameworks require an extra manual step of getting the latest Excel sheet through their website as their license prevent direct usage.
Expand Down Expand Up @@ -245,8 +244,10 @@ For docker setup on a remote server or hypervisor, checkout the [specific instru

- Python 3.11+
- pip 20.3+
- poetry 1.8+
- node 18+
- npm 10.2+
- pnpm 9.0+
- yaml-cpp (brew install yaml-cpp libyaml or apt install libyaml-cpp-dev)

### Running the backend
Expand Down Expand Up @@ -317,23 +318,14 @@ export AUTH_TOKEN_TTL=900 # optional, default value is 3600 seconds (60 minutes)
export AUTH_TOKEN_AUTO_REFRESH=True # optional, default value is True. It defines if the token TTL should be refreshed automatically after each request authenticated with the token
```

3. Choose the tool of your choice, either python-venv or virtualenv. For example:
3. Install poetry

```sh
# Install python-venv
sudo apt install python-venv # or python3-venv
# Create the virtual environment venv
python -m venv venv # or python3 -m venv venv
# To enter inside the virtual environment
source venv/bin/activate
# If you want to exit the virtual environment once finished
deactivate
```
Visit the poetry website for instructions: https://python-poetry.org/docs/#installation

4. Install required dependencies.

```sh
pip install -r requirements.txt
poetry install
```

5. Recommended: Install the pre-commit hooks.
Expand All @@ -357,21 +349,21 @@ pre-commit install
7. Apply migrations.

```sh
python manage.py migrate
poetry run python manage.py migrate
```

8. Create a Django superuser, that will be CISO Assistant administrator.

> If you have set a mailer and CISO_SUPERUSER_EMAIL variable, there's no need to create a Django superuser with `createsuperuser`, as it will be created automatically on first start. You should receive an email with a link to setup your password.
```sh
python manage.py createsuperuser
poetry run python manage.py createsuperuser
```

9. Run development server.

```sh
python manage.py runserver
poetry run python manage.py runserver
```

10. Configure the git hooks for generating the build name.
Expand All @@ -393,13 +385,14 @@ cd frontend
2. Install dependencies

```bash
npm install
npm install -g pnpm
pnpm install
```

3. Start a development server (make sure that the django app is running)

```bash
npm run dev
pnpm run dev
```

4. Reach the frontend on <http://localhost:5173>
Expand All @@ -413,7 +406,7 @@ All variables in the frontend have handy default values.

If you move the frontend on another host, you should set the following variable: PUBLIC_BACKEND_API_URL. Its default value is <http://localhost:8000/api>.

When you launch "node server" instead of "npm run dev", you need to set the ORIGIN variable to the same value as CISO_ASSISTANT_URL in the backend (e.g. <http://localhost:3000>).
When you launch "node server" instead of "pnpm run dev", you need to set the ORIGIN variable to the same value as CISO_ASSISTANT_URL in the backend (e.g. <http://localhost:3000>).

### Managing migrations

Expand All @@ -431,8 +424,8 @@ find . -path "*/migrations/*.pyc" -delete
After a change (or a clean), it is necessary to re-generate migration files:

```sh
python manage.py makemigrations
python manage.py migrate
poetry run python manage.py makemigrations
poetry run python manage.py migrate
```

These migration files should be tracked by version control.
Expand Down Expand Up @@ -462,12 +455,12 @@ To interact with it:

## Setting CISO Assistant for production

The docker-compose.yml highlights a relevant configuration with a Caddy proxy in front of the frontend.
The docker-compose-prod.yml highlights a relevant configuration with a Caddy proxy in front of the frontend. It exposes API calls only for SSO. Note that docker-compose.yml exposes the full API, which is not yet recommended for production.

Set DJANGO_DEBUG=False for security reason.

> [!NOTE]
> The frontend cannot infer the host automatically, so you need to either set the ORIGIN variable, or the HOST_HEADER and PROTOCOL_HEADER variables. Please see [the sveltekit doc](https://kit.svelte.dev/docs/adapter-node#environment-variables-origin-protocolheader-hostheader-and-port-header) on this tricky issue. Beware that this approach does not work with "npm run dev", which should not be a worry for production.
> The frontend cannot infer the host automatically, so you need to either set the ORIGIN variable, or the HOST_HEADER and PROTOCOL_HEADER variables. Please see [the sveltekit doc](https://kit.svelte.dev/docs/adapter-node#environment-variables-origin-protocolheader-hostheader-and-port-header) on this tricky issue. Beware that this approach does not work with "pnpm run dev", which should not be a worry for production.
> [!NOTE]
> Caddy needs to receive a SNI header. Therefore, for your public URL (the one declared in CISO_ASSISTANT_URL), you need to use a FQDN, not an IP address, as the SNI is not transmitted by a browser if the host is an IP address. Another tricky issue!
Expand Down
2 changes: 2 additions & 0 deletions backend/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def get_sorted_requirement_nodes_rec(start: list) -> dict:
"is_scored": req_as.is_scored if req_as else None,
"score": req_as.score if req_as else None,
"max_score": max_score if req_as else None,
"question": req_as.answer if req_as else None,
"mapping_inference": req_as.mapping_inference if req_as else None,
"status_display": req_as.get_status_display() if req_as else None,
"status_i18n": camel_case(req_as.status) if req_as else None,
Expand Down Expand Up @@ -320,6 +321,7 @@ def get_sorted_requirement_nodes_rec(start: list) -> dict:
"is_scored": child_req_as.is_scored if child_req_as else None,
"score": child_req_as.score if child_req_as else None,
"max_score": max_score if child_req_as else None,
"question": child_req_as.answer if child_req_as else None,
"mapping_inference": child_req_as.mapping_inference
if child_req_as
else None,
Expand Down
Loading

0 comments on commit 2261e12

Please sign in to comment.