@sun-asterisk/sunlint 1.3.39 → 1.3.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (422) hide show
  1. package/config/rules/rules-registry-generated.json +134 -108
  2. package/docs/GENERATED_FILES_QUICK_REFERENCE.md +96 -0
  3. package/docs/GENERATED_FILE_HANDLING_SUMMARY.md +152 -0
  4. package/docs/skills/CREATE_NEW_DART_RULE.md +161 -14
  5. package/origin-rules/dart-en.md +151 -163
  6. package/package.json +2 -1
  7. package/rules/dart/D002_dispose_resources/config.json +25 -0
  8. package/rules/dart/D003_prefer_widgets_over_methods/config.json +14 -0
  9. package/rules/dart/D004_avoid_shrinkwrap_listview/config.json +13 -0
  10. package/rules/dart/D005_limit_widget_nesting/config.json +13 -0
  11. package/rules/dart/D006_prefer_extracting_large_callbacks/config.json +25 -0
  12. package/rules/dart/D007_prefer_init_first_dispose_last/config.json +10 -0
  13. package/rules/dart/D008_avoid_long_functions/config.json +12 -0
  14. package/rules/dart/D009_limit_function_parameters/config.json +13 -0
  15. package/rules/dart/D010_limit_cyclomatic_complexity/config.json +12 -0
  16. package/rules/dart/D011_prefer_named_parameters/config.json +12 -0
  17. package/rules/dart/D012_prefer_named_boolean_parameters/config.json +9 -0
  18. package/rules/dart/D013_single_public_class/config.json +10 -0
  19. package/rules/dart/D014_unsafe_collection_access/config.json +10 -0
  20. package/rules/dart/D015_copywith_all_parameters/config.json +9 -0
  21. package/rules/dart/D016_project_should_have_tests/config.json +24 -0
  22. package/rules/dart/D017_pubspec_dependencies_review/config.json +23 -0
  23. package/rules/dart/D018_remove_commented_code/config.json +13 -0
  24. package/rules/dart/D019_avoid_single_child_multi_child_widget/config.json +21 -0
  25. package/rules/dart/D020_limit_if_else_branches/config.json +12 -0
  26. package/rules/dart/D021_avoid_negated_boolean_checks/config.json +14 -0
  27. package/rules/dart/D022_use_setstate_correctly/config.json +14 -0
  28. package/rules/dart/D023_avoid_unnecessary_method_overrides/config.json +13 -0
  29. package/rules/dart/D024_avoid_unnecessary_stateful_widget/config.json +9 -0
  30. package/rules/dart/D025_avoid_nested_conditional_expressions/config.json +9 -0
  31. package/skill-assets/sunlint-code-quality/AGENTS.md +80 -0
  32. package/skill-assets/sunlint-code-quality/SKILL.md +176 -0
  33. package/skill-assets/sunlint-code-quality/rules/csharp/C006-verb-noun-functions.md +36 -0
  34. package/skill-assets/sunlint-code-quality/rules/csharp/C013-no-dead-code.md +38 -0
  35. package/skill-assets/sunlint-code-quality/rules/csharp/C014-dependency-injection.md +45 -0
  36. package/skill-assets/sunlint-code-quality/rules/csharp/C017-no-constructor-logic.md +46 -0
  37. package/skill-assets/sunlint-code-quality/rules/csharp/C018-generic-errors.md +38 -0
  38. package/skill-assets/sunlint-code-quality/rules/csharp/C019-error-log-level.md +29 -0
  39. package/skill-assets/sunlint-code-quality/rules/csharp/C020-no-unused-imports.md +30 -0
  40. package/skill-assets/sunlint-code-quality/rules/csharp/C022-no-unused-variables.md +33 -0
  41. package/skill-assets/sunlint-code-quality/rules/csharp/C023-no-duplicate-names.md +36 -0
  42. package/skill-assets/sunlint-code-quality/rules/csharp/C024-centralize-constants.md +33 -0
  43. package/skill-assets/sunlint-code-quality/rules/csharp/C029-catch-log-root-cause.md +40 -0
  44. package/skill-assets/sunlint-code-quality/rules/csharp/C030-custom-error-classes.md +38 -0
  45. package/skill-assets/sunlint-code-quality/rules/csharp/C033-separate-data-access.md +53 -0
  46. package/skill-assets/sunlint-code-quality/rules/csharp/C035-error-context-logging.md +31 -0
  47. package/skill-assets/sunlint-code-quality/rules/csharp/C041-no-hardcoded-secrets.md +25 -0
  48. package/skill-assets/sunlint-code-quality/rules/csharp/C042-boolean-naming.md +27 -0
  49. package/skill-assets/sunlint-code-quality/rules/csharp/C052-controller-parsing.md +41 -0
  50. package/skill-assets/sunlint-code-quality/rules/csharp/C060-superclass-logic.md +33 -0
  51. package/skill-assets/sunlint-code-quality/rules/csharp/C067-no-hardcoded-config.md +24 -0
  52. package/skill-assets/sunlint-code-quality/rules/csharp/S003-open-redirect.md +47 -0
  53. package/skill-assets/sunlint-code-quality/rules/csharp/S004-no-log-credentials.md +28 -0
  54. package/skill-assets/sunlint-code-quality/rules/csharp/S005-server-authorization.md +51 -0
  55. package/skill-assets/sunlint-code-quality/rules/csharp/S006-default-credentials.md +42 -0
  56. package/skill-assets/sunlint-code-quality/rules/csharp/S007-output-encoding.md +36 -0
  57. package/skill-assets/sunlint-code-quality/rules/csharp/S009-approved-crypto.md +37 -0
  58. package/skill-assets/sunlint-code-quality/rules/csharp/S010-csprng.md +32 -0
  59. package/skill-assets/sunlint-code-quality/rules/csharp/S011-encrypted-client-hello.md +36 -0
  60. package/skill-assets/sunlint-code-quality/rules/csharp/S012-secrets-management.md +35 -0
  61. package/skill-assets/sunlint-code-quality/rules/csharp/S013-tls-connections.md +36 -0
  62. package/skill-assets/sunlint-code-quality/rules/csharp/S016-no-sensitive-query-string.md +39 -0
  63. package/skill-assets/sunlint-code-quality/rules/csharp/S017-parameterized-queries.md +47 -0
  64. package/skill-assets/sunlint-code-quality/rules/csharp/S019-email-input-sanitization.md +35 -0
  65. package/skill-assets/sunlint-code-quality/rules/csharp/S020-eval-code-execution.md +56 -0
  66. package/skill-assets/sunlint-code-quality/rules/csharp/S022-context-escaping.md +50 -0
  67. package/skill-assets/sunlint-code-quality/rules/csharp/S023-dynamic-js-encoding.md +34 -0
  68. package/skill-assets/sunlint-code-quality/rules/csharp/S025-server-validation.md +56 -0
  69. package/skill-assets/sunlint-code-quality/rules/csharp/S026-tls-encryption.md +28 -0
  70. package/skill-assets/sunlint-code-quality/rules/csharp/S027-mtls-validation.md +40 -0
  71. package/skill-assets/sunlint-code-quality/rules/csharp/S028-upload-limits.md +50 -0
  72. package/skill-assets/sunlint-code-quality/rules/csharp/S029-csrf-protection.md +42 -0
  73. package/skill-assets/sunlint-code-quality/rules/csharp/S030-directory-browsing.md +26 -0
  74. package/skill-assets/sunlint-code-quality/rules/csharp/S031-secure-cookie-flag.md +35 -0
  75. package/skill-assets/sunlint-code-quality/rules/csharp/S032-httponly-cookie.md +31 -0
  76. package/skill-assets/sunlint-code-quality/rules/csharp/S033-samesite-cookie.md +36 -0
  77. package/skill-assets/sunlint-code-quality/rules/csharp/S034-host-prefix-cookie.md +31 -0
  78. package/skill-assets/sunlint-code-quality/rules/csharp/S035-app-hostnames.md +26 -0
  79. package/skill-assets/sunlint-code-quality/rules/csharp/S036-internal-file-paths.md +36 -0
  80. package/skill-assets/sunlint-code-quality/rules/csharp/S037-anti-cache-headers.md +33 -0
  81. package/skill-assets/sunlint-code-quality/rules/csharp/S039-tls-certificate-validation.md +41 -0
  82. package/skill-assets/sunlint-code-quality/rules/csharp/S041-logout-invalidation.md +36 -0
  83. package/skill-assets/sunlint-code-quality/rules/csharp/S042-long-lived-sessions.md +47 -0
  84. package/skill-assets/sunlint-code-quality/rules/csharp/S044-critical-changes-reauth.md +45 -0
  85. package/skill-assets/sunlint-code-quality/rules/csharp/S045-brute-force-protection.md +48 -0
  86. package/skill-assets/sunlint-code-quality/rules/csharp/S047-oauth-csrf-protection.md +53 -0
  87. package/skill-assets/sunlint-code-quality/rules/csharp/S048-oauth-redirect-validation.md +37 -0
  88. package/skill-assets/sunlint-code-quality/rules/csharp/S049-auth-code-expiry.md +33 -0
  89. package/skill-assets/sunlint-code-quality/rules/csharp/S050-token-entropy.md +33 -0
  90. package/skill-assets/sunlint-code-quality/rules/csharp/S051-password-length.md +35 -0
  91. package/skill-assets/sunlint-code-quality/rules/csharp/S052-otp-entropy.md +26 -0
  92. package/skill-assets/sunlint-code-quality/rules/csharp/S053-generic-error-messages.md +32 -0
  93. package/skill-assets/sunlint-code-quality/rules/csharp/S054-no-default-admin.md +31 -0
  94. package/skill-assets/sunlint-code-quality/rules/csharp/S055-content-type-validation.md +44 -0
  95. package/skill-assets/sunlint-code-quality/rules/csharp/S056-log-injection.md +33 -0
  96. package/skill-assets/sunlint-code-quality/rules/csharp/S057-synchronized-time.md +27 -0
  97. package/skill-assets/sunlint-code-quality/rules/csharp/S058-ssrf-protection.md +54 -0
  98. package/skill-assets/sunlint-code-quality/rules/java/C006-verb-noun-functions.md +36 -0
  99. package/skill-assets/sunlint-code-quality/rules/java/C013-no-dead-code.md +175 -0
  100. package/skill-assets/sunlint-code-quality/rules/java/C014-dependency-injection.md +42 -0
  101. package/skill-assets/sunlint-code-quality/rules/java/C017-no-constructor-logic.md +39 -0
  102. package/skill-assets/sunlint-code-quality/rules/java/C018-generic-errors.md +28 -0
  103. package/skill-assets/sunlint-code-quality/rules/java/C019-error-log-level.md +34 -0
  104. package/skill-assets/sunlint-code-quality/rules/java/C020-no-unused-imports.md +34 -0
  105. package/skill-assets/sunlint-code-quality/rules/java/C022-no-unused-variables.md +31 -0
  106. package/skill-assets/sunlint-code-quality/rules/java/C023-no-duplicate-names.md +37 -0
  107. package/skill-assets/sunlint-code-quality/rules/java/C024-centralize-constants.md +36 -0
  108. package/skill-assets/sunlint-code-quality/rules/java/C029-catch-log-root-cause.md +42 -0
  109. package/skill-assets/sunlint-code-quality/rules/java/C030-custom-error-classes.md +50 -0
  110. package/skill-assets/sunlint-code-quality/rules/java/C033-separate-data-access.md +46 -0
  111. package/skill-assets/sunlint-code-quality/rules/java/C035-error-context-logging.md +38 -0
  112. package/skill-assets/sunlint-code-quality/rules/java/C041-no-hardcoded-secrets.md +34 -0
  113. package/skill-assets/sunlint-code-quality/rules/java/C042-boolean-naming.md +27 -0
  114. package/skill-assets/sunlint-code-quality/rules/java/C052-controller-parsing.md +39 -0
  115. package/skill-assets/sunlint-code-quality/rules/java/C060-superclass-logic.md +32 -0
  116. package/skill-assets/sunlint-code-quality/rules/java/C067-no-hardcoded-config.md +31 -0
  117. package/skill-assets/sunlint-code-quality/rules/java/S003-open-redirect.md +38 -0
  118. package/skill-assets/sunlint-code-quality/rules/java/S004-no-log-credentials.md +36 -0
  119. package/skill-assets/sunlint-code-quality/rules/java/S005-server-authorization.md +53 -0
  120. package/skill-assets/sunlint-code-quality/rules/java/S006-default-credentials.md +39 -0
  121. package/skill-assets/sunlint-code-quality/rules/java/S007-output-encoding.md +49 -0
  122. package/skill-assets/sunlint-code-quality/rules/java/S009-approved-crypto.md +40 -0
  123. package/skill-assets/sunlint-code-quality/rules/java/S010-csprng.md +36 -0
  124. package/skill-assets/sunlint-code-quality/rules/java/S011-encrypted-client-hello.md +27 -0
  125. package/skill-assets/sunlint-code-quality/rules/java/S012-secrets-management.md +34 -0
  126. package/skill-assets/sunlint-code-quality/rules/java/S013-tls-connections.md +40 -0
  127. package/skill-assets/sunlint-code-quality/rules/java/S016-no-sensitive-query-string.md +36 -0
  128. package/skill-assets/sunlint-code-quality/rules/java/S017-parameterized-queries.md +47 -0
  129. package/skill-assets/sunlint-code-quality/rules/java/S019-email-input-sanitization.md +32 -0
  130. package/skill-assets/sunlint-code-quality/rules/java/S020-eval-code-execution.md +45 -0
  131. package/skill-assets/sunlint-code-quality/rules/java/S022-context-escaping.md +28 -0
  132. package/skill-assets/sunlint-code-quality/rules/java/S023-dynamic-js-encoding.md +28 -0
  133. package/skill-assets/sunlint-code-quality/rules/java/S025-server-validation.md +58 -0
  134. package/skill-assets/sunlint-code-quality/rules/java/S026-tls-encryption.md +57 -0
  135. package/skill-assets/sunlint-code-quality/rules/java/S027-mtls-validation.md +26 -0
  136. package/skill-assets/sunlint-code-quality/rules/java/S028-upload-limits.md +35 -0
  137. package/skill-assets/sunlint-code-quality/rules/java/S029-csrf-protection.md +35 -0
  138. package/skill-assets/sunlint-code-quality/rules/java/S030-directory-browsing.md +38 -0
  139. package/skill-assets/sunlint-code-quality/rules/java/S031-secure-cookie-flag.md +38 -0
  140. package/skill-assets/sunlint-code-quality/rules/java/S032-httponly-cookie.md +31 -0
  141. package/skill-assets/sunlint-code-quality/rules/java/S033-samesite-cookie.md +42 -0
  142. package/skill-assets/sunlint-code-quality/rules/java/S034-host-prefix-cookie.md +35 -0
  143. package/skill-assets/sunlint-code-quality/rules/java/S035-app-hostnames.md +23 -0
  144. package/skill-assets/sunlint-code-quality/rules/java/S036-internal-file-paths.md +39 -0
  145. package/skill-assets/sunlint-code-quality/rules/java/S037-anti-cache-headers.md +37 -0
  146. package/skill-assets/sunlint-code-quality/rules/java/S039-tls-certificate-validation.md +43 -0
  147. package/skill-assets/sunlint-code-quality/rules/java/S041-logout-invalidation.md +53 -0
  148. package/skill-assets/sunlint-code-quality/rules/java/S042-long-lived-sessions.md +36 -0
  149. package/skill-assets/sunlint-code-quality/rules/java/S044-critical-changes-reauth.md +28 -0
  150. package/skill-assets/sunlint-code-quality/rules/java/S045-brute-force-protection.md +38 -0
  151. package/skill-assets/sunlint-code-quality/rules/java/S047-oauth-csrf-protection.md +33 -0
  152. package/skill-assets/sunlint-code-quality/rules/java/S048-oauth-redirect-validation.md +25 -0
  153. package/skill-assets/sunlint-code-quality/rules/java/S049-auth-code-expiry.md +23 -0
  154. package/skill-assets/sunlint-code-quality/rules/java/S050-token-entropy.md +20 -0
  155. package/skill-assets/sunlint-code-quality/rules/java/S051-password-length.md +20 -0
  156. package/skill-assets/sunlint-code-quality/rules/java/S052-otp-entropy.md +23 -0
  157. package/skill-assets/sunlint-code-quality/rules/java/S053-generic-error-messages.md +21 -0
  158. package/skill-assets/sunlint-code-quality/rules/java/S054-no-default-admin.md +16 -0
  159. package/skill-assets/sunlint-code-quality/rules/java/S055-content-type-validation.md +36 -0
  160. package/skill-assets/sunlint-code-quality/rules/java/S056-log-injection.md +38 -0
  161. package/skill-assets/sunlint-code-quality/rules/java/S057-synchronized-time.md +35 -0
  162. package/skill-assets/sunlint-code-quality/rules/java/S058-ssrf-protection.md +56 -0
  163. package/skill-assets/sunlint-code-quality/rules/kotlin/C006-verb-noun-functions.md +45 -0
  164. package/skill-assets/sunlint-code-quality/rules/kotlin/C013-no-dead-code.md +49 -0
  165. package/skill-assets/sunlint-code-quality/rules/kotlin/C014-dependency-injection.md +64 -0
  166. package/skill-assets/sunlint-code-quality/rules/kotlin/C017-no-constructor-logic.md +68 -0
  167. package/skill-assets/sunlint-code-quality/rules/kotlin/C018-generic-errors.md +46 -0
  168. package/skill-assets/sunlint-code-quality/rules/kotlin/C019-error-log-level.md +50 -0
  169. package/skill-assets/sunlint-code-quality/rules/kotlin/C020-no-unused-imports.md +44 -0
  170. package/skill-assets/sunlint-code-quality/rules/kotlin/C022-no-unused-variables.md +39 -0
  171. package/skill-assets/sunlint-code-quality/rules/kotlin/C023-no-duplicate-names.md +47 -0
  172. package/skill-assets/sunlint-code-quality/rules/kotlin/C024-centralize-constants.md +58 -0
  173. package/skill-assets/sunlint-code-quality/rules/kotlin/C029-catch-log-root-cause.md +50 -0
  174. package/skill-assets/sunlint-code-quality/rules/kotlin/C030-custom-error-classes.md +72 -0
  175. package/skill-assets/sunlint-code-quality/rules/kotlin/C033-separate-data-access.md +69 -0
  176. package/skill-assets/sunlint-code-quality/rules/kotlin/C035-error-context-logging.md +47 -0
  177. package/skill-assets/sunlint-code-quality/rules/kotlin/C041-no-hardcoded-secrets.md +47 -0
  178. package/skill-assets/sunlint-code-quality/rules/kotlin/C042-boolean-naming.md +42 -0
  179. package/skill-assets/sunlint-code-quality/rules/kotlin/C052-controller-parsing.md +71 -0
  180. package/skill-assets/sunlint-code-quality/rules/kotlin/C060-superclass-logic.md +60 -0
  181. package/skill-assets/sunlint-code-quality/rules/kotlin/C067-no-hardcoded-config.md +51 -0
  182. package/skill-assets/sunlint-code-quality/rules/kotlin/S003-open-redirect.md +66 -0
  183. package/skill-assets/sunlint-code-quality/rules/kotlin/S004-no-log-credentials.md +59 -0
  184. package/skill-assets/sunlint-code-quality/rules/kotlin/S005-server-authorization.md +75 -0
  185. package/skill-assets/sunlint-code-quality/rules/kotlin/S006-default-credentials.md +49 -0
  186. package/skill-assets/sunlint-code-quality/rules/kotlin/S007-output-encoding.md +62 -0
  187. package/skill-assets/sunlint-code-quality/rules/kotlin/S009-approved-crypto.md +51 -0
  188. package/skill-assets/sunlint-code-quality/rules/kotlin/S010-csprng.md +61 -0
  189. package/skill-assets/sunlint-code-quality/rules/kotlin/S011-encrypted-client-hello.md +48 -0
  190. package/skill-assets/sunlint-code-quality/rules/kotlin/S012-secrets-management.md +53 -0
  191. package/skill-assets/sunlint-code-quality/rules/kotlin/S013-tls-connections.md +61 -0
  192. package/skill-assets/sunlint-code-quality/rules/kotlin/S016-no-sensitive-query-string.md +51 -0
  193. package/skill-assets/sunlint-code-quality/rules/kotlin/S017-parameterized-queries.md +41 -0
  194. package/skill-assets/sunlint-code-quality/rules/kotlin/S019-email-input-sanitization.md +50 -0
  195. package/skill-assets/sunlint-code-quality/rules/kotlin/S020-eval-code-execution.md +57 -0
  196. package/skill-assets/sunlint-code-quality/rules/kotlin/S022-context-escaping.md +58 -0
  197. package/skill-assets/sunlint-code-quality/rules/kotlin/S023-dynamic-js-encoding.md +57 -0
  198. package/skill-assets/sunlint-code-quality/rules/kotlin/S025-server-validation.md +59 -0
  199. package/skill-assets/sunlint-code-quality/rules/kotlin/S026-tls-encryption.md +50 -0
  200. package/skill-assets/sunlint-code-quality/rules/kotlin/S027-mtls-validation.md +60 -0
  201. package/skill-assets/sunlint-code-quality/rules/kotlin/S028-upload-limits.md +67 -0
  202. package/skill-assets/sunlint-code-quality/rules/kotlin/S029-csrf-protection.md +57 -0
  203. package/skill-assets/sunlint-code-quality/rules/kotlin/S030-directory-browsing.md +50 -0
  204. package/skill-assets/sunlint-code-quality/rules/kotlin/S031-secure-cookie-flag.md +51 -0
  205. package/skill-assets/sunlint-code-quality/rules/kotlin/S032-httponly-cookie.md +49 -0
  206. package/skill-assets/sunlint-code-quality/rules/kotlin/S033-samesite-cookie.md +54 -0
  207. package/skill-assets/sunlint-code-quality/rules/kotlin/S034-host-prefix-cookie.md +50 -0
  208. package/skill-assets/sunlint-code-quality/rules/kotlin/S035-app-hostnames.md +59 -0
  209. package/skill-assets/sunlint-code-quality/rules/kotlin/S036-internal-file-paths.md +61 -0
  210. package/skill-assets/sunlint-code-quality/rules/kotlin/S037-anti-cache-headers.md +58 -0
  211. package/skill-assets/sunlint-code-quality/rules/kotlin/S039-tls-certificate-validation.md +62 -0
  212. package/skill-assets/sunlint-code-quality/rules/kotlin/S041-logout-invalidation.md +71 -0
  213. package/skill-assets/sunlint-code-quality/rules/kotlin/S042-long-lived-sessions.md +57 -0
  214. package/skill-assets/sunlint-code-quality/rules/kotlin/S044-critical-changes-reauth.md +64 -0
  215. package/skill-assets/sunlint-code-quality/rules/kotlin/S045-brute-force-protection.md +64 -0
  216. package/skill-assets/sunlint-code-quality/rules/kotlin/S047-oauth-csrf-protection.md +74 -0
  217. package/skill-assets/sunlint-code-quality/rules/kotlin/S048-oauth-redirect-validation.md +61 -0
  218. package/skill-assets/sunlint-code-quality/rules/kotlin/S049-auth-code-expiry.md +70 -0
  219. package/skill-assets/sunlint-code-quality/rules/kotlin/S050-token-entropy.md +65 -0
  220. package/skill-assets/sunlint-code-quality/rules/kotlin/S051-password-length.md +52 -0
  221. package/skill-assets/sunlint-code-quality/rules/kotlin/S052-otp-entropy.md +55 -0
  222. package/skill-assets/sunlint-code-quality/rules/kotlin/S053-generic-error-messages.md +66 -0
  223. package/skill-assets/sunlint-code-quality/rules/kotlin/S054-no-default-admin.md +57 -0
  224. package/skill-assets/sunlint-code-quality/rules/kotlin/S055-content-type-validation.md +58 -0
  225. package/skill-assets/sunlint-code-quality/rules/kotlin/S056-log-injection.md +47 -0
  226. package/skill-assets/sunlint-code-quality/rules/kotlin/S057-synchronized-time.md +49 -0
  227. package/skill-assets/sunlint-code-quality/rules/kotlin/S058-ssrf-protection.md +69 -0
  228. package/skill-assets/sunlint-code-quality/rules/php/C006-verb-noun-functions.md +46 -0
  229. package/skill-assets/sunlint-code-quality/rules/php/C013-no-dead-code.md +53 -0
  230. package/skill-assets/sunlint-code-quality/rules/php/C014-dependency-injection.md +71 -0
  231. package/skill-assets/sunlint-code-quality/rules/php/C017-no-constructor-logic.md +68 -0
  232. package/skill-assets/sunlint-code-quality/rules/php/C018-generic-errors.md +50 -0
  233. package/skill-assets/sunlint-code-quality/rules/php/C019-error-log-level.md +54 -0
  234. package/skill-assets/sunlint-code-quality/rules/php/C020-no-unused-imports.md +55 -0
  235. package/skill-assets/sunlint-code-quality/rules/php/C022-no-unused-variables.md +51 -0
  236. package/skill-assets/sunlint-code-quality/rules/php/C023-no-duplicate-names.md +61 -0
  237. package/skill-assets/sunlint-code-quality/rules/php/C024-centralize-constants.md +60 -0
  238. package/skill-assets/sunlint-code-quality/rules/php/C029-catch-log-root-cause.md +57 -0
  239. package/skill-assets/sunlint-code-quality/rules/php/C030-custom-error-classes.md +62 -0
  240. package/skill-assets/sunlint-code-quality/rules/php/C033-separate-data-access.md +79 -0
  241. package/skill-assets/sunlint-code-quality/rules/php/C035-error-context-logging.md +54 -0
  242. package/skill-assets/sunlint-code-quality/rules/php/C041-no-hardcoded-secrets.md +59 -0
  243. package/skill-assets/sunlint-code-quality/rules/php/C042-boolean-naming.md +52 -0
  244. package/skill-assets/sunlint-code-quality/rules/php/C052-controller-parsing.md +66 -0
  245. package/skill-assets/sunlint-code-quality/rules/php/C060-superclass-logic.md +54 -0
  246. package/skill-assets/sunlint-code-quality/rules/php/C067-no-hardcoded-config.md +55 -0
  247. package/skill-assets/sunlint-code-quality/rules/php/S003-open-redirect.md +60 -0
  248. package/skill-assets/sunlint-code-quality/rules/php/S004-no-log-credentials.md +67 -0
  249. package/skill-assets/sunlint-code-quality/rules/php/S005-server-authorization.md +57 -0
  250. package/skill-assets/sunlint-code-quality/rules/php/S006-default-credentials.md +61 -0
  251. package/skill-assets/sunlint-code-quality/rules/php/S007-output-encoding.md +61 -0
  252. package/skill-assets/sunlint-code-quality/rules/php/S009-approved-crypto.md +53 -0
  253. package/skill-assets/sunlint-code-quality/rules/php/S010-csprng.md +47 -0
  254. package/skill-assets/sunlint-code-quality/rules/php/S011-encrypted-client-hello.md +41 -0
  255. package/skill-assets/sunlint-code-quality/rules/php/S012-secrets-management.md +60 -0
  256. package/skill-assets/sunlint-code-quality/rules/php/S013-tls-connections.md +67 -0
  257. package/skill-assets/sunlint-code-quality/rules/php/S016-no-sensitive-query-string.md +61 -0
  258. package/skill-assets/sunlint-code-quality/rules/php/S017-parameterized-queries.md +44 -0
  259. package/skill-assets/sunlint-code-quality/rules/php/S019-email-input-sanitization.md +54 -0
  260. package/skill-assets/sunlint-code-quality/rules/php/S020-eval-code-execution.md +57 -0
  261. package/skill-assets/sunlint-code-quality/rules/php/S022-context-escaping.md +58 -0
  262. package/skill-assets/sunlint-code-quality/rules/php/S023-dynamic-js-encoding.md +62 -0
  263. package/skill-assets/sunlint-code-quality/rules/php/S025-server-validation.md +63 -0
  264. package/skill-assets/sunlint-code-quality/rules/php/S026-tls-encryption.md +48 -0
  265. package/skill-assets/sunlint-code-quality/rules/php/S027-mtls-validation.md +62 -0
  266. package/skill-assets/sunlint-code-quality/rules/php/S028-upload-limits.md +60 -0
  267. package/skill-assets/sunlint-code-quality/rules/php/S029-csrf-protection.md +65 -0
  268. package/skill-assets/sunlint-code-quality/rules/php/S030-directory-browsing.md +40 -0
  269. package/skill-assets/sunlint-code-quality/rules/php/S031-secure-cookie-flag.md +55 -0
  270. package/skill-assets/sunlint-code-quality/rules/php/S032-httponly-cookie.md +54 -0
  271. package/skill-assets/sunlint-code-quality/rules/php/S033-samesite-cookie.md +52 -0
  272. package/skill-assets/sunlint-code-quality/rules/php/S034-host-prefix-cookie.md +49 -0
  273. package/skill-assets/sunlint-code-quality/rules/php/S035-app-hostnames.md +49 -0
  274. package/skill-assets/sunlint-code-quality/rules/php/S036-internal-file-paths.md +56 -0
  275. package/skill-assets/sunlint-code-quality/rules/php/S037-anti-cache-headers.md +56 -0
  276. package/skill-assets/sunlint-code-quality/rules/php/S039-tls-certificate-validation.md +54 -0
  277. package/skill-assets/sunlint-code-quality/rules/php/S041-logout-invalidation.md +63 -0
  278. package/skill-assets/sunlint-code-quality/rules/php/S042-long-lived-sessions.md +57 -0
  279. package/skill-assets/sunlint-code-quality/rules/php/S044-critical-changes-reauth.md +71 -0
  280. package/skill-assets/sunlint-code-quality/rules/php/S045-brute-force-protection.md +67 -0
  281. package/skill-assets/sunlint-code-quality/rules/php/S047-oauth-csrf-protection.md +72 -0
  282. package/skill-assets/sunlint-code-quality/rules/php/S048-oauth-redirect-validation.md +54 -0
  283. package/skill-assets/sunlint-code-quality/rules/php/S049-auth-code-expiry.md +71 -0
  284. package/skill-assets/sunlint-code-quality/rules/php/S050-token-entropy.md +58 -0
  285. package/skill-assets/sunlint-code-quality/rules/php/S051-password-length.md +59 -0
  286. package/skill-assets/sunlint-code-quality/rules/php/S052-otp-entropy.md +45 -0
  287. package/skill-assets/sunlint-code-quality/rules/php/S053-generic-error-messages.md +59 -0
  288. package/skill-assets/sunlint-code-quality/rules/php/S054-no-default-admin.md +62 -0
  289. package/skill-assets/sunlint-code-quality/rules/php/S055-content-type-validation.md +58 -0
  290. package/skill-assets/sunlint-code-quality/rules/php/S056-log-injection.md +48 -0
  291. package/skill-assets/sunlint-code-quality/rules/php/S057-synchronized-time.md +52 -0
  292. package/skill-assets/sunlint-code-quality/rules/php/S058-ssrf-protection.md +65 -0
  293. package/skill-assets/sunlint-code-quality/rules/python/C006-verb-noun-functions.md +30 -0
  294. package/skill-assets/sunlint-code-quality/rules/python/C013-no-dead-code.md +24 -0
  295. package/skill-assets/sunlint-code-quality/rules/python/C014-dependency-injection.md +68 -0
  296. package/skill-assets/sunlint-code-quality/rules/python/C017-no-constructor-logic.md +30 -0
  297. package/skill-assets/sunlint-code-quality/rules/python/C018-generic-errors.md +25 -0
  298. package/skill-assets/sunlint-code-quality/rules/python/C019-error-log-level.md +26 -0
  299. package/skill-assets/sunlint-code-quality/rules/python/C020-no-unused-imports.md +28 -0
  300. package/skill-assets/sunlint-code-quality/rules/python/C022-no-unused-variables.md +24 -0
  301. package/skill-assets/sunlint-code-quality/rules/python/C023-no-duplicate-names.md +27 -0
  302. package/skill-assets/sunlint-code-quality/rules/python/C024-centralize-constants.md +27 -0
  303. package/skill-assets/sunlint-code-quality/rules/python/C029-catch-log-root-cause.md +61 -0
  304. package/skill-assets/sunlint-code-quality/rules/python/C030-custom-error-classes.md +28 -0
  305. package/skill-assets/sunlint-code-quality/rules/python/C033-separate-data-access.md +53 -0
  306. package/skill-assets/sunlint-code-quality/rules/python/C035-error-context-logging.md +26 -0
  307. package/skill-assets/sunlint-code-quality/rules/python/C041-no-hardcoded-secrets.md +23 -0
  308. package/skill-assets/sunlint-code-quality/rules/python/C042-boolean-naming.md +24 -0
  309. package/skill-assets/sunlint-code-quality/rules/python/C052-controller-parsing.md +34 -0
  310. package/skill-assets/sunlint-code-quality/rules/python/C060-superclass-logic.md +26 -0
  311. package/skill-assets/sunlint-code-quality/rules/python/C067-no-hardcoded-config.md +22 -0
  312. package/skill-assets/sunlint-code-quality/rules/python/S003-open-redirect.md +16 -0
  313. package/skill-assets/sunlint-code-quality/rules/python/S004-no-log-credentials.md +16 -0
  314. package/skill-assets/sunlint-code-quality/rules/python/S005-server-authorization.md +16 -0
  315. package/skill-assets/sunlint-code-quality/rules/python/S006-default-credentials.md +16 -0
  316. package/skill-assets/sunlint-code-quality/rules/python/S007-output-encoding.md +16 -0
  317. package/skill-assets/sunlint-code-quality/rules/python/S009-approved-crypto.md +16 -0
  318. package/skill-assets/sunlint-code-quality/rules/python/S010-csprng.md +16 -0
  319. package/skill-assets/sunlint-code-quality/rules/python/S011-encrypted-client-hello.md +16 -0
  320. package/skill-assets/sunlint-code-quality/rules/python/S012-secrets-management.md +16 -0
  321. package/skill-assets/sunlint-code-quality/rules/python/S013-tls-connections.md +16 -0
  322. package/skill-assets/sunlint-code-quality/rules/python/S016-no-sensitive-query-string.md +16 -0
  323. package/skill-assets/sunlint-code-quality/rules/python/S017-parameterized-queries.md +51 -0
  324. package/skill-assets/sunlint-code-quality/rules/python/S019-email-input-sanitization.md +16 -0
  325. package/skill-assets/sunlint-code-quality/rules/python/S020-eval-code-execution.md +51 -0
  326. package/skill-assets/sunlint-code-quality/rules/python/S022-context-escaping.md +16 -0
  327. package/skill-assets/sunlint-code-quality/rules/python/S023-dynamic-js-encoding.md +16 -0
  328. package/skill-assets/sunlint-code-quality/rules/python/S025-server-validation.md +16 -0
  329. package/skill-assets/sunlint-code-quality/rules/python/S026-tls-encryption.md +16 -0
  330. package/skill-assets/sunlint-code-quality/rules/python/S027-mtls-validation.md +16 -0
  331. package/skill-assets/sunlint-code-quality/rules/python/S028-upload-limits.md +16 -0
  332. package/skill-assets/sunlint-code-quality/rules/python/S029-csrf-protection.md +16 -0
  333. package/skill-assets/sunlint-code-quality/rules/python/S030-directory-browsing.md +16 -0
  334. package/skill-assets/sunlint-code-quality/rules/python/S031-secure-cookie-flag.md +16 -0
  335. package/skill-assets/sunlint-code-quality/rules/python/S032-httponly-cookie.md +16 -0
  336. package/skill-assets/sunlint-code-quality/rules/python/S033-samesite-cookie.md +16 -0
  337. package/skill-assets/sunlint-code-quality/rules/python/S034-host-prefix-cookie.md +16 -0
  338. package/skill-assets/sunlint-code-quality/rules/python/S035-app-hostnames.md +16 -0
  339. package/skill-assets/sunlint-code-quality/rules/python/S036-internal-file-paths.md +50 -0
  340. package/skill-assets/sunlint-code-quality/rules/python/S037-anti-cache-headers.md +16 -0
  341. package/skill-assets/sunlint-code-quality/rules/python/S039-tls-certificate-validation.md +16 -0
  342. package/skill-assets/sunlint-code-quality/rules/python/S041-logout-invalidation.md +16 -0
  343. package/skill-assets/sunlint-code-quality/rules/python/S042-long-lived-sessions.md +16 -0
  344. package/skill-assets/sunlint-code-quality/rules/python/S044-critical-changes-reauth.md +16 -0
  345. package/skill-assets/sunlint-code-quality/rules/python/S045-brute-force-protection.md +16 -0
  346. package/skill-assets/sunlint-code-quality/rules/python/S047-oauth-csrf-protection.md +16 -0
  347. package/skill-assets/sunlint-code-quality/rules/python/S048-oauth-redirect-validation.md +16 -0
  348. package/skill-assets/sunlint-code-quality/rules/python/S049-auth-code-expiry.md +16 -0
  349. package/skill-assets/sunlint-code-quality/rules/python/S050-token-entropy.md +16 -0
  350. package/skill-assets/sunlint-code-quality/rules/python/S051-password-length.md +16 -0
  351. package/skill-assets/sunlint-code-quality/rules/python/S052-otp-entropy.md +16 -0
  352. package/skill-assets/sunlint-code-quality/rules/python/S053-generic-error-messages.md +16 -0
  353. package/skill-assets/sunlint-code-quality/rules/python/S054-no-default-admin.md +16 -0
  354. package/skill-assets/sunlint-code-quality/rules/python/S055-content-type-validation.md +16 -0
  355. package/skill-assets/sunlint-code-quality/rules/python/S056-log-injection.md +16 -0
  356. package/skill-assets/sunlint-code-quality/rules/python/S057-synchronized-time.md +16 -0
  357. package/skill-assets/sunlint-code-quality/rules/python/S058-ssrf-protection.md +57 -0
  358. package/skill-assets/sunlint-code-quality/rules/typescript/C006-verb-noun-functions.md +45 -0
  359. package/skill-assets/sunlint-code-quality/rules/typescript/C013-no-dead-code.md +51 -0
  360. package/skill-assets/sunlint-code-quality/rules/typescript/C014-dependency-injection.md +69 -0
  361. package/skill-assets/sunlint-code-quality/rules/typescript/C017-no-constructor-logic.md +60 -0
  362. package/skill-assets/sunlint-code-quality/rules/typescript/C018-generic-errors.md +47 -0
  363. package/skill-assets/sunlint-code-quality/rules/typescript/C019-error-log-level.md +50 -0
  364. package/skill-assets/sunlint-code-quality/rules/typescript/C020-no-unused-imports.md +55 -0
  365. package/skill-assets/sunlint-code-quality/rules/typescript/C022-no-unused-variables.md +59 -0
  366. package/skill-assets/sunlint-code-quality/rules/typescript/C023-no-duplicate-names.md +58 -0
  367. package/skill-assets/sunlint-code-quality/rules/typescript/C024-centralize-constants.md +56 -0
  368. package/skill-assets/sunlint-code-quality/rules/typescript/C029-catch-log-root-cause.md +53 -0
  369. package/skill-assets/sunlint-code-quality/rules/typescript/C030-custom-error-classes.md +60 -0
  370. package/skill-assets/sunlint-code-quality/rules/typescript/C033-separate-data-access.md +69 -0
  371. package/skill-assets/sunlint-code-quality/rules/typescript/C035-error-context-logging.md +50 -0
  372. package/skill-assets/sunlint-code-quality/rules/typescript/C041-no-hardcoded-secrets.md +47 -0
  373. package/skill-assets/sunlint-code-quality/rules/typescript/C042-boolean-naming.md +42 -0
  374. package/skill-assets/sunlint-code-quality/rules/typescript/C052-controller-parsing.md +64 -0
  375. package/skill-assets/sunlint-code-quality/rules/typescript/C060-superclass-logic.md +67 -0
  376. package/skill-assets/sunlint-code-quality/rules/typescript/C067-no-hardcoded-config.md +52 -0
  377. package/skill-assets/sunlint-code-quality/rules/typescript/S003-open-redirect.md +76 -0
  378. package/skill-assets/sunlint-code-quality/rules/typescript/S004-no-log-credentials.md +71 -0
  379. package/skill-assets/sunlint-code-quality/rules/typescript/S005-server-authorization.md +68 -0
  380. package/skill-assets/sunlint-code-quality/rules/typescript/S006-default-credentials.md +69 -0
  381. package/skill-assets/sunlint-code-quality/rules/typescript/S007-output-encoding.md +60 -0
  382. package/skill-assets/sunlint-code-quality/rules/typescript/S009-approved-crypto.md +53 -0
  383. package/skill-assets/sunlint-code-quality/rules/typescript/S010-csprng.md +53 -0
  384. package/skill-assets/sunlint-code-quality/rules/typescript/S011-encrypted-client-hello.md +45 -0
  385. package/skill-assets/sunlint-code-quality/rules/typescript/S012-secrets-management.md +47 -0
  386. package/skill-assets/sunlint-code-quality/rules/typescript/S013-tls-connections.md +70 -0
  387. package/skill-assets/sunlint-code-quality/rules/typescript/S016-no-sensitive-query-string.md +53 -0
  388. package/skill-assets/sunlint-code-quality/rules/typescript/S017-parameterized-queries.md +55 -0
  389. package/skill-assets/sunlint-code-quality/rules/typescript/S019-email-input-sanitization.md +56 -0
  390. package/skill-assets/sunlint-code-quality/rules/typescript/S020-eval-code-execution.md +58 -0
  391. package/skill-assets/sunlint-code-quality/rules/typescript/S022-context-escaping.md +48 -0
  392. package/skill-assets/sunlint-code-quality/rules/typescript/S023-dynamic-js-encoding.md +52 -0
  393. package/skill-assets/sunlint-code-quality/rules/typescript/S025-server-validation.md +62 -0
  394. package/skill-assets/sunlint-code-quality/rules/typescript/S026-tls-encryption.md +47 -0
  395. package/skill-assets/sunlint-code-quality/rules/typescript/S027-mtls-validation.md +50 -0
  396. package/skill-assets/sunlint-code-quality/rules/typescript/S028-upload-limits.md +65 -0
  397. package/skill-assets/sunlint-code-quality/rules/typescript/S029-csrf-protection.md +62 -0
  398. package/skill-assets/sunlint-code-quality/rules/typescript/S030-directory-browsing.md +52 -0
  399. package/skill-assets/sunlint-code-quality/rules/typescript/S031-secure-cookie-flag.md +48 -0
  400. package/skill-assets/sunlint-code-quality/rules/typescript/S032-httponly-cookie.md +36 -0
  401. package/skill-assets/sunlint-code-quality/rules/typescript/S033-samesite-cookie.md +46 -0
  402. package/skill-assets/sunlint-code-quality/rules/typescript/S034-host-prefix-cookie.md +50 -0
  403. package/skill-assets/sunlint-code-quality/rules/typescript/S035-app-hostnames.md +49 -0
  404. package/skill-assets/sunlint-code-quality/rules/typescript/S036-internal-file-paths.md +53 -0
  405. package/skill-assets/sunlint-code-quality/rules/typescript/S037-anti-cache-headers.md +52 -0
  406. package/skill-assets/sunlint-code-quality/rules/typescript/S039-tls-certificate-validation.md +51 -0
  407. package/skill-assets/sunlint-code-quality/rules/typescript/S041-logout-invalidation.md +58 -0
  408. package/skill-assets/sunlint-code-quality/rules/typescript/S042-long-lived-sessions.md +55 -0
  409. package/skill-assets/sunlint-code-quality/rules/typescript/S044-critical-changes-reauth.md +69 -0
  410. package/skill-assets/sunlint-code-quality/rules/typescript/S045-brute-force-protection.md +59 -0
  411. package/skill-assets/sunlint-code-quality/rules/typescript/S047-oauth-csrf-protection.md +60 -0
  412. package/skill-assets/sunlint-code-quality/rules/typescript/S048-oauth-redirect-validation.md +59 -0
  413. package/skill-assets/sunlint-code-quality/rules/typescript/S049-auth-code-expiry.md +73 -0
  414. package/skill-assets/sunlint-code-quality/rules/typescript/S050-token-entropy.md +48 -0
  415. package/skill-assets/sunlint-code-quality/rules/typescript/S051-password-length.md +60 -0
  416. package/skill-assets/sunlint-code-quality/rules/typescript/S052-otp-entropy.md +49 -0
  417. package/skill-assets/sunlint-code-quality/rules/typescript/S053-generic-error-messages.md +61 -0
  418. package/skill-assets/sunlint-code-quality/rules/typescript/S054-no-default-admin.md +64 -0
  419. package/skill-assets/sunlint-code-quality/rules/typescript/S055-content-type-validation.md +64 -0
  420. package/skill-assets/sunlint-code-quality/rules/typescript/S056-log-injection.md +48 -0
  421. package/skill-assets/sunlint-code-quality/rules/typescript/S057-synchronized-time.md +57 -0
  422. package/skill-assets/sunlint-code-quality/rules/typescript/S058-ssrf-protection.md +63 -0
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: Use Only Approved Crypto Algorithms
3
+ impact: CRITICAL
4
+ impactDescription: prevents the use of broken or weak cryptography that can be easily cracked
5
+ tags: cryptography, encryption, algorithms, security, java
6
+ ---
7
+
8
+ ## Use Only Approved Crypto Algorithms
9
+
10
+ Avoid using deprecated or weak cryptographic algorithms (like MD5, SHA1, DES, or Blowfish with small keys). These are technically broken and can be cracked in minutes by modern hardware.
11
+
12
+ **Incorrect (weak crypto):**
13
+
14
+ ```java
15
+ // VULNERABLE: MD5 is broken
16
+ MessageDigest md = MessageDigest.getInstance("MD5");
17
+
18
+ // VULNERABLE: DES is weak
19
+ Cipher c = Cipher.getInstance("DES");
20
+ ```
21
+
22
+ **Correct (approved crypto):**
23
+
24
+ ```java
25
+ // SECURE: SHA-256 or SHA-512 for hashing
26
+ MessageDigest md = MessageDigest.getInstance("SHA-256");
27
+
28
+ // SECURE: AES-256 for symmetric encryption
29
+ Cipher c = Cipher.getInstance("AES/GCM/NoPadding");
30
+
31
+ // SECURE: Argon2 or BCrypt for password hashing
32
+ String hash = BCrypt.hashpw(password, BCrypt.gensalt());
33
+ ```
34
+
35
+ **Recommended Algorithms:**
36
+ - **Hashing:** SHA-256, SHA-512, SHA-3.
37
+ - **Encryption:** AES (128-bit or 256-bit) with GCM mode.
38
+ - **Passwords:** Argon2, BCrypt, SCrypt.
39
+
40
+ **Tools:** SonarQube (S1311), FindSecBugs
@@ -0,0 +1,36 @@
1
+ ---
2
+ title: Use CSPRNG For Security Purposes
3
+ impact: HIGH
4
+ impactDescription: prevents predictable random values that attackers can guess
5
+ tags: randomness, csprng, security, java
6
+ ---
7
+
8
+ ## Use CSPRNG For Security Purposes
9
+
10
+ Standard random number generators (like `java.util.Random`) are predictable and should never be used for security-sensitive operations like generating passwords, session tokens, or initialization vectors (IVs).
11
+
12
+ **Incorrect (predictable random):**
13
+
14
+ ```java
15
+ // DANGEROUS: Uses a linear congruential generator (LCG)
16
+ Random rand = new Random();
17
+ int token = rand.nextInt(1000000);
18
+ ```
19
+
20
+ **Correct (cryptographically secure random):**
21
+
22
+ ```java
23
+ // SECURE: Uses SecureRandom (CSPRNG)
24
+ SecureRandom secureRand = new SecureRandom();
25
+ byte[] tokenBytes = new byte[32];
26
+ secureRand.nextBytes(tokenBytes);
27
+ String token = Base64.getEncoder().encodeToString(tokenBytes);
28
+ ```
29
+
30
+ **When to use CSPRNG:**
31
+ - Session IDs and CSRF tokens.
32
+ - Password reset tokens.
33
+ - Cryptographic salts and IVs.
34
+ - Temporary passwords/OTPs.
35
+
36
+ **Tools:** SonarQube (S2245), FindSecBugs
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: Enable Encrypted Client Hello (ECH)
3
+ impact: MEDIUM
4
+ impactDescription: protects Server Name Indication (SNI) from eavesdropping
5
+ tags: tls, ech, sni, privacy, security, java
6
+ ---
7
+
8
+ ## Enable Encrypted Client Hello (ECH)
9
+
10
+ ECH encrypts the Server Name Indication (SNI) in the TLS handshake, preventing network observers from seeing which specific host you are connecting to. This is primarily a privacy feature that prevents ISP/network-level tracking.
11
+
12
+ **About ECH:**
13
+ ECH is managed at the system/infrastructure level (JDK 22+ or via load balancers like Cloudflare/Nginx).
14
+
15
+ **Correct (ensuring Java client support):**
16
+ Java 22 and above have experimental support for ECH. Ensure your runtime environment and HTTP clients are configured to use the latest TLS features.
17
+
18
+ ```java
19
+ // For Java 22+:
20
+ // -Djdk.tls.client.enableECH=true
21
+ // -Djdk.tls.server.enableECH=true
22
+ ```
23
+
24
+ **Deployment:**
25
+ Enable ECH on your CDN (e.g., Cloudflare) or your entry-point Load Balancer.
26
+
27
+ **Tools:** Cloudflare, Wireshark (to verify SNI encryption), JDK 22 documentation
@@ -0,0 +1,34 @@
1
+ ---
2
+ title: Use Secrets Management For Backend Secrets
3
+ impact: CRITICAL
4
+ impactDescription: prevents exposure of sensitive credentials in source code and version control
5
+ tags: secrets, management, vault, security, java
6
+ ---
7
+
8
+ ## Use Secrets Management For Backend Secrets
9
+
10
+ Sensitive data like API keys, database passwords, and private certificates should never be stored in plaintext in the codebase or checked into version control. Use a dedicated secrets management tool.
11
+
12
+ **Incorrect (secrets in source code):**
13
+
14
+ ```java
15
+ // VULNERABLE: Hardcoded API Key
16
+ public static final String STRIPE_SECRET = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
17
+ ```
18
+
19
+ **Correct (external secrets management):**
20
+
21
+ ```java
22
+ // 1. Environment Variables (Simple)
23
+ String apiKey = System.getenv("STRIPE_SECRET_KEY");
24
+
25
+ // 2. Spring Cloud Vault / Config (Recommended for Production)
26
+ @Value("${my.secret.key}")
27
+ private String secretKey;
28
+
29
+ // 3. AWS Secrets Manager / Azure Key Vault SDK
30
+ GetSecretValueRequest request = new GetSecretValueRequest().withSecretId("stripe/live/key");
31
+ String secret = client.getSecretValue(request).getSecretString();
32
+ ```
33
+
34
+ **Tools:** HashiCorp Vault, AWS Secrets Manager, Google Cloud Secret Manager, Kubernetes Secrets
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: Always Use TLS For All Connections
3
+ impact: HIGH
4
+ impactDescription: protects data in transit from eavesdropping and tampering
5
+ tags: tls, https, encryption, transport, security, java
6
+ ---
7
+
8
+ ## Always Use TLS For All Connections
9
+
10
+ Transmitting data over unencrypted HTTP, JDBC, or Redis connections exposes sensitive information to everyone on the network path. All connections in production must use TLS 1.2 or higher.
11
+
12
+ **Incorrect (unencrypted connections):**
13
+
14
+ ```java
15
+ // VULNERABLE: Using HTTP API
16
+ HttpClient client = HttpClient.newHttpClient();
17
+ HttpRequest request = HttpRequest.newBuilder()
18
+ .uri(URI.create("http://api.internal.com/data"))
19
+ .build();
20
+
21
+ // VULNERABLE: Unencrypted JDBC
22
+ String url = "jdbc:postgresql://db.server:5432/mydb";
23
+ ```
24
+
25
+ **Correct (TLS/SSL everywhere):**
26
+
27
+ ```java
28
+ // 1. HTTPS for all APIs
29
+ HttpRequest request = HttpRequest.newBuilder()
30
+ .uri(URI.create("https://api.internal.com/data"))
31
+ .build();
32
+
33
+ // 2. TLS for Database
34
+ String url = "jdbc:postgresql://db.server:5432/mydb?ssl=true&sslmode=verify-full";
35
+
36
+ // 3. Redis with TLS (Jedis/Lettuce)
37
+ RedisClient client = RedisClient.create("rediss://localhost:6380"); // Note: rediss://
38
+ ```
39
+
40
+ **Tools:** SSLyze, Qualys SSL Labs, Snyk, Manual Review
@@ -0,0 +1,36 @@
1
+ ---
2
+ title: Do Not Pass Sensitive Data In Query String
3
+ impact: HIGH
4
+ impactDescription: prevents sensitive data from leaking into browser history, server logs, and referrer headers
5
+ tags: query-string, sensitive-data, transport, security, java
6
+ ---
7
+
8
+ ## Do Not Pass Sensitive Data In Query String
9
+
10
+ URL parameters (the query string) are visible in browser history, bookmarks, proxy logs, and `Referer` headers. Sensitive data like passwords, tokens, or personal identifiers should never be part of a URL.
11
+
12
+ **Incorrect (sensitive query strings):**
13
+
14
+ ```java
15
+ // VULNERABLE: Token is in the URL
16
+ GET /api/user-details?auth_token=eyJhbGciOiJIUzI1NiI...
17
+ ```
18
+
19
+ **Correct (headers or body):**
20
+
21
+ ```java
22
+ // SECURE: Token passed in Authorization header
23
+ GET /api/user-details
24
+ Authorization: Bearer eyJhbGciOiJIUzI1NiI...
25
+
26
+ // SECURE: Data passed in POST body
27
+ POST /api/reset-password
28
+ Content-Type: application/json
29
+ { "token": "...", "newPassword": "..." }
30
+ ```
31
+
32
+ **Always use:**
33
+ - `POST` / `PUT` for any request containing sensitive data.
34
+ - Standard headers like `Authorization` for tokens.
35
+
36
+ **Tools:** OWASP ZAP, Manual Audit
@@ -0,0 +1,47 @@
1
+ ---
2
+ title: Always Use Parameterized Queries
3
+ impact: CRITICAL
4
+ impactDescription: prevents SQL and NoSQL injection attacks
5
+ tags: injection, sql, nosql, database, parameterized, security, java
6
+ ---
7
+
8
+ ## Always Use Parameterized Queries
9
+
10
+ SQL injection is one of the most critical security vulnerabilities. Directly concatenating user input into SQL strings allows attackers to manipulate queries, bypass authentication, or steal entire databases.
11
+
12
+ **Incorrect (string concatenation):**
13
+
14
+ ```java
15
+ // VULNERABLE: Direct concatenation
16
+ String userId = request.getParameter("id");
17
+ String query = "SELECT * FROM users WHERE id = '" + userId + "'";
18
+ Statement stmt = connection.createStatement();
19
+ ResultSet rs = stmt.executeQuery(query);
20
+ ```
21
+
22
+ **Correct (parameterized queries):**
23
+
24
+ ```java
25
+ // SECURE: Using PreparedStatement
26
+ String userId = request.getParameter("id");
27
+ String query = "SELECT * FROM users WHERE id = ?";
28
+ PreparedStatement pstmt = connection.prepareStatement(query);
29
+ pstmt.setString(1, userId);
30
+ ResultSet rs = pstmt.executeQuery();
31
+
32
+ // Using Spring Data JPA
33
+ @Query("SELECT u FROM User u WHERE u.id = :id")
34
+ User findUserById(@Param("id") String id);
35
+
36
+ // Using Hibernate Criteria
37
+ List<User> users = session.createSelectionQuery("from User where id = :id", User.class)
38
+ .setParameter("id", userId)
39
+ .getResultList();
40
+ ```
41
+
42
+ **Prevention Checklist:**
43
+ - Never use `Statement.executeQuery()` with concatenated strings.
44
+ - Always use `PreparedStatement` or a secure ORM (Hibernate, Spring Data).
45
+ - For NoSQL (e.g., MongoDB), use the driver's query builder instead of string parsing.
46
+
47
+ **Tools:** SonarQube (S2077, S3649), SpotBugs (FindSecBugs), Checkstyle, OWASP ZAP
@@ -0,0 +1,32 @@
1
+ ---
2
+ title: Sanitize Input Before Sending Emails
3
+ impact: MEDIUM
4
+ impactDescription: prevents email header injection and spam abuse
5
+ tags: email, injection, sanitization, security, java
6
+ ---
7
+
8
+ ## Sanitize Input Before Sending Emails
9
+
10
+ Email header injection occurs when user data is added to email headers (Subject, To, CC) without sanitizing newline characters. This allows attackers to add extra recipients or change the email content.
11
+
12
+ **Incorrect (vulnerable email sending):**
13
+
14
+ ```java
15
+ // VULNERABLE: Subject can contain \nBcc: victim@example.com
16
+ String subject = request.getParameter("subject");
17
+ SimpleMailMessage message = new SimpleMailMessage();
18
+ message.setSubject(subject);
19
+ mailSender.send(message);
20
+ ```
21
+
22
+ **Correct (sanitization):**
23
+
24
+ ```java
25
+ // SECURE: Remove newlines from all header fields
26
+ String sanitizedSubject = subject.replaceAll("[\\r\\n]", "");
27
+ SimpleMailMessage message = new SimpleMailMessage();
28
+ message.setSubject(sanitizedSubject);
29
+ mailSender.send(message);
30
+ ```
31
+
32
+ **Tools:** SonarQube, Manual Review
@@ -0,0 +1,45 @@
1
+ ---
2
+ title: Avoid Dynamic Code Execution
3
+ impact: CRITICAL
4
+ impactDescription: prevents arbitrary code execution vulnerabilities
5
+ tags: injection, eval, dynamic-code, rce, security, java
6
+ ---
7
+
8
+ ## Avoid Dynamic Code Execution
9
+
10
+ Dynamic execution of code (using `ScriptEngine`, `ClassLoader.defineClass`, or unsecured reflection) allows attackers to execute arbitrary commands if they can control the input, leading to a full system compromise.
11
+
12
+ **Incorrect (dynamic script execution):**
13
+
14
+ ```java
15
+ // DANGEROUS: Running JS strings from user input
16
+ ScriptEngineManager manager = new ScriptEngineManager();
17
+ ScriptEngine engine = manager.getEngineByName("JavaScript");
18
+ String script = request.getParameter("formula");
19
+ // Attacker: java.lang.Runtime.getRuntime().exec("rm -rf /")
20
+ engine.eval(script);
21
+ ```
22
+
23
+ **Correct (safe alternatives):**
24
+
25
+ ```java
26
+ // 1. Use an expression language with a restricted sandbox (e.g., Spring Expression Language with validation)
27
+ StandardEvaluationContext context = new StandardEvaluationContext(data);
28
+ // STRICTLY validate or restrict what expressions are allowed
29
+
30
+ // 2. Use a safe math parser for formulas
31
+ Expression e = new ExpressionBuilder(request.getParameter("formula"))
32
+ .build();
33
+ double result = e.evaluate();
34
+
35
+ // 3. Prefer static logic
36
+ if ("add".equals(action)) {
37
+ result = a + b;
38
+ }
39
+ ```
40
+
41
+ **Security Risks:**
42
+ - **Remote Code Execution (RCE):** The primary risk of using `eval()` or similar dynamic executors.
43
+ - **Resource Exhaustion:** Attackers might run heavy loops or consume memory.
44
+
45
+ **Tools:** SonarQube (S1523), SpotBugs (FindSecBugs), Manual Review
@@ -0,0 +1,28 @@
1
+ ---
2
+ title: Escape Data By Output Context
3
+ impact: MEDIUM
4
+ impactDescription: ensures correct encoding for each output context (HTML, JS, URL)
5
+ tags: xss, escaping, context, security, java
6
+ ---
7
+
8
+ ## Escape Data By Output Context
9
+
10
+ Different contexts require different escaping strategies. Using HTML encoding inside a JavaScript block or an HTML attribute does not fully prevent XSS.
11
+
12
+ **Incorrect (wrong encoding for context):**
13
+
14
+ ```java
15
+ // WRONG: Using forHtml in a JS block
16
+ String name = request.getParameter("name");
17
+ out.println("<script>var x = '" + Encode.forHtml(name) + "';</script>");
18
+ ```
19
+
20
+ **Correct (matching encoder to context):**
21
+
22
+ ```java
23
+ // SECURE: Use the context-specific encoder
24
+ out.println("<script>var x = '" + Encode.forJavaScript(name) + "';</script>");
25
+ out.println("<a href='/profile?u=" + Encode.forUriComponent(name) + "'>View</a>");
26
+ ```
27
+
28
+ **Tools:** OWASP Java Encoder
@@ -0,0 +1,28 @@
1
+ ---
2
+ title: Output Encoding For Dynamic JS/JSON
3
+ impact: HIGH
4
+ impactDescription: prevents code injection in JavaScript contexts
5
+ tags: xss, javascript, json, encoding, security, java
6
+ ---
7
+
8
+ ## Output Encoding For Dynamic JS/JSON
9
+
10
+ When embedding user data into a JSON object that will be rendered inside a `<script>` tag, you must ensure that characters like `<` and `>` are escaped to prevent an attacker from closing the script tag and opening a new one.
11
+
12
+ **Incorrect (direct embedding):**
13
+
14
+ ```java
15
+ // VULNERABLE: Input </script><script>alert('xss')</script>
16
+ String jsonData = mapper.writeValueAsString(userData);
17
+ out.println("<script>var data = " + jsonData + ";</script>");
18
+ ```
19
+
20
+ **Correct (properly escaped JSON):**
21
+
22
+ ```java
23
+ // SECURE: Use Jackson features or OWASP Encoder for JS
24
+ // Jackson can be configured to escape non-ascii characters
25
+ out.println("<script>var data = " + Encode.forJavaScript(jsonData) + ";</script>");
26
+ ```
27
+
28
+ **Tools:** Jackson `JsonGenerator.Feature.ESCAPE_NON_ASCII`, OWASP Java Encoder
@@ -0,0 +1,58 @@
1
+ ---
2
+ title: Always Validate Client Data Server-Side
3
+ impact: CRITICAL
4
+ impactDescription: prevents malformed data and security bypasses
5
+ tags: validation, input, server-side, security, java
6
+ ---
7
+
8
+ ## Always Validate Client Data Server-Side
9
+
10
+ Client-side validation (HTML attributes, JavaScript) is for user experience only. It can be easily bypassed by using tools like Postman, `curl`, or browser developer tools. All sensitive data and business logic constraints must be re-validated on the server.
11
+
12
+ **Incorrect (trusting client input):**
13
+
14
+ ```java
15
+ @PostMapping("/api/purchase")
16
+ public void purchase(@RequestBody PurchaseRequest req) {
17
+ // VULNERABLE: Assuming price is correct from client
18
+ int total = req.getPrice() * req.getQuantity();
19
+ paymentService.charge(total);
20
+ }
21
+ ```
22
+
23
+ **Correct (server-side validation):**
24
+
25
+ ```java
26
+ // 1. Use Bean Validation (JSR-380)
27
+ public class PurchaseRequest {
28
+ @NotNull
29
+ @Min(1)
30
+ private Long productId;
31
+
32
+ @Min(1)
33
+ @Max(100)
34
+ private int quantity;
35
+
36
+ // Do NOT include price in request; fetch it from DB
37
+ }
38
+
39
+ @PostMapping("/api/purchase")
40
+ public ResponseEntity<?> purchase(@Valid @RequestBody PurchaseRequest req) {
41
+ // 2. Business logic validation
42
+ Product product = productRepo.findById(req.getProductId())
43
+ .orElseThrow(() -> new ProductNotFoundException());
44
+
45
+ int total = product.getPrice() * req.getQuantity();
46
+ paymentService.charge(total);
47
+
48
+ return ResponseEntity.ok().build();
49
+ }
50
+ ```
51
+
52
+ **Validation Strategies:**
53
+ - **Whitelisting:** Only allow known-good input.
54
+ - **Strict Typing:** Use appropriate data types (e.g., `Long` for IDs, `BigDecimal` for currency).
55
+ - **Constraints:** Use `@NotNull`, `@Size`, `@Pattern` (Regex) in your DTOs.
56
+ - **Business Logic:** Validate state transitions (e.g., cannot "Cancel" an already "Shipped" order).
57
+
58
+ **Tools:** Hibernate Validator, Spring Boot Validation, OWASP ZAP, Manual Review
@@ -0,0 +1,57 @@
1
+ ---
2
+ title: TLS Encryption For All Connections
3
+ impact: CRITICAL
4
+ impactDescription: protects data in transit from interception and tampering
5
+ tags: tls, encryption, https, transport, security, java
6
+ ---
7
+
8
+ ## TLS Encryption For All Connections
9
+
10
+ All network communications, whether between the client and server or between internal services, must be encrypted using TLS. Unencrypted connections (HTTP, raw JDBC) allow attackers to perform Man-in-the-Middle (MitM) attacks to steal sensitive data.
11
+
12
+ **Incorrect (unencrypted connections):**
13
+
14
+ ```java
15
+ // VULNERABLE: Using HTTP instead of HTTPS
16
+ HttpClient client = HttpClient.newHttpClient();
17
+ HttpRequest request = HttpRequest.newBuilder()
18
+ .uri(URI.create("http://api.production.sun-asterisk.vn/data"))
19
+ .build();
20
+
21
+ // VULNERABLE: Unencrypted database connection
22
+ String url = "jdbc:postgresql://db.sun-asterisk.vn:5432/mydb";
23
+ ```
24
+
25
+ **Correct (TLS everywhere):**
26
+
27
+ ```java
28
+ // 1. HTTPS for all external API calls
29
+ HttpRequest request = HttpRequest.newBuilder()
30
+ .uri(URI.create("https://api.production.sun-asterisk.vn/data"))
31
+ .build();
32
+
33
+ // 2. TLS for Database connections
34
+ String url = "jdbc:postgresql://db.sun-asterisk.vn:5432/mydb?ssl=true";
35
+
36
+ // 3. Enabling HSTS to force browsers to use HTTPS
37
+ // In Spring Security:
38
+ // http.headers(headers -> headers
39
+ // .httpStrictTransportSecurity(hsts -> hsts
40
+ // .includeSubDomains(true)
41
+ // .maxAgeInSeconds(31536000)
42
+ // )
43
+ // );
44
+
45
+ // 4. Redirecting HTTP to HTTPS
46
+ // http.requiresChannel(channel -> channel
47
+ // .anyRequest().requiresSecure()
48
+ // );
49
+ ```
50
+
51
+ **Requirements:**
52
+ - All endpoints must strictly use HTTPS.
53
+ - Plain HTTP requests must be redirected to HTTPS.
54
+ - Use HSTS (`Strict-Transport-Security`) headers to prevent protocol downgrade attacks.
55
+ - Ensure internal service-to-service communication is also encrypted.
56
+
57
+ **Tools:** OWASP ZAP, SSLyze, Qualys SSL Labs, Manual Review
@@ -0,0 +1,26 @@
1
+ ---
2
+ title: Validate mTLS Certificates Before Auth
3
+ impact: HIGH
4
+ impactDescription: ensures that only clients with valid, trusted certificates can access the service
5
+ tags: tls, mtls, authentication, security, java
6
+ ---
7
+
8
+ ## Validate mTLS Certificates Before Auth
9
+
10
+ In a mutual TLS (mTLS) setup, the server must verify the client's certificate before allowing the request to proceed. This provides strong, certificate-based authentication.
11
+
12
+ **Implementation (Spring Security):**
13
+
14
+ ```java
15
+ // http.x509(x509 -> x509
16
+ // .subjectPrincipalRegex("CN=(.*?)(?:,|$)")
17
+ // .userDetailsService(myUserDetailsService)
18
+ // );
19
+ ```
20
+
21
+ **Key Points:**
22
+ - Ensure the Truststore only contains the CAs you explicitly trust.
23
+ - Verify expiration and revocation status of the client certificate.
24
+ - Link the Certificate's Common Name (CN) or Subject Alternative Name (SAN) to a specific user/service identity.
25
+
26
+ **Tools:** OpenSSL, Spring Security X.509
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: Limit Upload File Size And Count
3
+ impact: MEDIUM
4
+ impactDescription: prevents Denial of Service (DoS) attacks via disk exhaustion or memory pressure
5
+ tags: uploads, dos, security, java
6
+ ---
7
+
8
+ ## Limit Upload File Size And Count
9
+
10
+ Unrestricted file uploads allow an attacker to crash the server by sending massive files or thousands of small files, filling up disk space or consuming all available memory.
11
+
12
+ **Incorrect (no limits):**
13
+
14
+ ```java
15
+ // VULNERABLE: No limit on size
16
+ @PostMapping("/upload")
17
+ public void handleUpload(@RequestParam("file") MultipartFile file) {
18
+ file.transferTo(new File("/uploads/" + file.getOriginalFilename()));
19
+ }
20
+ ```
21
+
22
+ **Correct (configured limits):**
23
+
24
+ ```java
25
+ // 1. Spring Boot Configuration (application.properties)
26
+ // spring.servlet.multipart.max-file-size=2MB
27
+ // spring.servlet.multipart.max-request-size=10MB
28
+
29
+ // 2. Manual check
30
+ if (file.getSize() > 2 * 1024 * 1024) {
31
+ throw new BadRequestException("File too large");
32
+ }
33
+ ```
34
+
35
+ **Tools:** Spring Boot Multipart Properties, OWASP ZAP
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: Apply CSRF Protection
3
+ impact: HIGH
4
+ impactDescription: prevents Cross-Site Request Forgery attacks that could execute actions on behalf of the user
5
+ tags: csrf, security, java
6
+ ---
7
+
8
+ ## Apply CSRF Protection
9
+
10
+ CSRF attacks trick a logged-in user into sending a request to your application (e.g., via a hidden form on a malicious site). If the application relies only on cookies for authentication, the browser will include them, and the attack will succeed.
11
+
12
+ **Incorrect (no CSRF protection):**
13
+
14
+ ```java
15
+ // VULNERABLE: Spring Security disabled CSRF
16
+ http.csrf(csrf -> csrf.disable());
17
+ ```
18
+
19
+ **Correct (enabled and configured CSRF):**
20
+
21
+ ```java
22
+ // 1. Spring Security (Enabled by default)
23
+ // For SPAs (Stateless/JWT):
24
+ // http.csrf(csrf -> csrf.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()));
25
+
26
+ // 2. In Thymeleaf forms (automatic token insertion):
27
+ // <form th:action="@{/logout}" method="post">
28
+ ```
29
+
30
+ **Defense Strategies:**
31
+ - **Synchronizer Token Pattern:** Include a random token in every state-changing request (POST, PUT, DELETE).
32
+ - **SameSite Cookie Attribute:** Set `SameSite=Lax` or `Strict`.
33
+ - **Custom Headers:** For AJAX requests, require a custom header (e.g., `X-Requested-With`) which cannot be added cross-site without CORS permission.
34
+
35
+ **Tools:** Spring Security, OWASP ZAP
@@ -0,0 +1,38 @@
1
+ ---
2
+ title: Disable Directory Browsing
3
+ impact: MEDIUM
4
+ impactDescription: prevents attackers from seeing the directory structure and identifying sensitive files
5
+ tags: configuration, server, directory-browsing, security, java
6
+ ---
7
+
8
+ ## Disable Directory Browsing
9
+
10
+ If directory browsing is enabled, an attacker visiting a folder without an `index.html` file can see all files in that directory. This often leads to the discovery of sensitive configuration files, source code backups, or uploaded data.
11
+
12
+ **How to Disable:**
13
+
14
+ **1. In Embedded Tomcat (Spring Boot):**
15
+ It is disabled by default. Do not change the `server.tomcat.basedir` to a public-facing path without index files.
16
+
17
+ **2. In Standard `web.xml` (Legacy):**
18
+ ```xml
19
+ <servlet>
20
+ <servlet-name>default</servlet-name>
21
+ <servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
22
+ <init-param>
23
+ <param-name>listings</param-name>
24
+ <param-value>false</param-value> <!-- SECURE: Set to false -->
25
+ </init-param>
26
+ </servlet>
27
+ ```
28
+
29
+ **3. Using Spring Security:**
30
+ ```java
31
+ // Prevent direct access to static resource directories
32
+ http.authorizeHttpRequests(auth -> auth
33
+ .requestMatchers("/static/**").permitAll()
34
+ .requestMatchers("/config/**").denyAll()
35
+ );
36
+ ```
37
+
38
+ **Tools:** OWASP ZAP, Manual Review