Skip to content

Commit

Permalink
Merge pull request #1115 from guardian/aa/obligatron-null-tags
Browse files Browse the repository at this point in the history
fix(obligatron): Handle case where there no tags
  • Loading branch information
akash1810 committed Jun 20, 2024
2 parents 9ab16b1 + c902acb commit 8e16c9e
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions packages/obligatron/src/obligations/tagging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ import type { PrismaClient } from '@prisma/client';
import type { ObligationResult } from '.';

type FindingResource = {
/**
* The resource identifier, such as the ARN.
*/
Id: string;
Tags: Record<string, string>;

/**
* The tags on the resource.
*
* A value of `null` represents the absence of tags.
*/
Tags: null | Record<string, string>;
};

const securityHubLink = (region: string, findingId: string) => {
Expand Down Expand Up @@ -95,10 +104,13 @@ export async function evaluateTaggingObligation(
url: securityHubLink(finding.region, finding.id),
contacts: {
aws_account_id: finding.aws_account_id,
// Resource might only be missing one of these tags which might help us assert ownership
Stack: resource.Tags.Stack,
Stage: resource.Tags.Stage,
App: resource.Tags.App,

...(resource.Tags !== null && {
// Resource might only be missing one of these tags which might help us assert ownership
Stack: resource.Tags.Stack,
Stage: resource.Tags.Stage,
App: resource.Tags.App,
}),
},
})),
);
Expand Down

0 comments on commit 8e16c9e

Please sign in to comment.