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

Handle absent OTX API key in ThreatIntelPluginConfiguration #54

Merged
merged 1 commit into from Sep 27, 2017

Conversation

Projects
None yet
2 participants
@joschi
Contributor

joschi commented Sep 26, 2017

Fixes #53

@joschi joschi added this to the 2.4.0 milestone Sep 26, 2017

@joschi joschi requested a review from dennisoelkers Sep 26, 2017

@@ -19,7 +19,8 @@
public abstract boolean otxEnabled();
@JsonProperty("otx_api_key")
public abstract Optional<String> otxApiKey();
@Nullable
public abstract String otxApiKey();

This comment has been minimized.

@bernd

bernd Sep 27, 2017

Member

Wouldn't this be enough so we can keep the nice properties of java.util.Optional?

diff --git src/main/java/org/graylog/plugins/threatintel/ThreatIntelPluginConfiguration.java src/main/java/org/graylog/plugins/threatintel/ThreatIntelPluginConfiguration.java
index 130fa5d..9b983fa 100644
--- src/main/java/org/graylog/plugins/threatintel/ThreatIntelPluginConfiguration.java
+++ src/main/java/org/graylog/plugins/threatintel/ThreatIntelPluginConfiguration.java
@@ -38,7 +37,7 @@ public abstract class ThreatIntelPluginConfiguration {
                                                         @JsonProperty("abusech_ransom_enabled") boolean abusechRansomEnabled) {
         return builder()
                 .otxEnabled(otxEnabled)
-                .otxApiKey(otxApiKey)
+                .otxApiKey(Optional.ofNullable(otxApiKey))
                 .torEnabled(torEnabled)
                 .spamhausEnabled(spamhausEnabled)
                 .abusechRansomEnabled(abusechRansomEnabled)
@@ -62,7 +61,7 @@ public abstract class ThreatIntelPluginConfiguration {
     public static abstract class Builder {
         public abstract Builder otxEnabled(boolean otxEnabled);
 
-        public abstract Builder otxApiKey(String otxApiKey);
+        public abstract Builder otxApiKey(Optional<String> otxApiKey);
 
         public abstract Builder torEnabled(boolean torEnabled);

This comment has been minimized.

@joschi

joschi Sep 27, 2017

Contributor

Maybe, but Optional<T> is pretty useless in this case anyway (check the usages of ThreatIntelPluginConfiguration#otxApiKey()).
In other words, getting rid of the Optional<T> meant having less code.

This comment has been minimized.

@bernd

bernd Sep 27, 2017

Member

I wouldn't call it useless, but fair enough.

@bernd bernd self-assigned this Sep 27, 2017

@bernd

bernd approved these changes Sep 27, 2017

@bernd bernd merged commit e3b1ca2 into master Sep 27, 2017

2 checks passed

graylog-project/pr Jenkins build graylog-project-pr-snapshot 504 has succeeded
Details
license/cla Contributor License Agreement is signed.
Details

@bernd bernd deleted the issue-53 branch Sep 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment