OptimizedSecurityTaxonomy.java

1
package org.egothor.methodatlas.ai;
2
3
/**
4
 * Provides the optimized built-in taxonomy used to guide AI-based security
5
 * classification when prompt compactness and model reliability are prioritized.
6
 *
7
 * <p>
8
 * This class supplies a condensed taxonomy definition intended for use with
9
 * {@link org.egothor.methodatlas.ai.AiOptions.TaxonomyMode#OPTIMIZED}. In
10
 * contrast to {@link DefaultSecurityTaxonomy}, this variant is structured to
11
 * improve AI classification consistency by reducing prompt verbosity while
12
 * preserving the same controlled category set and classification intent.
13
 * </p>
14
 *
15
 * <h2>Design Goals</h2>
16
 *
17
 * <ul>
18
 * <li>minimize prompt length without changing the supported taxonomy</li>
19
 * <li>increase deterministic model behavior</li>
20
 * <li>reduce ambiguity in category selection</li>
21
 * <li>preserve professional terminology and decision rules</li>
22
 * </ul>
23
 *
24
 * <p>
25
 * The taxonomy text returned by this class is intended to be embedded directly
26
 * into AI prompts and therefore favors concise, machine-oriented instruction
27
 * structure over explanatory prose.
28
 * </p>
29
 *
30
 * <p>
31
 * This class is a non-instantiable utility holder.
32
 * </p>
33
 *
34
 * @see DefaultSecurityTaxonomy
35
 * @see org.egothor.methodatlas.ai.AiSuggestionEngineImpl
36
 * @see org.egothor.methodatlas.ai.AiOptions.TaxonomyMode
37
 */
38
public final class OptimizedSecurityTaxonomy {
39
    /**
40
     * Prevents instantiation of this utility class.
41
     */
42
    private OptimizedSecurityTaxonomy() {
43
    }
44
45
    /**
46
     * Returns the optimized built-in taxonomy text used for AI classification.
47
     *
48
     * <p>
49
     * The returned taxonomy is a compact instruction set designed for large
50
     * language models performing security classification of JUnit test methods. It
51
     * preserves the same controlled tag set as the default taxonomy while
52
     * presenting the rules in a shorter, more model-oriented structure.
53
     * </p>
54
     *
55
     * <p>
56
     * The taxonomy defines:
57
     * </p>
58
     * <ul>
59
     * <li>the meaning of a security-relevant test</li>
60
     * <li>the mandatory {@code security} umbrella tag</li>
61
     * <li>the allowed category tags</li>
62
     * <li>selection rules for assigning taxonomy tags</li>
63
     * <li>guidance for use of the optional {@code owasp} tag</li>
64
     * <li>the required {@code SECURITY: <property> - <scenario>} display name
65
     * format</li>
66
     * </ul>
67
     *
68
     * <p>
69
     * This optimized variant is suitable when improved model consistency or shorter
70
     * prompt size is more important than human-oriented explanatory wording.
71
     * </p>
72
     *
73
     * @return optimized taxonomy text used to instruct AI classification
74
     *
75
     * @see DefaultSecurityTaxonomy#text()
76
     * @see org.egothor.methodatlas.ai.AiSuggestionEngineImpl
77
     */
78
    public static String text() {
79 1 1. text : replaced return value with "" for org/egothor/methodatlas/ai/OptimizedSecurityTaxonomy::text → SURVIVED
        return """
80
                SECURITY TEST CLASSIFICATION SPECIFICATION
81
                ==========================================
82
83
                Goal
84
                ----
85
86
                Classify JUnit 5 test methods that validate security properties.
87
88
                The output MUST follow the allowed tag taxonomy and MUST NOT introduce new tags.
89
90
91
                Security-Relevant Test Definition
92
                ---------------------------------
93
94
                A test is security-relevant when it verifies any of the following:
95
96
                • authentication behavior
97
                • authorization decisions
98
                • cryptographic correctness
99
                • validation of untrusted input
100
                • protection against injection attacks
101
                • protection of sensitive data
102
                • security event logging
103
                • secure error handling
104
105
                If failure of the test could allow:
106
107
                • unauthorized access
108
                • data exposure
109
                • privilege escalation
110
                • security control bypass
111
112
                then the test is security-relevant.
113
114
115
                Mandatory Tag
116
                -------------
117
118
                Every security-relevant test MUST contain:
119
120
                security
121
122
123
                Allowed Category Tags
124
                ---------------------
125
126
                Only the following tags are permitted:
127
128
                auth
129
                access-control
130
                crypto
131
                input-validation
132
                injection
133
                data-protection
134
                logging
135
                error-handling
136
                owasp
137
138
139
                Category Semantics
140
                ------------------
141
142
                auth
143
                    authentication validation
144
                    identity verification
145
                    credential checks
146
                    token/session validation
147
148
                access-control
149
                    authorization enforcement
150
                    permission checks
151
                    role evaluation
152
                    ownership validation
153
154
                crypto
155
                    encryption/decryption
156
                    signature verification
157
                    key usage
158
                    nonce/IV rules
159
                    hashing or key derivation
160
161
                input-validation
162
                    validation of untrusted inputs
163
                    canonicalization
164
                    malformed input rejection
165
                    path normalization
166
167
                injection
168
                    protection against injection attacks
169
                    SQL/NoSQL injection
170
                    command injection
171
                    template injection
172
                    deserialization vulnerabilities
173
174
                data-protection
175
                    encryption of sensitive data
176
                    secret handling
177
                    PII protection
178
                    secure storage
179
180
                logging
181
                    security event logging
182
                    audit events
183
                    absence of secrets in logs
184
185
                error-handling
186
                    safe error messages
187
                    no information leakage
188
                    safe fallback behavior
189
190
191
                OWASP Tag
192
                ---------
193
194
                The `owasp` tag indicates that the test validates protection against a vulnerability
195
                category commonly described in OWASP guidance such as:
196
197
                • injection
198
                • broken authentication
199
                • broken access control
200
                • security misconfiguration
201
                • sensitive data exposure
202
                • insecure deserialization
203
                • cross-site scripting
204
205
                The `owasp` tag should only be used when the test clearly targets a known
206
                OWASP vulnerability category.
207
208
                Prefer combining `owasp` with a more precise taxonomy tag.
209
210
211
                Tag Selection Rules
212
                -------------------
213
214
                1. If a test validates a security property → include `security`.
215
                2. Add 1–3 additional category tags when applicable.
216
                3. Prefer the most specific tag.
217
                4. Do not assign tags when security relevance is unclear.
218
                5. Never invent new tags.
219
220
221
                Display Name Format
222
                -------------------
223
224
                SECURITY: <security property> - <scenario>
225
226
                Examples:
227
228
                SECURITY: access control - deny non-owner account access
229
                SECURITY: crypto - reject reused nonce in AEAD
230
                SECURITY: input validation - reject path traversal sequences
231
                """;
232
    }
233
}

Mutations

79

1.1
Location : text
Killed by : none
replaced return value with "" for org/egothor/methodatlas/ai/OptimizedSecurityTaxonomy::text → SURVIVED
Covering tests

Active mutators

Tests examined


Report generated by PIT 1.22.1