Skip to content
This repository was archived by the owner on Feb 5, 2026. It is now read-only.

Commit 8b33d44

Browse files
[LOG-11301] InsightOps Java library should send data by TLS by default
1 parent 91f15e9 commit 8b33d44

File tree

10 files changed

+54
-81
lines changed

10 files changed

+54
-81
lines changed

pom.xml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@
1010
<disruptor.version>3.3.6</disruptor.version>
1111
</properties>
1212

13-
<parent>
14-
<groupId>org.sonatype.oss</groupId>
15-
<artifactId>oss-parent</artifactId>
16-
<version>7</version>
17-
</parent>
18-
1913
<modelVersion>4.0.0</modelVersion>
2014
<groupId>com.rapid7</groupId>
2115
<artifactId>r7insight_java</artifactId>
2216
<packaging>jar</packaging>
2317
<name>r7insight_java</name>
24-
<version>1.1.40-SNAPSHOT</version>
18+
<version>1.1.40</version>
2519
<description>Contains logback, log4j, and log4j2 appenders that will send log data to Logentries</description>
2620
<url>https://github.com/rapid7/r7insight_java</url>
2721
<licenses>
@@ -101,20 +95,6 @@
10195
</activation>
10296
<build>
10397
<plugins>
104-
<plugin>
105-
<groupId>org.apache.maven.plugins</groupId>
106-
<artifactId>maven-gpg-plugin</artifactId>
107-
<version>1.1</version>
108-
<executions>
109-
<execution>
110-
<id>sign-artifacts</id>
111-
<phase>verify</phase>
112-
<goals>
113-
<goal>sign</goal>
114-
</goals>
115-
</execution>
116-
</executions>
117-
</plugin>
11898
<plugin>
11999
<groupId>org.apache.maven.plugins</groupId>
120100
<artifactId>maven-source-plugin</artifactId>

src/main/java/com/rapid7/log4j/LogentriesAppender.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public LogentriesAppender() {
3333
/**
3434
* Sets the token
3535
*
36-
* @param token
36+
* @param token Insight OPS token
3737
*/
3838
public void setToken(String token) {
3939
this.configurationBuilder.useToken(token);
@@ -42,7 +42,7 @@ public void setToken(String token) {
4242
/**
4343
* Sets the region
4444
*
45-
* @param region
45+
* @param region region to send the log to (e.g. eu or us)
4646
*/
4747
public void setRegion(String region) {
4848
this.configurationBuilder.inRegion(region);
@@ -60,7 +60,7 @@ public void setHttpPut(boolean httpPut) {
6060
/**
6161
* Sets the ACCOUNT KEY value for HTTP PUT
6262
*
63-
* @param accountKey
63+
* @param accountKey account key value (for http put only)
6464
*/
6565
public void setKey(String accountKey) {
6666
this.configurationBuilder.useAccountKey(accountKey);
@@ -69,7 +69,7 @@ public void setKey(String accountKey) {
6969
/**
7070
* Sets the LOCATION value for HTTP PUT
7171
*
72-
* @param logLocation
72+
* @param logLocation location on server (for http put only)
7373
*/
7474
public void setLocation(String logLocation) {
7575
this.configurationBuilder.httpPutLocation(logLocation);
@@ -78,7 +78,7 @@ public void setLocation(String logLocation) {
7878
/**
7979
* Sets the SSL boolean flag
8080
*
81-
* @param ssl
81+
* @param ssl true to send logs encrypted over ssl/tls
8282
*/
8383
public void setSsl(boolean ssl) {
8484
this.configurationBuilder.useSSL(ssl);
@@ -115,7 +115,7 @@ public void setDataHubAddr(String dataHubAddr) {
115115
/**
116116
* Sets the port number on which DataHub instance waits for log messages.
117117
*
118-
* @param dataHubPort
118+
* @param dataHubPort data hub port number
119119
*/
120120
public void setDataHubPort(int dataHubPort) {
121121
this.configurationBuilder.toServerPort(dataHubPort);
@@ -124,7 +124,7 @@ public void setDataHubPort(int dataHubPort) {
124124
/**
125125
* Determines whether to send HostName alongside with the log message
126126
*
127-
* @param logHostName
127+
* @param logHostName true to add server host name as log prefix
128128
*/
129129
public void setLogHostName(boolean logHostName) {
130130
this.configurationBuilder.logHostNameAsPrefix(logHostName);
@@ -133,7 +133,7 @@ public void setLogHostName(boolean logHostName) {
133133
/**
134134
* Sets the HostName from the configuration
135135
*
136-
* @param hostName
136+
* @param hostName host name value
137137
*/
138138
public void setHostName(String hostName) {
139139
this.configurationBuilder.useAsHostName(hostName);
@@ -142,7 +142,7 @@ public void setHostName(String hostName) {
142142
/**
143143
* Sets LogID parameter from the configuration, it will appear as prefix in any log line
144144
*
145-
* @param logID
145+
* @param logID log prefix
146146
*/
147147
public void setLogID(String logID) {
148148
this.configurationBuilder.setLogIdPrefix(logID);
@@ -151,7 +151,7 @@ public void setLogID(String logID) {
151151
/**
152152
* Implements AppenderSkeleton Append method, handles time and format
153153
*
154-
* @event event to log
154+
* @param event event to log
155155
*/
156156
@Override
157157
protected void append(LoggingEvent event) {

src/main/java/com/rapid7/log4j2/LogentriesAppender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
/**
1717
* Log4J2 Appender that writes to Logentries.
18-
* <p/>
18+
*
1919
* Created by josh on 11/15/14.
2020
*/
2121
@Plugin(name = "Logentries", category = "Core", elementType = "appender", printObject = true)

src/main/java/com/rapid7/log4j2/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Log4J2 -> Logentries integration.
2+
* Log4J2 - Logentries integration.
33
* <p>
44
* Created by josh on 11/15/14.
55
*/

src/main/java/com/rapid7/logback/ExceptionFormatter.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55

66
/**
77
* Formatter to generate Logentries-compatible stack traces.
8-
* <p>
98
* <p>The Logentries TCP token input is delimited by a traditional newline '\n'
109
* char, so multiline events like stack traces should use the unicode line
1110
* separator.</p>
12-
* <p>
1311
* <p>This class simplifies the coercion of logged exceptions into events that
1412
* can be easily viewed and searched through <a
1513
* href="https://logentries.com">Logentries</a>.</p>
@@ -29,7 +27,6 @@ public class ExceptionFormatter {
2927

3028
/**
3129
* Returns a formatted stack trace for an exception.
32-
* <p>
3330
* <p>This method provides a full (non-truncated) trace delimited by
3431
* {@link #DELIMITER}. Currently it doesn't make any use of Java 7's <a
3532
* href="http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html#suppressed-exceptions">exception

src/main/java/com/rapid7/logback/LogentriesAppender.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public LogentriesAppender() {
5454
/**
5555
* Sets the token.
5656
*
57-
* @param token
57+
* @param token Insight OPS token
5858
*/
5959
public void setToken(String token) {
6060
this.configurationBuilder.useToken(token);
@@ -63,7 +63,7 @@ public void setToken(String token) {
6363
/**
6464
* Sets the region.
6565
*
66-
* @param region
66+
* @param region region to send the log to (e.g. eu or us)
6767
*/
6868
public void setRegion(String region) {
6969
this.configurationBuilder.inRegion(region);
@@ -82,7 +82,7 @@ public void setHttpPut(boolean httpPut) {
8282
/**
8383
* Sets the ACCOUNT KEY value for HTTP PUT.
8484
*
85-
* @param accountKey
85+
* @param accountKey account key value (for http put only)
8686
*/
8787
public void setKey(String accountKey) {
8888
this.configurationBuilder.useAccountKey(accountKey);
@@ -91,7 +91,7 @@ public void setKey(String accountKey) {
9191
/**
9292
* Sets the LOCATION value for HTTP PUT.
9393
*
94-
* @param logLocation
94+
* @param logLocation location on server (for http put only)
9595
*/
9696
public void setLocation(String logLocation) {
9797
this.configurationBuilder.httpPutLocation(logLocation);
@@ -100,15 +100,14 @@ public void setLocation(String logLocation) {
100100
/**
101101
* Sets the SSL boolean flag
102102
*
103-
* @param ssl
103+
* @param ssl true to send logs encrypted over ssl/tls
104104
*/
105105
public void setSsl(boolean ssl) {
106106
this.configurationBuilder.useSSL(ssl);
107107
}
108108

109109
/**
110110
* Sets the debug flag.
111-
* <p>
112111
* <p>Appender in debug mode will print error messages on error console.</p>
113112
*
114113
* @param debug debug flag to set
@@ -138,7 +137,7 @@ public void setDataHubAddr(String dataHubAddr) {
138137
/**
139138
* Sets the port number on which DataHub instance waits for log messages.
140139
*
141-
* @param dataHubPort
140+
* @param dataHubPort data hub port number
142141
*/
143142
public void setDataHubPort(int dataHubPort) {
144143
this.configurationBuilder.toServerPort(dataHubPort);
@@ -147,7 +146,7 @@ public void setDataHubPort(int dataHubPort) {
147146
/**
148147
* Determines whether to send HostName alongside with the log message
149148
*
150-
* @param logHostName
149+
* @param logHostName true to add server host name as log prefix
151150
*/
152151
public void setLogHostName(boolean logHostName) {
153152
this.configurationBuilder.logHostNameAsPrefix(logHostName);
@@ -156,7 +155,7 @@ public void setLogHostName(boolean logHostName) {
156155
/**
157156
* Sets the HostName from the configuration
158157
*
159-
* @param hostName
158+
* @param hostName host name value
160159
*/
161160
public void setHostName(String hostName) {
162161
this.configurationBuilder.useAsHostName(hostName);
@@ -165,16 +164,16 @@ public void setHostName(String hostName) {
165164
/**
166165
* Sets LogID parameter from the configuration
167166
*
168-
* @param logID
167+
* @param logID log prefix
169168
*/
170169
public void setLogID(String logID) {
171170
this.configurationBuilder.setLogIdPrefix(logID);
172171
}
173172

174173
/**
175-
* Sets the suffixPattern to be the <pattern> field in the .xml configuration file
174+
* Sets the suffixPattern to be the pattern field in the .xml configuration file
176175
*
177-
* @param encoder
176+
* @param encoder Logback Pattern Layout Encoder
178177
*/
179178
public void setEncoder(PatternLayoutEncoder encoder) {
180179
this.suffixPattern = encoder.getPattern();
@@ -197,6 +196,7 @@ String getPrefixPattern() {
197196
* Returns the string value of the <b>Facility</b> option.
198197
* <p>
199198
* See {@link #setFacility} for the set of allowed values.
199+
* @return facility name
200200
*/
201201
public String getFacility() {
202202
return facilityStr;
@@ -207,9 +207,10 @@ public String getFacility() {
207207
* MAIL, DAEMON, AUTH, SYSLOG, LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP, NTP,
208208
* AUDIT, ALERT, CLOCK, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5,
209209
* LOCAL6, LOCAL7. Case is not important.
210-
* <p>
211210
* <p>See {@link SyslogConstants} and RFC 3164 for more information about
212211
* the <b>Facility</b> option.
212+
*
213+
* @param facilityStr facility name
213214
*/
214215
public void setFacility(String facilityStr) {
215216
if (facilityStr != null) {
@@ -224,6 +225,8 @@ public Layout<ILoggingEvent> getLayout() {
224225

225226
/**
226227
* Sets the layout for the Appender
228+
*
229+
* @param layout logback layout
227230
*/
228231
public void setLayout(Layout<ILoggingEvent> layout) {
229232
this.layout = layout;
@@ -232,7 +235,7 @@ public void setLayout(Layout<ILoggingEvent> layout) {
232235
/**
233236
* Implements AppenderSkeleton Append method, handles time and format
234237
*
235-
* @event event to log
238+
* @param event event to log
236239
*/
237240
@Override
238241
protected void append(ILoggingEvent event) {
@@ -264,9 +267,9 @@ public Layout<ILoggingEvent> buildLayout() {
264267
}
265268

266269
/**
267-
* See {@link #setSuffixPattern(String).
270+
* See @link #setSuffixPattern(String).
268271
*
269-
* @return
272+
* @return suffix pattern
270273
*/
271274
public String getSuffixPattern() {
272275
return suffixPattern;
@@ -276,7 +279,7 @@ public String getSuffixPattern() {
276279
* The <b>suffixPattern</b> option specifies the format of the
277280
* non-standardized part of the message sent to the syslog server.
278281
*
279-
* @param suffixPattern
282+
* @param suffixPattern suffix pattern
280283
*/
281284
public void setSuffixPattern(String suffixPattern) {
282285
this.suffixPattern = suffixPattern;

src/main/java/com/rapid7/net/AsyncLogger.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
* <p>
1919
* a Rapid7™ service
2020
* <p>
21-
* <p>
2221
* VERSION: 1.2.0
2322
*
2423
* @author Viliam Holub
@@ -168,6 +167,8 @@ public final class AsyncLogger {
168167

169168
/**
170169
* Initializes asynchronous logging.
170+
*
171+
* @param configuration logger options
171172
*/
172173
public AsyncLogger(LoggerConfiguration configuration) {
173174

src/test/resources/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/test/resources/logback.sample.xml

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/test/resources/logback.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<configuration>
3+
<appender name="LE" class="com.rapid7.logback.LogentriesAppender">
4+
<Token>0c7407d4-fd0d-4436-bb50-44f1266b4490</Token>
5+
<Region>eu</Region>
6+
<Ssl>true</Ssl>
7+
<facility>USER</facility>
8+
<dataHubAddr>localhost</dataHubAddr>
9+
<dataHubPort>20000</dataHubPort>
10+
<debug>true</debug>
11+
<encoder>
12+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
13+
</encoder>
14+
</appender>
15+
16+
<root level="debug">
17+
<appender-ref ref="LE" />
18+
</root>
19+
</configuration>

0 commit comments

Comments
 (0)