forked from username/flaskpaste
validate MIN_ENTROPY config bounds [0, 8]
This commit is contained in:
@@ -42,9 +42,11 @@ class Config:
|
||||
# Minimum entropy requirement (0 = disabled)
|
||||
# Encrypted data has ~7.5-8.0 bits/byte, plaintext ~4.0-5.0
|
||||
# Set to 6.0+ to effectively require encryption
|
||||
MIN_ENTROPY = float(os.environ.get("FLASKPASTE_MIN_ENTROPY", 0))
|
||||
_min_entropy_raw = float(os.environ.get("FLASKPASTE_MIN_ENTROPY", 0))
|
||||
MIN_ENTROPY = max(0.0, min(8.0, _min_entropy_raw)) # Clamp to valid range [0, 8]
|
||||
# Minimum size for entropy check (small data has unreliable entropy measurement)
|
||||
MIN_ENTROPY_SIZE = int(os.environ.get("FLASKPASTE_MIN_ENTROPY_SIZE", 256))
|
||||
_min_entropy_size_raw = int(os.environ.get("FLASKPASTE_MIN_ENTROPY_SIZE", 256))
|
||||
MIN_ENTROPY_SIZE = max(1, _min_entropy_size_raw) # Must be positive
|
||||
|
||||
# Require binary content (reject recognizable formats)
|
||||
# Rejects content with known magic bytes (PNG, JPEG, PDF, etc.) and UTF-8 text.
|
||||
|
||||
Reference in New Issue
Block a user