-
Notifications
You must be signed in to change notification settings - Fork 26
Feature/action transient secrets #1699
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
base: develop
Are you sure you want to change the base?
Conversation
7f56c42
to
23a4a2f
Compare
1c8dc3f
to
9883ed4
Compare
static async addActionSecret(actionRunId: string, actionSecrets: Record<string, string>): Promise<void> { | ||
this.actionSecretsMap.set(actionRunId, actionSecrets); | ||
|
||
logger.info(`Secret found for Action Run: ${actionRunId}, running action...`); |
Check warning
Code scanning / CodeQL
Log injection Medium
user-provided value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spent some time looking at/tweaking this one today, some thoughts:
Major
A few things re: the setTimeout
s on L32 and L47 of actionRunner.ts
:
- These both use the same timeout value, but are very different scenarios. The first is "once I've received an action run, how long should I wait to receive the secrets it requires" - this should always be pretty short. The other is (I think) "once I've submitted an action to be started by the pool, how long should I wait for it to be finished running before I delete its secrets to be safe" - this could be much longer, since it includes the time that the action will be queued waiting for other action runs. 60 seconds is probably more than enough time for the first, but not enough for the latter (maybe more like 10-60 minutes? open to suggestion but it's more of an emergency backstop).
- The "timed out" message inside the first one (L32) will always be logged, even if the secrets were received. We should either cancel the timeout, or more simply, wrap an
if
around the innards to check if it still needs to be removed. - The second timeout (L47) is not started until after the
await
ed function returns, which is after the action run has already completed. I think it should go before, so it catches very-long-running actions as intended, or cases whereawait actionRunFunc
throws. It should also have a cancel orif
like the other one, so that it doesn't log on every run. - We should also call
deleteActionSecret
immediately after theawait actionRunFunc
for the nominal case, so we don't wait around for the long timeout before deleting the secrets. If we got past that line, I don't think we need them anymore.
Minor
- I merged in changes from
develop
and fixed conflicts/migration numbers - Fixed a bug in 50860ac (the admin secret code I added before last release) since it was accidentally mutating the secrets objects, breaking tests
- Pushed small changes in 46c4373 to replace the secrets/runs objects with
Map
s. CodeQL was correct in this case - since they're unvalidated strings straight from the user, it's safer not to dereference objects directly with them since they could accidentally or maliciously access JS internals likeconstructor
etc. and cause weird issues.
Just addressed all of your feedback! |
|
if (actionRunFunc) { | ||
setTimeout(() => { | ||
if (this.actionSecretsMap.get(actionRunId) !== null) { | ||
logger.info(`Secret for Action Run: ${actionRunId} timed out waiting for the associated action run.`); |
Check warning
Code scanning / CodeQL
Log injection Medium
user-provided value
} | ||
}, this.WAIT_FOR_ACTION_RUN_TIMEOUT); | ||
|
||
await actionRunFunc(actionRunId); |
Check failure
Code scanning / CodeQL
Unvalidated dynamic method call High
Description
This PR adds transient secrets that can be added during an action run. Those secrets are stored in memory in the
action-server
until they are retrieved for the associatedaction_run
.Verification
Manually tested.
Documentation
NA
Future work
Refactor the delay / wait period for the secrets.