Skip to content

Commit

Permalink
chore: refactor JSON.parse usage on unsafe code
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Barbosa <[email protected]>
  • Loading branch information
t1agob committed Jul 23, 2024
1 parent 9db99e1 commit d6b4fdf
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/service/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ export async function createComponentEntitiesReferenceDict({ items: componentEnt
const componentEntitiesDict: Record<string, { ref: string, name: string }> = {};

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] = {
Expand Down

0 comments on commit d6b4fdf

Please sign in to comment.