From d6b4fdf8b04569a28119dc4fce0f70be3eb7f3d1 Mon Sep 17 00:00:00 2001 From: Tiago Barbosa Date: Wed, 24 Jul 2024 00:07:54 +0100 Subject: [PATCH] chore: refactor JSON.parse usage on unsafe code Signed-off-by: Tiago Barbosa --- src/service/router.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/service/router.ts b/src/service/router.ts index f1fe3fd..8bc3dcd 100644 --- a/src/service/router.ts +++ b/src/service/router.ts @@ -28,10 +28,9 @@ export async function createComponentEntitiesReferenceDict({ items: componentEnt const componentEntitiesDict: Record = {}; await Promise.all(componentEntities.map(async (entity) => { - const annotations: Annotations = JSON.parse(JSON.stringify(entity.metadata.annotations)); - const serviceId = annotations['pagerduty.com/service-id']; - const integrationKey = annotations['pagerduty.com/integration-key']; - const account = annotations['pagerduty.com/account'] ?? ""; + const serviceId = entity.metadata.annotations?.['pagerduty.com/service-id']; + const integrationKey = entity.metadata.annotations?.['pagerduty.com/integration-key']; + const account = entity.metadata.annotations?.['pagerduty.com/account']; if (serviceId !== undefined && serviceId !== "") { componentEntitiesDict[serviceId] = {