Skip to content

Prevent leaking data by log file, by not placing the log file in the website public_html - #36

Open
rmpel wants to merge 2 commits into
OpenWebconcept:mainfrom
rmpel:feature/prevent-data-leak-by-log
Open

rmpel wants to merge 2 commits into
OpenWebconcept:mainfrom
rmpel:feature/prevent-data-leak-by-log

Conversation

@rmpel

@rmpel rmpel commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Issue on composer based websites, probably also applicable on other plugins.

The default log file location dirname(ABSPATH) resolves to public_html when WordPress is installed in a subdirectory, as is normal when installing with composer.

This patch allows 3 methods of moving the log files to a secure location.

@mvdhoek1 mvdhoek1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Graag ook nog documentatie van PREFILL_GRAVITY_FORMS_LOG_DIR en de pg::logger/log_directory filter.

*
* @return mixed|string|null
*/
private function getLogFilePath()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is dit niet iets eenvoudiger en zonder gebruik van env vars:

/**
 * The default dirname(ABSPATH) resolves to the public webroot when WordPress
 * is installed in a subdirectory (e.g. Bedrock), so allow overriding it.
 * Returns null when the directory is invalid, in which case file logging is skipped.
 */
private function getLogDirectory(): ?string
{
	$directory = defined('PREFILL_GRAVITY_FORMS_LOG_DIR') ? PREFILL_GRAVITY_FORMS_LOG_DIR : dirname(ABSPATH);
	$directory = apply_filters('pg::logger/log_directory', $directory);

	if (! is_string($directory) || '' === $directory || ! is_dir($directory) || ! is_writable($directory)) {
		/** This action is documented in src/PrefillGravityForms/Traits/Logger.php */
		do_action('pg::exception/intercept', new Exception(sprintf('Log directory "%s" does not exist or is not writable, file logging is disabled.', is_string($directory) ? $directory : gettype($directory)), 300), 'warning');

		return null;
	}

	return untrailingslashit($directory);
}

@rmpel

rmpel commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Als jullie een betere/mooiere oplossing hebben, ga je gang :) als ik/we uiteindelijk die files maar buiten de webroot kunnen plaatsen :)

Dank je wel.

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

Successfully merging this pull request may close these issues.

2 participants