File tree 2 files changed +17
-0
lines changed
core/src/main/java/hudson/console
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 36
36
import javax .annotation .Nonnull ;
37
37
import java .io .IOException ;
38
38
import java .io .OutputStream ;
39
+ import java .io .Serializable ;
40
+ import jenkins .util .JenkinsJVM ;
39
41
40
42
/**
41
43
* A hook to allow filtering of information that is written to the console log.
42
44
* Unlike {@link ConsoleAnnotator} and {@link ConsoleNote}, this class provides
43
45
* direct access to the underlying {@link OutputStream} so it's possible to suppress
44
46
* data, which isn't possible from the other interfaces.
45
47
* ({@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.
46
52
* @author dty
47
53
* @since 1.383
48
54
* @see BuildWrapper#decorateLogger
Original file line number Diff line number Diff line change 107
107
* is also important, although {@link ConsoleNote}s that failed to deserialize will be simply ignored, so the
108
108
* worst thing that can happen is that you just lose some notes.
109
109
*
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
+ *
110
121
* <h2>Behaviour, JavaScript, and CSS</h2>
111
122
* <p>
112
123
* {@link ConsoleNote} can have associated {@code script.js} and {@code style.css} (put them
You can’t perform that action at this time.
0 commit comments