Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add validation to the ECS Task Metadata #96

Merged
merged 3 commits into from
Feb 15, 2024

Conversation

philasmar
Copy link
Contributor

Issue #, if available:
DOTNET-7341

Description of changes:

  • Added validation for the ECS Metadata endpoint to look for the IP 169.254.170.2
  • Added a POCO that represents the data returned by the endpoint which adds more validation on the structure of the data
  • Added validation to the Cluster and TaskARN returned

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.


// Use a regular expression to validate the characters
// Valid characters include letters (uppercase and lowercase), numbers, hyphens, and underscores
Regex validPattern = new Regex(@"^[A-Za-z0-9\-_]+$");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am on the fence about the use of RegEx and it's performance impact in this context. Any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this should only ever be called once so it should have negligible performance impact. Also since it should use the Compiled option since it is only being used. Not that you are using it but adding that feedback in case another reviewer suggest it.

@philasmar philasmar requested a review from 96malhar February 15, 2024 18:53
@philasmar philasmar requested a review from 96malhar February 15, 2024 19:29
@philasmar philasmar merged commit 1aa4506 into dev Feb 15, 2024
5 checks passed
@philasmar philasmar deleted the asmarp/validate-ecs-task-metadata branch March 20, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants