Skip to content

Make ConvertKit_API::create_log() protected #66

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

Closed
slaFFik opened this issue Jul 16, 2023 · 2 comments
Closed

Make ConvertKit_API::create_log() protected #66

slaFFik opened this issue Jul 16, 2023 · 2 comments

Comments

@slaFFik
Copy link

slaFFik commented Jul 16, 2023

Is your feature request related to a problem? Please describe.

When the debugging needs to be enabled on a live site (don't ask, clients' sites), the API key is logged into a publicly available file.
That's because reconfiguring the whole site to make that log file outside of the server access is not possible - so the log file public.
So scrappers etc can accidentally see the API key.

Example of the record:

[2023-07-16T19:58:19.753138+00:00] ck-debug.INFO: GET, Request body: {"api_key":"abc1234567890def"} [] []

Describe the solution you'd like

In order to more or less easily modify the behavior without rewriting the implementation, I'd like to be able to parse the message that is sent - and prevent the API key leaking into the log.

The easiest solution - overload the ConvertKit_API::create_log() method in a parent class that extends the default ConvertKit_API. After that - do the easy search-replace to remove the API key.

Right now it's impossible because that method is private.

Can you please make it protected?

Describe alternatives you've considered

No response

Additional context

No response

@slaFFik
Copy link
Author

slaFFik commented Jul 16, 2023

Well, or one can create own Logger Handler, that will have a write() method that does the str_replace() or whatever. The __contruct() method of the ConvertKit_API class will need to be overloaded though.

But really, it would be much easier to just modify one single create_log() method than going ^ route.

@n7studios
Copy link
Contributor

Thanks. I think this PR handles this better, by:

  • adding a parameter to the constructor to define the log file destination,
  • automatically mask the API Key and Secret before writing to the log file

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 a pull request may close this issue.

2 participants