Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add server_config.json reference page #4274

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
220 changes: 188 additions & 32 deletions docs/content/reference/server-configuration.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,208 @@
---
title: "Server configuration"
draft: true
pre: '<i class="fas fa-cogs"></i> '
draft: false
description: "Reference material for the server_config.json file"
pre: "<i class='fa fa-cogs'></i> "
---
{{< table_of_contents >}}

## Configuring the Monkey Island
## Configuration

The Monkey Island Server is configured through the `server_config.json` file.
<!--
This documentation was autogenerated by passing the plugin's config-schema.json
through https://github.com/adobe/jsonschema2md. It was then modified by hand to
remove extraneous information.
-->

{{% notice info %}}
Refer to the [setup guides](../../setup/) to learn how to use
the `server_config.json` file for each deployment.
{{% /notice %}}
| Property | Type | Required | Nullable |
| :----------------------------------- | :-------- | :------- | :------------- |
| [data\_dir](#data_dir) | `string` | Optional | cannot be null |
| [log\_level](#log_level) | `string` | Optional | cannot be null |
| [mongodb](#mongodb) | `object` | Optional | cannot be null |
| [ssl\_certificate](#ssl_certificate) | `object` | Optional | cannot be null |
| [island\_port](#island_port) | `integer` | Optional | cannot be null |

### Creating a configuration file
### data\_dir

The directory where the Island will store runtime artifacts.

`data_dir`

* is optional

* Type: `string`

* cannot be null

#### data\_dir Constraints

The value of this string must be a valid path.

#### data\_dir Default Value

The default value for Windows is:

```json
"%AppData%\\monkey_island"
```

The default value for Linux is:

```json
"$HOME/.monkey_island"
```

### log\_level

The threshold for the Island logger.

`log_level`

* is optional

* Type: `string`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we list the acceptable values?

Copy link
Contributor Author

@shreyamalviya shreyamalviya Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have any constraints on the value in the code. It doesn't make sense to add it ourselves in the reference documentation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth adding the constraints in the code.


* cannot be null

#### log\_level Default Value

The default value is:

```json
"INFO"
```

### mongodb

The MongoDB configuration for the Island server.

`mongodb`

* is optional

* Type: `object`

* cannot be null

#### mongodb Properties
**_start\_mongodb_**

If enabled, the MongoDB server will be started automatically with the Island.

`start_mongodb`

* is optional

* Type: `boolean`

* cannot be null

_start\_mongodb Default Value_

The default value is:

```json
true
```

#### mongodb Default Value

The default value is:

Here's an example `server_config.json` with all options specified:
```json
{
"island_port": 443,
"log_level": "DEBUG",
"ssl_certificate": {
"ssl_certificate_file": "<PATH_TO_CRT_FILE>",
"ssl_certificate_key_file": "<PATH_TO_KEY_FILE>"
},
"mongodb": {
"start_mongodb": true
},
"data_dir": "/monkey_island_data"
"start_mongodb": true
}
```

Only relevant options can be specified, for example:
### ssl\_certificate

The SSL certificates configuration for the Island server.

`ssl_certificate`

* is optional

* Type: `object`

* cannot be null

#### ssl\_certificate Properties
**_ssl\_certificate\_file_**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should nix the header at this level and do #### ssl_certificate_file and #### ssl_certificate_key_file. At the top level, there's no header for "properties". In other words, Under ## Configuration there is not ### Configuration Properties.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for mongo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly fine to me except that "start_mongodb" and "mongodb Default Value" are both h4.
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could omit "mongodb Default value". All of mongodb's properties have default values, so you can extrapolate the default value of the whole object from there. You could also provide an example of the whole file in a different subsection at the same level as ### Configuration Properties.


The path to the SSL certificate file that the Island server will use.

`ssl_certificate_file`

* is optional

* Type: `string`

* cannot be null

_ssl\_certificate\_file Constraints_

The value of this string must be a valid path.

_ssl\_certificate\_file Default Value_

The default value is:

```json
"<infection_monkey_installation_path>\\monkey_island\\cc\\server.crt"
```

**_ssl\_certificate\_key\_file_**

The path to the SSL certificate key file that the Island server will use.

`ssl_certificate_key_file`

* is optional

* Type: `string`

* cannot be null

_ssl\_certificate\_key\_file Constraints_

The value of this string must be a valid path.

_ssl\_certificate\_key\_file Default Value_

The default value is:

```json
"<infection_monkey_installation_path>\\monkey_island\\cc\\server.key"
```

#### ssl\_certificate Default Value

The default value is:

```json
{
"ssl_certificate": {
"ssl_certificate_file": "<PATH_TO_CRT_FILE>",
"ssl_certificate_key_file": "<PATH_TO_KEY_FILE>"
}
"ssl_certificate_file": "<infection_monkey_installation_path>\\monkey_island\\cc\\server.crt",
"ssl_certificate_key_file": "<infection_monkey_installation_path>\\monkey_island\\cc\\server.key"
}
```

### Configuration options
### island\_port

The port on which the Island server should listen.

`island_port`

* is optional

See setup instructions for your operating system to understand how to apply these.
* Type: `integer`

- `island_port` - Port used by the Island C&C server. Default is `443`.
- `log_level` - can be set to `"DEBUG"`(verbose), `"INFO"`(less verbose) or `"ERROR"`(silent, except errors).
- `ssl_certificate` - contains paths for files, required to run the Island Server with custom certificate.
- `data_dir` - path to a writeable directory where the Island will store the database and other files.
- `mongodb` - options for MongoDB. Should not be changed unless you want to run your own instance of MongoDB.
* cannot be null

#### island\_port Default Value

The default value is:

```json
443
```
46 changes: 38 additions & 8 deletions monkey/monkey_island/cc/setup/island_config_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,52 @@


class MongoDBConfig(InfectionMonkeyBaseModel):
start_mongodb: bool = DEFAULT_START_MONGO_DB
start_mongodb: bool = Field(
default=DEFAULT_START_MONGO_DB,
description="If enabled, the MongoDB server will be started automatically with the Island.",
)


# TODO: rename redundant ssl_certificate_file and split the classes into idividual files
class SSLCertificatesConfig(InfectionMonkeyBaseModel):
ssl_certificate_file: Annotated[
Path, Field(default=Path(DEFAULT_CRT_PATH)), BeforeValidator(expand_path)
Path,
Field(
default=Path(DEFAULT_CRT_PATH),
description="The path to the SSL certificate file that the Island server will use.",
),
BeforeValidator(expand_path),
]
ssl_certificate_key_file: Annotated[
Path, Field(default=Path(DEFAULT_KEY_PATH)), BeforeValidator(expand_path)
Path,
Field(
default=Path(DEFAULT_KEY_PATH),
description="The path to the SSL certificate key file that the Island server will use.",
),
BeforeValidator(expand_path),
]


class IslandConfigOptions(InfectionMonkeyBaseModel):
data_dir: Annotated[Path, Field(default=DEFAULT_DATA_DIR), BeforeValidator(expand_path)]
log_level: str = DEFAULT_LOG_LEVEL
mongodb: MongoDBConfig = MongoDBConfig()
ssl_certificate: SSLCertificatesConfig = SSLCertificatesConfig()
island_port: int = DEFAULT_ISLAND_PORT
data_dir: Annotated[
Path,
Field(
default=DEFAULT_DATA_DIR,
description="The directory where the Island will store runtime artifacts.",
),
BeforeValidator(expand_path),
]
log_level: str = Field(
default=DEFAULT_LOG_LEVEL, description="The threshold for the Island logger."
shreyamalviya marked this conversation as resolved.
Show resolved Hide resolved
)
mongodb: MongoDBConfig = Field(
default=MongoDBConfig(), description="The MongoDB configuration for the Island server."
)
ssl_certificate: SSLCertificatesConfig = Field(
default=SSLCertificatesConfig(),
description="The SSL certificates configuration for the Island server.",
)
island_port: int = Field(
default=DEFAULT_ISLAND_PORT,
description="The port on which the Island server should listen.",
)