Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
common_analysis_oms
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-gitdep
common_analysis_oms
Commits
f5ea6bcb
Commit
f5ea6bcb
authored
Mar 29, 2016
by
Peter Weidenbach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
file analysis test added; meta data in result dict cleaned up
parent
80fcccc7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
oms.py
common_analysis_oms/oms.py
+9
-5
test_oms.py
tests/test_oms.py
+8
-5
No files found.
common_analysis_oms/oms.py
View file @
f5ea6bcb
...
...
@@ -6,22 +6,27 @@ import hashlib
import
json
from
re
import
findall
from
subprocess
import
Popen
,
PIPE
from
time
import
time
from
os
import
listdir
,
path
from
distutils
import
spawn
import
logging
system_version
=
get_version_string_from_git
(
get_directory_for_filename
(
__file__
))
plugin_version
=
get_version_string_from_git
(
get_directory_for_filename
(
__file__
))
system_version
=
"OMS 0.2.1"
class
CommonAnalysisOMS
(
AnalysisPluginFile
):
"""
The OMS plugin scans a file with several malware scanners.
:iconst av_list: List of installed malware scanners
"""
av_list
=
[]
BASE_DIR
=
path
.
dirname
(
path
.
abspath
(
__file__
))
PLUGIN_DIR
=
path
.
join
(
BASE_DIR
,
"plugins"
)
def
__init__
(
self
):
super
(
CommonAnalysisOMS
,
self
)
.
__init__
(
system_version
)
super
(
CommonAnalysisOMS
,
self
)
.
__init__
(
plugin_version
,
system_version
=
system_version
)
self
.
load_plugins
()
self
.
result_dict
=
{}
...
...
@@ -97,10 +102,9 @@ class CommonAnalysisOMS(AnalysisPluginFile):
def
scan_file
(
self
,
file_to_analyze
):
self
.
result_dict
self
.
result_dict
[
"positives"
]
=
0
self
.
result_dict
[
"scan_date"
]
=
time
()
self
.
result_dict
[
"md5"
]
=
self
.
get_md5
(
file_to_analyze
)
self
.
result_dict
[
"scanners"
]
=
[
av
[
"name"
]
for
av
in
self
.
av_list
]
self
.
result_dict
[
"number_of_scanners"
]
=
len
(
self
.
result_dict
[
"scanners"
])
self
.
result_dict
[
"scans"
]
=
self
.
execute_scans
(
file_to_analyze
)
logging
.
debug
(
json
.
dumps
(
self
.
result_dict
,
indent
=
2
)
)
logging
.
debug
(
self
.
result_dict
)
return
self
.
result_dict
tests/test_oms.py
View file @
f5ea6bcb
'''
Created on Mar 24, 2016
@author: weidenba
'''
import
unittest
from
os
import
path
from
time
import
time
from
common_analysis_oms.oms
import
CommonAnalysisOMS
...
...
@@ -40,6 +36,13 @@ class Test(unittest.TestCase):
self
.
assertEqual
(
result
[
"positives"
],
result
[
'number_of_scanners'
])
self
.
assertTrue
(
False
not
in
[
result
[
"scans"
][
av
][
"detected"
]
for
av
in
result
[
"scans"
]])
def
test_analyze_file
(
self
):
result
=
self
.
oms
.
analyze_file
(
MALICIOUS_FILE_PATH
)
self
.
assertGreater
(
result
[
'positives'
],
0
,
"should be at least 1"
)
self
.
assertIn
(
'scans'
,
result
,
"scans not in result"
)
self
.
assertIn
(
'plugin_version'
,
result
,
"plugin_version not in results"
)
self
.
assertAlmostEqual
(
result
[
'analysis_date'
],
time
(),
msg
=
"Time not correct. This test might fail, if you installed many AVs"
,
delta
=
120
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment