Skip to content

Commit

Permalink
throw error when no iocs are stored due to incompatible ioc types fro…
Browse files Browse the repository at this point in the history
…m S3 downloaded iocs file

Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
  • Loading branch information
eirsep committed Jul 2, 2024
1 parent 5b12588 commit 077cf1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.OpenSearchStatusException;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.securityanalytics.commons.model.IOC;
import org.opensearch.securityanalytics.commons.model.STIX2;
import org.opensearch.securityanalytics.commons.model.UpdateAction;
Expand Down Expand Up @@ -43,6 +45,10 @@ public void accept(final STIX2 ioc) {
// TODO hurneyt refactor once the enum values are updated
// If the IOC received is not a type listed for the config, do not add it to the queue
if (!feedStore.getSaTifSourceConfig().getIocTypes().contains(stix2IOC.getType().name())) {
log.error("{} is not a supported Ioc type for tif source config {}. Skipping IOC {}: of type {} value {}",
stix2IOC.getType().name(), feedStore.getSaTifSourceConfig().getId(),
stix2IOC.getId(), stix2IOC.getType(), stix2IOC.getValue()
);
return;
}

Expand All @@ -56,7 +62,7 @@ public void accept(final STIX2 ioc) {

public void flushIOCs() {
if (queue.isEmpty()) {
return;
throw new OpenSearchStatusException("No compatible Iocs were downloaded for config " + feedStore.getSaTifSourceConfig().getName(), RestStatus.BAD_REQUEST);
}

final List<STIX2IOC> iocsToFlush = new ArrayList<>(queue.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ public void createIocAndTIFSourceConfig(
listener.onFailure(ex);
}
));
listener.onFailure(e);
})
);
}, e -> {
Expand Down

0 comments on commit 077cf1b

Please sign in to comment.