diff --git a/src/panel/details.tsx b/src/panel/details.tsx index 7612cdd1..609f083c 100644 --- a/src/panel/details.tsx +++ b/src/panel/details.tsx @@ -9,7 +9,7 @@ import * as React from 'react'; import { Component, Fragment } from 'react'; import ReactMarkdown from 'react-markdown'; import { Location, Result, StackFrame } from 'sarif'; -import { parseArtifactLocation, parseLocation, decodeFileUri } from '../shared'; +import { parseArtifactLocation, parseLocation, decodeFileUri, parseMessage } from '../shared'; import './details.scss'; import './index.scss'; import { postSelectArtifact, postSelectLog } from './indexStore'; @@ -83,14 +83,23 @@ interface DetailsProps { result: Result, height: IObservableValue } Locations {result.locations?.map((loc, i) => { const ploc = loc.physicalLocation; - const [uri, _] = parseArtifactLocation(result, ploc?.artifactLocation); - return { - e.preventDefault(); // Cancel # nav. - postSelectArtifact(result, ploc); - }}> - {uri?.file ?? '-'} - ; + const artifactLocation = ploc?.artifactLocation; + const artifactDescription = artifactLocation?.description; + let artifactTextDescription = ''; + if (artifactDescription) { + [artifactTextDescription, ] = parseMessage(result, artifactDescription); + } + const [uri, ] = parseArtifactLocation(result, artifactLocation); + + return <> + { + e.preventDefault(); // Cancel # nav. + postSelectArtifact(result, ploc); + }}> + {uri?.file ?? '-'} +  {artifactTextDescription ?? ''}
+ ; }) ?? }
Log ) { ?? toolComponent?.rules?.find(rule => rule.id === result.ruleId) ?? getDriverlessRule(result.ruleId); - const message = result._rule?.messageStrings?.[result.message.id ?? -1] ?? result.message; - result._message = format(message.text || result.message?.text, result.message.arguments) ?? '—'; - result._markdown = format(message.markdown || result.message?.markdown, result.message.arguments); // No '—', leave undefined if empty. + [result._message, result._markdown] = parseMessage(result, result.message); result.level = effectiveLevel(result); result.baselineState = result.baselineState ?? 'new'; @@ -180,6 +178,13 @@ export function parseLocation(result: Result, loc?: Location) { return { message, uri, uriContent, region }; } +export function parseMessage(result: Result, message: Message): [string, string | undefined] { + const _message = result._rule?.messageStrings?.[message.id ?? -1] ?? message; + const textMessage = format(_message.text, message.arguments) ?? '—'; + const markdownMessage = format(_message.markdown, message.arguments); // No '—', leave undefined if empty. + return [textMessage, markdownMessage] +} + // Improve: `result` purely used for `_run.artifacts`. export function parseArtifactLocation(result: Result, anyArtLoc: ArtifactLocation | undefined) { if (!anyArtLoc) return [undefined, undefined];