-
Notifications
You must be signed in to change notification settings - Fork 93
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
add should_create_single_alert_for_findings field to security-analytics #757
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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
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 |
---|---|---|
|
@@ -43,6 +43,7 @@ data class Monitor( | |
val uiMetadata: Map<String, Any>, | ||
val dataSources: DataSources = DataSources(), | ||
val deleteQueryIndexInEveryRun: Boolean? = false, | ||
val shouldCreateSingleAlertForFindings: Boolean? = false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since alerts are generated by triggers, would it be worthwhile to make this configurable at the trigger-level instead of the monitor-level? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
val owner: String? = "alerting" | ||
) : ScheduledJob { | ||
|
||
|
@@ -112,6 +113,7 @@ data class Monitor( | |
DataSources() | ||
}, | ||
deleteQueryIndexInEveryRun = sin.readOptionalBoolean(), | ||
shouldCreateSingleAlertForFindings = sin.readOptionalBoolean(), | ||
owner = sin.readOptionalString() | ||
) | ||
|
||
|
@@ -172,6 +174,7 @@ data class Monitor( | |
if (uiMetadata.isNotEmpty()) builder.field(UI_METADATA_FIELD, uiMetadata) | ||
builder.field(DATA_SOURCES_FIELD, dataSources) | ||
builder.field(DELETE_QUERY_INDEX_IN_EVERY_RUN_FIELD, deleteQueryIndexInEveryRun) | ||
builder.field(SHOULD_CREATE_SINGLE_ALERT_FOR_FINDINGS_FIELD, shouldCreateSingleAlertForFindings) | ||
builder.field(OWNER_FIELD, owner) | ||
if (params.paramAsBoolean("with_type", false)) builder.endObject() | ||
return builder.endObject() | ||
|
@@ -224,6 +227,7 @@ data class Monitor( | |
out.writeBoolean(dataSources != null) // for backward compatibility with pre-existing monitors which don't have datasources field | ||
dataSources.writeTo(out) | ||
out.writeOptionalBoolean(deleteQueryIndexInEveryRun) | ||
out.writeOptionalBoolean(shouldCreateSingleAlertForFindings) | ||
out.writeOptionalString(owner) | ||
} | ||
|
||
|
@@ -245,6 +249,7 @@ data class Monitor( | |
const val DATA_SOURCES_FIELD = "data_sources" | ||
const val ENABLED_TIME_FIELD = "enabled_time" | ||
const val DELETE_QUERY_INDEX_IN_EVERY_RUN_FIELD = "delete_query_index_in_every_run" | ||
const val SHOULD_CREATE_SINGLE_ALERT_FOR_FINDINGS_FIELD = "should_create_single_alert_for_findings" | ||
const val OWNER_FIELD = "owner" | ||
val MONITOR_TYPE_PATTERN = Pattern.compile("[a-zA-Z0-9_]{5,25}") | ||
|
||
|
@@ -274,6 +279,7 @@ data class Monitor( | |
val inputs: MutableList<Input> = mutableListOf() | ||
var dataSources = DataSources() | ||
var deleteQueryIndexInEveryRun = false | ||
var delegateMonitor = false | ||
var owner = "alerting" | ||
|
||
XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, xcp.currentToken(), xcp) | ||
|
@@ -332,6 +338,11 @@ data class Monitor( | |
} else { | ||
xcp.booleanValue() | ||
} | ||
SHOULD_CREATE_SINGLE_ALERT_FOR_FINDINGS_FIELD -> delegateMonitor = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) { | ||
delegateMonitor | ||
} else { | ||
xcp.booleanValue() | ||
} | ||
OWNER_FIELD -> owner = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) owner else xcp.text() | ||
else -> { | ||
xcp.skipChildren() | ||
|
@@ -360,6 +371,7 @@ data class Monitor( | |
uiMetadata, | ||
dataSources, | ||
deleteQueryIndexInEveryRun, | ||
delegateMonitor, | ||
owner | ||
) | ||
} | ||
|
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
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
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.
why are we adding this here?
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.
just to add
findingIds
toIndexExecutionContext
.