Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
fix(api): return missing finding data (#1929)
Browse files Browse the repository at this point in the history
* fix(orchestrator): return finding id from createOrUpdateDBFinding

Signed-off-by: András Jáky <ajaky@cisco.com>

* fix(api): add missing odatasql Secret schema metas

Signed-off-by: András Jáky <ajaky@cisco.com>

---------

Signed-off-by: András Jáky <ajaky@cisco.com>
  • Loading branch information
akijakya authored Jul 17, 2024
1 parent a61acee commit b913ab1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion api/server/database/gorm/odata.go
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,8 @@ var schemaMetas = map[string]odatasql.SchemaMeta{
"filePath": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"startLine": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"endLine": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"startColumn": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"endColumn": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"fingerprint": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
},
},
Expand Down Expand Up @@ -1256,7 +1258,7 @@ var schemaMetas = map[string]odatasql.SchemaMeta{
},
"finding": odatasql.FieldMeta{
FieldType: odatasql.RelationshipFieldType,
RelationshipSchema: "Finding",
RelationshipSchema: findingSchemaName,
RelationshipProperty: "id",
},
"firstSeen": odatasql.FieldMeta{FieldType: odatasql.DateTimeFieldType},
Expand Down
3 changes: 1 addition & 2 deletions orchestrator/processor/assetscan/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ func (asp *AssetScanProcessor) createOrUpdateDBFinding(ctx context.Context, info
return "", fmt.Errorf("failed to create finding: %w", err)
}

var id string
id := *conflictError.ConflictingFinding.Id
// Update existing finding if newer
if conflictError.ConflictingFinding.LastSeen.Before(completedTime) {
id = *conflictError.ConflictingFinding.Id
finding := apitypes.Finding{
LastSeen: &completedTime,
LastSeenBy: &apitypes.AssetScanRelationship{
Expand Down

0 comments on commit b913ab1

Please sign in to comment.