Skip to content

Commit

Permalink
adapt cpe.js
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-mng committed Jan 15, 2025
1 parent b0d3bb9 commit aa7dc0c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/gmp/models/cpe.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ class Cpe extends Info {
delete ret.update_time;
}

if (isDefined(ret.raw_data) && isDefined(ret.raw_data['cpe-item'])) {
const cpeItem = ret.raw_data['cpe-item'];
if (isDefined(cpeItem._deprecated_by)) {
ret.deprecatedBy = cpeItem._deprecated_by;
}
/*
* This code includes a backup check for deprecated field `raw_data`.
* Once `raw_data` is removed from the API, this backup check can be removed.
*/

if (ret.deprecate === 1 && isDefined(ret.deprecated_by)) {
ret.deprecatedBy = ret.deprecated_by;
} else if (isDefined(ret.raw_data?.['cpe-item']?._deprecated_by)) {
ret.deprecatedBy = ret.raw_data['cpe-item']._deprecated_by;
}

return ret;
}
}
Expand Down

0 comments on commit aa7dc0c

Please sign in to comment.