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

entrypoint appends to the config file, resulting in errors after #36

Open
dominikborkowski opened this issue Aug 29, 2023 · 0 comments
Open

Comments

@dominikborkowski
Copy link

Hello,

First of all, thanks for all the hard work on this container setup. We've done it in the past, but never as comprehensive as this project.

There is a small issue with how the PHP config is written. Namely, it appends on each container start, rather than overwriting it, and it's visible only when the PHP error logging is enabled. This becomes an issue if the container is restarted: the main page doesn't redirect to login.php, and all pages show a fair number of warnings (that number increments with each container restart).

https://github.com/cytopia/docker-dvwa/blob/master/docker/entrypoint.sh#L113

main page:
image

login page:
image

One way to solve it would be to write out the entire file via entrypoint, without having a static config + dynamic append. For example, a combined version:

###
### Create configuration
###

cat > /var/www/html/config/config.inc.php <<EOF
<?php

# If you are having problems connecting to the MySQL database and all of the variables below are correct
# try changing the 'db_server' variable from localhost to 127.0.0.1. Fixes a problem due to sockets.
#   Thanks to @digininja for the fix.

# Database management system to use
\$DBMS = 'MySQL';

# Database variables
#   WARNING: The database specified under db_database WILL BE ENTIRELY DELETED during setup.
#   Please use a database dedicated to DVWA.
#
# If you are using MariaDB then you cannot use root, you must use create a dedicated DVWA user.
#   See README.md for more information on this.
\$_DVWA = array();
\$_DVWA[ 'db_port'] = '3306';
\$_DVWA[ 'db_server' ]   = '${MYSQL_HOSTNAME}';
\$_DVWA[ 'db_database' ] = '${MYSQL_DATABASE}';
\$_DVWA[ 'db_user' ]     = '${MYSQL_USERNAME}';
\$_DVWA[ 'db_password' ] = '${MYSQL_PASSWORD}';

\$_DVWA[ 'recaptcha_public_key' ]  = '${DEF_RECAPTCHA_PUB_KEY}';
\$_DVWA[ 'recaptcha_private_key' ] = '${DEF_RECAPTCHA_PRIV_KEY}';
\$_DVWA[ 'default_security_level' ] = '${DEF_SECURITY_LEVEL}';
\$_DVWA[ 'default_phpids_level' ] = '${DEF_PHPIDS_ENABLED}';
\$_DVWA[ 'default_phpids_verbose' ] = '${DEF_PHPIDS_VERBOSE}';

define ("MYSQL", "mysql");
define ("SQLITE", "sqlite");
# TODO: make this configurable via docker env vars
\$_DVWA["SQLI_DB"]    = MYSQL;
#\$_DVWA["SQLI_DB"]   = SQLITE;
#\$_DVWA["SQLITE_DB"] = "sqli.db";
?>
EOF

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant