Skip to content

run the task before registering the task definition #2

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

Merged
merged 3 commits into from
Sep 8, 2023

Conversation

leslie-corbalt
Copy link

https://jiraent.cms.gov/browse/CMCSMACD-1626

Description of changes:
We use GITHUB_TOKEN as a task environment variable. Environment variables are stored in the clear in a task definition. When the task definition is registered, the token is visible in the task definition.

This is okay because the token expires at the end of a GitHub Actions job. However, if the task definition is registered first (and the token is exposed) and the task takes a while to run then a valid token is exposed for the duration of the long-running task.

This commit runs the task first. Immediately after the task finishes running, the task definition is registered. Since this action is the last step of the job, the token expires after the registration completes. The token that is exposd in the task definition after it expires.

Tested:
Printed out the task definition that was used to the run the task.
Printed out the task definition that was registered after the task ran.
The action runs task definition revision artillery-dev:107.
The action registers task definition revision artillery-dev:108.

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

This is because we use GITHUB_TOKEN as a task environment
variable. Environment variables are stored in the clear in
a task definition. When the task definition is registered, the token
is available in the task definition.

This is okay because the token expires at the end of a GitHub Actions
job. However, if the task definition is registered first (and the token is exposed) and
the task takes a while to run then a valid token is exposed for the
duration of the long-running task.

This commit runs the task first. Immediately after the task finishes
running, the task definition is registered. Since this action is the
last step of the job, the token expires after the registration completes.
The token exposd in the task definition is invalid.
Copy link

@ben-harvey ben-harvey left a comment

Choose a reason for hiding this comment

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

One question about the README

@@ -95,6 +95,7 @@ async function run() {

// Get inputs
const taskDefinitionFile = core.getInput('task-definition', { required: true });
const taskDefArnToRun = core.getInput('task-definition-arn', { required: true });

Choose a reason for hiding this comment

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

I think adding this as a required variable means that the README examples are now out of date. Will you take a look and see if the README needs any other updates?

Copy link
Author

Choose a reason for hiding this comment

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

Good point! Done.

Copy link

@ben-harvey ben-harvey left a comment

Choose a reason for hiding this comment

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

LGTM!

@leslie-corbalt leslie-corbalt merged commit f43f04a into master Sep 8, 2023
@leslie-corbalt
Copy link
Author

#2

@leslie-corbalt leslie-corbalt deleted the lbk-run-first-register-second branch September 8, 2023 13:58
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.

2 participants