Skip to content

Commit

Permalink
add flag to indicate if resources are active (#2389)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnmahanth authored Dec 9, 2024
1 parent d765ebd commit 0953bc7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions deepfence_server/model/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type BasicNode struct {
Name string `json:"name" required:"true"`
NodeType string `json:"node_type" required:"true"`
HostName string `json:"host_name" required:"true"`
Active bool `json:"active" required:"true"`
}

type Connection struct {
Expand Down
9 changes: 4 additions & 5 deletions deepfence_server/reporters/lookup/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,7 @@ func getGenericDirectNodeReport[T reporters.Cypherable](ctx context.Context, fil
OPTIONAL MATCH (l) -[:DETECTED]-> (n)
OPTIONAL MATCH (l) -[:SCANNED]-> (k)
WITH distinct k
WHERE k.active=true
RETURN collect(coalesce(k.node_id, '') + '##' + coalesce(k.node_name, '') + '##' + coalesce(k.node_type, '')) as resources
RETURN collect(coalesce(k.node_id, '') + '##' + coalesce(k.node_name, '') + '##' + coalesce(k.node_type, '') + '##' + coalesce(k.active, '')) as resources
}
RETURN ` + reporters.FieldFilterCypher("n", filter.InFieldFilter) + `, e, resources`
} else {
Expand All @@ -336,8 +335,7 @@ func getGenericDirectNodeReport[T reporters.Cypherable](ctx context.Context, fil
OPTIONAL MATCH (l) -[:DETECTED]-> (n)
OPTIONAL MATCH (l) -[:SCANNED]-> (k)
WITH distinct k
WHERE k.active=true
RETURN collect(coalesce(k.node_id, '') + '##' + coalesce(k.node_name, '') + '##' + coalesce(k.node_type, '')) as resources
RETURN collect(coalesce(k.node_id, '') + '##' + coalesce(k.node_name, '') + '##' + coalesce(k.node_type, '') + '##' + coalesce(k.active, '')) as resources
}
RETURN ` + reporters.FieldFilterCypher("n", filter.InFieldFilter) + `, e, resources`
}
Expand Down Expand Up @@ -391,13 +389,14 @@ func getGenericDirectNodeReport[T reporters.Cypherable](ctx context.Context, fil
resourceListString := make([]model.BasicNode, len(resourceList))
for i, v := range resourceList {
nodeDetails := strings.Split(v.(string), nodeReportResourcesSplit)
if len(nodeDetails) != 3 {
if len(nodeDetails) != 4 {
continue
}
resourceListString[i] = model.BasicNode{
NodeID: nodeDetails[0],
Name: nodeDetails[1],
NodeType: nodeDetails[2],
Active: nodeDetails[3] == "true",
}
}
nodeMap["resources"] = resourceListString
Expand Down

0 comments on commit 0953bc7

Please sign in to comment.