File tree Expand file tree Collapse file tree 2 files changed +25
-24
lines changed Expand file tree Collapse file tree 2 files changed +25
-24
lines changed Original file line number Diff line number Diff line change @@ -303,20 +303,22 @@ export const listVirtualMFADevices = async (
303303 try {
304304 iam . listVirtualMFADevices (
305305 args ,
306- async ( err : AWSError , data : ListVirtualMFADevicesResponse ) => {
306+ ( err : AWSError , data : ListVirtualMFADevicesResponse ) => {
307307 if ( err ) {
308308 errorLog . generateAwsErrorLog ( {
309309 functionName : 'iam:listVirtualMFADevices' ,
310310 err,
311311 } )
312312 }
313313
314- const { VirtualMFADevices = [ ] , IsTruncated, Marker } = data
314+ if ( ! isEmpty ( data ) ) {
315+ const { VirtualMFADevices = [ ] , IsTruncated, Marker } = data
315316
316- virtualMFADeviceList . push ( ...VirtualMFADevices )
317+ virtualMFADeviceList . push ( ...VirtualMFADevices )
317318
318- if ( IsTruncated ) {
319- listAllVirtualMFADevices ( Marker )
319+ if ( IsTruncated ) {
320+ listAllVirtualMFADevices ( Marker )
321+ }
320322 }
321323
322324 resolve ( virtualMFADeviceList )
@@ -345,21 +347,18 @@ export const listIamUsers = async (
345347 iam . listUsers (
346348 { Marker : marker } ,
347349 async ( err : AWSError , data : ListUsersResponse ) => {
348- /**
349- * No data
350- */
351-
352- if ( isEmpty ( data ) ) {
353- return resolve ( result )
354- }
355-
356350 if ( err ) {
357351 errorLog . generateAwsErrorLog ( {
358352 functionName : 'iam:listUsers' ,
359353 err,
360354 } )
361355 }
362356
357+ // No data
358+ if ( isEmpty ( data ) ) {
359+ return resolve ( result )
360+ }
361+
363362 const { Users : users = [ ] , IsTruncated, Marker } = data
364363
365364 users . map ( user => {
Original file line number Diff line number Diff line change @@ -569,10 +569,10 @@ export default class Provider extends CloudGraph.Client {
569569
570570 const config = await this . getAwsConfig ( account )
571571 const { accountId } = await this . getIdentity ( account )
572- try {
573- for ( const resource of resourceNames ) {
574- const serviceClass = this . getService ( resource )
575- if ( serviceClass && serviceClass . getData ) {
572+ for ( const resource of resourceNames ) {
573+ const serviceClass = this . getService ( resource )
574+ if ( serviceClass && serviceClass . getData ) {
575+ try {
576576 const data = await serviceClass . getData ( {
577577 regions : configuredRegions ,
578578 config,
@@ -587,17 +587,19 @@ export default class Provider extends CloudGraph.Client {
587587 data,
588588 } )
589589 this . logger . success ( `${ resource } scan completed` )
590- } else {
591- this . logger . warn (
592- `Skipping service ${ resource } as there was an issue getting data for it. Is it currently supported? `
590+ } catch ( error : any ) {
591+ this . logger . error (
592+ `There was an error scanning AWS sdk data for ${ resource } resource `
593593 )
594+ this . logger . debug ( error )
594595 }
596+ } else {
597+ this . logger . warn (
598+ `Skipping service ${ resource } as there was an issue getting data for it. Is it currently supported?`
599+ )
595600 }
596- this . logger . success ( `Account: ${ accountId } scan completed` )
597- } catch ( error : any ) {
598- this . logger . error ( 'There was an error scanning AWS sdk data' )
599- this . logger . debug ( error )
600601 }
602+ this . logger . success ( `Account: ${ accountId } scan completed` )
601603 return result
602604 }
603605
You can’t perform that action at this time.
0 commit comments