chg: Bump deps, add pep8 test

pull/534/head
Raphaël Vinot 2020-01-30 11:44:13 +01:00
parent cbce2cfbfe
commit 4e586d0de5
10 changed files with 88 additions and 81 deletions

View File

@ -12,6 +12,7 @@ pymisp = {editable = true,extras = ["fileobjects", "neo", "openioc", "virustotal
docutils = "==0.15" docutils = "==0.15"
memory-profiler = "*" memory-profiler = "*"
mypy = "*" mypy = "*"
flake8 = "*"
[packages] [packages]
pymisp = {editable = true,extras = ["fileobjects", "openioc", "virustotal", "pdfexport"],path = "."} pymisp = {editable = true,extras = ["fileobjects", "openioc", "virustotal", "pdfexport"],path = "."}

68
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "77accb43d4bbba1ff86f29a66cae21eb56bc19ce82e39b096763dfaf65a9d5d8" "sha256": "980c848909285e25224dc957df15e733666b06107dfbd97e6edfcd51c8da9206"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
@ -66,14 +66,6 @@
], ],
"version": "==2.8" "version": "==2.8"
}, },
"importlib-metadata": {
"hashes": [
"sha256:bdd9b7c397c273bcc9a11d6629a38487cd07154fa255a467bf704cd2c258e359",
"sha256:f17c015735e1a88296994c0697ecea7e11db24290941983b08c9feb30921e6d8"
],
"markers": "python_version < '3.8'",
"version": "==1.4.0"
},
"jsonschema": { "jsonschema": {
"hashes": [ "hashes": [
"sha256:4e5b3cf8216f577bee9ce139cbe72eca3ea4f292ec60928ff24758ce626cd163", "sha256:4e5b3cf8216f577bee9ce139cbe72eca3ea4f292ec60928ff24758ce626cd163",
@ -240,13 +232,6 @@
"sha256:565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1" "sha256:565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1"
], ],
"version": "==1.11.2" "version": "==1.11.2"
},
"zipp": {
"hashes": [
"sha256:ccc94ed0909b58ffe34430ea5451f07bc0c76467d7081619a454bf5c98b89e28",
"sha256:feae2f18633c32fc71f2de629bfb3bd3c9325cd4419642b1f1da42ee488d9b98"
],
"version": "==2.1.0"
} }
}, },
"develop": { "develop": {
@ -394,6 +379,21 @@
"index": "pypi", "index": "pypi",
"version": "==0.15" "version": "==0.15"
}, },
"entrypoints": {
"hashes": [
"sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19",
"sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451"
],
"version": "==0.3"
},
"flake8": {
"hashes": [
"sha256:45681a117ecc81e870cbf1262835ae4af5e7a8b08e40b944a8a6e6b895914cfb",
"sha256:49356e766643ad15072a789a20915d3c91dc89fd313ccd71802303fd67e4deca"
],
"index": "pypi",
"version": "==3.7.9"
},
"idna": { "idna": {
"hashes": [ "hashes": [
"sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407",
@ -408,14 +408,6 @@
], ],
"version": "==1.2.0" "version": "==1.2.0"
}, },
"importlib-metadata": {
"hashes": [
"sha256:bdd9b7c397c273bcc9a11d6629a38487cd07154fa255a467bf704cd2c258e359",
"sha256:f17c015735e1a88296994c0697ecea7e11db24290941983b08c9feb30921e6d8"
],
"markers": "python_version < '3.8'",
"version": "==1.4.0"
},
"jinja2": { "jinja2": {
"hashes": [ "hashes": [
"sha256:6e7a3c2934694d59ad334c93dd1b6c96699cf24c53fdb8ec848ac6b23e685734", "sha256:6e7a3c2934694d59ad334c93dd1b6c96699cf24c53fdb8ec848ac6b23e685734",
@ -487,6 +479,13 @@
], ],
"version": "==1.1.1" "version": "==1.1.1"
}, },
"mccabe": {
"hashes": [
"sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42",
"sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
],
"version": "==0.6.1"
},
"memory-profiler": { "memory-profiler": {
"hashes": [ "hashes": [
"sha256:23b196f91ea9ac9996e30bfab1e82fecc30a4a1d24870e81d1e81625f786a2c3" "sha256:23b196f91ea9ac9996e30bfab1e82fecc30a4a1d24870e81d1e81625f786a2c3"
@ -606,12 +605,26 @@
], ],
"version": "==4.3.0" "version": "==4.3.0"
}, },
"pycodestyle": {
"hashes": [
"sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56",
"sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c"
],
"version": "==2.5.0"
},
"pydeep": { "pydeep": {
"hashes": [ "hashes": [
"sha256:22866eb422d1d5907f8076ee792da65caecb172425d27576274e2a8eacf6afc1" "sha256:22866eb422d1d5907f8076ee792da65caecb172425d27576274e2a8eacf6afc1"
], ],
"version": "==0.4" "version": "==0.4"
}, },
"pyflakes": {
"hashes": [
"sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0",
"sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2"
],
"version": "==2.1.1"
},
"pygments": { "pygments": {
"hashes": [ "hashes": [
"sha256:5ffada19f6203563680669ee7f53b64dabbeb100eb51b61996085e99c03b284a", "sha256:5ffada19f6203563680669ee7f53b64dabbeb100eb51b61996085e99c03b284a",
@ -854,13 +867,6 @@
"sha256:565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1" "sha256:565a021fd19419476b9362b05eeaa094178de64f8361e44468f9e9d7843901e1"
], ],
"version": "==1.11.2" "version": "==1.11.2"
},
"zipp": {
"hashes": [
"sha256:ccc94ed0909b58ffe34430ea5451f07bc0c76467d7081619a454bf5c98b89e28",
"sha256:feae2f18633c32fc71f2de629bfb3bd3c9325cd4419642b1f1da42ee488d9b98"
],
"version": "==2.1.0"
} }
} }
} }

View File

@ -1,7 +1,5 @@
__version__ = '2.4.120' __version__ = '2.4.120'
import logging import logging
import warnings
import sys
FORMAT = "%(levelname)s [%(filename)s:%(lineno)s - %(funcName)s() ] %(message)s" FORMAT = "%(levelname)s [%(filename)s:%(lineno)s - %(funcName)s() ] %(message)s"
formatter = logging.Formatter(FORMAT) formatter = logging.Formatter(FORMAT)

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from datetime import date, datetime, timezone from datetime import date, datetime
from deprecated import deprecated # type: ignore from deprecated import deprecated # type: ignore
from json import JSONEncoder from json import JSONEncoder
@ -21,7 +21,7 @@ except ImportError:
import logging import logging
from enum import Enum from enum import Enum
from typing import Union, Optional, List from typing import Union, Optional
from .exceptions import PyMISPInvalidFormat, PyMISPError from .exceptions import PyMISPInvalidFormat, PyMISPError

View File

@ -7,6 +7,7 @@ from datetime import datetime, date
from dateutil.parser import parse from dateutil.parser import parse
from typing import Union, Optional from typing import Union, Optional
class AbstractMISPObjectGenerator(MISPObject): class AbstractMISPObjectGenerator(MISPObject):
def _detect_epoch(self, timestamp: Union[str, int, float]) -> bool: def _detect_epoch(self, timestamp: Union[str, int, float]) -> bool:

View File

@ -84,10 +84,10 @@ class PEObject(AbstractMISPObjectGenerator):
self.add_attribute('compilation-timestamp', value=datetime.utcfromtimestamp(self.__pe.header.time_date_stamps).isoformat()) self.add_attribute('compilation-timestamp', value=datetime.utcfromtimestamp(self.__pe.header.time_date_stamps).isoformat())
# self.imphash = self.__pe.get_imphash() # self.imphash = self.__pe.get_imphash()
try: try:
if (self.__pe.has_resources and if (self.__pe.has_resources
self.__pe.resources_manager.has_version and and self.__pe.resources_manager.has_version
self.__pe.resources_manager.version.has_string_file_info and and self.__pe.resources_manager.version.has_string_file_info
self.__pe.resources_manager.version.string_file_info.langcode_items): and self.__pe.resources_manager.version.string_file_info.langcode_items):
fileinfo = dict(self.__pe.resources_manager.version.string_file_info.langcode_items[0].items.items()) fileinfo = dict(self.__pe.resources_manager.version.string_file_info.langcode_items[0].items.items())
self.add_attribute('original-filename', value=fileinfo.get('OriginalFilename')) self.add_attribute('original-filename', value=fileinfo.get('OriginalFilename'))
self.add_attribute('internal-filename', value=fileinfo.get('InternalName')) self.add_attribute('internal-filename', value=fileinfo.get('InternalName'))
@ -108,8 +108,8 @@ class PEObject(AbstractMISPObjectGenerator):
for section in self.__pe.sections: for section in self.__pe.sections:
s = PESectionObject(section, self._standalone, default_attributes_parameters=self._default_attributes_parameters) s = PESectionObject(section, self._standalone, default_attributes_parameters=self._default_attributes_parameters)
self.add_reference(s.uuid, 'includes', 'Section {} of PE'.format(pos)) self.add_reference(s.uuid, 'includes', 'Section {} of PE'.format(pos))
if ((self.__pe.entrypoint >= section.virtual_address) and if ((self.__pe.entrypoint >= section.virtual_address)
(self.__pe.entrypoint < (section.virtual_address + section.virtual_size))): and (self.__pe.entrypoint < (section.virtual_address + section.virtual_size))):
self.add_attribute('entrypoint-section-at-position', value='{}|{}'.format(section.name, pos)) self.add_attribute('entrypoint-section-at-position', value='{}|{}'.format(section.name, pos))
pos += 1 pos += 1
self.sections.append(s) self.sections.append(s)

View File

@ -481,14 +481,17 @@ def get_clusters_table_styles():
def safe_string(bad_str): def safe_string(bad_str):
return escape(str(bad_str)) return escape(str(bad_str))
def is_safe_value(value): def is_safe_value(value):
return (value is not None return (value is not None
and value != "") and value != "")
def is_safe_table(value): def is_safe_table(value):
return (value is not None return (value is not None
and value != []) and value != [])
def is_safe_attribute(curr_object, attribute_name): def is_safe_attribute(curr_object, attribute_name):
return (hasattr(curr_object, attribute_name) return (hasattr(curr_object, attribute_name)
and getattr(curr_object, attribute_name) is not None and getattr(curr_object, attribute_name) is not None

View File

@ -1,10 +1,7 @@
#!/usr/bin/python3 #!/usr/bin/python3
import sys
import getopt
import requests import requests
import json import json
from pymisp import MISPObject
from .abstractgenerator import AbstractMISPObjectGenerator from .abstractgenerator import AbstractMISPObjectGenerator

View File

@ -5,3 +5,4 @@ set -x
pipenv run nosetests-3.4 --with-coverage --cover-package=pymisp,tests --cover-tests tests/test_*.py pipenv run nosetests-3.4 --with-coverage --cover-package=pymisp,tests --cover-tests tests/test_*.py
pipenv run mypy tests/testlive_comprehensive.py tests/test_mispevent.py tests/testlive_sync.py pymisp pipenv run mypy tests/testlive_comprehensive.py tests/test_mispevent.py tests/testlive_sync.py pymisp
pipenv run flake8 --ignore=E501,W503,E226,E252 pymisp