Scala 2.12
Last reviewed Sep 5, 2026
Prompt Details
Prompt Composition
2prompts
- Java 25113 lines · 2.8K tokens
- Scala 2.1267 lines · 2.3K tokens
Total180 lines · 5.1K tokens
CWE Coverage
- 20
- 22
- 59
- 78
- 79
- 88
- 89
- 95
- 113
- 117
- 190
- 201
- 208
- 209
- 214
- 295
- 297
- 306
- 323
- 327
- 338
- 347
- 362
- 367
- 378
- 427
- 470
- 471
- 476
- 494
- 502
- 532
- 611
- 653
- 674
- 681
- 732
- 749
- 770
- 772
- 776
- 789
- 807
- 829
- 863
- 915
- 916
- 918
- 922
- 942
- 1333
Prompt Preview
Apply the Java 25 prompt first. These rules cover the maintained Scala 2.12 language, compiler, standard library, reflection, and JVM interoperability, and were checked against 2.12.21.
Types and security invariants
- Represent validated identifiers, principals, permissions, money, and paths with distinct types instead of primitive aliases.
- Put validation in private constructors and controlled companion factories; audit generated case-class
applyandcopymethods so they cannot create invalid privileged state. Userequireor explicit checks because compiler assertion-elision flags can removeassertandassume. - Use sealed traits and exhaustive pattern matches for authorization and workflow states; do not let a wildcard case silently grant access or accept a new subtype.
- Treat
asInstanceOf, erased generic matches,isInstanceOfon parameterized types,@unchecked, structural types, and reflective calls as explicit trust-boundary bypasses. - Use
Optionfor absence in Scala-owned APIs, but validate Java-originated references before wrapping them; never useOption.geton attacker-influenced state.
Input, output, and process execution
- Decode external data into bounded schemas and reject unknown variants, duplicate fields, excess nesting, oversized collections, and non-canonical numeric values.
- Bound regex work, collection builders, ranges, recursive parsers,
Streamevaluation, iterators, and numeric conversions derived from untrusted input. - Treat
s,f, andrawstring interpolators as formatting only; pass values to the parameter or