Skip to content

Commit

Permalink
Update set_up_proxy(), add DEBUG envar, minor fixes (#71)
Browse files Browse the repository at this point in the history
* added missing PROXY_ENABLE envar to docker-compose.yml

add default value of false is PROXY_ENABLE unset

altered set_up_proxy() in configure_misp.sh to use json-based config system

fixed MISP.ca_path setting to use --force, since doesn't end in .pem

* Add DEBUG envar

Works in both config.php and system_settings table.
  • Loading branch information
UFOSmuggler authored Jun 11, 2024
1 parent da3e3ae commit 261c541
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 12 deletions.
18 changes: 7 additions & 11 deletions core/files/configure_misp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ source /utilities.sh
[ -z "$OIDC_ENABLE" ] && OIDC_ENABLE="false"
[ -z "$LDAP_ENABLE" ] && LDAP_ENABLE="false"
[ -z "$ENABLE_DB_SETTINGS" ] && ENABLE_DB_SETTINGS="false"
[ -z "$PROXY_ENABLE" ] && PROXY_ENABLE="false"
[ -z "$DEBUG" ] && DEBUG=0

# We now use envsubst for safe variable substitution with pseudo-json objects for env var enforcement
# envsubst won't evaluate anything like $() or conditional variable expansion so lets do that here
Expand Down Expand Up @@ -202,18 +204,12 @@ set_up_aad() {
}

set_up_proxy() {
if [[ "$PROXY_ENABLE" != "true" ]]; then
if [[ "$PROXY_ENABLE" == "true" ]]; then
echo "... configuring proxy settings"
init_settings "proxy"
else
echo "... Proxy disabled"
return
fi

echo "... configuring proxy settings"

sudo -u www-data /var/www/MISP/app/Console/cake Admin setSetting -q "Proxy.host" "$PROXY_HOST"
sudo -u www-data /var/www/MISP/app/Console/cake Admin setSetting -q "Proxy.port" "$PROXY_PORT"
sudo -u www-data /var/www/MISP/app/Console/cake Admin setSetting -q "Proxy.method" "$PROXY_METHOD"
sudo -u www-data /var/www/MISP/app/Console/cake Admin setSetting -q "Proxy.user" "$PROXY_USER"
sudo -u www-data /var/www/MISP/app/Console/cake Admin setSetting -q "Proxy.password" "$PROXY_PASSWORD"
}

apply_updates() {
Expand Down Expand Up @@ -468,4 +464,4 @@ echo "MISP | Set Up AAD ..." && set_up_aad
echo "MISP | Set Up Proxy ..." && set_up_proxy

echo "MISP | Mark instance live"
sudo -u www-data /var/www/MISP/app/Console/cake Admin live 1
sudo -u www-data /var/www/MISP/app/Console/cake Admin live 1
3 changes: 2 additions & 1 deletion core/files/etc/misp-docker/cli_only.defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"default_value": false
},
"MISP.ca_path": {
"default_value": "/etc/ssl/certs/ca-certificates.crt"
"default_value": "/etc/ssl/certs/ca-certificates.crt",
"command_args": "-f"
},
"MISP.menu_custom_right_link": {
"default_value": ""
Expand Down
4 changes: 4 additions & 0 deletions core/files/etc/misp-docker/initialisation.envars.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"debug": {
"default_value": "${DEBUG}",
"command_args": "-f"
},
"MISP.baseurl": {
"default_value": "${BASE_URL}"
},
Expand Down
17 changes: 17 additions & 0 deletions core/files/etc/misp-docker/proxy.envars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"Proxy.host": {
"default_value": "${PROXY_HOST}"
},
"Proxy.port": {
"default_value": "${PROXY_PORT}"
},
"Proxy.method": {
"default_value": "${PROXY_METHOD}"
},
"Proxy.user": {
"default_value": "${PROXY_USER}"
},
"Proxy.password": {
"default_value": "${PROXY_PASSWORD}"
}
}
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ services:
- "AAD_MISP_SITEADMIN=${AAD_MISP_SITEADMIN}"
- "AAD_CHECK_GROUPS=${AAD_CHECK_GROUPS}"
# Proxy settings
- "PROXY_ENABLE=${PROXY_ENABLE}"
- "PROXY_HOST=${PROXY_HOST}"
- "PROXY_PORT=${PROXY_PORT}"
- "PROXY_METHOD=${PROXY_METHOD}"
Expand All @@ -153,6 +154,8 @@ services:
- "MYSQL_USER=${MYSQL_USER:-misp}"
- "MYSQL_PASSWORD=${MYSQL_PASSWORD:-example}"
- "MYSQL_DATABASE=${MYSQL_DATABASE:-misp}"
# Debug setting
- "DEBUG=${DEBUG}"

misp-modules:
image: ghcr.io/misp/misp-docker/misp-modules:latest
Expand Down
7 changes: 7 additions & 0 deletions template.env
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,10 @@ SYNCSERVERS_1_KEY=
# PROXY_METHOD=
# PROXY_USER=
# PROXY_PASSWORD=

# Enable debugging
# ALWAYS SET THIS TO 0 IN PRODUCTION
# 0 - Debug off (default)
# 1 - Debug on
# 2 - Debug on + SQL dump
# DEBUG=

0 comments on commit 261c541

Please sign in to comment.