@@ -138,6 +138,83 @@ const listFindings = [
138138
139139] ;
140140
141+ const listFindingsV2 = [
142+ {
143+ "findings" : [
144+ {
145+ "analyzedAt" : "2025-01-23T13:06:24+00:00" ,
146+ "createdAt" : "2025-01-23T13:06:56+00:00" ,
147+ "id" : "1a234567-bc6d-7yui-h5j7-4f5f9j8987y0" ,
148+ "resource" : "arn:aws:iam::123456789123:role/abcd-abcd-adfitoui-abcdefg-p1-AsdfghTfjdudnjkDkjg-Z9JgMyMzcxOZ" ,
149+ "resourceType" : "AWS::IAM::Role" ,
150+ "resourceOwnerAccount" : "123456789123" ,
151+ "status" : "ACTIVE" ,
152+ "updatedAt" : "2025-01-23T13:06:56+00:00" ,
153+ "findingType" : "UnusedIAMRole"
154+ } ,
155+ {
156+ "analyzedAt" : "2025-01-23T13:06:24+00:00" ,
157+ "createdAt" : "2025-01-23T13:06:56+00:00" ,
158+ "id" : "938r4848-4h4j-8449-76d8-8768dh5dhh4u" ,
159+ "resource" : "arn:aws:iam::123456789123:role/abcd-abcd-adfitoui-abcdefg-AsdfghTfjdudnjkDkjg-6vzrTVSqTaNe" ,
160+ "resourceType" : "AWS::IAM::Role" ,
161+ "resourceOwnerAccount" : "123456789123" ,
162+ "status" : "ACTIVE" ,
163+ "updatedAt" : "2025-01-23T13:06:56+00:00" ,
164+ "findingType" : "UnusedIAMRole"
165+ } ,
166+ {
167+ "analyzedAt" : "2025-01-23T13:06:55+00:00" ,
168+ "createdAt" : "2025-01-23T13:06:56+00:00" ,
169+ "id" : "7484f848-984j-498l-784s-yryh74748f45" ,
170+ "resource" : "arn:aws:iam::123456789123:role/service-role/sdfghyFj-FGH-njkkjg-plgd-6uhjn9ok" ,
171+ "resourceType" : "AWS::IAM::Role" ,
172+ "resourceOwnerAccount" : "123456789123" ,
173+ "status" : "ACTIVE" ,
174+ "updatedAt" : "2025-01-23T13:06:56+00:00" ,
175+ "findingType" : "UnusedPermission"
176+ } ,
177+ ]
178+ } ,
179+ {
180+ "findings" : [
181+ {
182+ "analyzedAt" : "2025-01-23T13:06:24+00:00" ,
183+ "createdAt" : "2025-01-23T13:06:56+00:00" ,
184+ "id" : "1a234567-bc6d-7yui-h5j7-4f5f9j8987y0" ,
185+ "resource" : "arn:aws:iam::123456789123:role/abcd-abcd-adfitoui-abcdefg-p1-AsdfghTfjdudnjkDkjg-Z9JgMyMzcxOZ" ,
186+ "resourceType" : "AWS::IAM::Role" ,
187+ "resourceOwnerAccount" : "123456789123" ,
188+ "status" : "ARCHIVED" ,
189+ "updatedAt" : "2025-01-23T13:06:56+00:00" ,
190+ "findingType" : "UnusedIAMRole"
191+ } ,
192+ {
193+ "analyzedAt" : "2025-01-23T13:06:24+00:00" ,
194+ "createdAt" : "2025-01-23T13:06:56+00:00" ,
195+ "id" : "938r4848-4h4j-8449-76d8-8768dh5dhh4u" ,
196+ "resource" : "arn:aws:iam::123456789123:role/abcd-abcd-adfitoui-abcdefg-AsdfghTfjdudnjkDkjg-6vzrTVSqTaNe" ,
197+ "resourceType" : "AWS::IAM::Role" ,
198+ "resourceOwnerAccount" : "123456789123" ,
199+ "status" : "ARCHIVED" ,
200+ "updatedAt" : "2025-01-23T13:06:56+00:00" ,
201+ "findingType" : "UnusedIAMRole"
202+ } ,
203+ {
204+ "analyzedAt" : "2025-01-23T13:06:55+00:00" ,
205+ "createdAt" : "2025-01-23T13:06:56+00:00" ,
206+ "id" : "7484f848-984j-498l-784s-yryh74748f45" ,
207+ "resource" : "arn:aws:iam::123456789123:role/service-role/sdfghyFj-FGH-njkkjg-plgd-6uhjn9ok" ,
208+ "resourceType" : "AWS::IAM::Role" ,
209+ "resourceOwnerAccount" : "123456789123" ,
210+ "status" : "RESOLVED" ,
211+ "updatedAt" : "2025-01-23T13:06:56+00:00" ,
212+ "findingType" : "UnusedPermission"
213+ } ,
214+ ]
215+ }
216+
217+ ]
141218
142219const createCache = ( analyzer , listFindings , analyzerErr , listFindingsErr ) => {
143220 var analyzerArn = ( analyzer && analyzer . length ) ? analyzer [ 0 ] . arn : null ;
@@ -163,7 +240,7 @@ const createCache = (analyzer, listFindings, analyzerErr, listFindingsErr) => {
163240
164241describe ( 'accessAnalyzerActiveFindings' , function ( ) {
165242 describe ( 'run' , function ( ) {
166- it ( 'should FAIL if Amazon IAM access analyzer has active findings.' , function ( done ) {
243+ it ( 'should FAIL if Amazon IAM access analyzer V1 has active findings.' , function ( done ) {
167244 const cache = createCache ( listAnalyzers , listFindings [ 0 ] ) ;
168245 accessAnalyzerActiveFindings . run ( cache , { } , ( err , results ) => {
169246 expect ( results . length ) . to . equal ( 1 ) ;
@@ -174,7 +251,18 @@ describe('accessAnalyzerActiveFindings', function () {
174251 } ) ;
175252 } ) ;
176253
177- it ( 'should PASS if Amazon IAM access analyzer have no active findings.' , function ( done ) {
254+ it ( 'should FAIL if Amazon IAM access analyzer v2 has active findings.' , function ( done ) {
255+ const cache = createCache ( listAnalyzers , listFindingsV2 [ 0 ] ) ;
256+ accessAnalyzerActiveFindings . run ( cache , { } , ( err , results ) => {
257+ expect ( results . length ) . to . equal ( 1 ) ;
258+ expect ( results [ 0 ] . status ) . to . equal ( 2 ) ;
259+ expect ( results [ 0 ] . region ) . to . equal ( 'us-east-1' ) ;
260+ expect ( results [ 0 ] . message ) . to . include ( 'Amazon IAM Access Analyzer has active findings' ) ;
261+ done ( ) ;
262+ } ) ;
263+ } ) ;
264+
265+ it ( 'should PASS if Amazon IAM access analyzer V1 have no active findings.' , function ( done ) {
178266 const cache = createCache ( listAnalyzers , listFindings [ 1 ] ) ;
179267 accessAnalyzerActiveFindings . run ( cache , { } , ( err , results ) => {
180268 expect ( results . length ) . to . equal ( 1 ) ;
@@ -186,6 +274,19 @@ describe('accessAnalyzerActiveFindings', function () {
186274 } ) ;
187275 } ) ;
188276
277+
278+ it ( 'should PASS if Amazon IAM access analyzer V2 have no active findings.' , function ( done ) {
279+ const cache = createCache ( listAnalyzers , listFindingsV2 [ 1 ] ) ;
280+ accessAnalyzerActiveFindings . run ( cache , { } , ( err , results ) => {
281+ expect ( results . length ) . to . equal ( 1 ) ;
282+ expect ( results [ 0 ] . status ) . to . equal ( 0 ) ;
283+ expect ( results [ 0 ] . region ) . to . equal ( 'us-east-1' ) ;
284+ expect ( results [ 0 ] . message ) . to . include ( 'Amazon IAM Access Analyzer has no active findings' ) ;
285+
286+ done ( ) ;
287+ } ) ;
288+ } ) ;
289+
189290 it ( 'should PASS if no analyzers found' , function ( done ) {
190291 const cache = createCache ( [ ] ) ;
191292 accessAnalyzerActiveFindings . run ( cache , { } , ( err , results ) => {
0 commit comments