@@ -696,6 +696,25 @@ describe('Rule suppression system', () => {
696
696
const metadata = test . getMetadata ( 'cdk_nag' ) ?. rules_to_suppress ;
697
697
expect ( metadata ) . toContainEqual ( expect . objectContaining ( suppression ) ) ;
698
698
} ) ;
699
+ test ( 'Reason containing multibyte characters is base64 encoded' , ( ) => {
700
+ const stack = new Stack ( ) ;
701
+ Aspects . of ( stack ) . add ( new AwsSolutionsChecks ( ) ) ;
702
+ const test = new CfnRoute ( stack , 'CfnRoute' , { routeTableId : 'foo' } ) ;
703
+ const suppression = {
704
+ id : 'AwsSolutions-EC23' ,
705
+ reason : 'あいうえおかきくけこ' ,
706
+ } ;
707
+ const suppressionInMetadata = {
708
+ id : 'AwsSolutions-EC23' ,
709
+ reason : '44GC44GE44GG44GI44GK44GL44GN44GP44GR44GT' ,
710
+ is_reason_encoded : true ,
711
+ } ;
712
+ NagSuppressions . addResourceSuppressions ( test , [ suppression ] ) ;
713
+ const metadata = test . getMetadata ( 'cdk_nag' ) ?. rules_to_suppress ;
714
+ expect ( metadata ) . toContainEqual (
715
+ expect . objectContaining ( suppressionInMetadata )
716
+ ) ;
717
+ } ) ;
699
718
test ( 'suppressed rule logging enabled' , ( ) => {
700
719
const stack = new Stack ( ) ;
701
720
Aspects . of ( stack ) . add ( new AwsSolutionsChecks ( { logIgnores : true } ) ) ;
@@ -1031,6 +1050,25 @@ describe('Report system', () => {
1031
1050
] ;
1032
1051
expect ( pack . lines . sort ( ) ) . toEqual ( expectedOuput . sort ( ) ) ;
1033
1052
} ) ;
1053
+ test ( 'Suppression values are written properly when multibyte characters are used in reason' , ( ) => {
1054
+ const app = new App ( ) ;
1055
+ const stack = new Stack ( app , 'Stack1' ) ;
1056
+ const pack = new TestPack ( ) ;
1057
+ Aspects . of ( app ) . add ( pack ) ;
1058
+ const resource = new CfnResource ( stack , 'rResource' , { type : 'foo' } ) ;
1059
+ NagSuppressions . addResourceSuppressions ( resource , [
1060
+ {
1061
+ id : `${ pack . readPackName } -${ NagRuleCompliance . NON_COMPLIANT } ` ,
1062
+ reason : 'あいうえおかきくけこ' ,
1063
+ } ,
1064
+ ] ) ;
1065
+ app . synth ( ) ;
1066
+ const expectedOuput = [
1067
+ '"Test-Compliant","Stack1/rResource","Compliant","N/A","Error","foo."\n' ,
1068
+ '"Test-Non-Compliant","Stack1/rResource","Suppressed","あいうえおかきくけこ","Error","foo."\n' ,
1069
+ ] ;
1070
+ expect ( pack . lines . sort ( ) ) . toEqual ( expectedOuput . sort ( ) ) ;
1071
+ } ) ;
1034
1072
test ( 'Error values are written properly' , ( ) => {
1035
1073
const app = new App ( ) ;
1036
1074
const stack = new Stack ( app , 'Stack1' ) ;
0 commit comments