Skip to content

allower downstream plugin to adjust the apply order of TaskListenerDecorator created from TaskListenerDecorator.Factory#166

Merged
car-roll merged 3 commits into
jenkinsci:masterfrom
fengxx:bugfix/adjust_decorator_order
Jun 30, 2022
Merged

allower downstream plugin to adjust the apply order of TaskListenerDecorator created from TaskListenerDecorator.Factory#166
car-roll merged 3 commits into
jenkinsci:masterfrom
fengxx:bugfix/adjust_decorator_order

Conversation

@fengxx

@fengxx fengxx commented Jul 21, 2021

Copy link
Copy Markdown
Contributor
  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

used to fix downstream plugin issues SECURITY-2128

  • plugin can adjust the apply order of TaskListenerDecorator created from TaskListenerDecorator.Factory so pipeline filter steps such as withCredentials are filtered first

@fengxx
fengxx force-pushed the bugfix/adjust_decorator_order branch 2 times, most recently from adb5628 to 37ce7ca Compare July 21, 2021 15:13
@fengxx

fengxx commented Aug 23, 2021

Copy link
Copy Markdown
Contributor Author

@jglick @svanoort @dwnusbaum could you please review the PR

  • make TaskListenerDecorator.Factory (global pipeline level) apply earlier than step level decorator (steps call BodyInvoker.mergeConsoleLogFilters)
  • use default lookup order (instead of reversed) for plugins implementing TaskListenerDecorator.Factory, consistent with ConsoleLogFiler

@timja

timja commented Aug 23, 2021

Copy link
Copy Markdown
Member

cc @car-roll

@jglick

jglick commented Aug 23, 2021

Copy link
Copy Markdown
Member

There is a reason the reverse is there. I am not sure I recall it at this point (it has been years), but I suspect this is not right. Check downstream tests in workflow-durable-task-step.

From my perspective, the proper fix for the reported problem (ordering between withCredentials and the Splunk log redirector) is to use LogStorage, as in jenkinsci/splunk-devops-plugin#17. If there are minor enhancements needed to JEP-210 to make that practical then they should be explored.

@jglick

jglick commented Aug 23, 2021

Copy link
Copy Markdown
Member

(Even if TaskListenerDecorator.Factory were the best way to implement the Splunk use case, for compatibility reasons I would still find this patch too risky. The factory could be given an optional flag to apply on the opposite side of mainDecorator so that the behavior of existing code would be unchanged.)

@pyieh

pyieh commented Aug 26, 2021

Copy link
Copy Markdown

@jglick When I discussed with Ted Xiao here https://issues.jenkins.io/browse/SECURITY-2401 he cited LogStorage being exclusive, where the first one loaded wins, as being a possible problem. If different plugins implement different LogStorages, they may conflict.

The splunk secret leakage has been a growing problem on our end, and we'd like to work with your team to see about getting this fixed.

@jglick

jglick commented Aug 27, 2021

Copy link
Copy Markdown
Member

If different plugins implement different LogStorages, they may conflict.

True, though that seems pretty hypothetical as

  • Currently there is just one public implementation, for AWS CloudWatch Logs, which is really intended more as a reference implementation than as a practical feature.
  • The logging system in Splunk sounds offhand like a natural alternative to that or to other plausible log storages. (I know nothing about this product, though.)

If and when this becomes a real problem, there is a simple solution: a plugin offering a multiplexing or “tee” storage implementation that lets you select any number of sinks (including the built-in log file as one option), picking exactly one as the authoritative source for read operations from within Jenkins.

@fengxx
fengxx force-pushed the bugfix/adjust_decorator_order branch from 37ce7ca to a0eb94f Compare August 28, 2021 07:36
@fengxx

fengxx commented Aug 28, 2021

Copy link
Copy Markdown
Contributor Author

I think log plugins (splunk, logstash, datalog) implemented TaskListenerDecorator.Factory instead of LogStorages for various reasons. IMHO some log systems separate write and read (search, report, alert), log plugins only cares about the write part, but LogStorages requires plugin to implement read part also. if LogStorages is easy to adopt, most log plugins would already switched to it in last 3 years.
I tested this on workflow-durable-task-step but no test failure, I have no idea why reverse required.
Anyway, added a flag to restore the behavior

@jglick

jglick commented Aug 30, 2021

Copy link
Copy Markdown
Member

for various reasons

Timing and/or ignorance, I suspect.

Comment thread src/main/java/org/jenkinsci/plugins/workflow/log/TaskListenerDecorator.java Outdated
@fengxx
fengxx force-pushed the bugfix/adjust_decorator_order branch from a0eb94f to 59b4e94 Compare September 3, 2021 07:59

@jglick jglick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+0 I guess—the patch looks good and should be compatible, though I still do not advise using this API for the Splunk plugin except perhaps as a hotfix.

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.lessThan;

@Issue("SECURITY-2128")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
@Issue("SECURITY-2128")

Misleading; this is not correcting a security vulnerability.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed and updated PR

@fengxx
fengxx force-pushed the bugfix/adjust_decorator_order branch from 59b4e94 to 96bb78b Compare September 4, 2021 00:48
@pyieh

pyieh commented Sep 10, 2021

Copy link
Copy Markdown

@jglick @fengxx What is the current status of this change? And has a design decision been made moving forward?

@pyieh

pyieh commented Oct 19, 2021

Copy link
Copy Markdown

@jglick @fengxx Checking in again to see if there's been any progress made in this effort? We have a current workaround, but this is posing as a security risk to our team.

@jglick

jglick commented Oct 20, 2021

Copy link
Copy Markdown
Member

I am not a maintainer.

@pyieh

pyieh commented Oct 21, 2021

Copy link
Copy Markdown

I am not a maintainer.

Understood, but you and @fengxx were having discussions around how his implementation broke backwards compatibility and if moving towards the use of LogStorage was the better design. So just wanted to check in and see if there had been any progress there.

@jglick

jglick commented Oct 21, 2021

Copy link
Copy Markdown
Member

how his implementation broke backwards compatibility

I think that has been resolved.

if moving towards the use of LogStorage was the better design

A matter of opinion I guess.

@pyieh

pyieh commented Oct 21, 2021

Copy link
Copy Markdown

@fengxx Can you confirm that the backward compatibility issues that @jglick previously brought up have been resolved?

@fengxx

fengxx commented Oct 30, 2021

Copy link
Copy Markdown
Contributor Author

I had updated the PR per review comments and there is no breakage of backward compatibility

@fengxx

fengxx commented Oct 30, 2021

Copy link
Copy Markdown
Contributor Author

@dwnusbaum are you the maintainer of the plugin? could you please review the PR

@jglick

jglick commented Nov 1, 2021

Copy link
Copy Markdown
Member

Not sure who claims to maintain this plugin. @bitwiseman? @olamy?

@timja

timja commented Nov 1, 2021

Copy link
Copy Markdown
Member

@jenkinsci/workflow-api-plugin-developers

@pyieh

pyieh commented Dec 3, 2021

Copy link
Copy Markdown

Checking in again to see if there's been any progress made here

@timja
timja requested a review from a team December 3, 2021 08:30
@fengxx
fengxx force-pushed the bugfix/adjust_decorator_order branch from 96bb78b to ff42eba Compare February 16, 2022 14:56
@fengxx fengxx changed the title adjust the apply order of TaskListenerDecorator created from TaskListenerDecorator.Factory allower downstream plugin to adjust the apply order of TaskListenerDecorator created from TaskListenerDecorator.Factory Feb 16, 2022
@fengxx
fengxx force-pushed the bugfix/adjust_decorator_order branch from ff42eba to 36a8153 Compare February 16, 2022 16:07
@fengxx

fengxx commented Feb 16, 2022

Copy link
Copy Markdown
Contributor Author

rebased on master branch, request for review

@pyieh

pyieh commented May 3, 2022

Copy link
Copy Markdown

@fengxx @timja Do we have a point of contact for who owns this plugin so we can get this PR reviewed?

@timja

timja commented May 3, 2022

Copy link
Copy Markdown
Member

These are the members of the GitHub team:
image

@pyieh

pyieh commented May 3, 2022

Copy link
Copy Markdown

@dwnusbaum @bitwiseman @kshultzCB @car-roll Can someone please review this?

@mikenau

mikenau commented May 13, 2022

Copy link
Copy Markdown

Hi @dwnusbaum @bitwiseman @car-roll @svanoort @joseblas @rsandell @jglick @abayer @olamy,

Sorry for the wide casting blast, but we are trying to get the ball moving on this PR so we can hopefully fix a long running issue with sensitive data not being masked properly in the https://plugins.jenkins.io/splunk-devops/ plugin.

Please let us know if we should be working with anyone specific on this or if there is anything else needed for this PR. We (Intuit) are very interested in this change.

Thanks,
-Mike

@mikenau

mikenau commented May 13, 2022

Copy link
Copy Markdown

Thanks for jumping in and approving @olamy 👍 . What's the next step in order to get this merged and released?

@olamy

olamy commented May 13, 2022

Copy link
Copy Markdown
Member

Thanks for jumping in and approving @olamy 👍 . What's the next step in order to get this merged and released?

let's wait few more days if someone else has comments then I will merge that.

@dwnusbaum

Copy link
Copy Markdown
Member

I am sorry, but the effect of using the new mode is not immediately clear to me, and I do not have time to investigate to understand the exact problem and the effects of the new mode, so I have no plans to review this PR.

In terms of general advice, I would recommend marking the new API method @Restricted(Beta.class) just to indicate that it is not recommended for general use. Also, just as a matter of course we prefer not to introduce new APIs without a linked PR to another plugin that consumes the API, so I would recommend filing a linked PR against Splunk that consumes this PR and adds tests showing that it fixes the issue. You can depend on workflow-api 1137.v36a_8153e5c69, which is an incremental build of this PR, see here for details.

My personal feeling is that something along the lines of jenkinsci/splunk-devops-plugin#17 that uses LogStorage would be a preferable approach, although perhaps TeeConsoleLogStorageFactory should be defined either here in workflow-api or in some new plugin (maybe with an associated GUI or other settings). If LogStorage is not currently suitable for whatever Splunk needs to do, I think we should probably see if there is some way to improve it so that it is suitable.

@pyieh

pyieh commented May 16, 2022

Copy link
Copy Markdown

@dwnusbaum @fengxx I'm okay with marking the API as beta. As long as it's exposed in some way that we can use it downstream in the splunk-devops-plugin

@pyieh

pyieh commented May 18, 2022

Copy link
Copy Markdown

We have validated a proof of concept fix in the Splunk devops here plugin using this incremental version of the workflow-api plugin

@mikenau

mikenau commented May 19, 2022

Copy link
Copy Markdown

We have validated a proof of concept fix in the Splunk devops here plugin using this incremental version of the workflow-api plugin

That's great @pyieh!

@dwnusbaum and @olamy - Can this PR be merged now that we have a linked PR with the Splunk Devops Plugin consuming the change?

@mikenau

mikenau commented May 31, 2022

Copy link
Copy Markdown

We have validated a proof of concept fix in the Splunk devops here plugin using this incremental version of the workflow-api plugin

That's great @pyieh!

@dwnusbaum and @olamy - Can this PR be merged now that we have a linked PR with the Splunk Devops Plugin consuming the change?

Hi @dwnusbaum @bitwiseman @car-roll @svanoort @joseblas @rsandell @jglick @abayer @olamy - Can this change be merged in now that @pyieh has verified it on the Splunk Devops Plugin here - jenkinsci/splunk-devops-plugin#20?

@pyieh

pyieh commented Jun 7, 2022

Copy link
Copy Markdown

@dwnusbaum @olamy Wanted to check in again to see if this PR can be merged so we can begin consuming the official version in the splunk-devops plugin

@mikenau

mikenau commented Jun 13, 2022

Copy link
Copy Markdown

Hi @dwnusbaum @bitwiseman @car-roll @svanoort @joseblas @rsandell @jglick @abayer @olamy @NotMyFault @basil Circling back on this. We are hoping to get this PR merged asap so we can start consuming the changes as part of the Splunk Devops Plugin (jenkinsci/splunk-devops-plugin#20) which will help to close a credentials leaking issue

@YeruchamB

Copy link
Copy Markdown

Hi @dwnusbaum @bitwiseman @car-roll @svanoort @joseblas @rsandell @jglick @abayer @olamy @NotMyFault @basil Circling back on this. We are hoping to get this PR merged asap so we can start consuming the changes as part of the Splunk Devops Plugin (jenkinsci/splunk-devops-plugin#20) which will help to close a credentials leaking issue

Pinging this

@car-roll
car-roll enabled auto-merge (squash) June 30, 2022 21:04
@car-roll
car-roll merged commit 02c3dba into jenkinsci:master Jun 30, 2022
@mikenau

mikenau commented Jul 1, 2022

Copy link
Copy Markdown

Thanks everyone 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants