forked from opensearch-project/security-analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/threat_intel' into 3.0-threat-intel-dev
Signed-off-by: AWSHurneyt <[email protected]>
- Loading branch information
Showing
34 changed files
with
1,944 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
.../java/org/opensearch/securityanalytics/threatIntel/action/SAGetTIFSourceConfigAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.securityanalytics.threatIntel.action; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
import static org.opensearch.securityanalytics.threatIntel.sacommons.IndexTIFSourceConfigAction.GET_TIF_SOURCE_CONFIG_ACTION_NAME; | ||
|
||
/** | ||
* Get TIF Source Config Action | ||
*/ | ||
public class SAGetTIFSourceConfigAction extends ActionType<SAGetTIFSourceConfigResponse> { | ||
|
||
public static final SAGetTIFSourceConfigAction INSTANCE = new SAGetTIFSourceConfigAction(); | ||
public static final String NAME = GET_TIF_SOURCE_CONFIG_ACTION_NAME; | ||
private SAGetTIFSourceConfigAction() { | ||
super(NAME, SAGetTIFSourceConfigResponse::new); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...java/org/opensearch/securityanalytics/threatIntel/action/SAGetTIFSourceConfigRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
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 java.io.IOException; | ||
import java.util.Locale; | ||
|
||
import static org.opensearch.action.ValidateActions.addValidationError; | ||
|
||
/** | ||
* Get threat intel feed source config request | ||
*/ | ||
public class SAGetTIFSourceConfigRequest extends ActionRequest { | ||
private final String id; | ||
private final Long version; | ||
public static final String TIF_SOURCE_CONFIG_ID = "tif_source_config_id"; | ||
|
||
public SAGetTIFSourceConfigRequest(String id, Long version) { | ||
super(); | ||
this.id = id; | ||
this.version = version; | ||
} | ||
|
||
public SAGetTIFSourceConfigRequest(StreamInput sin) throws IOException { | ||
this(sin.readString(), // id | ||
sin.readLong()); // version | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(id); | ||
out.writeLong(version); | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public Long getVersion() { | ||
return version; | ||
} | ||
|
||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
ActionRequestValidationException validationException = null; | ||
if (id == null || id.isEmpty()) { | ||
validationException = addValidationError(String.format(Locale.getDefault(), "%s is missing", TIF_SOURCE_CONFIG_ID), validationException); | ||
} | ||
return validationException; | ||
} | ||
|
||
} |
101 changes: 101 additions & 0 deletions
101
...ava/org/opensearch/securityanalytics/threatIntel/action/SAGetTIFSourceConfigResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.securityanalytics.threatIntel.action; | ||
|
||
import org.opensearch.core.action.ActionResponse; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.rest.RestStatus; | ||
import org.opensearch.core.xcontent.ToXContentObject; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
import org.opensearch.securityanalytics.threatIntel.model.SATIFSourceConfigDto; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.opensearch.securityanalytics.util.RestHandlerUtils._ID; | ||
import static org.opensearch.securityanalytics.util.RestHandlerUtils._VERSION; | ||
|
||
public class SAGetTIFSourceConfigResponse extends ActionResponse implements ToXContentObject { | ||
private final String id; | ||
|
||
private final Long version; | ||
|
||
private final RestStatus status; | ||
|
||
private final SATIFSourceConfigDto SaTifSourceConfigDto; | ||
|
||
|
||
public SAGetTIFSourceConfigResponse(String id, Long version, RestStatus status, SATIFSourceConfigDto SaTifSourceConfigDto) { | ||
super(); | ||
this.id = id; | ||
this.version = version; | ||
this.status = status; | ||
this.SaTifSourceConfigDto = SaTifSourceConfigDto; | ||
} | ||
|
||
public SAGetTIFSourceConfigResponse(StreamInput sin) throws IOException { | ||
this( | ||
sin.readString(), // id | ||
sin.readLong(), // version | ||
sin.readEnum(RestStatus.class), // status | ||
sin.readBoolean()? SATIFSourceConfigDto.readFrom(sin) : null // SA tif config dto | ||
); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(id); | ||
out.writeLong(version); | ||
out.writeEnum(status); | ||
if (SaTifSourceConfigDto != null) { | ||
out.writeBoolean((true)); | ||
SaTifSourceConfigDto.writeTo(out); | ||
} else { | ||
out.writeBoolean(false); | ||
} | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject() | ||
.field(_ID, id) | ||
.field(_VERSION, version); | ||
builder.startObject("tif_config") | ||
.field(SATIFSourceConfigDto.FEED_NAME_FIELD, SaTifSourceConfigDto.getName()) | ||
.field(SATIFSourceConfigDto.FEED_FORMAT_FIELD, SaTifSourceConfigDto.getFeedFormat()) | ||
.field(SATIFSourceConfigDto.FEED_TYPE_FIELD, SaTifSourceConfigDto.getFeedType()) | ||
.field(SATIFSourceConfigDto.STATE_FIELD, SaTifSourceConfigDto.getState()) | ||
.field(SATIFSourceConfigDto.ENABLED_TIME_FIELD, SaTifSourceConfigDto.getEnabledTime()) | ||
.field(SATIFSourceConfigDto.ENABLED_FIELD, SaTifSourceConfigDto.isEnabled()) | ||
.field(SATIFSourceConfigDto.CREATED_AT_FIELD, SaTifSourceConfigDto.getCreatedAt()) | ||
.field(SATIFSourceConfigDto.LAST_UPDATE_TIME_FIELD, SaTifSourceConfigDto.getLastUpdateTime()) | ||
.field(SATIFSourceConfigDto.LAST_REFRESHED_TIME_FIELD, SaTifSourceConfigDto.getLastRefreshedTime()) | ||
.field(SATIFSourceConfigDto.REFRESH_TYPE_FIELD, SaTifSourceConfigDto.getRefreshType()) | ||
.field(SATIFSourceConfigDto.LAST_REFRESHED_USER_FIELD, SaTifSourceConfigDto.getLastRefreshedUser()) | ||
.field(SATIFSourceConfigDto.SCHEDULE_FIELD, SaTifSourceConfigDto.getSchedule()) | ||
// source | ||
.field(SATIFSourceConfigDto.CREATED_BY_USER_FIELD, SaTifSourceConfigDto.getCreatedByUser()) | ||
.field(SATIFSourceConfigDto.IOC_MAP_STORE_FIELD, SaTifSourceConfigDto.getIocMapStore()) | ||
.field(SATIFSourceConfigDto.IOC_TYPES_FIELD, SaTifSourceConfigDto.getIocTypes()) | ||
.endObject(); | ||
return builder.endObject(); | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public Long getVersion() { | ||
return version; | ||
} | ||
|
||
public RestStatus getStatus() { | ||
return status; | ||
} | ||
|
||
public SATIFSourceConfigDto getSaTifSourceConfigDto() { | ||
return SaTifSourceConfigDto; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ava/org/opensearch/securityanalytics/threatIntel/action/SAIndexTIFSourceConfigAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.securityanalytics.threatIntel.action; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
import static org.opensearch.securityanalytics.threatIntel.sacommons.IndexTIFSourceConfigAction.INDEX_TIF_SOURCE_CONFIG_ACTION_NAME; | ||
|
||
/** | ||
* Threat intel tif job creation action | ||
*/ | ||
public class SAIndexTIFSourceConfigAction extends ActionType<SAIndexTIFSourceConfigResponse> { | ||
|
||
public static final SAIndexTIFSourceConfigAction INSTANCE = new SAIndexTIFSourceConfigAction(); | ||
public static final String NAME = INDEX_TIF_SOURCE_CONFIG_ACTION_NAME; | ||
private SAIndexTIFSourceConfigAction() { | ||
super(NAME, SAIndexTIFSourceConfigResponse::new); | ||
} | ||
} |
Oops, something went wrong.