entropy: exempt small content from check

Small data has unreliable entropy measurement due to sample size.
MIN_ENTROPY_SIZE (default 256 bytes) sets the threshold.
This commit is contained in:
Username
2025-12-20 08:48:13 +01:00
parent 8addf2d9e8
commit 7deba711d4
4 changed files with 23 additions and 6 deletions

View File

@@ -455,7 +455,8 @@ def create_paste():
# Check minimum entropy requirement (encryption enforcement)
min_entropy = current_app.config.get("MIN_ENTROPY", 0)
if min_entropy > 0:
min_entropy_size = current_app.config.get("MIN_ENTROPY_SIZE", 256)
if min_entropy > 0 and content_size >= min_entropy_size:
entropy = _calculate_entropy(content)
if entropy < min_entropy:
current_app.logger.warning(