-
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
Draft of IOC service #1048
Draft of IOC service #1048
Conversation
src/main/java/org/opensearch/securityanalytics/SecurityAnalyticsPlugin.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/securityanalytics/services/IocServiceIT.java
Show resolved
Hide resolved
src/main/java/org/opensearch/securityanalytics/model/IocDao.java
Outdated
Show resolved
Hide resolved
* @return TRUE if the index is an IOC-related system index, and exists; else returns FALSE. | ||
*/ | ||
public boolean hasIocSystemIndex(String index) { | ||
return index.startsWith(IOC_INDEX_NAME_BASE) && this.clusterService.state().routingTable().hasIndex(index); |
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 do we have to do index.startsWith(IOC_INDEX_NAME_BASE)
and why is method public?
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.
@eirsep I added the startsWith
check just to confirm that the function is only being used to create indexes for the purposes of this feature. Do you think that check should be removed?
I implemented it as public just out of habit in case I might need it elsewhere; I'll change it to private in a separate PR as I'll need to refactor the tests that use it (unless we're fine with leaving it as a public function).
src/main/java/org/opensearch/securityanalytics/services/IocService.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/securityanalytics/SecurityAnalyticsPlugin.java
Show resolved
Hide resolved
src/main/java/org/opensearch/securityanalytics/model/IocDao.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/securityanalytics/model/IocDao.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/securityanalytics/services/IocService.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/securityanalytics/services/IocService.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/securityanalytics/services/IocService.java
Outdated
Show resolved
Hide resolved
406f827
to
5429ac9
Compare
243a0ca
to
cadd169
Compare
243a0ca
to
4fc0d84
Compare
16a1e3a
to
03364a2
Compare
"type": "keyword" | ||
}, | ||
"name": { | ||
"type": "text", |
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 cant name be keyword like id?
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.
Revised to keyword type.
}, | ||
"created": { | ||
"type": "date", | ||
"format": "strict_date_optional_time||epoch_millis" |
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.
do we need this restriction?
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.
We use similar format for the mappings of some other plugin assets (e.g., detectors). Did you have another format in mind?
For now, I've revised this to strict_date_time||epoch_millis
. My thoughts are that the create date should be required whereas the modified date could be null if the entry hasn't been updated.
}, | ||
"modified": { | ||
"type": "date", | ||
"format": "strict_date_optional_time||epoch_millis" |
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.
do we need this restriction?
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.
We use similar format for the mappings of some other plugin assets (e.g., detectors). Did you have another format in mind?
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.
can you check some minor comments?
|
||
public FetchIocsActionResponse(List<IOC> iocs) { | ||
super(); | ||
iocs.forEach( ioc -> this.iocs.add(new IocDto(ioc))); |
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.
Should this be done in transport/service class?
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 It can be. The FetchIocsActionResponse
object is just a placeholder I've been using to test the changes. We can refactor and remove it before launch.
4fc0d84
to
63dd56c
Compare
Signed-off-by: AWSHurneyt <[email protected]>
Signed-off-by: AWSHurneyt <[email protected]>
Signed-off-by: AWSHurneyt <[email protected]>
Signed-off-by: AWSHurneyt <[email protected]>
Signed-off-by: AWSHurneyt <[email protected]>
Signed-off-by: AWSHurneyt <[email protected]>
Signed-off-by: AWSHurneyt <[email protected]>
fa58d0c
to
186264a
Compare
@eirsep Responded. |
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class FetchIocsActionResponse extends ActionResponse implements ToXContentObject { |
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.
NIT: let's keep consistent naming: ListIocsResponse?
|
||
public class IocDao implements Writeable, ToXContentObject { | ||
private static final Logger logger = LogManager.getLogger(IocDao.class); | ||
public class IOC implements Writeable, ToXContentObject { |
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.
how come Ioc is a concrete class and also STIX2Ioc?
.timeField(IOC.MODIFIED_FIELD, modified) | ||
.field(IOC.DESCRIPTION_FIELD, description) | ||
.field(IOC.LABELS_FIELD, labels) | ||
.field(IOC.FEED_ID_FIELD, feedId) | ||
.endObject(); | ||
} | ||
|
||
public static IocDto parse(XContentParser xcp, String id) throws IOException { |
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.
this defeats the purpose of having separate classes for DTO and the model.. if there is ever a divergence we would end up having to re-write this method
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.
Plz invoke IocService from TIFConfigService
17f7074
into
opensearch-project:feature/threat_intel
* Removed unused imports. Removed redundant helper function. Signed-off-by: AWSHurneyt <[email protected]> * Added note about system index refactoring. Signed-off-by: AWSHurneyt <[email protected]> * Implemented draft of IocService. Signed-off-by: AWSHurneyt <[email protected]> * Made changes based on PR feedback. Signed-off-by: AWSHurneyt <[email protected]> * Fixed test helper function. Signed-off-by: AWSHurneyt <[email protected]> * Removed unused imports. Signed-off-by: AWSHurneyt <[email protected]> * Adjusted mappings based on PR feedback. Signed-off-by: AWSHurneyt <[email protected]> --------- Signed-off-by: AWSHurneyt <[email protected]>
Description
Implemented draft of IocService.
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.