Skip to content

Commit

Permalink
chore: add regex for ACM ARNs
Browse files Browse the repository at this point in the history
  • Loading branch information
akash1810 committed Feb 12, 2021
1 parent 390a734 commit aef795f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/constants/regex-pattern.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ describe("the regex patterns", () => {
expect(regex.test("[email protected]")).toBeFalsy();
expect(regex.test("[email protected]")).toBeFalsy();
});

it("should successfully regex against ACM ARNs", () => {
const regex = new RegExp(RegexPattern.ACM_ARN);
expect(regex.test("arn:aws:acm:eu-west-1:000000000000:certificate/123abc-0000-0000-0000-123abc")).toBeTruthy();
expect(regex.test("arn:aws:acm:eu-west-1:000000000000:tls/123abc-0000-0000-0000-123abc")).toBeFalsy();
});
});
4 changes: 4 additions & 0 deletions src/constants/regex-pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ const s3ArnRegex = `arn:aws:s3:::${s3BucketRegex}*`;

const emailRegex = "^[a-zA-Z]+(\\.[a-zA-Z]+)*@theguardian.com$";

// TODO be more strict on region?
const acmRegex = "arn:aws:acm:[0-9a-z\\-]+:[0-9]{12}:certificate/[0-9a-z\\-]+";

export const RegexPattern = {
ARN: arnRegex,
S3ARN: s3ArnRegex,
GUARDIAN_EMAIL: emailRegex,
ACM_ARN: acmRegex,
};

0 comments on commit aef795f

Please sign in to comment.