@@ -88,12 +88,42 @@ describe('security-hub.adapter helpers', () => {
8888 expect ( formatRelatedRequirements ( [ ] ) ) . toBe ( '' ) ;
8989 } ) ;
9090
91- it ( 'formats a NIST 800-53 requirement in parser-compatible form' , ( ) => {
92- expect ( formatRelatedRequirements ( [ 'NIST.800-53.r5 AC-2' ] ) ) . toMatch (
93- / n i s t .* A C - 2 / i,
91+ it ( 'emits NIST 800-53 verbatim when no explicit version separator is present' , ( ) => {
92+ // NIST embeds the revision in the standard name ("NIST.800-53.r5"),
93+ // so the structured `standard version (control)` regex doesn't
94+ // match — fallback emits the raw string and the parser surfaces it
95+ // as a single chip label. Better than fabricating a placeholder.
96+ expect ( formatRelatedRequirements ( [ 'NIST.800-53.r5 AC-2' ] ) ) . toBe (
97+ 'NIST.800-53.r5 AC-2' ,
9498 ) ;
9599 } ) ;
96100
101+ it ( 'formats CIS AWS Foundations Benchmark in parser-compatible form (regex must accept lowercase)' , ( ) => {
102+ // Cubic P2 regression guard — the prior regex `[A-Z][A-Z0-9 .]+?`
103+ // could not match "Foundations" / "Benchmark" because of the
104+ // lowercase letters, so this format silently fell through.
105+ const result = formatRelatedRequirements ( [
106+ 'CIS AWS Foundations Benchmark v1.2.0 1.1' ,
107+ ] ) ;
108+ expect ( result ) . toMatch ( / ^ c i s .* 1 \. 2 \. 0 \( 1 \. 1 \) $ / ) ;
109+ } ) ;
110+
111+ it ( 'formats PCI DSS in parser-compatible form' , ( ) => {
112+ const result = formatRelatedRequirements ( [ 'PCI DSS v3.2.1 8.2.3' ] ) ;
113+ expect ( result ) . toBe ( 'pci dss 3.2.1 (8.2.3)' ) ;
114+ } ) ;
115+
116+ it ( 'formats AWS FSBP in parser-compatible form, handling the slash separator' , ( ) => {
117+ // Cubic P2 regression guard — `/` between version and control is
118+ // unique to AWS Foundational Security Best Practices. Without the
119+ // pre-normalization, the regex `\s+` between version and control
120+ // would never match.
121+ const result = formatRelatedRequirements ( [
122+ 'AWS Foundational Security Best Practices v1.0.0/EC2.2' ,
123+ ] ) ;
124+ expect ( result ) . toMatch ( / ^ a w s f s b p 1 \. 0 \. 0 \( E C 2 \. 2 \) $ / ) ;
125+ } ) ;
126+
97127 it ( 'joins multiple requirements with "; " so the parser splits them correctly' , ( ) => {
98128 const result = formatRelatedRequirements ( [
99129 'NIST.800-53.r5 AC-2' ,
0 commit comments