Skip to content

Commit

Permalink
fix: priority score of an issue is not displayed (#207)
Browse files Browse the repository at this point in the history
* updated the priority value fetch
added risk key into the defined type for IssueAttributes

* priority is fetched primarly from attributes.priority.score, secondarly from attributes.risk.score.value

* commented new score location

* renamed column priority score to score

---------

Co-authored-by: jwinter <[email protected]>
  • Loading branch information
winterji and jwinter authored Nov 21, 2024
1 parent 358220b commit fb8393e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const IssuesTable: FC<DenseTableProps> = ({ issues, pageUrl }) => {
{ title: "Type", field: "type" },
{ title: "Status", field: "status" },
{ title: "Description", field: "description" },
{ title: "Priority Score", field: "priority" },
{ title: "Score", field: "score" },
];

const data = issues
Expand All @@ -38,7 +38,8 @@ export const IssuesTable: FC<DenseTableProps> = ({ issues, pageUrl }) => {
status: issue.attributes.status,
statusRaw: issue.attributes.status,
description: issue.attributes.title,
priority: issue.attributes.priority?.score || "",
// either gets a priority score or a risk score
score: issue.attributes.priority?.score || issue.attributes.risk?.score.value || "",
};

for (const key in values) {
Expand Down Expand Up @@ -70,7 +71,7 @@ export const IssuesTable: FC<DenseTableProps> = ({ issues, pageUrl }) => {
if (a.statusRaw === "resolved" && b.statusRaw === "resolved") {
return severity[a.severityRaw] < severity[b.severityRaw] ? 1 : -1;
}
return a.priority < b.priority ? 1 : -1;
return a.score < b.score ? 1 : -1;
}
return severity[a.severityRaw] < severity[b.severityRaw] ? 1 : -1;
});
Expand Down
36 changes: 36 additions & 0 deletions src/types/unifiedIssuesTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,36 @@ export interface Priority {
score: number;
}

export interface Score {
/**
* A model version as string.
* @type {string}
* @memberof Score
*/
model?: string;
/**
* A numeric priority score from 0 to 1000 determined by snyk.
* @type {number}
* @memberof Score
*/
value: number;
}

export interface Risk {
/**
* An array of factors that contributed to scoring.
* @type {Array<PriorityFactor>}
* @memberof Risk
*/
factors?: Array<PriorityFactor>;
/**
* A priority score determined by snyk.
* @type {Score}
* @memberof Risk
*/
score: Score;
}

export enum ProblemTypeDef {
Rule = "rule",
Vulnerability = "vulnerability",
Expand Down Expand Up @@ -340,6 +370,12 @@ export interface IssueAttributes {
* @memberof IssueAttributes
*/
priority?: Priority;
/**
*
* @type {Risk}
* @memberof IssueAttributes
*/
risk?: Risk;
/**
* A list of details for vulnerability data, policy, etc that are the source of this issue.
* @type {Array<Problem>}
Expand Down

0 comments on commit fb8393e

Please sign in to comment.