Skip to content

Commit

Permalink
feature: BED-5132 - aggregate risk and posture data
Browse files Browse the repository at this point in the history
- added a new supporting graph database method for retrieving ad/azure domins by id
- added a new error response for missing required query params
  • Loading branch information
sircodemane committed Jan 22, 2025
1 parent b90fd6c commit ea836a3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/api/src/api/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ const (
ErrorResponseDetailsUniqueViolation = "unique constraint was violated"
ErrorResponseDetailsNotImplemented = "All good things to those who wait. Not implemented."

FmtErrorResponseDetailsBadQueryParameters = "there are errors in the query parameters: %v"
FmtErrorResponseDetailsBadQueryParameters = "there are errors in the query parameters: %v"
FmtErrorResponseDetailsMissingRequiredQueryParameter = "missing required query parameter: %v"
)

func IsErrorResponse(response *http.Response) bool {
Expand Down
21 changes: 21 additions & 0 deletions cmd/api/src/queries/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ type Graph interface {
GetNodesByKind(ctx context.Context, kinds ...graph.Kind) (graph.NodeSet, error)
GetFilteredAndSortedNodes(orderCriteria model.OrderCriteria, filterCriteria graph.Criteria) (graph.NodeSet, error)
FetchNodesByObjectIDs(ctx context.Context, objectIDs ...string) (graph.NodeSet, error)
FetchNodesByObjectIDsAndKinds(ctx context.Context, kinds graph.Kinds, objectIDs ...string) (graph.NodeSet, error)
ValidateOUs(ctx context.Context, ous []string) ([]string, error)
BatchNodeUpdate(ctx context.Context, nodeUpdate graph.NodeUpdate) error
RawCypherQuery(ctx context.Context, pQuery PreparedQuery, includeProperties bool) (model.UnifiedGraph, error)
Expand Down Expand Up @@ -726,6 +727,26 @@ func (s *GraphQuery) FetchNodesByObjectIDs(ctx context.Context, objectIDs ...str
})
}

func (s *GraphQuery) FetchNodesByObjectIDsAndKinds(ctx context.Context, kinds graph.Kinds, objectIDs ...string) (graph.NodeSet, error) {
var nodes graph.NodeSet

return nodes, s.Graph.ReadTransaction(ctx, func(tx graph.Transaction) error {
if fetchedNodes, err := ops.FetchNodeSet(tx.Nodes().Filterf(
func() graph.Criteria {
return query.And(
query.KindIn(query.Node(), kinds...),
query.In(query.NodeProperty(common.ObjectID.String()), objectIDs),
)
}),
); err != nil {
return err
} else {
nodes = fetchedNodes
return nil
}
})
}

func (s *GraphQuery) ValidateOUs(ctx context.Context, ous []string) ([]string, error) {
var validated = make([]string, 0)

Expand Down

0 comments on commit ea836a3

Please sign in to comment.