Fix import order, add flake8-import-order plugin

to Tox
stix2.1
clenk 2017-04-24 18:29:56 -04:00
parent fe4c4d78fc
commit cd815bfe84
24 changed files with 70 additions and 44 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python
from setuptools import setup, find_packages
from setuptools import find_packages, setup
install_requires = [
'pytz',

View File

@ -1,7 +1,7 @@
"""STIX 2 Bundle object"""
from .base import _STIXBase
from .properties import IDProperty, TypeProperty, Property
from .properties import IDProperty, Property, TypeProperty
class Bundle(_STIXBase):

View File

@ -1,8 +1,8 @@
"""STIX 2 Common Data Types and Properties"""
from .properties import (ListProperty, BooleanProperty,
ReferenceProperty, TimestampProperty)
from .other import ExternalReference, GranularMarking
from .properties import (BooleanProperty, ListProperty, ReferenceProperty,
TimestampProperty)
from .utils import NOW
COMMON_PROPERTIES = {

View File

@ -1,10 +1,10 @@
"""STIX 2.0 Objects that are neither SDOs nor SROs"""
from .base import _STIXBase
from .properties import (IDProperty, TypeProperty, ListProperty, TimestampProperty,
ReferenceProperty, Property, SelectorProperty,
StringProperty)
from .utils import NOW, get_dict
from .properties import (IDProperty, ListProperty, Property, ReferenceProperty,
SelectorProperty, StringProperty, TimestampProperty,
TypeProperty)
from .utils import get_dict, NOW
class ExternalReference(_STIXBase):

View File

@ -1,11 +1,13 @@
import collections
import datetime as dt
import inspect
import re
import uuid
from six import text_type
import datetime as dt
import pytz
from dateutil import parser
import inspect
import collections
import pytz
from six import text_type
from .base import _STIXBase

View File

@ -3,9 +3,9 @@
from .base import _STIXBase
from .common import COMMON_PROPERTIES
from .other import KillChainPhase
from .properties import (Property, ListProperty, StringProperty, TypeProperty,
IDProperty, TimestampProperty, ReferenceProperty,
IntegerProperty)
from .properties import (IDProperty, IntegerProperty, ListProperty, Property,
ReferenceProperty, StringProperty, TimestampProperty,
TypeProperty)
from .utils import NOW

View File

@ -2,9 +2,9 @@
from .base import _STIXBase
from .common import COMMON_PROPERTIES
from .properties import (ListProperty, StringProperty, TypeProperty,
IDProperty, TimestampProperty, ReferenceProperty,
IntegerProperty)
from .properties import (IDProperty, IntegerProperty, ListProperty,
ReferenceProperty, StringProperty, TimestampProperty,
TypeProperty)
class Relationship(_STIXBase):

View File

@ -1,6 +1,7 @@
import datetime as dt
import pytest
import pytz
import datetime as dt
import stix2
from .constants import ATTACK_PATTERN_ID

View File

@ -1,6 +1,7 @@
import datetime as dt
import pytest
import pytz
import datetime as dt
import stix2
from .constants import CAMPAIGN_ID

View File

@ -1,6 +1,7 @@
import datetime as dt
import pytest
import pytz
import datetime as dt
import stix2
from .constants import COURSE_OF_ACTION_ID

View File

@ -1,8 +1,8 @@
"""Tests for stix.ExternalReference"""
import pytest
import re
import pytest
import stix2
VERIS = """{

View File

@ -1,6 +1,7 @@
import datetime as dt
import pytest
import pytz
import datetime as dt
import stix2
from .constants import IDENTITY_ID

View File

@ -1,9 +1,8 @@
import datetime as dt
import re
import pytest
import pytz
import re
import stix2
from .constants import FAKE_TIME, INDICATOR_ID, INDICATOR_KWARGS

View File

@ -1,6 +1,7 @@
import datetime as dt
import pytest
import pytz
import datetime as dt
import stix2
from .constants import INTRUSION_SET_ID

View File

@ -1,9 +1,8 @@
import datetime as dt
import re
import pytest
import pytz
import re
import stix2
from .constants import FAKE_TIME, MALWARE_ID, MALWARE_KWARGS
@ -148,3 +147,16 @@ def test_parse_malware_kill_chain_phases():
assert mal.kill_chain_phases[0].phase_name == "reconnaissance"
assert mal['kill_chain_phases'][0]['kill_chain_name'] == "lockheed-martin-cyber-kill-chain"
assert mal['kill_chain_phases'][0]['phase_name'] == "reconnaissance"
def test_parse_malware_clean_kill_chain_phases():
kill_chain = """
"kill_chain_phases": [
{
"kill_chain_name": "lockheed-martin-cyber-kill-chain",
"phase_name": 1
}
]"""
data = EXPECTED_MALWARE.replace('malware"', 'malware",%s' % kill_chain)
mal = stix2.parse(data)
assert mal['kill_chain_phases'][0]['phase_name'] == "1"

View File

@ -1,8 +1,9 @@
import stix2
from stix2.other import TLP_WHITE
import datetime as dt
import pytest
import pytz
import datetime as dt
import stix2
from stix2.other import TLP_WHITE
from .constants import MARKING_DEFINITION_ID

View File

@ -1,6 +1,7 @@
import datetime as dt
import pytest
import pytz
import datetime as dt
import stix2
from .constants import OBSERVED_DATA_ID

View File

@ -1,9 +1,8 @@
import pytest
from stix2.properties import (Property, BooleanProperty, ListProperty,
StringProperty, TypeProperty, IDProperty,
IntegerProperty, ReferenceProperty,
TimestampProperty)
from stix2.properties import (BooleanProperty, IDProperty, IntegerProperty,
ListProperty, Property, ReferenceProperty,
StringProperty, TimestampProperty, TypeProperty)
from .constants import FAKE_TIME

View File

@ -1,7 +1,9 @@
import stix2
import datetime as dt
import pytest
import pytz
import datetime as dt
import stix2
from .constants import INDICATOR_KWARGS, REPORT_ID
EXPECTED = """{

View File

@ -1,6 +1,7 @@
import datetime as dt
import pytest
import pytz
import datetime as dt
import stix2
from .constants import THREAT_ACTOR_ID

View File

@ -1,6 +1,7 @@
import datetime as dt
import pytest
import pytz
import datetime as dt
import stix2
from .constants import TOOL_ID

View File

@ -1,6 +1,7 @@
import datetime as dt
import pytest
import pytz
import datetime as dt
import stix2
from .constants import VULNERABILITY_ID

View File

@ -1,9 +1,10 @@
"""Utility functions and classes for the stix2 library."""
import datetime as dt
import pytz
import json
import pytz
# Sentinel value for fields that should be set to the current time.
# We can't use the standard 'default' approach, since if there are multiple
# timestamps in a single object, the timestamps will vary by a few microseconds.

View File

@ -8,10 +8,11 @@ commands = pytest
[testenv:pycodestyle]
deps =
flake8
flake8-import-order
pycodestyle
commands =
pycodestyle ./stix2
flake8 --max-line-length=160
flake8 --max-line-length=160 --import-order-style='google'
[pycodestyle]
ignore=