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

Exception when importing STIX 2 Indicators due to invalid default type in valid_from #410

Closed
JasonKeirstead opened this issue Jan 15, 2020 · 0 comments
Assignees
Labels
bug use for describing something not working as expected solved use to identify issue that has been solved (must be linked to the solving PR)
Milestone

Comments

@JasonKeirstead
Copy link
Contributor

Please replace every line in curly brackets { like this } with an appropriate answer, and remove this line.

Description

If you try to import a STIX 2 Indicator object with no valid_from, the code sets it to a millisecond long value when the database expects it to be a Date type, which throws an error.

Environment

OpenCTI current source code

Reproducible Steps

Steps to create the smallest reproducible scenario:

Step 1: Create a STIX 2 Indicator, without valid_from set
Step 2: Ensure it is valid STIX
Step 3: Attempt import to OpenCTI

Expected Output

Expect it to import

Actual Output

grakn.core.kb.concept.api.GraknConceptException: The value [1579035233199] of type [Long] must be of datatype [java.time.LocalDateTime] at grakn.core.kb.concept.api.GraknConceptException.create(GraknConceptException.java:55) at grakn.core.kb.concept.api.GraknConceptException.invalidAttributeValue(GraknConceptException.java:116) at grakn.core.concept.manager.ConceptManagerImpl.createAttribute(ConceptManagerImpl.java:271) at grakn.core.concept.manager.ConceptManagerImpl.createAttribute(ConceptManagerImpl.java:92) at grakn.core.concept.impl.AttributeTypeImpl.putAttribute(AttributeTypeImpl.java:120)

Additional information

Problematic generated insert statement

insert $entity isa Indicator, has internal_id_key "indicator--590884dd-3573-470d-b12c-91097f412be3", has stix_id_key "indicator--590884dd-3573-470d-b12c-91097f412be3", has name "Indicator", has description "", has indicator_pattern "[ipv4-addr:value = '172.31.88.63']", has pattern_type "stix2", has main_observable_type "ipv4-addr", has valid_from 1579098216711, has valid_from_day "2020-01-15", has valid_from_month "2020-01", has valid_from_year "2020", has valid_until 2021-01-14T14:23:36, has valid_until_day "2021-01-14", has valid_until_month "2021-01", has valid_until_year "2021", has score 50, has created 2019-11-27T15:26:08, has modified 2019-11-27T15:26:08, has entity_type "indicator", has created_at 2020-01-15T14:23:36, has created_at_day "2020-01-15", has created_at_month "2020-01", has created_at_year "2020", has updated_at 2020-01-15T14:23:36, has alias "", has revoked false, has valid_from_day "2020-01-15", has valid_from_month "2020-01", has valid_from_year "2020", has valid_until_day "2021-01-14", has valid_until_month "2021-01", has valid_until_year "2021", has created_at_day "2020-01-15", has created_at_month "2020-01", has created_at_year "2020";

@richard-julien richard-julien added the bug use for describing something not working as expected label Jan 17, 2020
@SamuelHassine SamuelHassine added the solved use to identify issue that has been solved (must be linked to the solving PR) label Jan 22, 2020
@SamuelHassine SamuelHassine added this to the Release 2.1.3 milestone Jan 22, 2020
SamuelHassine pushed a commit that referenced this issue Jan 22, 2020
The date type of valid_from() in Grakn is a Date object, so this throws an exception if it is set to Date.now(), which is a millisecond Long timestamp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug use for describing something not working as expected solved use to identify issue that has been solved (must be linked to the solving PR)
Projects
None yet
Development

No branches or pull requests

3 participants