Skip to content
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 5 commits into from
Dec 10, 2024

Conversation

sbcd90
Copy link
Collaborator

@sbcd90 sbcd90 commented Nov 26, 2024

Description

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Subhobrata Dey <[email protected]>
Signed-off-by: Subhobrata Dey <[email protected]>
@@ -21,7 +21,8 @@ data class IndexExecutionContext(
val updatedIndexNames: List<String>,
val concreteIndexNames: List<String>,
val conflictingFields: List<String>,
val docIds: List<String>? = emptyList()
val docIds: List<String>? = emptyList(),
val findingIds: List<String>? = emptyList()
Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to add findingIds to IndexExecutionContext.

Copy link
Member

@eirsep eirsep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finding_ids should already be present in the workflow context?

@@ -43,6 +43,7 @@ data class Monitor(
val uiMetadata: Map<String, Any>,
val dataSources: DataSources = DataSources(),
val deleteQueryIndexInEveryRun: Boolean? = false,
val shouldPersistFindingsAndAlerts: Boolean? = false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be true by default?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the field is named now as shouldCreateSingleAlertForFindings. & its set to False by default.

@@ -332,6 +338,11 @@ data class Monitor(
} else {
xcp.booleanValue()
}
SHOULD_PERSIST_FINDINGS_AND_ALERTS_FIELD -> delegateMonitor = if (xcp.currentToken() == XContentParser.Token.VALUE_NULL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking of a scenario where this field is null
shouldn't we persist alerts and findings by default but we have initilalized var delegateMonitor = false and wont end up persisting

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as #757 (comment)

@@ -17,7 +17,7 @@ data class WorkflowRunContext(
val workflowId: String,
val workflowMetadataId: String,
val chainedMonitorId: String?,
val matchingDocIdsPerIndex: Map<String, List<String>>,
val matchingDocIdsPerIndex: Pair<Map<String, List<String>>, List<String>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change backward compatible?

can we revert this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed this.

@eirsep
Copy link
Member

eirsep commented Nov 29, 2024

this PR seems to be making multiple minor changes and additions
plz split into multiple PRs or add more description about each change for context

@jowg-amazon
Copy link
Collaborator

jowg-amazon commented Dec 3, 2024

plz split into multiple PRs or add more description about each change for context

+1 is there a github issue or something we can track to see why we're making these changes?

@eirsep
Copy link
Member

eirsep commented Dec 4, 2024

as discussed we seem to be creating a single alert for all findings
should_persist or not is not in question
plz rename flag to indicate that we create one alert for all docs' findings

Signed-off-by: Subhobrata Dey <[email protected]>
@sbcd90
Copy link
Collaborator Author

sbcd90 commented Dec 5, 2024

finding_ids should already be present in the workflow context?

only docIds belonging to findingIds were present in workflow context.

Signed-off-by: Subhobrata Dey <[email protected]>
@sbcd90 sbcd90 changed the title add should_persist_and_alerts field to security-analytics add should_create_single_alert_for_findings field to security-analytics Dec 5, 2024
@@ -43,6 +43,7 @@ data class Monitor(
val uiMetadata: Map<String, Any>,
val dataSources: DataSources = DataSources(),
val deleteQueryIndexInEveryRun: Boolean? = false,
val shouldCreateSingleAlertForFindings: Boolean? = false,
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbcd90 clarified offline that this setting will control whether findings are generated as well (findings are generated at the monitor-level; not trigger-level). Approving, but @sbcd90 in your next PR, could you add a comment/rename the variable to illustrate that?

@sbcd90 sbcd90 merged commit 197eb82 into opensearch-project:main Dec 10, 2024
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants