Commit f7954585 by Victor M. Alvarez

Enable “dotnet” module and features dependant on libcrypto in “pe” module

parent c441f2fd
...@@ -148,9 +148,10 @@ clone_script: ...@@ -148,9 +148,10 @@ clone_script:
build_script: build_script:
# Build the compiled extension # Build the compiled extension
- "%CMD_IN_ENV% python setup.py build_ext --enable-cuckoo - "%CMD_IN_ENV% python setup.py build_ext --enable-cuckoo --enable-dotnet
-L../jansson-%JANSSON_VERSION%/build/lib/Release;../%OPENSSL_LIB%/%OPENSSL_LIB_DIR% -L../jansson-%JANSSON_VERSION%/build/lib/Release;../%OPENSSL_LIB%/%OPENSSL_LIB_DIR%
-I../jansson-%JANSSON_VERSION%/build/include;../%OPENSSL_LIB%/include -I../jansson-%JANSSON_VERSION%/build/include;../%OPENSSL_LIB%/include
-D_CRT_SECURE_NO_WARNINGS -DHASH_MODULE -DHAVE_LIBCRYPTO
-llibcryptoMT" -llibcryptoMT"
after_build: after_build:
......
...@@ -35,6 +35,7 @@ OPTIONS = [ ...@@ -35,6 +35,7 @@ OPTIONS = [
('dynamic-linking', None, 'link dynamically against libyara'), ('dynamic-linking', None, 'link dynamically against libyara'),
('enable-cuckoo', None, 'enable "cuckoo" module'), ('enable-cuckoo', None, 'enable "cuckoo" module'),
('enable-magic', None, 'enable "magic" module'), ('enable-magic', None, 'enable "magic" module'),
('enable-dotnet', None, 'enable "dotnet" module'),
('enable-profiling', None, 'enable profiling features')] ('enable-profiling', None, 'enable profiling features')]
...@@ -42,6 +43,7 @@ BOOLEAN_OPTIONS = [ ...@@ -42,6 +43,7 @@ BOOLEAN_OPTIONS = [
'dynamic-linking', 'dynamic-linking',
'enable-cuckoo', 'enable-cuckoo',
'enable-magic', 'enable-magic',
'enable-dotnet',
'enable-profiling'] 'enable-profiling']
...@@ -93,6 +95,7 @@ class BuildCommand(build): ...@@ -93,6 +95,7 @@ class BuildCommand(build):
self.dynamic_linking = None self.dynamic_linking = None
self.enable_magic = None self.enable_magic = None
self.enable_cuckoo = None self.enable_cuckoo = None
self.enable_dotnet = None
self.enable_profiling = None self.enable_profiling = None
def finalize_options(self): def finalize_options(self):
...@@ -112,6 +115,7 @@ class BuildExtCommand(build_ext): ...@@ -112,6 +115,7 @@ class BuildExtCommand(build_ext):
self.dynamic_linking = None self.dynamic_linking = None
self.enable_magic = None self.enable_magic = None
self.enable_cuckoo = None self.enable_cuckoo = None
self.enable_dotnet = None
self.enable_profiling = None self.enable_profiling = None
def finalize_options(self): def finalize_options(self):
...@@ -125,6 +129,7 @@ class BuildExtCommand(build_ext): ...@@ -125,6 +129,7 @@ class BuildExtCommand(build_ext):
('dynamic_linking', 'dynamic_linking'), ('dynamic_linking', 'dynamic_linking'),
('enable_magic', 'enable_magic'), ('enable_magic', 'enable_magic'),
('enable_cuckoo', 'enable_cuckoo'), ('enable_cuckoo', 'enable_cuckoo'),
('enable_dotnet', 'enable_dotnet'),
('enable_profiling', 'enable_profiling')) ('enable_profiling', 'enable_profiling'))
if self.enable_magic and self.dynamic_linking: if self.enable_magic and self.dynamic_linking:
...@@ -133,6 +138,9 @@ class BuildExtCommand(build_ext): ...@@ -133,6 +138,9 @@ class BuildExtCommand(build_ext):
if self.enable_cuckoo and self.dynamic_linking: if self.enable_cuckoo and self.dynamic_linking:
raise distutils.errors.DistutilsOptionError( raise distutils.errors.DistutilsOptionError(
'--enable-cuckoo can''t be used with --dynamic-linking') '--enable-cuckoo can''t be used with --dynamic-linking')
if self.enable_dotnet and self.dynamic_linking:
raise distutils.errors.DistutilsOptionError(
'--enable-dotnet can''t be used with --dynamic-linking')
def run(self): def run(self):
"""Execute the build command.""" """Execute the build command."""
...@@ -147,11 +155,6 @@ class BuildExtCommand(build_ext): ...@@ -147,11 +155,6 @@ class BuildExtCommand(build_ext):
if self.plat_name in ('win32','win-amd64'): if self.plat_name in ('win32','win-amd64'):
building_for_windows = True building_for_windows = True
#bits = '64' if self.plat_name == 'win-amd64' else '32'
module.define_macros.append(('_CRT_SECURE_NO_WARNINGS','1'))
#module.include_dirs.append('yara/windows/include')
module.libraries.append('advapi32')
module.libraries.append('user32')
else: else:
building_for_windows = False building_for_windows = False
...@@ -177,18 +180,13 @@ class BuildExtCommand(build_ext): ...@@ -177,18 +180,13 @@ class BuildExtCommand(build_ext):
if self.dynamic_linking: if self.dynamic_linking:
module.libraries.append('yara') module.libraries.append('yara')
else: else:
#if building_for_windows: if not ('HASH_MODULE', '1') in self.define:
# module.library_dirs.append('yara/windows/lib') if (has_function('MD5_Init', libraries=['crypto']) and
has_function('SHA256_Init', libraries=['crypto'])):
if building_for_windows: module.define_macros.append(('HASH_MODULE', '1'))
module.define_macros.append(('HASH_MODULE', '1')) module.libraries.append('crypto')
#module.libraries.append('libeay32') else:
elif (has_function('MD5_Init', libraries=['crypto']) and exclusions.append('yara/libyara/modules/hash.c')
has_function('SHA256_Init', libraries=['crypto'])):
module.define_macros.append(('HASH_MODULE', '1'))
module.libraries.append('crypto')
else:
exclusions.append('yara/libyara/modules/hash.c')
if self.enable_magic: if self.enable_magic:
module.define_macros.append(('MAGIC_MODULE', '1')) module.define_macros.append(('MAGIC_MODULE', '1'))
...@@ -201,6 +199,11 @@ class BuildExtCommand(build_ext): ...@@ -201,6 +199,11 @@ class BuildExtCommand(build_ext):
else: else:
exclusions.append('yara/libyara/modules/cuckoo.c') exclusions.append('yara/libyara/modules/cuckoo.c')
if self.enable_dotnet:
module.define_macros.append(('DOTNET_MODULE', '1'))
else:
exclusions.append('yara/libyara/modules/dotnet.c')
exclusions = [os.path.normpath(x) for x in exclusions] exclusions = [os.path.normpath(x) for x in exclusions]
for directory, _, files in os.walk('yara/libyara/'): for directory, _, files in os.walk('yara/libyara/'):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment