Skip to content

Commit

Permalink
fix missing node_name crash
Browse files Browse the repository at this point in the history
  • Loading branch information
noboruma committed Jan 30, 2025
1 parent 0353ab2 commit f6721e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions deepfence_server/reporters/scan/scan_reporters.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func GetCloudAccountIDs(ctx context.Context, cloudProviderIds []model.NodeIdenti
if len(orgNodeIds) > 0 {
nres, err = tx.Run(ctx, `
MATCH (n:CloudNode) -[:IS_CHILD] -> (m)
WHERE n.node_id IN $node_ids
WHERE n.node_id IN $node_ids
AND NOT m.node_id IN $child_node_ids
`+reporters.ParseFieldFilters2CypherWhereConditions(`m`, filterClauses, false)+`
RETURN m.node_id`,
Expand Down Expand Up @@ -542,14 +542,14 @@ func GetScansList(ctx context.Context, scanType utils.Neo4jScanType, nodeIDs []m
AND (` + strings.Join(nodeTypesStr, " OR ") + `)
` + reporters.ParseFieldFilters2CypherWhereConditions("m", mo.Some(ff), false) + `
` + orderFilter + `
RETURN m.node_id, m.status, m.status_message, m.created_at, m.updated_at, n.node_id, n.node_name, labels(n) as node_type
RETURN m.node_id, m.status, m.status_message, m.created_at, m.updated_at, n.node_id, COALESCE(n.node_name, ""), labels(n) as node_type
` + fw.FetchWindow2CypherQuery()
} else {
query = `
MATCH (m:` + string(scanType) + `) -[:SCANNED]-> (n)
` + reporters.ParseFieldFilters2CypherWhereConditions("m", mo.Some(ff), true) + `
` + orderFilter + `
RETURN m.node_id, m.status, m.status_message, m.created_at, m.updated_at, n.node_id, n.node_name, labels(n) as node_type
RETURN m.node_id, m.status, m.status_message, m.created_at, m.updated_at, n.node_id, COALESCE(n.node_name, ""), labels(n) as node_type
` + fw.FetchWindow2CypherQuery()
}
scansInfo, err = processScansListQuery(ctx, query, nodeIDsStr, tx)
Expand Down Expand Up @@ -656,8 +656,8 @@ func GetScanResultDiff[T any](ctx context.Context, scanType utils.Neo4jScanType,
OPTIONAL MATCH (c:ContainerImage{node_id: f.docker_image_id}) -[:ALIAS] ->(t) -[ma:MASKED]-> (d)
OPTIONAL MATCH (cb:ContainerImage{node_id: n.docker_image_id}) -[:IS] ->(is) -[mis:MASKED]-> (d)
WITH e, d, r, collect(ma) as ma_list, collect(mis) as mis_list
WITH apoc.map.merge( e{.*},
d{.*, masked: coalesce(d.masked or r.masked or e.masked or head(ma_list).masked or head(mis_list).masked, false),
WITH apoc.map.merge( e{.*},
d{.*, masked: coalesce(d.masked or r.masked or e.masked or head(ma_list).masked or head(mis_list).masked, false),
name: coalesce(e.name, d.name, '')}) AS merged_data` +
reporters.ParseFieldFilters2CypherWhereConditions("d", mo.Some(ff), true) +
ffCondition + ` RETURN merged_data ` +
Expand Down Expand Up @@ -749,7 +749,7 @@ func GetScanResults[T any](ctx context.Context, scanType utils.Neo4jScanType, sc
WITH d, n, e, r, m
OPTIONAL MATCH (cb:ContainerImage{node_id: n.docker_image_id}) -[:IS] ->(is) -[mis:MASKED]-> (d)
WITH apoc.map.merge( e{.*},
d{.*, masked: coalesce(d.masked or r.masked or e.masked
d{.*, masked: coalesce(d.masked or r.masked or e.masked
or m.masked or mis.masked, false),
name: coalesce(e.name, d.name, '')}) as d` +
reporters.ParseFieldFilters2CypherWhereConditions("d", mo.Some(ff), true) +
Expand Down
2 changes: 1 addition & 1 deletion deepfence_server/reporters/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ func searchGenericScanInfoReport(ctx context.Context, scanType utils.Neo4jScanTy
ORDER BY n.updated_at DESC` +
scanFilter.Window.FetchWindow2CypherQuery() +
`}` +
` RETURN n.node_id as scan_id, n.status as status, n.status_message as status_message, n.created_at as created_at, n.updated_at as updated_at, m.node_id as node_id, COALESCE(m.node_type, m.cloud_provider) as node_type, m.node_name as node_name` +
` RETURN n.node_id as scan_id, n.status as status, n.status_message as status_message, n.created_at as created_at, n.updated_at as updated_at, m.node_id as node_id, COALESCE(m.node_type, m.cloud_provider) as node_type, COALESCE(m.node_name,"") as node_name` +
reporters.OrderFilter2CypherCondition("", scanFilter.Filters.OrderFilter, nil) +
fw.FetchWindow2CypherQuery()
log.Debug().Msgf("search query: %v", query)
Expand Down

0 comments on commit f6721e4

Please sign in to comment.