Skip to content

Commit 8d73038

Browse files
committed
Noting JEP-210 impact on ConsoleNote encoding as suggested in jenkinsci/workflow-durable-task-step-plugin#80 (comment).
1 parent 4c6be45 commit 8d73038

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

core/src/main/java/hudson/console/ConsoleLogFilter.java

+6
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,19 @@
3636
import javax.annotation.Nonnull;
3737
import java.io.IOException;
3838
import java.io.OutputStream;
39+
import java.io.Serializable;
40+
import jenkins.util.JenkinsJVM;
3941

4042
/**
4143
* A hook to allow filtering of information that is written to the console log.
4244
* Unlike {@link ConsoleAnnotator} and {@link ConsoleNote}, this class provides
4345
* direct access to the underlying {@link OutputStream} so it's possible to suppress
4446
* data, which isn't possible from the other interfaces.
4547
* ({@link ArgumentListBuilder#add(String, boolean)} is a simpler way to suppress a single password.)
48+
* <p>Implementations which are {@link Serializable} may be sent to an agent JVM for processing.
49+
* In particular, this happens under <a href="https://jenkins.io/jep/210">JEP-210</a>.
50+
* In this case, the implementation should not assume that {@link JenkinsJVM#isJenkinsJVM},
51+
* and if generating {@link ConsoleNote}s will need to encode them on the master side first.
4652
* @author dty
4753
* @since 1.383
4854
* @see BuildWrapper#decorateLogger

core/src/main/java/hudson/console/ConsoleNote.java

+11
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@
107107
* is also important, although {@link ConsoleNote}s that failed to deserialize will be simply ignored, so the
108108
* worst thing that can happen is that you just lose some notes.
109109
*
110+
* <p>
111+
* Note that {@link #encode}, {@link #encodeTo(OutputStream)}, and {@link #encodeTo(Writer)}
112+
* should be called on the Jenkins master.
113+
* If called from an agent JVM, a signature will be missing and so as per
114+
* <a href="https://jenkins.io/security/advisory/2017-02-01/#persisted-cross-site-scripting-vulnerability-in-console-notes">SECURITY-382</a>
115+
* the console note will be ignored.
116+
* This may happen, in particular, if the note was generated by a {@link ConsoleLogFilter} sent to the agent.
117+
* Alternative solutions include using a {@link ConsoleAnnotatorFactory} where practical;
118+
* or generating the encoded form of the note on the master side and sending it to the agent,
119+
* for example by saving that form as instance fields in a {@link ConsoleLogFilter} implementation.
120+
*
110121
* <h2>Behaviour, JavaScript, and CSS</h2>
111122
* <p>
112123
* {@link ConsoleNote} can have associated {@code script.js} and {@code style.css} (put them

0 commit comments

Comments
 (0)