From 4cf4ab4b1b1de336f340c336d94cba1d5ced99a8 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 7 Nov 2022 14:03:26 -0500 Subject: [PATCH] Defend CRDResourceDetails against bad jsonPaths Signed-off-by: Sebastian Malton --- .../components/+custom-resources/crd-resource-details.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/+custom-resources/crd-resource-details.tsx b/src/renderer/components/+custom-resources/crd-resource-details.tsx index a52d60c7ee..3bd1e821fa 100644 --- a/src/renderer/components/+custom-resources/crd-resource-details.tsx +++ b/src/renderer/components/+custom-resources/crd-resource-details.tsx @@ -15,11 +15,10 @@ import { KubeObjectMeta } from "../kube-object-meta"; import { Input } from "../input"; import type { AdditionalPrinterColumnsV1 } from "../../../common/k8s-api/endpoints/custom-resource-definition.api"; import { CustomResourceDefinition } from "../../../common/k8s-api/endpoints/custom-resource-definition.api"; -import { convertKubectlJsonPathToNodeJsonPath } from "../../utils/jsonPath"; +import { safeJSONPathValue } from "../../utils/jsonPath"; import type { KubeObjectMetadata, KubeObjectStatus } from "../../../common/k8s-api/kube-object"; import { KubeObject } from "../../../common/k8s-api/kube-object"; import logger from "../../../common/logger"; -import { JSONPath } from "@astronautlabs/jsonpath"; export interface CustomResourceDetailsProps extends KubeObjectDetailsProps { crd: CustomResourceDefinition; @@ -66,7 +65,7 @@ export class CustomResourceDetails extends React.Component ( - {convertSpecValue(JSONPath.query(resource, convertKubectlJsonPathToNodeJsonPath(jsonPath)))} + {convertSpecValue(safeJSONPathValue(resource, jsonPath))} )); }