-
Notifications
You must be signed in to change notification settings - Fork 76
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
Fix ioc store config mappings #1087
Fix ioc store config mappings #1087
Conversation
Signed-off-by: Joanne Wang <[email protected]>
Signed-off-by: Joanne Wang <[email protected]>
@@ -115,8 +115,11 @@ public void indexIocs(List<STIX2IOC> iocs) throws IOException { | |||
String feedIndexName = initFeedIndex(saTifSourceConfig.getId()); | |||
|
|||
// Add the created index to the IocStoreConfig | |||
((DefaultIocStoreConfig) saTifSourceConfig.getIocStoreConfig()).getIocMapStore().putIfAbsent(saTifSourceConfig.getId(), new ArrayList<>()); | |||
((DefaultIocStoreConfig) saTifSourceConfig.getIocStoreConfig()).getIocMapStore().get(saTifSourceConfig.getId()).add(feedIndexName); | |||
saTifSourceConfig.getIocTypes().forEach(type -> { |
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 blocking, but we should probably considering refactoring the IocTypes
list in the config data model to store a list of the IOCType enums instead of Strings.
https://github.com/opensearch-project/security-analytics-commons/blob/main/tif/src/main/java/org/opensearch/securityanalytics/commons/model/IOCType.java#L10
@@ -25,7 +25,7 @@ public class DefaultIocStoreConfig extends IocStoreConfig implements Writeable, | |||
public static final String DEFAULT_FIELD = "default"; | |||
public static final String IOC_MAP = "ioc_map"; | |||
|
|||
// Maps the SATIFSourceConfig ID to the list of index/alias names | |||
// Maps the IOCs to the list of index/alias names |
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.
Would this be "IOC types" to the index/alias names?
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.
yes fixing comment to include ioc types
Signed-off-by: Joanne Wang <[email protected]>
// // wait for job runner to run | ||
// waitUntil(() -> { | ||
// try { | ||
// return verifyJobRan(createdId, firstUpdatedTime); |
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 blocking, but could you add a javadoc comment to the verifyJobRan
function to help clarify its use?
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.
added
Signed-off-by: Joanne Wang <[email protected]>
@@ -115,8 +115,11 @@ public void indexIocs(List<STIX2IOC> iocs) throws IOException { | |||
String feedIndexName = initFeedIndex(saTifSourceConfig.getId()); | |||
|
|||
// Add the created index to the IocStoreConfig | |||
((DefaultIocStoreConfig) saTifSourceConfig.getIocStoreConfig()).getIocMapStore().putIfAbsent(saTifSourceConfig.getId(), new ArrayList<>()); | |||
((DefaultIocStoreConfig) saTifSourceConfig.getIocStoreConfig()).getIocMapStore().get(saTifSourceConfig.getId()).add(feedIndexName); | |||
saTifSourceConfig.getIocTypes().forEach(type -> { |
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.
@jowg-amazon A quick way to resolve the bug where the index name is being added each time the feed is refreshed would be to add the following add this following check around the forEach
loop.
if (!feedIndexExists(feedIndexName)) {
...
}
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.
Would this always be true since we are doing initFeedIndex
first?
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.
Actually, it would be better to refactor the initFeedIndex
function to take in the index name, and a boolean "exists" variable; and replace the call to feedIndexExists
in the init function with the boolean variable.
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.
Refactored method so that it checks if the index exists first, if it does not exist then it will initialize the index and add it to the ioc map
Signed-off-by: Joanne Wang <[email protected]>
c28f84f
into
opensearch-project:feature/threat_intel
* fix mappings Signed-off-by: Joanne Wang <[email protected]> * comment Signed-off-by: Joanne Wang <[email protected]> * fix comment Signed-off-by: Joanne Wang <[email protected]> * added java doc and todo Signed-off-by: Joanne Wang <[email protected]> * remove duplicate index names from mapping Signed-off-by: Joanne Wang <[email protected]> --------- Signed-off-by: Joanne Wang <[email protected]>
Description
[Describe what this change achieves]
Issues Resolved
[List any issues this PR will resolve]
Check List
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.