Skip to content

Commit

Permalink
Merge pull request #1086 from Shopify/disable_logging_args_in_jobs
Browse files Browse the repository at this point in the history
Disable logging args in ShopifyApp jobs
  • Loading branch information
Tim Anema authored Sep 29, 2020
2 parents c4f89a8 + 2837a78 commit 9813df1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ Authentication Issues
A great deal of the issues surrounding this repo are around authenticating (installing) the generated app with Shopify.

If you are experiencing issues with your app authenticating/installing the best way to get help fast is to create a repo with the minimal amount of code to demonstrate the issue and a clearly documented set of steps you took to arrive there. This will help us solve your problem quicker since we won't need to spend any time figuring out how to reproduce the bug. Please also include your operating system and browser.

Security
--------

Please be certain to redact any private information from your logs or code snippets such as Api Keys, Api Secrets, and any authentication tokens such as shop_tokens.
21 changes: 21 additions & 0 deletions lib/shopify_app/engine.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# frozen_string_literal: true
module ShopifyApp
module RedactJobParams
private

def args_info(job)
log_disabled_classes = %w(ShopifyApp::ScripttagsManagerJob ShopifyApp::WebhooksManagerJob)
return "" if log_disabled_classes.include?(job.class.name)
super
end
end

class Engine < Rails::Engine
engine_name 'shopify_app'
isolate_namespace ShopifyApp
Expand All @@ -21,5 +31,16 @@ class Engine < Rails::Engine
app.config.middleware.insert_after(ShopifyApp::SameSiteCookieMiddleware, ShopifyApp::JWTMiddleware)
end
end

initializer "shopify_app.redact_job_params" do
ActiveSupport.on_load(:active_job) do
if ActiveJob::Base.respond_to?(:log_arguments?)
WebhooksManagerJob.log_arguments = false
ScripttagsManagerJob.log_arguments = false
elsif ActiveJob::Logging::LogSubscriber.private_method_defined?(:args_info)
ActiveJob::Logging::LogSubscriber.prepend(RedactJobParams)
end
end
end
end
end

0 comments on commit 9813df1

Please sign in to comment.