Skip to content

Commit a13c1dd

Browse files
committed
Added the copilot module to the repo including the docs and instruction instructions. Updated all old references to Cases with NC3.
1 parent d736f5d commit a13c1dd

26 files changed

Lines changed: 556 additions & 214 deletions

.env.dev

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,14 @@ STATS_SECRET_KEY=changeme_generate_random_secret_key_for_production
3737
# Stats API Key - Leave empty on first run, it will be generated by the stats service
3838
# After first run, get it from the stats service logs or container
3939
STATS_API_KEY=
40+
41+
# Copilot Configuration
42+
IS_COPILOT_ENABLED=0
43+
COPILOT_OLLAMA_ENABLED=1
44+
COPILOT_OLLAMA_TRANSPORT=openai-chat
45+
COPILOT_OLLAMA_BASE_URL=http://127.0.0.1:11434
46+
COPILOT_OLLAMA_ENDPOINT_PATH=/chat/completions
47+
COPILOT_OLLAMA_MODEL=llama-70b
48+
COPILOT_OLLAMA_API_KEY=
49+
COPILOT_OLLAMA_JSON_MODE=0
50+
COPILOT_OLLAMA_TIMEOUT=20

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ data/*
2727
.env
2828
.docker-initialized
2929
docker/db_data
30-
.vscode
30+
.vscode

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ MONARC Changelog
619619
- the MONARC core objects (assets, threats, vulnerabilities and risks) are now
620620
identified with UUIDs. We published the objects on the
621621
[MONARC objects sharing platform](https://objects.monarc.lu). Risks from
622-
the CASES models are also [available](https://objects.monarc.lu/schema/16);
622+
the NC3 models are also [available](https://objects.monarc.lu/schema/16);
623623
- Assets, threats, vulnerabilities, risks and referentials can be imported
624624
in the knowledge base of your analysis from MOSP without leaving the MONARC
625625
user interface.

INSTALL/INSTALL.debian10.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,8 @@ In your MariaDB interpreter:
139139
MariaDB [(none)]> CREATE DATABASE monarc_cli DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
140140
MariaDB [(none)]> CREATE DATABASE monarc_common DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
141141

142-
* monarc_common contains models and data created by CASES;
143-
* monarc_cli contains all client risk analyses. Each analysis is based on CASES
144-
model of monarc_common.
142+
* monarc_common contains models and data created by NC3;
143+
* monarc_cli contains all client risk analyses. Each analysis is based on NC3 model of monarc_common.
145144

146145
### Initializes the database
147146

INSTALL/INSTALL.ubuntu1604.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,8 @@ There are 2 parts:
126126
CREATE DATABASE monarc_cli DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
127127
CREATE DATABASE monarc_common DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
128128

129-
* monarc_common contains models and data created by CASES;
130-
* monarc_cli contains all client risk analyses. Each analysis is based on CASES
131-
model of monarc_common.
129+
* monarc_common contains models and data created by NC3;
130+
* monarc_cli contains all client risk analyses. Each analysis is based on NC3 model of monarc_common.
132131

133132
### Initializes the database
134133

INSTALL/INSTALL.ubuntu1804.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ In your MariaDB interpreter:
136136
MariaDB [(none)]> CREATE DATABASE monarc_cli DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
137137
MariaDB [(none)]> CREATE DATABASE monarc_common DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
138138

139-
* monarc_common contains models and data created by CASES;
140-
* monarc_cli contains all client risk analyses. Each analysis is based on CASES
141-
model of monarc_common.
139+
* monarc_common contains models and data created by NC3;
140+
* monarc_cli contains all client risk analyses. Each analysis is based on NC3 model of monarc_common.
142141

143142
### Initializes the database
144143

INSTALL/INSTALL.ubuntu2004.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,8 @@ MariaDB [(none)]> CREATE DATABASE monarc_cli DEFAULT CHARACTER SET utf8 DEFAULT
130130
MariaDB [(none)]> CREATE DATABASE monarc_common DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
131131
```
132132

133-
* monarc_common contains models and data created by CASES;
134-
* monarc_cli contains all client risk analyses. Each analysis is based on CASES
135-
model of monarc_common.
133+
* monarc_common contains models and data created by NC3;
134+
* monarc_cli contains all client risk analyses. Each analysis is based on NC3 model of monarc_common.
136135

137136
### Initializes the database
138137

INSTALL/INSTALL.ubuntu2204.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,8 @@ CREATE DATABASE monarc_cli DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_gener
160160
CREATE DATABASE monarc_common DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
161161
```
162162

163-
* monarc_common contains models and data created by CASES;
164-
* monarc_cli contains all client risk analyses. Each analysis is based on CASES
165-
model of monarc_common.
163+
* monarc_common contains models and data created by NC3;
164+
* monarc_cli contains all client risk analyses. Each analysis is based on NC3 model of monarc_common.
166165

167166
### Initializes the database
168167

INSTALL/INSTALL.ubuntu2404.md

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ CREATE DATABASE monarc_cli DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_gener
123123
CREATE DATABASE monarc_common DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
124124
```
125125

126-
* monarc_common contains models and data created by CASES;
127-
* monarc_cli contains all client risk analyses. Each analysis is based on CASES model of monarc_common.
126+
* monarc_common contains models and data created by NC3;
127+
* monarc_cli contains all client risk analyses. Each analysis is based on NC3 model of monarc_common.
128128

129129
## 4.3 Initialize the database
130130

@@ -185,6 +185,71 @@ php ./vendor/robmorgan/phinx/bin/phinx seed:run -c ./module/Monarc/FrontOffice/m
185185
The username is *admin@admin.localhost* and the password is *admin*.
186186

187187

188+
## 4.7 Enable Copilot (optional)
189+
190+
Recent FrontOffice releases already include the `monarc/copilot` Composer dependency. For custom source deployments, ensure dependencies are installed:
191+
192+
```bash
193+
composer install
194+
```
195+
196+
Create the Laminas module symlink:
197+
198+
```bash
199+
cd /var/lib/monarc/fo
200+
mkdir -p module/Monarc
201+
ln -sfn ./../../vendor/monarc/copilot module/Monarc/Copilot
202+
```
203+
204+
Enable the feature flag in `config/autoload/local.php`:
205+
206+
```php
207+
'isCopilotEnabled' => true,
208+
```
209+
210+
Create the Copilot runtime configuration:
211+
212+
```bash
213+
cp ./config/autoload/copilot.local.php.dist ./config/autoload/copilot.local.php
214+
nano ./config/autoload/copilot.local.php
215+
```
216+
217+
Example configuration:
218+
219+
```php
220+
<?php
221+
222+
return [
223+
'copilot' => [
224+
'ollama' => [
225+
'enabled' => true,
226+
'transport' => 'openai-chat',
227+
'baseUrl' => 'http://127.0.0.1:11434',
228+
'endpointPath' => '/chat/completions',
229+
'model' => 'llama-70b',
230+
'apiKey' => '',
231+
'jsonMode' => false,
232+
'timeout' => 20,
233+
],
234+
],
235+
];
236+
```
237+
238+
Refresh the linked frontend resources:
239+
240+
```bash
241+
./scripts/update-all.sh -d
242+
```
243+
244+
Restart Apache:
245+
246+
```bash
247+
sudo apachectl restart
248+
```
249+
250+
After login, the `Show copilot` button is available on ANR pages when `isCopilotEnabled` is enabled and the configured LLM endpoint is reachable.
251+
252+
188253
# 5. Statistics for Global Dashboard
189254

190255
If you would like to use the global dashboard stats feature, you need to

README.docker.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@ This guide explains how to set up a local development environment for MONARC Fro
9797
- Username: `admin@admin.localhost`
9898
- Password: `admin`
9999

100+
8. **(Optional) Enable Copilot**:
101+
Edit `.env` and configure the Copilot variables:
102+
```bash
103+
IS_COPILOT_ENABLED=1
104+
COPILOT_OLLAMA_ENABLED=1
105+
COPILOT_OLLAMA_TRANSPORT=openai-chat
106+
COPILOT_OLLAMA_BASE_URL=http://127.0.0.1:11434
107+
COPILOT_OLLAMA_ENDPOINT_PATH=/chat/completions
108+
COPILOT_OLLAMA_MODEL=llama-70b
109+
COPILOT_OLLAMA_API_KEY=
110+
COPILOT_OLLAMA_JSON_MODE=0
111+
COPILOT_OLLAMA_TIMEOUT=20
112+
```
113+
Then restart the application container:
114+
```bash
115+
docker compose -f docker-compose.dev.yml restart monarcfoapp
116+
```
117+
100118
## Services
101119

102120
The development environment includes the following services:
@@ -230,6 +248,31 @@ docker compose -f docker-compose.dev.yml down -v
230248

231249
## Common Tasks
232250

251+
### Enabling Copilot
252+
253+
The Docker entrypoint prepares Copilot automatically on startup:
254+
255+
- creates `module/Monarc/Copilot`
256+
- writes `config/autoload/copilot.local.php` from environment variables
257+
- recreates `public/js/copilot/CopilotWidget.js`
258+
- recreates `public/css/copilot/copilot.css`
259+
260+
To enable the UI:
261+
262+
1. Set `IS_COPILOT_ENABLED=1` in `.env`
263+
2. Point `COPILOT_OLLAMA_BASE_URL` to a reachable LLM endpoint
264+
3. Restart the application container:
265+
```bash
266+
docker compose -f docker-compose.dev.yml restart monarcfoapp
267+
```
268+
269+
If the Copilot button is still missing, verify:
270+
271+
- `docker compose -f docker-compose.dev.yml exec monarcfoapp ls -l module/Monarc/Copilot`
272+
- `docker compose -f docker-compose.dev.yml exec monarcfoapp ls -l public/js/copilot public/css/copilot`
273+
- `docker compose -f docker-compose.dev.yml exec monarcfoapp cat config/autoload/copilot.local.php`
274+
- `docker compose -f docker-compose.dev.yml logs monarcfoapp`
275+
233276
### Using BackOffice monarc_common
234277

235278
To reuse the BackOffice `monarc_common` database:

0 commit comments

Comments
 (0)