Skip to content

Commit

Permalink
Merge pull request #71 from hazcod/feat/warnings
Browse files Browse the repository at this point in the history
fix(falcon): fetch device details in chunks of 100
  • Loading branch information
hazcod authored Feb 7, 2023
2 parents a739f52 + 0f22334 commit 4b700ed
Showing 1 changed file with 39 additions and 8 deletions.
47 changes: 39 additions & 8 deletions pkg/falcon/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,50 @@ func GetMessages(config *config.Config, ctx context.Context) (results map[string
return nil, nil, nil, errors.Wrap(err, "could not query all hosts")
}

hostDetail, err := client.Hosts.GetDeviceDetails(&hosts.GetDeviceDetailsParams{
Ids: hostResult.Payload.Resources,
Context: ctx,
HTTPClient: nil,
})
if err != nil || !hostDetail.IsSuccess() {
return nil, nil, nil, errors.Wrap(err, "could not query all host details")
allHostDetails := make([]*models.DomainDeviceSwagger, 0)

step := 100
sliceStart := 0
sliceEnd := sliceStart + step

for {

if sliceEnd == len(hostResult.Payload.Resources)-1 {
break
}

if sliceEnd >= len(hostResult.Payload.Resources) {
sliceEnd = len(hostResult.Payload.Resources) - 1
}

if sliceEnd == sliceStart {
break
}

logrus.WithField("slice_start", sliceStart).WithField("slice_end", sliceEnd).
Debug("fetching host device details")

slicePart := hostResult.Payload.Resources[sliceStart:sliceEnd]

hostDetail, err := client.Hosts.GetDeviceDetails(&hosts.GetDeviceDetailsParams{
Ids: slicePart,
Context: ctx,
HTTPClient: nil,
})
if err != nil || !hostDetail.IsSuccess() {
return nil, nil, nil, errors.Wrap(err, "could not query all host details")
}

allHostDetails = append(allHostDetails, hostDetail.Payload.Resources...)

sliceStart = sliceEnd
sliceEnd = sliceStart + step
}

securityErrorsMap := make(map[string]struct{})
now := time.Now()

for _, detail := range hostDetail.Payload.Resources {
for _, detail := range allHostDetails {

email, err := findEmailTag(detail.Tags, config.Email.Domains)
if err != nil || email == "" {
Expand Down

0 comments on commit 4b700ed

Please sign in to comment.