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

Prevent from propagating env vars at outside of fork task scope #128

Merged
merged 1 commit into from
Jun 3, 2019

Conversation

itkq
Copy link

@itkq itkq commented Jun 2, 2019

Since deserialized context value of Token model by getting through
AttributeSet#attributes is passed by reference, additional env values
passed to create_child_token method overwrite a context which a token
instance variable has. This cause unintentional env values propagation
like KUROKO2_PARALLEL_FORK_SIZE at outside of the fork task scope.

To avoid this, use the deep copy for context value instead.

@cookpad/infra please review

attributes = attributes.merge(uuid: SecureRandom.uuid, parent: token, script: child_node.to_script, path: '/')
attributes['context'] = token.context.deep_dup
Copy link
Member

Choose a reason for hiding this comment

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

(nit) this assignment can be merged into the above line

attributes = token.attributes.except('id', 'uuid', 'script', 'path', 'message', 'created_at', 'updated_at', 'context')
attributes = attributes.merge(uuid: SecureRandom.uuid, parent: token, script: child_node.to_script, path: '/', context: token.context.deep_dup)

Copy link
Author

Choose a reason for hiding this comment

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

Nitpicked. 174918f

Since deserialized context value of Token model by getting through
AttributeSet#attributes is passed by reference, additional env values
passed to create_child_token method overwrite a context which a token
instance variable has. This cause unintentional env values propagation
like KUROKO2_PARALLEL_FORK_SIZE at outside of the fork task scope.

To avoid this, use the deep copy for context value instead.
@itkq
Copy link
Author

itkq commented Jun 3, 2019

Thanks for reviewing!

@itkq itkq merged commit 1e962c7 into cookpad:master Jun 3, 2019
@itkq itkq deleted the prop branch June 3, 2019 05:16
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