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

Add support for Python 3.7 #75

Merged
merged 4 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ python:
- "3.4"
- "3.5"
- "3.6"
matrix:
include:
- python: 3.7 # https://github.com/travis-ci/travis-ci/issues/9069#issuecomment-425720905
dist: xenial
sudo: true
install:
- pip install -U pip setuptools
- pip install tox-travis pre-commit
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def get_version():
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
keywords="stix stix2 json validation validator stix-validator stix2-validator",
packages=find_packages(),
Expand Down
2 changes: 1 addition & 1 deletion stix2validator/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ def ipfix():
for line in data.iter_lines():
if line:
line = line.decode("utf-8")
if re.match('^\d+(,[a-zA-Z0-9]+){2},', line):
if re.match(r'^\d+(,[a-zA-Z0-9]+){2},', line):
vals = line.split(',')
if vals[1]:
ilist.append(vals[1])
Expand Down
16 changes: 8 additions & 8 deletions stix2validator/musts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from .output import info
from .util import cyber_observable_check, has_cyber_observable_data

CUSTOM_TYPE_PREFIX_RE = re.compile("^x\-.+\-.+$")
CUSTOM_TYPE_LAX_PREFIX_RE = re.compile("^x\-.+$")
CUSTOM_PROPERTY_PREFIX_RE = re.compile("^x_.+_.+$")
CUSTOM_PROPERTY_LAX_PREFIX_RE = re.compile("^x_.+$")
CUSTOM_TYPE_PREFIX_RE = re.compile(r"^x\-.+\-.+$")
CUSTOM_TYPE_LAX_PREFIX_RE = re.compile(r"^x\-.+$")
CUSTOM_PROPERTY_PREFIX_RE = re.compile(r"^x_.+_.+$")
CUSTOM_PROPERTY_LAX_PREFIX_RE = re.compile(r"^x_.+$")


def timestamp(instance):
Expand Down Expand Up @@ -255,7 +255,7 @@ def artifact_mime_type(instance):

else:
info("Can't reach IANA website; using regex for mime types.")
mime_re = re.compile('^(application|audio|font|image|message|model'
mime_re = re.compile(r'^(application|audio|font|image|message|model'
'|multipart|text|video)/[a-zA-Z0-9.+_-]+')
if not mime_re.match(obj['mime_type']):
yield JSONError("The 'mime_type' property of object '%s' "
Expand All @@ -269,7 +269,7 @@ def character_set(instance):
"""Ensure certain properties of cyber observable objects come from the IANA
Character Set list.
"""
char_re = re.compile('^[a-zA-Z0-9_\(\)-]+$')
char_re = re.compile(r'^[a-zA-Z0-9_\(\)-]+$')
for key, obj in instance['objects'].items():
if ('type' in obj and obj['type'] == 'directory' and 'path_enc' in obj):
if enums.char_sets():
Expand Down Expand Up @@ -413,8 +413,8 @@ def patterns(instance, options):
yield PatternError(str(e), instance['id'])
return

type_format_re = re.compile('^\\-?[a-z0-9]+(-[a-z0-9]+)*\\-?$')
property_format_re = re.compile('^[a-z0-9_]{3,250}$')
type_format_re = re.compile(r'^\-?[a-z0-9]+(-[a-z0-9]+)*\-?$')
property_format_re = re.compile(r'^[a-z0-9_]{3,250}$')

p = Pattern(pattern)
inspection = p.inspect().comparisons
Expand Down
16 changes: 8 additions & 8 deletions stix2validator/shoulds.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ def relationships_strict(instance):

r_type = instance['relationship_type']
try:
r_source = re.search("(.+)\-\-", instance['source_ref']).group(1)
r_target = re.search("(.+)\-\-", instance['target_ref']).group(1)
r_source = re.search(r"(.+)\-\-", instance['source_ref']).group(1)
r_target = re.search(r"(.+)\-\-", instance['target_ref']).group(1)
except (AttributeError, TypeError):
# Schemas already catch errors of these properties not being strings or
# not containing the string '--'.
Expand Down Expand Up @@ -314,7 +314,7 @@ def valid_hash_value(hashname):
"""Return true if given value is a valid, recommended hash name according
to the STIX 2 specification.
"""
custom_hash_prefix_re = re.compile("^x_")
custom_hash_prefix_re = re.compile(r"^x_")
if hashname in enums.HASH_ALGO_OV or custom_hash_prefix_re.match(hashname):
return True
else:
Expand Down Expand Up @@ -482,7 +482,7 @@ def vocab_account_type(instance):
def observable_object_keys(instance):
"""Ensure observable-objects keys are non-negative integers.
"""
digits_re = re.compile("^\d+$")
digits_re = re.compile(r"^\d+$")
for key in instance['objects']:
if not digits_re.match(key):
yield JSONError("'%s' is not a good key value. Observable Objects "
Expand All @@ -494,7 +494,7 @@ def test_dict_keys(item, inst_id):
"""Recursively generate errors for incorrectly formatted cyber observable
dictionary keys.
"""
not_caps_re = re.compile("^[^A-Z]+$")
not_caps_re = re.compile(r"^[^A-Z]+$")
for k, v in item.items():
if not not_caps_re.match(k):
yield JSONError("As a dictionary key for cyber observable "
Expand Down Expand Up @@ -766,7 +766,7 @@ def mime_type(instance):
"""Ensure the 'mime_type' property of file objects comes from the Template
column in the IANA media type registry.
"""
mime_pattern = re.compile('^(application|audio|font|image|message|model'
mime_pattern = re.compile(r'^(application|audio|font|image|message|model'
'|multipart|text|video)/[a-zA-Z0-9.+_-]+')
for key, obj in instance['objects'].items():
if ('type' in obj and obj['type'] == 'file' and 'mime_type' in obj):
Expand Down Expand Up @@ -821,7 +821,7 @@ def ipfix(instance):
"""Ensure the 'protocols' property of network-traffic objects contains only
values from the IANA IP Flow Information Export (IPFIX) Entities Registry.
"""
ipf_pattern = re.compile('^[a-z][a-zA-Z0-9]+')
ipf_pattern = re.compile(r'^[a-z][a-zA-Z0-9]+')
for key, obj in instance['objects'].items():
if ('type' in obj and obj['type'] == 'network-traffic' and
'ipfix' in obj):
Expand Down Expand Up @@ -917,7 +917,7 @@ def pdf_doc_info(instance):
def windows_process_priority_format(instance):
"""Ensure the 'priority' property of windows-process-ext ends in '_CLASS'.
"""
class_suffix_re = re.compile('.+_CLASS$')
class_suffix_re = re.compile(r'.+_CLASS$')
for key, obj in instance['objects'].items():
if 'type' in obj and obj['type'] == 'process':
try:
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27,py34,py35,py36,style,isort-check,packaging
envlist = py27,py34,py35,py36,py37,style,isort-check,packaging

[testenv]
deps =
Expand Down Expand Up @@ -44,3 +44,4 @@ python =
3.4: py34, style
3.5: py35, style
3.6: py36, style, isort-check, packaging
3.7: py37, style