Display non-MaD provenance in results view
This commit is contained in:
@@ -10,9 +10,18 @@ import { SarifLocation } from "./SarifLocation";
|
|||||||
|
|
||||||
/** The definition of a taxon for a data extension model row. */
|
/** The definition of a taxon for a data extension model row. */
|
||||||
interface ModelTaxon {
|
interface ModelTaxon {
|
||||||
|
kind: "model";
|
||||||
location: SarifLogLocation;
|
location: SarifLogLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A taxon for a built-in model, such as `AdditionalFlowStep`. */
|
||||||
|
interface BuiltInTaxon {
|
||||||
|
kind: "string";
|
||||||
|
text: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type TaxonDefinition = ModelTaxon | BuiltInTaxon;
|
||||||
|
|
||||||
/** Resolve an `ArtifactLocation` that might contain a relative reference instead of an absolute
|
/** Resolve an `ArtifactLocation` that might contain a relative reference instead of an absolute
|
||||||
* URI.
|
* URI.
|
||||||
*/
|
*/
|
||||||
@@ -49,12 +58,33 @@ function getLocalPackUri(extension: ToolComponent): URL | undefined {
|
|||||||
return new URL(localPackLocation.uri);
|
return new URL(localPackLocation.uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resolve a `ReportingDescriptorReference` to the `ReportingDescriptor` for the taxon that it
|
/** Resolve a `ReportingDescriptorReference` to the built-in taxon it refers to, or `undefined` if
|
||||||
* refers to.
|
* it is not a built-in taxon.
|
||||||
*/
|
*/
|
||||||
function resolveTaxonDefinition(
|
function resolveBuiltInTaxon(
|
||||||
run: Run,
|
|
||||||
taxonRef: ReportingDescriptorReference,
|
taxonRef: ReportingDescriptorReference,
|
||||||
|
): BuiltInTaxon | undefined {
|
||||||
|
if (
|
||||||
|
taxonRef.id !== undefined &&
|
||||||
|
taxonRef.index === undefined &&
|
||||||
|
taxonRef.toolComponent === undefined
|
||||||
|
) {
|
||||||
|
return {
|
||||||
|
kind: "string",
|
||||||
|
text: taxonRef.id,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve a `ReportingDescriptorReference` to the MaD taxon definition it refers to, or
|
||||||
|
* `undefined` if it does not refer to a MaD model.
|
||||||
|
*/
|
||||||
|
function resolveModelTaxon(
|
||||||
|
taxonRef: ReportingDescriptorReference,
|
||||||
|
run: Run,
|
||||||
): ModelTaxon | undefined {
|
): ModelTaxon | undefined {
|
||||||
const extensions = run.tool.extensions;
|
const extensions = run.tool.extensions;
|
||||||
if (extensions === undefined) {
|
if (extensions === undefined) {
|
||||||
@@ -101,6 +131,7 @@ function resolveTaxonDefinition(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
kind: "model",
|
||||||
location: {
|
location: {
|
||||||
physicalLocation: {
|
physicalLocation: {
|
||||||
...location,
|
...location,
|
||||||
@@ -113,6 +144,14 @@ function resolveTaxonDefinition(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Resolve a `ReportingDescriptorReference` to the taxon definition it refers to. */
|
||||||
|
function resolveTaxonDefinition(
|
||||||
|
run: Run,
|
||||||
|
taxonRef: ReportingDescriptorReference,
|
||||||
|
): TaxonDefinition | undefined {
|
||||||
|
return resolveModelTaxon(taxonRef, run) ?? resolveBuiltInTaxon(taxonRef);
|
||||||
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
taxa: ReportingDescriptorReference[] | undefined;
|
taxa: ReportingDescriptorReference[] | undefined;
|
||||||
run: Run | undefined;
|
run: Run | undefined;
|
||||||
@@ -148,8 +187,9 @@ export function TaxaLocations({
|
|||||||
<div key={index}>
|
<div key={index}>
|
||||||
{`(${role}) `}
|
{`(${role}) `}
|
||||||
<SarifLocation
|
<SarifLocation
|
||||||
loc={taxonDef.location}
|
loc={taxonDef.kind === "model" ? taxonDef.location : undefined}
|
||||||
databaseUri={undefined}
|
databaseUri={undefined}
|
||||||
|
text={taxonDef.kind === "string" ? taxonDef.text : undefined}
|
||||||
sourceLocationPrefix=""
|
sourceLocationPrefix=""
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user