Initial release: Go Jdenticon library v0.1.0
- Core library with SVG and PNG generation - CLI tool with generate and batch commands - Cross-platform path handling for Windows compatibility - Comprehensive test suite with integration tests
This commit is contained in:
22
internal/constants/limits.go
Normal file
22
internal/constants/limits.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package constants
|
||||
|
||||
// Default security limits for DoS protection.
|
||||
// These constants define safe default values for user inputs to prevent
|
||||
// denial of service attacks through resource exhaustion while remaining configurable.
|
||||
|
||||
// DefaultMaxIconSize is the default maximum dimension (width or height) for a generated icon.
|
||||
// A 4096x4096 RGBA image requires ~64MB of memory, which is generous for legitimate
|
||||
// use while preventing unbounded memory allocation attacks.
|
||||
// This limit is stricter than the JavaScript reference implementation for enhanced security.
|
||||
const DefaultMaxIconSize = 4096
|
||||
|
||||
// DefaultMaxInputLength is the default maximum number of bytes for the input string to be hashed.
|
||||
// 1MB is sufficient for any reasonable identifier and prevents hash computation DoS attacks.
|
||||
// Input strings longer than this are rejected before hashing begins.
|
||||
const DefaultMaxInputLength = 1 * 1024 * 1024 // 1 MB
|
||||
|
||||
// DefaultMaxComplexity is the default maximum geometric complexity score for an identicon.
|
||||
// This score is calculated as the sum of complexity points for all shapes in an identicon.
|
||||
// A complexity score of 100 allows for diverse identicons while preventing resource exhaustion.
|
||||
// This value may be adjusted based on empirical analysis of typical identicon complexity.
|
||||
const DefaultMaxComplexity = 100
|
||||
Reference in New Issue
Block a user