Skip to content

Commit

Permalink
Reflect field_mapping changes in __init__()
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanvg committed Mar 21, 2018
1 parent 3de1422 commit 1ec51ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions scripts/field_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,6 @@ def main():
except Exception as ex:
LOG.exception(ex)


if __name__ == "__main__":
main()
23 changes: 16 additions & 7 deletions stixmarx/fields/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def _initialize_fields():
from stixmarx.fields.stix.stix1118 import _FIELDS
_FIELD_MAPPINGS.update(_FIELDS)
else:
from stixmarx.fields.stix.stix1118 import _FIELDS
from stixmarx.fields.stix.stix11110 import _FIELDS
_FIELD_MAPPINGS.update(_FIELDS)
message = ("No compatible stix %s mappings found. Loaded "
"latest unchanged 1.1.1.8 field mappings.")
"latest unchanged 1.1.1.10 field mappings.")
LOG.info(message, utils.stix.__version__)

elif utils.stix.__version__.startswith("1.2.0."):
Expand All @@ -42,14 +42,20 @@ def _initialize_fields():
elif utils.stix.__version__ == "1.2.0.2":
from stixmarx.fields.stix.stix1202 import _FIELDS
_FIELD_MAPPINGS.update(_FIELDS)
elif utils.stix.__version__ in ("1.2.0.3", "1.2.0.4"):
elif utils.stix.__version__ == "1.2.0.3":
from stixmarx.fields.stix.stix1203 import _FIELDS
_FIELD_MAPPINGS.update(_FIELDS)
elif utils.stix.__version__ == "1.2.0.4":
from stixmarx.fields.stix.stix1204 import _FIELDS
_FIELD_MAPPINGS.update(_FIELDS)
elif utils.stix.__version__ == "1.2.0.5":
from stixmarx.fields.stix.stix1205 import _FIELDS
_FIELD_MAPPINGS.update(_FIELDS)
else:
from stixmarx.fields.stix.stix1203 import _FIELDS
from stixmarx.fields.stix.stix1205 import _FIELDS
_FIELD_MAPPINGS.update(_FIELDS)
message = ("No compatible stix %s mappings found. Loaded "
"latest unchanged 1.2.0.3 field mappings.")
"latest unchanged 1.2.0.5 field mappings.")
LOG.info(message, utils.stix.__version__)

else:
Expand All @@ -64,11 +70,14 @@ def _initialize_fields():
if utils.cybox.__version__ in ("2.1.0.13", "2.1.0.14"):
from stixmarx.fields.cybox.cybox21013 import _FIELDS
_FIELD_MAPPINGS.update(_FIELDS)
elif utils.cybox.__version__ in ("2.1.0.15", "2.1.0.16"):
from stixmarx.fields.cybox.cybox21016 import _FIELDS
_FIELD_MAPPINGS.update(_FIELDS)
else:
from stixmarx.fields.cybox.cybox21013 import _FIELDS
from stixmarx.fields.cybox.cybox21016 import _FIELDS
_FIELD_MAPPINGS.update(_FIELDS)
message = ("No compatible cybox %s mappings found. Loaded "
"latest unchanged 2.1.0.13 field mappings.")
"latest unchanged 2.1.0.16 field mappings.")
LOG.info(message, utils.cybox.__version__)

else:
Expand Down

0 comments on commit 1ec51ad

Please sign in to comment.