Skip to content

Commit

Permalink
x-pack/filebeat/input/entityanalytics/provider/azuread: fix query han…
Browse files Browse the repository at this point in the history
…dling
  • Loading branch information
efd6 committed May 7, 2024
1 parent 2f5bd9e commit d15c665
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Restore netflow input on Windows {pull}39024[39024]
- Upgrade azure-event-hubs-go and azure-storage-blob-go dependencies. {pull}38861[38861]
- Fix concurrency/error handling bugs in the AWS S3 input that could drop data and prevent ingestion of large buckets. {pull}39131[39131]
- Fix EntraID query handling. {issue}39419[39419] {pull}39420[39420]

*Heartbeat*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ import (
const (
defaultAPIEndpoint = "https://graph.microsoft.com/v1.0"

defaultGroupsQuery = "$select=displayName,members"
defaultUsersQuery = "$select=accountEnabled,userPrincipalName,mail,displayName,givenName,surname,jobTitle,officeLocation,mobilePhone,businessPhones"
defaultDevicesQuery = "$select=accountEnabled,deviceId,displayName,operatingSystem,operatingSystemVersion,physicalIds,extensionAttributes,alternativeSecurityIds"
queryName = "$select"
defaultGroupsQuery = "displayName,members"
defaultUsersQuery = "accountEnabled,userPrincipalName,mail,displayName,givenName,surname,jobTitle,officeLocation,mobilePhone,businessPhones"
defaultDevicesQuery = "accountEnabled,deviceId,displayName,operatingSystem,operatingSystemVersion,physicalIds,extensionAttributes,alternativeSecurityIds"

apiGroupType = "#microsoft.graph.group"
apiUserType = "#microsoft.graph.user"
Expand Down Expand Up @@ -353,21 +354,21 @@ func New(cfg *config.C, logger *logp.Logger, auth authenticator.Authenticator) (
if err != nil {
return nil, fmt.Errorf("invalid groups URL endpoint: %w", err)
}
groupsURL.RawQuery = url.QueryEscape(formatQuery(c.Select.GroupQuery, defaultGroupsQuery))
groupsURL.RawQuery = queryName + "=" + url.QueryEscape(formatQuery(c.Select.GroupQuery, defaultGroupsQuery))
f.groupsURL = groupsURL.String()

usersURL, err := url.Parse(f.conf.APIEndpoint + "/users/delta")
if err != nil {
return nil, fmt.Errorf("invalid users URL endpoint: %w", err)
}
usersURL.RawQuery = url.QueryEscape(formatQuery(c.Select.UserQuery, defaultUsersQuery))
usersURL.RawQuery = queryName + "=" + url.QueryEscape(formatQuery(c.Select.UserQuery, defaultUsersQuery))
f.usersURL = usersURL.String()

devicesURL, err := url.Parse(f.conf.APIEndpoint + "/devices/delta")
if err != nil {
return nil, fmt.Errorf("invalid devices URL endpoint: %w", err)
}
devicesURL.RawQuery = url.QueryEscape(formatQuery(c.Select.DeviceQuery, defaultDevicesQuery))
devicesURL.RawQuery = queryName + "=" + url.QueryEscape(formatQuery(c.Select.DeviceQuery, defaultDevicesQuery))
f.devicesURL = devicesURL.String()

// The API takes a departure from the query approach here, so we
Expand All @@ -386,7 +387,7 @@ func formatQuery(query []string, dflt string) string {
if len(query) == 0 {
return dflt
}
return "$select=" + strings.Join(query, ",")
return strings.Join(query, ",")
}

// newUserFromAPI translates an API-representation of a user to a fetcher.User.
Expand Down

0 comments on commit d15c665

Please sign in to comment.