forked from claw/flaskpaste
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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user