From 738b6606b6ba1e892128bb53f46157d9aa943fa3 Mon Sep 17 00:00:00 2001 From: Joanne Wang Date: Wed, 4 Oct 2023 00:07:36 -0700 Subject: [PATCH] remove lombok Signed-off-by: Joanne Wang --- .../action/DeleteDatasourceAction.java | 2 +- .../action/DeleteDatasourceRequest.java | 8 +- .../DeleteDatasourceTransportAction.java | 12 +- .../action/GetDatasourceAction.java | 2 +- .../action/GetDatasourceRequest.java | 2 +- .../action/GetDatasourceResponse.java | 4 +- .../action/GetDatasourceTransportAction.java | 6 +- .../action/PutDatasourceAction.java | 2 +- .../action/PutDatasourceRequest.java | 52 +++++- .../action/PutDatasourceTransportAction.java | 14 +- .../action/RestDeleteDatasourceHandler.java | 5 +- .../action/RestGetDatasourceHandler.java | 2 +- .../action/RestPutDatasourceHandler.java | 4 +- .../action/RestUpdateDatasourceHandler.java | 2 +- .../action/UpdateDatasourceAction.java | 2 +- .../action/UpdateDatasourceRequest.java | 24 ++- .../UpdateDatasourceTransportAction.java | 14 +- .../common/DatasourceManifest.java | 33 +++- .../threatintel/common/DatasourceState.java | 2 +- .../common/ParameterValidator.java | 2 +- .../common/StashedThreadContext.java | 2 +- .../common/ThreatIntelExecutor.java | 2 +- .../common/ThreatIntelLockService.java | 4 +- .../common/ThreatIntelSettings.java | 2 +- .../threatintel/dao/DatasourceDao.java | 10 +- .../threatintel/dao/ThreatIntelFeedDao.java | 18 +- .../threatintel/jobscheduler/Datasource.java | 160 +++++++++++++++--- .../jobscheduler/DatasourceExtension.java | 2 +- .../jobscheduler/DatasourceRunner.java | 10 +- .../jobscheduler/DatasourceTask.java | 2 +- .../jobscheduler/DatasourceUpdateService.java | 10 +- .../securityanalytics/threatintel/url.java | 46 ----- .../findings/FindingServiceTests.java | 31 ---- 33 files changed, 313 insertions(+), 180 deletions(-) delete mode 100644 src/main/java/org/opensearch/securityanalytics/threatintel/url.java diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/DeleteDatasourceAction.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/DeleteDatasourceAction.java index 98147bb9f..35effc4b7 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/DeleteDatasourceAction.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/DeleteDatasourceAction.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.action.ActionType; import org.opensearch.action.support.master.AcknowledgedResponse; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/DeleteDatasourceRequest.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/DeleteDatasourceRequest.java index 1cde05690..654b93985 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/DeleteDatasourceRequest.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/DeleteDatasourceRequest.java @@ -3,13 +3,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.securityanalytics.threatintel.common.ParameterValidator; +import org.opensearch.securityanalytics.threatIntel.common.ParameterValidator; import java.io.IOException; @@ -36,6 +36,10 @@ public DeleteDatasourceRequest(final StreamInput in) throws IOException { this.name = in.readString(); } + public DeleteDatasourceRequest(final String name) { + this.name = name; + } + @Override public ActionRequestValidationException validate() { ActionRequestValidationException errors = null; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/DeleteDatasourceTransportAction.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/DeleteDatasourceTransportAction.java index 2117bbf13..d8515d40e 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/DeleteDatasourceTransportAction.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/DeleteDatasourceTransportAction.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -18,11 +18,11 @@ import org.opensearch.ingest.IngestService; import org.opensearch.securityanalytics.model.DetectorTrigger; -import org.opensearch.securityanalytics.threatintel.common.DatasourceState; -import org.opensearch.securityanalytics.threatintel.common.ThreatIntelLockService; -import org.opensearch.securityanalytics.threatintel.dao.DatasourceDao; -import org.opensearch.securityanalytics.threatintel.dao.ThreatIntelFeedDao; -import org.opensearch.securityanalytics.threatintel.jobscheduler.Datasource; +import org.opensearch.securityanalytics.threatIntel.common.DatasourceState; +import org.opensearch.securityanalytics.threatIntel.common.ThreatIntelLockService; +import org.opensearch.securityanalytics.threatIntel.dao.DatasourceDao; +import org.opensearch.securityanalytics.threatIntel.dao.ThreatIntelFeedDao; +import org.opensearch.securityanalytics.threatIntel.jobscheduler.Datasource; import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceAction.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceAction.java index e7487226b..6befdde04 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceAction.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceAction.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.action.ActionType; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceRequest.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceRequest.java index 2c1e82994..16f36b08e 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceRequest.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceRequest.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceResponse.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceResponse.java index cc9b86c9d..d404ad728 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceResponse.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceResponse.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.core.ParseField; import org.opensearch.core.action.ActionResponse; @@ -11,7 +11,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ToXContentObject; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.securityanalytics.threatintel.jobscheduler.Datasource; +import org.opensearch.securityanalytics.threatIntel.jobscheduler.Datasource; import java.io.IOException; import java.time.Instant; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceTransportAction.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceTransportAction.java index 1b1a3d9d7..cb1419517 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceTransportAction.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/GetDatasourceTransportAction.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.OpenSearchException; import org.opensearch.action.support.ActionFilters; @@ -11,8 +11,8 @@ import org.opensearch.common.inject.Inject; import org.opensearch.core.action.ActionListener; import org.opensearch.index.IndexNotFoundException; -import org.opensearch.securityanalytics.threatintel.dao.DatasourceDao; -import org.opensearch.securityanalytics.threatintel.jobscheduler.Datasource; +import org.opensearch.securityanalytics.threatIntel.dao.DatasourceDao; +import org.opensearch.securityanalytics.threatIntel.jobscheduler.Datasource; import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/PutDatasourceAction.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/PutDatasourceAction.java index f111a0195..6a6acb9ed 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/PutDatasourceAction.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/PutDatasourceAction.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.action.ActionType; import org.opensearch.action.support.master.AcknowledgedResponse; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/PutDatasourceRequest.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/PutDatasourceRequest.java index 4e717a8be..dac67ed43 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/PutDatasourceRequest.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/PutDatasourceRequest.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import java.io.IOException; import java.net.MalformedURLException; @@ -22,8 +22,8 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.securityanalytics.model.DetectorTrigger; -import org.opensearch.securityanalytics.threatintel.common.DatasourceManifest; -import org.opensearch.securityanalytics.threatintel.common.ParameterValidator; +import org.opensearch.securityanalytics.threatIntel.common.DatasourceManifest; +import org.opensearch.securityanalytics.threatIntel.common.ParameterValidator; /** * Threat intel datasource creation request @@ -62,6 +62,50 @@ public class PutDatasourceRequest extends ActionRequest { private List contained_iocs_field; + public void setFeedFormat(String feedFormat) { + this.feedFormat = feedFormat; + } + + public void setThisEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public void setFeedName(String feedName) { + this.feedName = feedName; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setOrganization(String organization) { + this.organization = organization; + } + + public void setContained_iocs_field(List contained_iocs_field) { + this.contained_iocs_field = contained_iocs_field; + } + + public List getContained_iocs_field() { + return contained_iocs_field; + } + + public String getFeedFormat() { + return feedFormat; + } + + public String getFeedName() { + return feedName; + } + + @Override + public String getDescription() { + return description; + } + + public String getOrganization() { + return organization; + } /** * @param updateInterval update interval of a datasource * @return update interval of a datasource @@ -75,7 +119,7 @@ public class PutDatasourceRequest extends ActionRequest { static { PARSER = new ObjectParser<>("put_datasource"); PARSER.declareString((request, val) -> request.setFeedFormat(val), FEED_FORMAT_FIELD); - PARSER.declareString((request, val) -> request.setEndpoint(val), ENDPOINT_FIELD); + PARSER.declareString((request, val) -> request.setThisEndpoint(val), ENDPOINT_FIELD); PARSER.declareString((request, val) -> request.setFeedName(val), FEED_NAME_FIELD); PARSER.declareString((request, val) -> request.setDescription(val), DESCRIPTION_FIELD); PARSER.declareString((request, val) -> request.setOrganization(val), ORGANIZATION_FIELD); diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/PutDatasourceTransportAction.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/PutDatasourceTransportAction.java index 6b8e72c0a..f1f87c4c5 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/PutDatasourceTransportAction.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/PutDatasourceTransportAction.java @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; -import static org.opensearch.securityanalytics.threatintel.common.ThreatIntelLockService.LOCK_DURATION_IN_SECONDS; +import static org.opensearch.securityanalytics.threatIntel.common.ThreatIntelLockService.LOCK_DURATION_IN_SECONDS; import java.time.Instant; import java.util.ConcurrentModificationException; @@ -26,11 +26,11 @@ import org.opensearch.index.engine.VersionConflictEngineException; import org.opensearch.jobscheduler.spi.LockModel; import org.opensearch.securityanalytics.model.DetectorTrigger; -import org.opensearch.securityanalytics.threatintel.common.DatasourceState; -import org.opensearch.securityanalytics.threatintel.common.ThreatIntelLockService; -import org.opensearch.securityanalytics.threatintel.dao.DatasourceDao; -import org.opensearch.securityanalytics.threatintel.jobscheduler.Datasource; -import org.opensearch.securityanalytics.threatintel.jobscheduler.DatasourceUpdateService; +import org.opensearch.securityanalytics.threatIntel.common.DatasourceState; +import org.opensearch.securityanalytics.threatIntel.common.ThreatIntelLockService; +import org.opensearch.securityanalytics.threatIntel.dao.DatasourceDao; +import org.opensearch.securityanalytics.threatIntel.jobscheduler.Datasource; +import org.opensearch.securityanalytics.threatIntel.jobscheduler.DatasourceUpdateService; import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestDeleteDatasourceHandler.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestDeleteDatasourceHandler.java index 7b5555cc9..3da4c4abc 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestDeleteDatasourceHandler.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestDeleteDatasourceHandler.java @@ -3,13 +3,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.client.node.NodeClient; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.RestRequest; import org.opensearch.rest.action.RestToXContentListener; +import java.io.IOException; import java.util.List; import java.util.Locale; @@ -28,7 +29,7 @@ public String getName() { } @Override - protected RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) { + protected RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { final String name = request.param(PARAMS_NAME); final DeleteDatasourceRequest deleteDatasourceRequest = new DeleteDatasourceRequest(name); diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestGetDatasourceHandler.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestGetDatasourceHandler.java index dbb492f1e..ddbecdad5 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestGetDatasourceHandler.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestGetDatasourceHandler.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.client.node.NodeClient; import org.opensearch.core.common.Strings; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestPutDatasourceHandler.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestPutDatasourceHandler.java index d7b1e96d5..5c9ecd7b4 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestPutDatasourceHandler.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestPutDatasourceHandler.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.ClusterSettings; @@ -12,7 +12,7 @@ import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.RestRequest; import org.opensearch.rest.action.RestToXContentListener; -import org.opensearch.securityanalytics.threatintel.common.ThreatIntelSettings; +import org.opensearch.securityanalytics.threatIntel.common.ThreatIntelSettings; import java.io.IOException; import java.util.List; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestUpdateDatasourceHandler.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestUpdateDatasourceHandler.java index 7d8e30438..3f755670f 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestUpdateDatasourceHandler.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/RestUpdateDatasourceHandler.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.client.node.NodeClient; import org.opensearch.core.xcontent.XContentParser; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/UpdateDatasourceAction.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/UpdateDatasourceAction.java index beae44a59..ddf2d42e6 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/UpdateDatasourceAction.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/UpdateDatasourceAction.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.action.ActionType; import org.opensearch.action.support.master.AcknowledgedResponse; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/UpdateDatasourceRequest.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/UpdateDatasourceRequest.java index ffc12640b..7d70f45aa 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/UpdateDatasourceRequest.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/UpdateDatasourceRequest.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -15,8 +15,8 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.xcontent.ObjectParser; import org.opensearch.securityanalytics.model.DetectorTrigger; -import org.opensearch.securityanalytics.threatintel.common.DatasourceManifest; -import org.opensearch.securityanalytics.threatintel.common.ParameterValidator; +import org.opensearch.securityanalytics.threatIntel.common.DatasourceManifest; +import org.opensearch.securityanalytics.threatIntel.common.ParameterValidator; import java.io.IOException; import java.net.MalformedURLException; @@ -40,11 +40,13 @@ public class UpdateDatasourceRequest extends ActionRequest { * @return the datasource name */ private String name; + /** * @param endpoint url to a manifest file for a datasource * @return url to a manifest file for a datasource */ private String endpoint; + /** * @param updateInterval update interval of a datasource * @return update interval of a datasource @@ -61,8 +63,22 @@ public class UpdateDatasourceRequest extends ActionRequest { PARSER.declareLong((request, val) -> request.setUpdateInterval(TimeValue.timeValueDays(val)), UPDATE_INTERVAL_IN_DAYS_FIELD); } - private void setEndpoint(String val) { + public String getName() { + return name; + } + public String getEndpoint() { + return endpoint; + } + private void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public TimeValue getUpdateInterval() { + return updateInterval; + } + private void setUpdateInterval(TimeValue updateInterval){ + this.updateInterval = updateInterval; } /** diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/action/UpdateDatasourceTransportAction.java b/src/main/java/org/opensearch/securityanalytics/threatintel/action/UpdateDatasourceTransportAction.java index 0e4eb3288..11d99e41c 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/action/UpdateDatasourceTransportAction.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/action/UpdateDatasourceTransportAction.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.action; +package org.opensearch.securityanalytics.threatIntel.action; import org.opensearch.OpenSearchStatusException; import org.opensearch.ResourceNotFoundException; @@ -14,12 +14,12 @@ import org.opensearch.core.action.ActionListener; import org.opensearch.core.rest.RestStatus; import org.opensearch.jobscheduler.spi.schedule.IntervalSchedule; -import org.opensearch.securityanalytics.threatintel.common.DatasourceState; -import org.opensearch.securityanalytics.threatintel.common.ThreatIntelLockService; -import org.opensearch.securityanalytics.threatintel.dao.DatasourceDao; -import org.opensearch.securityanalytics.threatintel.jobscheduler.Datasource; -import org.opensearch.securityanalytics.threatintel.jobscheduler.DatasourceTask; -import org.opensearch.securityanalytics.threatintel.jobscheduler.DatasourceUpdateService; +import org.opensearch.securityanalytics.threatIntel.common.DatasourceState; +import org.opensearch.securityanalytics.threatIntel.common.ThreatIntelLockService; +import org.opensearch.securityanalytics.threatIntel.dao.DatasourceDao; +import org.opensearch.securityanalytics.threatIntel.jobscheduler.Datasource; +import org.opensearch.securityanalytics.threatIntel.jobscheduler.DatasourceTask; +import org.opensearch.securityanalytics.threatIntel.jobscheduler.DatasourceUpdateService; import org.opensearch.tasks.Task; import org.opensearch.threadpool.ThreadPool; import org.opensearch.transport.TransportService; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/common/DatasourceManifest.java b/src/main/java/org/opensearch/securityanalytics/threatintel/common/DatasourceManifest.java index be754d846..0b23d66e8 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/common/DatasourceManifest.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/common/DatasourceManifest.java @@ -2,7 +2,7 @@ * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.common; +package org.opensearch.securityanalytics.threatIntel.common; import java.io.BufferedReader; import java.io.IOException; @@ -47,6 +47,7 @@ public class DatasourceManifest { * @return URL of a ZIP file containing a database */ private String url; + /** * @param dbName A database file name inside the ZIP file * @return A database file name inside the ZIP file @@ -57,6 +58,7 @@ public class DatasourceManifest { * @return SHA256 hash value of a database file */ private String sha256Hash; + /** * @param organization A database organization name * @return A database organization name @@ -73,6 +75,35 @@ public class DatasourceManifest { */ private Long updatedAt; + public String getDbName() { + return dbName; + } + + public String getOrganization() { + return organization; + } + + public String getSha256Hash() { + return sha256Hash; + } + + public String getDescription() { + return description; + } + + public Long getUpdatedAt() { + return updatedAt; + } + + public DatasourceManifest(final String url, final String dbName, final String sha256Hash, final String organization, final String description, final Long updatedAt) { + this.url = url; + this.dbName = dbName; + this.sha256Hash = sha256Hash; + this.organization = organization; + this.description = description; + this.updatedAt = updatedAt; + } + /** * Datasource manifest parser */ diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/common/DatasourceState.java b/src/main/java/org/opensearch/securityanalytics/threatintel/common/DatasourceState.java index f5de3861f..a516b1d34 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/common/DatasourceState.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/common/DatasourceState.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.common; +package org.opensearch.securityanalytics.threatIntel.common; /** * Threat intel datasource state diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/common/ParameterValidator.java b/src/main/java/org/opensearch/securityanalytics/threatintel/common/ParameterValidator.java index 51acfece4..13276975c 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/common/ParameterValidator.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/common/ParameterValidator.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.common; +package org.opensearch.securityanalytics.threatIntel.common; import java.nio.charset.StandardCharsets; import java.util.ArrayList; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/common/StashedThreadContext.java b/src/main/java/org/opensearch/securityanalytics/threatintel/common/StashedThreadContext.java index 2d4ac79bf..32f4e6d40 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/common/StashedThreadContext.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/common/StashedThreadContext.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.common; +package org.opensearch.securityanalytics.threatIntel.common; import java.util.function.Supplier; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/common/ThreatIntelExecutor.java b/src/main/java/org/opensearch/securityanalytics/threatintel/common/ThreatIntelExecutor.java index 7a887fc6d..b3817786c 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/common/ThreatIntelExecutor.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/common/ThreatIntelExecutor.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.common; +package org.opensearch.securityanalytics.threatIntel.common; import java.util.concurrent.ExecutorService; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/common/ThreatIntelLockService.java b/src/main/java/org/opensearch/securityanalytics/threatintel/common/ThreatIntelLockService.java index 03bbcde02..8847d681e 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/common/ThreatIntelLockService.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/common/ThreatIntelLockService.java @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.common; +package org.opensearch.securityanalytics.threatIntel.common; -import static org.opensearch.securityanalytics.threatintel.jobscheduler.DatasourceExtension.JOB_INDEX_NAME; +import static org.opensearch.securityanalytics.threatIntel.jobscheduler.DatasourceExtension.JOB_INDEX_NAME; import java.time.Instant; import java.util.Optional; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/common/ThreatIntelSettings.java b/src/main/java/org/opensearch/securityanalytics/threatintel/common/ThreatIntelSettings.java index e997af730..1d649e0b6 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/common/ThreatIntelSettings.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/common/ThreatIntelSettings.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.common; +package org.opensearch.securityanalytics.threatIntel.common; import java.net.MalformedURLException; import java.net.URISyntaxException; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/dao/DatasourceDao.java b/src/main/java/org/opensearch/securityanalytics/threatintel/dao/DatasourceDao.java index 5ec565df3..9d6a15241 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/dao/DatasourceDao.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/dao/DatasourceDao.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.dao; +package org.opensearch.securityanalytics.threatIntel.dao; import java.io.BufferedReader; import java.io.IOException; @@ -50,10 +50,10 @@ import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.securityanalytics.model.DetectorTrigger; -import org.opensearch.securityanalytics.threatintel.common.ThreatIntelSettings; -import org.opensearch.securityanalytics.threatintel.jobscheduler.Datasource; -import org.opensearch.securityanalytics.threatintel.jobscheduler.DatasourceExtension; -import org.opensearch.securityanalytics.threatintel.common.StashedThreadContext; +import org.opensearch.securityanalytics.threatIntel.common.ThreatIntelSettings; +import org.opensearch.securityanalytics.threatIntel.jobscheduler.Datasource; +import org.opensearch.securityanalytics.threatIntel.jobscheduler.DatasourceExtension; +import org.opensearch.securityanalytics.threatIntel.common.StashedThreadContext; import org.opensearch.index.IndexNotFoundException; import org.opensearch.index.query.QueryBuilders; import org.opensearch.search.SearchHit; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/dao/ThreatIntelFeedDao.java b/src/main/java/org/opensearch/securityanalytics/threatintel/dao/ThreatIntelFeedDao.java index 172c1e139..f0a4fa615 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/dao/ThreatIntelFeedDao.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/dao/ThreatIntelFeedDao.java @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.dao; +package org.opensearch.securityanalytics.threatIntel.dao; -import static org.opensearch.securityanalytics.threatintel.jobscheduler.Datasource.THREAT_INTEL_DATA_INDEX_NAME_PREFIX; +import static org.opensearch.securityanalytics.threatIntel.jobscheduler.Datasource.THREAT_INTEL_DATA_INDEX_NAME_PREFIX; import java.io.BufferedReader; import java.io.IOException; @@ -58,10 +58,10 @@ import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.securityanalytics.model.DetectorTrigger; -import org.opensearch.securityanalytics.threatintel.common.DatasourceManifest; -import org.opensearch.securityanalytics.threatintel.common.ThreatIntelSettings; +import org.opensearch.securityanalytics.threatIntel.common.DatasourceManifest; +import org.opensearch.securityanalytics.threatIntel.common.ThreatIntelSettings; -import org.opensearch.securityanalytics.threatintel.common.StashedThreadContext; +import org.opensearch.securityanalytics.threatIntel.common.StashedThreadContext; import org.opensearch.index.query.QueryBuilders; import org.opensearch.securityanalytics.util.SecurityAnalyticsException; @@ -276,10 +276,10 @@ public Map getTIFData(final String indexName, final String ip) { * @param renewLock Runnable to renew lock */ public void putTIFData( - @NonNull final String indexName, - @NonNull final String[] fields, - @NonNull final Iterator iterator, - @NonNull final Runnable renewLock + final String indexName, //non null all of these fields + final String[] fields, + final Iterator iterator, + final Runnable renewLock ) throws IOException { TimeValue timeout = clusterSettings.get(ThreatIntelSettings.THREAT_INTEL_TIMEOUT); Integer batchSize = clusterSettings.get(ThreatIntelSettings.BATCH_SIZE); diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/Datasource.java b/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/Datasource.java index 7c75eab8d..948c6f0e0 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/Datasource.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/Datasource.java @@ -6,7 +6,7 @@ * this file be licensed under the Apache-2.0 license or a * compatible open source license. */ -package org.opensearch.securityanalytics.threatintel.jobscheduler; +package org.opensearch.securityanalytics.threatIntel.jobscheduler; import org.opensearch.core.ParseField; import org.opensearch.core.common.io.stream.StreamInput; @@ -27,10 +27,10 @@ import static org.opensearch.common.time.DateUtils.toInstant; -import org.opensearch.securityanalytics.threatintel.action.PutDatasourceRequest; -import org.opensearch.securityanalytics.threatintel.common.DatasourceManifest; -import org.opensearch.securityanalytics.threatintel.common.DatasourceState; -import org.opensearch.securityanalytics.threatintel.common.ThreatIntelLockService; +import org.opensearch.securityanalytics.threatIntel.action.PutDatasourceRequest; +import org.opensearch.securityanalytics.threatIntel.common.DatasourceManifest; +import org.opensearch.securityanalytics.threatIntel.common.DatasourceState; +import org.opensearch.securityanalytics.threatIntel.common.ThreatIntelLockService; public class Datasource implements Writeable, ScheduledJobParameter { /** @@ -78,6 +78,7 @@ public class Datasource implements Writeable, ScheduledJobParameter { * @return name of a datasource */ private String name; + /** * @param lastUpdateTime Last update time of a datasource * @return Last update time of a datasource @@ -151,11 +152,11 @@ public class Datasource implements Writeable, ScheduledJobParameter { * @return State of a datasource */ private DatasourceState state; + /** * @param currentIndex the current index name having threat intel feed data * @return the current index name having threat intel feed data */ - @Getter(AccessLevel.NONE) private String currentIndex; /** * @param indices A list of indices having threat intel feed data including currentIndex @@ -173,6 +174,30 @@ public class Datasource implements Writeable, ScheduledJobParameter { */ private UpdateStats updateStats; + public DatasourceTask getTask() { + return task; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public void setLastUpdateTime(Instant lastUpdateTime) { + this.lastUpdateTime = lastUpdateTime; + } + + public void setOrganization(String organization) { + this.organization = organization; + } + + public void setCurrentIndex(String currentIndex) { + this.currentIndex = currentIndex; + } + + public void setTask(DatasourceTask task) { + this.task = task; + } + /** * Datasource parser @@ -244,25 +269,48 @@ public Datasource() { this(null, null, null, null, null, null, null, null); } + public Datasource(final String name, final Instant lastUpdateTime, final Instant enabledTime, final Boolean isEnabled, + final IntervalSchedule schedule, DatasourceTask task, final String feedFormat, final String endpoint, + final String feedName, final String description, final String organization, final List contained_iocs_field, + final DatasourceState state, final String currentIndex, final List indices, final Database database, final UpdateStats updateStats) { + this.name = name; + this.lastUpdateTime = lastUpdateTime; + this.enabledTime = enabledTime; + this.isEnabled = isEnabled; + this.schedule = schedule; + this.task = task; + this.feedFormat = feedFormat; + this.endpoint = endpoint; + this.feedName = feedName; + this.description = description; + this.organization = organization; + this.contained_iocs_field = contained_iocs_field; + this.state = state; + this.currentIndex = currentIndex; + this.indices = indices; + this.database = database; + this.updateStats = updateStats; + } + public Datasource(final String name, final IntervalSchedule schedule, final String feedFormat, final String endpoint, final String feedName, final String description, final String organization, final List contained_iocs_field ) { this( - name, - Instant.now().truncatedTo(ChronoUnit.MILLIS), - null, - false, - schedule, - DatasourceTask.ALL, - feedFormat, - endpoint, - feedName, - description, - organization, - contained_iocs_field, - DatasourceState.CREATING, - null, - new ArrayList<>(), - new Database(), - new UpdateStats() + name, + Instant.now().truncatedTo(ChronoUnit.MILLIS), + null, + false, + schedule, + DatasourceTask.ALL, + feedFormat, + endpoint, + feedName, + description, + organization, + contained_iocs_field, + DatasourceState.CREATING, + null, + new ArrayList<>(), + new Database(), + new UpdateStats() ); } @@ -506,17 +554,58 @@ public static class Database implements Writeable, ToXContent { * @return SHA256 hash value of a database file */ private String sha256Hash; + /** * @param updatedAt A date when the database was updated * @return A date when the database was updated */ private Instant updatedAt; + /** * @param fields A list of available fields in the database * @return A list of available fields in the database */ private List fields; + public Database(String provider, String sha256Hash, Instant updatedAt, List fields) { + this.provider = provider; + this.sha256Hash = sha256Hash; + this.updatedAt = updatedAt; + this.fields = fields; + } + + public void setProvider(String provider) { + this.provider = provider; + } + + public void setSha256Hash(String sha256Hash) { + this.sha256Hash = sha256Hash; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + + public void setFields(List fields) { + this.fields = fields; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public String getSha256Hash() { + return sha256Hash; + } + + public List getFields() { + return fields; + } + + public String getProvider() { + return provider; + } + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( "datasource_metadata_database", true, @@ -542,6 +631,8 @@ public Database(final StreamInput in) throws IOException { fields = in.readOptionalStringList(); } + private Database(){} + @Override public void writeTo(final StreamOutput out) throws IOException { out.writeOptionalString(provider); @@ -605,12 +696,27 @@ public static class UpdateStats implements Writeable, ToXContent { * @return The last time when threat intel feed data update was failed */ private Instant lastFailedAt; + /** * @param lastSkippedAt The last time when threat intel feed data update was skipped as there was no new update from an endpoint * @return The last time when threat intel feed data update was skipped as there was no new update from an endpoint */ private Instant lastSkippedAt; + private UpdateStats(){} + + public void setLastSkippedAt(Instant lastSkippedAt) { + this.lastSkippedAt = lastSkippedAt; + } + + public void setLastSucceededAt(Instant lastSucceededAt) { + this.lastSucceededAt = lastSucceededAt; + } + + public void setLastProcessingTimeInMillis(Long lastProcessingTimeInMillis) { + this.lastProcessingTimeInMillis = lastProcessingTimeInMillis; + } + private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( "datasource_metadata_update_stats", true, @@ -637,6 +743,14 @@ public UpdateStats(final StreamInput in) throws IOException { lastSkippedAt = toInstant(in.readOptionalVLong()); } + public UpdateStats(Instant lastSucceededAt, Long lastProcessingTimeInMillis, Instant lastFailedAt, Instant lastSkippedAt) { + this.lastSucceededAt = lastSucceededAt; + this.lastProcessingTimeInMillis = lastProcessingTimeInMillis; + this.lastFailedAt = lastFailedAt; + this.lastSkippedAt = lastSkippedAt; + } + + @Override public void writeTo(final StreamOutput out) throws IOException { out.writeOptionalVLong(lastSucceededAt == null ? null : lastSucceededAt.toEpochMilli()); diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceExtension.java b/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceExtension.java index c010444e7..4d32973e6 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceExtension.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceExtension.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.jobscheduler; +package org.opensearch.securityanalytics.threatIntel.jobscheduler; import org.opensearch.jobscheduler.spi.JobSchedulerExtension; import org.opensearch.jobscheduler.spi.ScheduledJobParser; diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceRunner.java b/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceRunner.java index e4252db27..2041d1ece 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceRunner.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceRunner.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.jobscheduler; +package org.opensearch.securityanalytics.threatIntel.jobscheduler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -20,10 +20,10 @@ import java.util.concurrent.atomic.AtomicReference; import java.time.Instant; -import org.opensearch.securityanalytics.threatintel.common.DatasourceState; -import org.opensearch.securityanalytics.threatintel.common.ThreatIntelExecutor; -import org.opensearch.securityanalytics.threatintel.common.ThreatIntelLockService; -import org.opensearch.securityanalytics.threatintel.dao.DatasourceDao; +import org.opensearch.securityanalytics.threatIntel.common.DatasourceState; +import org.opensearch.securityanalytics.threatIntel.common.ThreatIntelExecutor; +import org.opensearch.securityanalytics.threatIntel.common.ThreatIntelLockService; +import org.opensearch.securityanalytics.threatIntel.dao.DatasourceDao; /** * Datasource update task * diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceTask.java b/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceTask.java index e60e72d5f..b0e9ac184 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceTask.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceTask.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.jobscheduler; +package org.opensearch.securityanalytics.threatIntel.jobscheduler; /** * Task that {@link DatasourceRunner} will run diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceUpdateService.java b/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceUpdateService.java index 7e7e01985..235513db1 100644 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceUpdateService.java +++ b/src/main/java/org/opensearch/securityanalytics/threatintel/jobscheduler/DatasourceUpdateService.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package org.opensearch.securityanalytics.threatintel.jobscheduler; +package org.opensearch.securityanalytics.threatIntel.jobscheduler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -27,10 +27,10 @@ import org.opensearch.core.rest.RestStatus; import org.opensearch.jobscheduler.spi.schedule.IntervalSchedule; import org.opensearch.securityanalytics.model.DetectorTrigger; -import org.opensearch.securityanalytics.threatintel.common.DatasourceManifest; -import org.opensearch.securityanalytics.threatintel.dao.DatasourceDao; -import org.opensearch.securityanalytics.threatintel.dao.ThreatIntelFeedDao; -import org.opensearch.securityanalytics.threatintel.common.DatasourceState; +import org.opensearch.securityanalytics.threatIntel.common.DatasourceManifest; +import org.opensearch.securityanalytics.threatIntel.dao.DatasourceDao; +import org.opensearch.securityanalytics.threatIntel.dao.ThreatIntelFeedDao; +import org.opensearch.securityanalytics.threatIntel.common.DatasourceState; import org.opensearch.securityanalytics.util.SecurityAnalyticsException; public class DatasourceUpdateService { diff --git a/src/main/java/org/opensearch/securityanalytics/threatintel/url.java b/src/main/java/org/opensearch/securityanalytics/threatintel/url.java deleted file mode 100644 index cc598aed6..000000000 --- a/src/main/java/org/opensearch/securityanalytics/threatintel/url.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.opensearch.securityanalytics.threatintel; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URL; -import java.net.URLConnection; - -public class url { - - public static void main(String[] args) throws IOException { - - URL url = new URL("https://reputation.alienvault.com/reputation.generic"); - URLConnection connection = url.openConnection(); - - InputStreamReader input = new InputStreamReader(connection.getInputStream()); - BufferedReader buffer = null; - String line = ""; - String csvSplitBy = ","; - - System.out.println("here"); - - try { - buffer = new BufferedReader(input); - while ((line = buffer.readLine()) != null) { - System.out.println(line); - } - - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (buffer != null) { - try { - buffer.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - } -} - diff --git a/src/test/java/org/opensearch/securityanalytics/findings/FindingServiceTests.java b/src/test/java/org/opensearch/securityanalytics/findings/FindingServiceTests.java index 87af60b7f..30e5f1c57 100644 --- a/src/test/java/org/opensearch/securityanalytics/findings/FindingServiceTests.java +++ b/src/test/java/org/opensearch/securityanalytics/findings/FindingServiceTests.java @@ -166,37 +166,6 @@ public void onFailure(Exception e) { } }); } - public void testUrlForThreatIntel() throws Exception { - URL url = new URL("https://reputation.alienvault.com/reputation.generic"); - URLConnection connection = url.openConnection(); - - InputStreamReader input = new InputStreamReader(connection.getInputStream()); - BufferedReader buffer = null; - String line = ""; - String csvSplitBy = ","; - - System.out.println("here"); - - try { - buffer = new BufferedReader(input); - while ((line = buffer.readLine()) != null) { - System.out.println(line); - } - - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (buffer != null) { - try { - buffer.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } public void testGetFindings_getFindingsByMonitorIdFailure() {