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 validation for threat intel source config #1393

Merged
merged 3 commits into from
Oct 30, 2024

Conversation

jowg-amazon
Copy link
Collaborator

Description

Add source config validation so source config cannot be created without valid name, type, format, source, and ioc type. Additionally allows source configs with null values to still be read and deleted.

Related Issues

Resolves #1366

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.

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.

can we add test to verify #1366 is solved

Signed-off-by: Joanne Wang <[email protected]>
@@ -24,7 +24,19 @@ public class SourceConfigDtoValidator {
public List<String> validateSourceConfigDto(SATIFSourceConfigDto sourceConfigDto) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As a follow-up item, let's add validation for the refresh frequency.

@@ -24,7 +24,19 @@ public class SourceConfigDtoValidator {
public List<String> validateSourceConfigDto(SATIFSourceConfigDto sourceConfigDto) {
List<String> errorMsgs = new ArrayList<>();

if (sourceConfigDto.getIocTypes().isEmpty()) {
if (sourceConfigDto.getName() == null || sourceConfigDto.getName().isEmpty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added validation for names based on how frontend currently validates the name

errorMsgs.add("Name must not be empty");
}

if (sourceConfigDto.getFormat() == null || sourceConfigDto.getFormat().isEmpty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may need to add length validation for this as well. Unless this gets validated somewhere downstream, the config could be created via backend API with something like 300k characters; which could disrupt functionality.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added length validation

Signed-off-by: Joanne Wang <[email protected]>
@jowg-amazon
Copy link
Collaborator Author

can we add test to verify #1366 is solved

Added parsing tests to make sure null fields can be parsed

Copy link
Collaborator

@AWSHurneyt AWSHurneyt left a comment

Choose a reason for hiding this comment

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

Changes LGTM. Approving assuming other's comments are addressed.

@eirsep eirsep merged commit 364f42d into opensearch-project:main Oct 30, 2024
9 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 30, 2024
* add validation for source config and allow null to be read in parser

Signed-off-by: Joanne Wang <[email protected]>

* add parsing tests

Signed-off-by: Joanne Wang <[email protected]>

* add additional validation

Signed-off-by: Joanne Wang <[email protected]>

---------

Signed-off-by: Joanne Wang <[email protected]>
(cherry picked from commit 364f42d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 30, 2024
* add validation for source config and allow null to be read in parser

Signed-off-by: Joanne Wang <[email protected]>

* add parsing tests

Signed-off-by: Joanne Wang <[email protected]>

* add additional validation

Signed-off-by: Joanne Wang <[email protected]>

---------

Signed-off-by: Joanne Wang <[email protected]>
(cherry picked from commit 364f42d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 30, 2024
* add validation for source config and allow null to be read in parser

Signed-off-by: Joanne Wang <[email protected]>

* add parsing tests

Signed-off-by: Joanne Wang <[email protected]>

* add additional validation

Signed-off-by: Joanne Wang <[email protected]>

---------

Signed-off-by: Joanne Wang <[email protected]>
(cherry picked from commit 364f42d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 30, 2024
* add validation for source config and allow null to be read in parser

Signed-off-by: Joanne Wang <[email protected]>

* add parsing tests

Signed-off-by: Joanne Wang <[email protected]>

* add additional validation

Signed-off-by: Joanne Wang <[email protected]>

---------

Signed-off-by: Joanne Wang <[email protected]>
(cherry picked from commit 364f42d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 30, 2024
* add validation for source config and allow null to be read in parser

Signed-off-by: Joanne Wang <[email protected]>

* add parsing tests

Signed-off-by: Joanne Wang <[email protected]>

* add additional validation

Signed-off-by: Joanne Wang <[email protected]>

---------

Signed-off-by: Joanne Wang <[email protected]>
(cherry picked from commit 364f42d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
jowg-amazon pushed a commit that referenced this pull request Oct 30, 2024
* add validation for source config and allow null to be read in parser



* add parsing tests



* add additional validation



---------


(cherry picked from commit 364f42d)

Signed-off-by: Joanne Wang <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
jowg-amazon pushed a commit that referenced this pull request Oct 30, 2024
* add validation for source config and allow null to be read in parser



* add parsing tests



* add additional validation



---------


(cherry picked from commit 364f42d)

Signed-off-by: Joanne Wang <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AWSHurneyt pushed a commit that referenced this pull request Oct 31, 2024
* add validation for source config and allow null to be read in parser



* add parsing tests



* add additional validation



---------


(cherry picked from commit 364f42d)

Signed-off-by: Joanne Wang <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AWSHurneyt pushed a commit that referenced this pull request Oct 31, 2024
* add validation for source config and allow null to be read in parser



* add parsing tests



* add additional validation



---------


(cherry picked from commit 364f42d)

Signed-off-by: Joanne Wang <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AWSHurneyt pushed a commit that referenced this pull request Oct 31, 2024
* add validation for source config and allow null to be read in parser



* add parsing tests



* add additional validation



---------


(cherry picked from commit 364f42d)

Signed-off-by: Joanne Wang <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] PUT on source without "name" in request makes the source unable to be fetched/deleted/listed/updated
3 participants