File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
main/java/com/cloudbees/syslog
test/java/com/cloudbees/syslog Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,16 @@ public class SDElement implements Serializable {
3030
3131 private static final long serialVersionUID = 1L ;
3232
33+ /**
34+ * Reserved SD-IDs as documented in <a href="https://www.rfc-editor.org/rfc/rfc5424.txt">RFC-5424</a>
35+ */
36+ public static final String [] RESERVED_SDID = new String []{
37+ "timeQuality" ,
38+ "tzKnown" ,
39+ "isSynced" ,
40+ "syncAccuracy"
41+ };
42+
3343 public SDElement (String sdID ) {
3444 validateSDID (sdID );
3545 this .sdID = sdID ;
@@ -131,6 +141,18 @@ private void validateSDID(String sdName) {
131141 if (sdName .contains ("\" " )) {
132142 throw new IllegalArgumentException ("SD-ID cannot contain '\" '" );
133143 }
144+ if (! sdName .contains ("@" )) {
145+ boolean found = false ;
146+ for (String rn : RESERVED_SDID ) {
147+ if (rn .equals (sdName )) {
148+ found = true ;
149+ break ;
150+ }
151+ }
152+ if (! found ) {
153+ throw new IllegalArgumentException ("SD-ID is not known registered SDID: " + sdName );
154+ }
155+ }
134156 }
135157
136158}
Original file line number Diff line number Diff line change @@ -87,7 +87,6 @@ public void testRfc5424FormatWithStructuredData() throws Exception {
8787 expected = "<14>1 2013-12-05T10:30:05.000Z myserver.example.com my_app - - [exampleSDID@32473 iut=\" 3\" eventSource=\" Application\" eventID=\" 1011\" ][examplePriority@32473 class=\" high\" ] a syslog message" ;
8888
8989 assertThat (actual , is (expected ));
90-
9190 }
9291
9392 @ Test
You can’t perform that action at this time.
0 commit comments