-
Notifications
You must be signed in to change notification settings - Fork 78
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
Threat intel monitor implementation #1092
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c3476fe
Add 2.15 release notes (#1061)
engechas 62e4453
Alerts in correlations [Experminental] (#1040)
riysaxen-amzn a74f509
Alerts in Correlations Part 2 (#1062)
riysaxen-amzn 362f0d6
updates the release notes 2.15 (#1070)
riysaxen-amzn b99121e
pass integ tests (#1082)
sbcd90 f4bc11a
ioc scan business logic
eirsep 28b8ff4
add search ioc findings api
sbcd90 ab94cfe
refactor iocFinding model and service to pull out CRUD operations to …
eirsep 127bde5
threat intel alert model and crud operations
eirsep 2e072f0
threat intel trigger execution logic
eirsep f8bab1e
Merge remote-tracking branch 'origin/main' into tim
eirsep 34bc5a2
Merge remote-tracking branch 'origin/feature/threat_intel' into tim
eirsep 07d5c13
wire in ioc findings
eirsep 721abca
get threat intel monitor alerts API
eirsep 784d9fa
revert commented out code
eirsep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
release-notes/opensearch-security-analytics.release-notes-2.15.0.0.md
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,19 @@ | ||
## Version 2.15.0.0 2024-06-10 | ||
|
||
Compatible with OpenSearch 2.15.0 | ||
|
||
### Features | ||
* Alerts in correlations [Experminental] ([#1040](https://github.com/opensearch-project/security-analytics/pull/1040)) | ||
* Alerts in Correlations Part 2 ([#1062](https://github.com/opensearch-project/security-analytics/pull/1062)) | ||
|
||
### Maintenance | ||
* Increment version to 2.15.0-SNAPSHOT. ([#1055](https://github.com/opensearch-project/security-analytics/pull/1055)) | ||
* Fix codecov calculation ([#1021](https://github.com/opensearch-project/security-analytics/pull/1021)) | ||
* Stabilize integ tests ([#1014](https://github.com/opensearch-project/security-analytics/pull/1014)) | ||
|
||
### Bug Fixes | ||
* Fix chained findings monitor logic in update detector flow ([#1019](https://github.com/opensearch-project/security-analytics/pull/1019)) | ||
* Change default filter to time based fields ([#1030](https://github.com/opensearch-project/security-analytics/pull/1030)) | ||
|
||
### Documentation | ||
* Added 2.15.0 release notes. ([#1061](https://github.com/opensearch-project/security-analytics/pull/1061)) |
53 changes: 38 additions & 15 deletions
53
src/main/java/org/opensearch/securityanalytics/SecurityAnalyticsPlugin.java
Large diffs are not rendered by default.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
src/main/java/org/opensearch/securityanalytics/action/AckCorrelationAlertsAction.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,20 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.securityanalytics.action; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
/** | ||
* Acknowledge Correlation Alert Action | ||
*/ | ||
public class AckCorrelationAlertsAction extends ActionType<AckCorrelationAlertsResponse> { | ||
public static final String NAME = "cluster:admin/opensearch/securityanalytics/correlationAlerts/ack"; | ||
public static final AckCorrelationAlertsAction INSTANCE = new AckCorrelationAlertsAction(); | ||
|
||
public AckCorrelationAlertsAction() { | ||
super(NAME, AckCorrelationAlertsResponse::new); | ||
} | ||
} | ||
|
56 changes: 56 additions & 0 deletions
56
src/main/java/org/opensearch/securityanalytics/action/AckCorrelationAlertsRequest.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,56 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.securityanalytics.action; | ||
|
||
import org.opensearch.action.ActionRequest; | ||
import org.opensearch.action.ActionRequestValidationException; | ||
import org.opensearch.action.ValidateActions; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.xcontent.ToXContent; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class AckCorrelationAlertsRequest extends ActionRequest { | ||
private final List<String> correlationAlertIds; | ||
|
||
public AckCorrelationAlertsRequest(List<String> correlationAlertIds) { | ||
this.correlationAlertIds = correlationAlertIds; | ||
} | ||
|
||
public AckCorrelationAlertsRequest(StreamInput in) throws IOException { | ||
correlationAlertIds = Collections.unmodifiableList(in.readStringList()); | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
ActionRequestValidationException validationException = null; | ||
if(correlationAlertIds == null || correlationAlertIds.isEmpty()) { | ||
validationException = ValidateActions.addValidationError("alert ids list cannot be empty", validationException); | ||
} | ||
return validationException; | ||
} | ||
|
||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeStringCollection(this.correlationAlertIds); | ||
} | ||
|
||
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { | ||
return builder.startObject() | ||
.field("correlation_alert_ids", correlationAlertIds) | ||
.endObject(); | ||
} | ||
|
||
public static AckAlertsRequest readFrom(StreamInput sin) throws IOException { | ||
return new AckAlertsRequest(sin); | ||
} | ||
|
||
public List<String> getCorrelationAlertIds() { | ||
return correlationAlertIds; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/org/opensearch/securityanalytics/action/AckCorrelationAlertsResponse.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,56 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.securityanalytics.action; | ||
|
||
import org.opensearch.commons.alerting.model.CorrelationAlert; | ||
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.xcontent.ToXContentObject; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class AckCorrelationAlertsResponse extends ActionResponse implements ToXContentObject { | ||
|
||
private final List<CorrelationAlert> acknowledged; | ||
private final List<CorrelationAlert> failed; | ||
|
||
public AckCorrelationAlertsResponse(List<CorrelationAlert> acknowledged, List<CorrelationAlert> failed) { | ||
this.acknowledged = acknowledged; | ||
this.failed = failed; | ||
} | ||
|
||
public AckCorrelationAlertsResponse(StreamInput sin) throws IOException { | ||
this( | ||
Collections.unmodifiableList(sin.readList(CorrelationAlert::new)), | ||
Collections.unmodifiableList(sin.readList(CorrelationAlert::new)) | ||
); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput streamOutput) throws IOException { | ||
streamOutput.writeList(this.acknowledged); | ||
streamOutput.writeList(this.failed); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject() | ||
.field("acknowledged",this.acknowledged) | ||
.field("failed",this.failed); | ||
return builder.endObject(); | ||
} | ||
|
||
public List<CorrelationAlert> getAcknowledged() { | ||
return acknowledged; | ||
} | ||
|
||
public List<CorrelationAlert> getFailed() { | ||
return failed; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/org/opensearch/securityanalytics/action/GetCorrelationAlertsAction.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,17 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.securityanalytics.action; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
public class GetCorrelationAlertsAction extends ActionType<GetCorrelationAlertsResponse> { | ||
|
||
public static final GetCorrelationAlertsAction INSTANCE = new GetCorrelationAlertsAction(); | ||
public static final String NAME = "cluster:admin/opensearch/securityanalytics/correlationAlerts/get"; | ||
|
||
public GetCorrelationAlertsAction() { | ||
super(NAME, GetCorrelationAlertsResponse::new); | ||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
src/main/java/org/opensearch/securityanalytics/action/GetCorrelationAlertsRequest.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,112 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.securityanalytics.action; | ||
|
||
import org.opensearch.action.ActionRequest; | ||
import org.opensearch.action.ActionRequestValidationException; | ||
import org.opensearch.commons.alerting.model.Table; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
import java.time.Instant; | ||
import java.util.Locale; | ||
|
||
import static org.opensearch.action.ValidateActions.addValidationError; | ||
|
||
public class GetCorrelationAlertsRequest extends ActionRequest { | ||
private String correlationRuleId; | ||
private String correlationRuleName; | ||
private Table table; | ||
private String severityLevel; | ||
private String alertState; | ||
|
||
private Instant startTime; | ||
|
||
private Instant endTime; | ||
|
||
public static final String CORRELATION_RULE_ID = "correlation_rule_id"; | ||
|
||
public GetCorrelationAlertsRequest( | ||
String correlationRuleId, | ||
String correlationRuleName, | ||
Table table, | ||
String severityLevel, | ||
String alertState, | ||
Instant startTime, | ||
Instant endTime | ||
) { | ||
super(); | ||
this.correlationRuleId = correlationRuleId; | ||
this.correlationRuleName = correlationRuleName; | ||
this.table = table; | ||
this.severityLevel = severityLevel; | ||
this.alertState = alertState; | ||
this.startTime = startTime; | ||
this.endTime = endTime; | ||
} | ||
public GetCorrelationAlertsRequest(StreamInput sin) throws IOException { | ||
this( | ||
sin.readOptionalString(), | ||
sin.readOptionalString(), | ||
Table.readFrom(sin), | ||
sin.readString(), | ||
sin.readString(), | ||
sin.readOptionalInstant(), | ||
sin.readOptionalInstant() | ||
); | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
ActionRequestValidationException validationException = null; | ||
if ((correlationRuleId != null && correlationRuleId.isEmpty())) { | ||
validationException = addValidationError(String.format(Locale.getDefault(), | ||
"Correlation ruleId is empty or not valid", CORRELATION_RULE_ID), | ||
validationException); | ||
} | ||
return validationException; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeOptionalString(correlationRuleId); | ||
out.writeOptionalString(correlationRuleName); | ||
table.writeTo(out); | ||
out.writeString(severityLevel); | ||
out.writeString(alertState); | ||
out.writeOptionalInstant(startTime); | ||
out.writeOptionalInstant(endTime); | ||
} | ||
|
||
public String getCorrelationRuleId() { | ||
return correlationRuleId; | ||
} | ||
|
||
public Table getTable() { | ||
return table; | ||
} | ||
|
||
public String getSeverityLevel() { | ||
return severityLevel; | ||
} | ||
|
||
public String getAlertState() { | ||
return alertState; | ||
} | ||
|
||
public String getCorrelationRuleName() { | ||
return correlationRuleName; | ||
} | ||
|
||
public Instant getStartTime() { | ||
return startTime; | ||
} | ||
|
||
public Instant getEndTime() { | ||
return endTime; | ||
} | ||
} | ||
|
54 changes: 54 additions & 0 deletions
54
src/main/java/org/opensearch/securityanalytics/action/GetCorrelationAlertsResponse.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,54 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package org.opensearch.securityanalytics.action; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensearch.commons.alerting.model.CorrelationAlert; | ||
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.xcontent.ToXContentObject; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class GetCorrelationAlertsResponse extends ActionResponse implements ToXContentObject { | ||
|
||
private static final Logger log = LogManager.getLogger(GetCorrelationAlertsResponse.class); | ||
private static final String CORRELATION_ALERTS_FIELD = "correlationAlerts"; | ||
private static final String TOTAL_ALERTS_FIELD = "total_alerts"; | ||
|
||
private List<CorrelationAlert> alerts; | ||
private Integer totalAlerts; | ||
|
||
public GetCorrelationAlertsResponse(List<CorrelationAlert> alerts, Integer totalAlerts) { | ||
super(); | ||
this.alerts = alerts; | ||
this.totalAlerts = totalAlerts; | ||
} | ||
|
||
public GetCorrelationAlertsResponse(StreamInput sin) throws IOException { | ||
this( | ||
Collections.unmodifiableList(sin.readList(CorrelationAlert::new)), | ||
sin.readInt() | ||
); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeCollection(this.alerts); | ||
out.writeInt(this.totalAlerts); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject() | ||
.field(CORRELATION_ALERTS_FIELD, this.alerts) | ||
.field(TOTAL_ALERTS_FIELD, this.totalAlerts); | ||
return builder.endObject(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Should
correlationAlerts
be all lowercase likesecurityanalytics
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not from my PR
merged main branch