Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security upgrades #54

Merged
merged 3 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@
</developer>
</developers>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>2.15.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!--compile scope-->
<dependency>
Expand All @@ -66,7 +78,7 @@
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>4.11</version>
<version>7.4</version>
</dependency>

<!-- Annotations-->
Expand All @@ -81,7 +93,7 @@
<dependency>
<groupId>uk.co.flamingpenguin.jewelcli</groupId>
<artifactId>jewelcli</artifactId>
<version>0.6</version>
<version>0.59</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
Expand Down Expand Up @@ -111,13 +123,6 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.7.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>17.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import ch.qos.logback.classic.net.SyslogAppender;
import ch.qos.logback.core.ConsoleAppender;
import ch.qos.logback.core.status.Status;
import com.google.common.collect.FluentIterable;
import com.spotify.logging.logback.CustomLogstashEncoder;
import io.sentry.logback.SentryAppender;
import net.logstash.logback.composite.loggingevent.ArgumentsJsonProvider;
Expand Down Expand Up @@ -214,9 +213,9 @@ private void assertLogstashEncoder(final Level level) {
final CustomLogstashEncoder encoder = (CustomLogstashEncoder) stdout.getEncoder();
assertEquals(
1,
FluentIterable.from(encoder.getProviders().getProviders())
.filter(ArgumentsJsonProvider.class)
.size());
encoder.getProviders().getProviders().stream()
.filter(ArgumentsJsonProvider.class::isInstance)
.count());
}

private void assertDefault(final String ident, final Level level) {
Expand Down
17 changes: 13 additions & 4 deletions src/test/java/com/spotify/logging/logback/LogstashEncoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.spotify.logging.LoggingConfigurator;
import com.spotify.logging.LoggingConfigurator.Level;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import net.logstash.logback.encoder.LogstashEncoder;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -52,8 +53,8 @@ public void shouldIncludeStructuredArguments() throws JsonProcessingException {
"foo={} bar={} list={} map={} thing={}",
value("foo", 17),
value("bar", "quux"),
value("list", ImmutableList.of(1, 2)),
value("map", ImmutableMap.of("a", 3, "b", 4)),
value("list", Arrays.asList(1, 2)),
value("map", mapOf("a", 3, "b", 4)),
value("thing", new Thing(5, "6")));
final String log = systemOutRule.getLog();
final JsonNode parsedMessage = mapper.readTree(log);
Expand All @@ -67,6 +68,14 @@ public void shouldIncludeStructuredArguments() throws JsonProcessingException {
assertEquals(mapper.createObjectNode().put("v1", 5).put("v2", "6"), parsedMessage.get("thing"));
}

private <V> Map<String, V> mapOf(
final String keyA, final V valueA, final String keyB, final V valueB) {
final Map<String, V> map = new HashMap<>();
map.put(keyA, valueA);
map.put(keyB, valueB);
return map;
}

public static class Thing {

private final int v1;
Expand Down