Skip to content

Commit e33ff2e

Browse files
author
Marco Franceschi
committed
fix: Fixed glueJob and glueRegistry issues during scan
1 parent cbecdc4 commit e33ff2e

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

src/services/glueJob/data.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Config } from 'aws-sdk/lib/config'
22
import GLUE from 'aws-sdk/clients/glue'
3-
import { groupBy } from 'lodash'
3+
import { groupBy, isEmpty } from 'lodash'
44
import { convertToPromise, fetchAllPaginatedData } from '../../utils/fetchUtils'
55
import { initTestEndpoint } from '../../utils'
66
import ErrorLog from '../../utils/errorLog'
@@ -23,29 +23,31 @@ export default async ({
2323
}: {
2424
regions: string
2525
config: Config
26-
}): Promise<{ [region: string]: RawAwsGlueJob[]}> => {
26+
}): Promise<{ [region: string]: RawAwsGlueJob[] }> => {
2727
const result: RawAwsGlueJob[] = []
2828

2929
const activeRegions = regions.split(',')
3030

3131
for (const region of activeRegions) {
32-
let glueJobData: GLUE.Job[]
32+
let glueJobData: GLUE.Job[] = []
3333
try {
34-
glueJobData = await fetchAllPaginatedData({
35-
getResourcesFn: convertToPromise({
36-
sdkContext: new GLUE({ ...config, region, endpoint }),
37-
fnName: 'getJobs',
38-
}),
39-
accessor: '',
40-
}) ?? []
34+
glueJobData =
35+
(await fetchAllPaginatedData({
36+
getResourcesFn: convertToPromise({
37+
sdkContext: new GLUE({ ...config, region, endpoint }),
38+
fnName: 'getJobs',
39+
}),
40+
accessor: '',
41+
})) ?? []
4142
} catch (err) {
4243
errorLog.generateAwsErrorLog({
4344
functionName: 'glueJob:getJobs',
44-
err
45+
err,
4546
})
4647
}
4748

48-
result.push(...glueJobData.map(val => ({ ...val, region })))
49+
if (!isEmpty(glueJobData))
50+
result.push(...glueJobData.map(val => ({ ...val, region })))
4951
}
5052
errorLog.reset()
5153
return groupBy(result, 'region')

src/services/glueRegistry/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default async ({
3131
const activeRegions = regions.split(',')
3232

3333
for (const region of activeRegions) {
34-
let glueRegistryData: GLUE.RegistryListItem[]
34+
let glueRegistryData: GLUE.RegistryListItem[] = []
3535
try {
3636
glueRegistryData = await fetchAllPaginatedData({
3737
getResourcesFn: convertToPromise({

0 commit comments

Comments
 (0)