validation_rules.yaml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. # Asset Validation Rules Configuration
  2. # This file defines validation rules and constraints for different asset types
  3. audio_validation:
  4. wav:
  5. max_size_mb: 50
  6. min_size_bytes: 1024
  7. allowed_sample_rates: [16000, 22050, 44100, 48000]
  8. allowed_channels: [1, 2]
  9. allowed_bit_depths: [16, 24, 32]
  10. max_duration_seconds: 300
  11. require_valid_header: true
  12. mp3:
  13. max_size_mb: 20
  14. min_size_bytes: 512
  15. allowed_bitrates: [128, 192, 256, 320]
  16. max_duration_seconds: 600
  17. require_id3_tag: false
  18. ogg:
  19. max_size_mb: 30
  20. min_size_bytes: 1024
  21. max_duration_seconds: 600
  22. require_vorbis_codec: true
  23. image_validation:
  24. png:
  25. max_size_mb: 10
  26. min_size_bytes: 100
  27. max_width: 4096
  28. max_height: 4096
  29. min_width: 16
  30. min_height: 16
  31. allow_transparency: true
  32. require_valid_signature: true
  33. jpeg:
  34. max_size_mb: 10
  35. min_size_bytes: 100
  36. max_width: 4096
  37. max_height: 4096
  38. min_width: 16
  39. min_height: 16
  40. max_quality: 95
  41. min_quality: 60
  42. gif:
  43. max_size_mb: 5
  44. min_size_bytes: 100
  45. max_width: 2048
  46. max_height: 2048
  47. max_frames: 100
  48. max_duration_seconds: 30
  49. text_validation:
  50. json:
  51. max_size_mb: 5
  52. min_size_bytes: 2
  53. required_encoding: "utf-8"
  54. validate_syntax: true
  55. max_nesting_depth: 20
  56. allow_comments: false
  57. yaml:
  58. max_size_mb: 2
  59. min_size_bytes: 1
  60. required_encoding: "utf-8"
  61. validate_syntax: true
  62. max_nesting_depth: 15
  63. allow_duplicate_keys: false
  64. plain:
  65. max_size_mb: 1
  66. min_size_bytes: 0
  67. allowed_encodings: ["utf-8", "ascii"]
  68. max_line_length: 1000
  69. check_binary_content: true
  70. config_validation:
  71. json_config:
  72. extends: "text.json"
  73. require_schema_validation: true
  74. required_fields: ["version", "name"]
  75. validate_references: true
  76. yaml_config:
  77. extends: "text.yaml"
  78. require_schema_validation: true
  79. required_fields: ["version", "name"]
  80. validate_references: true
  81. security_rules:
  82. scan_patterns:
  83. - name: "script_injection"
  84. severity: "high"
  85. patterns:
  86. - '<script[^>]*>.*?</script>'
  87. - 'javascript:'
  88. - 'on\w+\s*='
  89. - name: "file_inclusion"
  90. severity: "medium"
  91. patterns:
  92. - '\.\./.*\.\./'
  93. - 'file://'
  94. - '\\\\.*\\\\'
  95. - name: "command_injection"
  96. severity: "high"
  97. patterns:
  98. - '[;&|`$]'
  99. - 'eval\s*\('
  100. - 'exec\s*\('
  101. file_permissions:
  102. max_permissions: "644"
  103. warn_world_readable: true
  104. warn_world_writable: true
  105. scan_executables: true
  106. performance_rules:
  107. size_warnings:
  108. audio:
  109. large_file_mb: 25
  110. very_large_file_mb: 50
  111. image:
  112. large_file_mb: 5
  113. very_large_file_mb: 10
  114. text:
  115. large_file_kb: 500
  116. very_large_file_kb: 1000
  117. resolution_warnings:
  118. image:
  119. high_resolution_pixels: 4000000 # 4 megapixels
  120. very_high_resolution_pixels: 16000000 # 16 megapixels
  121. quality_suggestions:
  122. audio:
  123. recommend_sample_rate: 44100
  124. recommend_channels: 2
  125. recommend_bit_depth: 16
  126. image:
  127. recommend_compression: true
  128. recommend_format: "png"
  129. validation_profiles:
  130. strict:
  131. treat_warnings_as_errors: true
  132. enable_security_checks: true
  133. enable_performance_checks: true
  134. require_metadata_validation: true
  135. standard:
  136. treat_warnings_as_errors: false
  137. enable_security_checks: true
  138. enable_performance_checks: true
  139. require_metadata_validation: false
  140. permissive:
  141. treat_warnings_as_errors: false
  142. enable_security_checks: false
  143. enable_performance_checks: false
  144. require_metadata_validation: false
  145. metadata:
  146. version: "1.0.0"
  147. schema_version: "1.0"
  148. last_updated: "2024-01-01"
  149. description: "Comprehensive validation rules for Trixy asset management"
  150. applies_to: ["trixy_core.assets"]