8000 [FEATURE] Mask sensitive run arguments by 3assy2018 · Pull Request #1169 · Shopify/maintenance_tasks · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[FEATURE] Mask sensitive run arguments #1169

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

Conversation

3assy2018
Copy link
Contributor
@3assy2018 3assy2018 commented Feb 17, 2025

In some cases, maintenance tasks require the use of sensitive data in their arguments; however, I noticed that there should be a protection layer to hide these sensitive data from the UI once the task is submitted to run.
This PR introduces a new class method in the maintenance tasks to mask any sensitive attributes and hide them in the arguments list in the UI.

[TBD] The PR also assumes that the Rails global parameter filters contain sensitive keys, which should be automatically taken into account, and redacted globally across maintenance tasks.

The final result should look like the following screenshot:
Screenshot 2025-02-17 at 17 14 45

@3assy2018 3assy2018 force-pushed the feature/mask-sensitive-run-arguments branch from b819e27 to cc1e7c8 Compare February 17, 2025 17:32
Copy link
Contributor
@adrianna-chang-shopify adrianna-chang-shopify left a comment

Choose a reason for hiding this comment

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

Hi, thanks for contributing to the gem! I have one comment about where the argument filtering should live, but otherwise I think this feature makes sense, and I like that we're leaning on the AS Parameter Filter.

cc @Shopify/rails if anyone else would like to take a look at this.

# Mask sensitive information from the arguments of a task.
#
# @param run [Run] the Run that contains the arguments to be masked.
def mask_arguments(run)
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about having the Run handle this instead? That would allow us to memoize the parameter filter.

module MaintenanceTasks
  class Run < ApplicationRecord
    ...
    def masked_arguments
      argument_filter.filter(arguments)
    end

    private

    def argument_filter
      @argument_filter ||= ParameterFilter.new(Rails.application.config.filter_parameters + task.masked_attributes)
    end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks a lot @adrianna-chang-shopify for the feedback! I've moved the method from the helper to the Run model as requested.

8000
@@ -28,6 +28,11 @@ class NotFoundError < NameError; end
# @api private
class_attribute :collection_builder_strategy, default: NullCollectionBuilder.new

# the sensitive attributes that will be filtered when fetching a run.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# the sensitive attributes that will be filtered when fetching a run.
# The sensitive attributes that will be filtered when fetching a run.

README.md Outdated
end
```

If you have any filtered parameters in the global rails parameter filter, they will be
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about linking to the docs here?

Copy link
Contributor Author 8000

Choose a reason for hiding this comment

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

Great idea, thanks for flagging it! I added it in the latest commit

Copy link
Contributor
@nvasilevski nvasilevski left a comment

Choose a reason for hiding this comment

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

Thank you! Proposed feature makes total sense and implementation looks clean 👌
I'll let @adrianna-chang-shopify to review and we can most likely merge it!

Copy link
Contributor
@adrianna-chang-shopify adrianna-chang-shopify left a comment

Choose a reason for hiding this comment

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

Looks good to me! Can you squash your commits and then I'll merge?

@3assy2018
Copy link
Contributor Author

Hey Shopifolk!
Thanks a lot for your collaboration, and happy to hear that the feature looks good.

@adrianna-chang-shopify I have tried to squash the commits as you requested, but I ended up having a strange commit history, but it it squashed anyways.
Let me know if you have any further requests 🙇‍♂️

@adrianna-chang-shopify adrianna-chang-shopify merged commit b3415b1 into Shopify:main Feb 20, 2025
20 checks passed
@etiennebarrie etiennebarrie mentioned this pull request May 6, 2025
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
0