Skip to content

Commit 63d67cc

Browse files
authored
Merge pull request #52 from carbonblack/develop
Release version 1.0a2
2 parents 8721ae4 + 5be5bac commit 63d67cc

File tree

13 files changed

+555
-16
lines changed

13 files changed

+555
-16
lines changed

README.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#### \*\*Disclaimer: This is an ALPHA release\*\*
66

7-
**Latest Version:** 1.0a1
7+
**Latest Version:** 1.0a2
88
<br>
99
**Release Date:** 05/11/2020
1010

@@ -32,6 +32,9 @@ The Carbon Black Cloud Binary Toolkit is design to work on Python 3.6 and above.
3232

3333
All requirements are installed as part of `pip install` or if you're planning on pushing changes to the Carbon Black Cloud Binary Toolkit, the following can be used after cloning the repo `pip install requirements.txt`
3434

35+
### Carbon Black Cloud
36+
* Enterprise EDR
37+
3538
### Python Packages
3639
* argparse
3740
* cbapi
@@ -41,8 +44,17 @@ All requirements are installed as part of `pip install` or if you're planning on
4144
* schema
4245
* yara-python
4346

44-
### Carbon Black Cloud
45-
* Enterprise EDR
47+
#### Note:
48+
49+
* **Windows** users will need to have [Microsoft Visual C++ 14.0 Build Tools](https://visualstudio.microsoft.com/visual-cpp-build-tools) installed in order to compile yara-python.
50+
51+
* **Linux** users will need to have the python developer package installed in order to compile yara-python. If you receive compile errors, make sure you are on the latest gcc compiler version
52+
53+
Linux Distribution | Command
54+
---- | ----
55+
Amazon Linux/Centos/RHEL | `yum install python3-devel`
56+
Ubuntu | `apt-get install python3-dev`
57+
OpenSUSE/SUSE | `zypper install python3-devel`
4658

4759
## Getting Started
4860

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0a1
1+
1.0a2

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Package dependencies
2-
argparse
32
cbapi
43
python-dateutil
54
pyyaml

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ def read(fname):
1111

1212

1313
install_reqs = [
14-
"argparse",
1514
"cbapi",
1615
"python-dateutil",
1716
"pyyaml",

src/cbc_binary_toolkit/cli_input.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ def read_csv(file):
4646
with file as csvfile:
4747
file_data = csv.reader(csvfile)
4848
for row in file_data:
49-
hash = row[0]
50-
if len(hash) != 64:
51-
raise AssertionError(f'Hash should be 64 chars, instead is {len(hash)} chars: {hash}')
52-
hashes.append(str(hash))
49+
if len(row) > 0:
50+
hash_val = row[0]
51+
if len(hash_val) != 64:
52+
raise AssertionError(f'Hash should be 64 chars, instead is {len(hash_val)} chars: {hash_val}')
53+
hashes.append(str(hash_val))
5354
if not hashes:
5455
raise AssertionError(f'There are no hashes in File {file.name}')
5556

src/cbc_binary_toolkit_examples/tools/analysis_util.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __init__(self, default_install):
6464
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
6565
help="The base log level (default {0})".format(DEFAULT_LOG_LEVEL))
6666

67-
commands = self._parser.add_subparsers(help="Binary analysis commands", dest="command_name", required=True)
67+
commands = self._parser.add_subparsers(help="Binary analysis commands", dest="command_name")
6868

6969
# Analyze command parser
7070
analyze_command = commands.add_parser("analyze", help="Analyze a list of hashes by command line or file")
@@ -240,6 +240,14 @@ def main(self, cmdline_args):
240240

241241
log.debug("Started: {}".format(datetime.now()))
242242

243+
if args.command_name is None:
244+
print(
245+
"usage: cbc-binary-analysis [-h] [-c CONFIG]\n"
246+
" [-ll {DEBUG,INFO,WARNING,ERROR,CRITICAL}]\n"
247+
" {analyze,restart,clear} ...\n"
248+
"cbc-binary-analysis: error: the following arguments are required: command_name")
249+
return
250+
243251
try:
244252
if self.config is None:
245253
if args.config != self.default_install:

src/tests/component/input_fixtures/basic/csv_answer

+1-1
Large diffs are not rendered by default.

src/tests/component/input_fixtures/basic/csv_input

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ wcsnjsehflpjkhcaetuwpsxwspbzeurpegvggkecpfhlvhmsjyvhgmkbylxpladx
148148
xcekwgwjyuqmuoekobzxxxtmoevibdiqtbcmphoyucizjasovwsslprnyxyjysfn
149149
cbpfomylbygbpuczssqywhlwahiwlddawakthsaiozcnohbgspqticvetotbmuau
150150
dnsjltirypganyjdqnwghozhoogksltscstimfmshuwfclrdebevvthdpmoycjsz
151-
ifzykmuobvqifmhpwunktihgqfptgvjxdwjjokoidwhukovlfrxvaiunisgdilhæ
151+
ifzykmuobvqifmhpwunktihgqfptgvjxdwjjokoidwhukovlfrxvaiunisgdilha
152152
hltoyinfnvzeciiyxihdspriggsfofoaypaqzhcwvwlpslauhugcvkkivbhzewlj
153153
ohmwkeuyaufdwutklzusfxflsqtagyxipoeywdzhkbfofscgoqgtymrmdupfvima
154154
eywgkykymqxnzxdauhacnrbfmprehwetrquwawtqdlxhjdsxblijojgaedunecrh

src/tests/component/input_fixtures/basic/csv_input_with_blank_lines

+513
Large diffs are not rendered by default.

src/tests/component/input_fixtures/basic/csv_input_wrong_hashlength

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ wcsnjsehflpjkhcaetuwpsxwspbzeurpegvggkecpfhlvhmsjyvhgmkbylxpladx
148148
xcekwgwjyuqmuoekobzxxxtmoevibdiqtbcmphoyucizjasovwsslprnyxyjysfn
149149
cbpfomylbygbpuczssqywhlwahiwlddawakthsaiozcnohbgspqticvetotbmuau
150150
dnsjltirypganyjdqnwghozhoogksltscstimfmshuwfclrdebevvthdpmoycjsz
151-
ifzykmuobvqifmhpwunktihgqfptgvjxdwjjokoidwhukovlfrxvaiunisgdilhæ
151+
ifzykmuobvqifmhpwunktihgqfptgvjxdwjjokoidwhukovlfrxvaiunisgdilha
152152
hltoyinfnvzeciiyxihdspriggsfofoaypaqzhcwvwlpslauhugcvkkivbhzewlj
153153
ohmwkeuyaufdwutklzusfxflsqtagyxipoeywdzhkbfofscgoqgtymrmdupfvima
154154
eywgkykymqxnzxdauhacnrbfmprehwetrquwawtqdlxhjdsxblijojgaedunecrh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/tests/component/input_fixtures/file_path_constants.py

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"""File paths for testing purposes"""
1515

1616
BASIC_INPUT_FILE = 'input_fixtures/basic/csv_input'
17+
BLANK_LINES_CSV_INPUT_FILE = 'input_fixtures/basic/csv_input_with_blank_lines'
1718
LARGE_INPUT_FILE = 'input_fixtures/large/csv_input'
1819
BASIC_JSON_INPUT_FILE = 'input_fixtures/basic/json_input'
1920
LARGE_JSON_INPUT_FILE = 'input_fixtures/large/json_input'
@@ -31,5 +32,6 @@
3132

3233
DOES_NOT_EXIST_FILE = 'input_fixtures/not_a_real_path'
3334
EMPTY_CSV = 'input_fixtures/basic/empty_csv'
35+
ONE_BLANK_LINE_CSV = 'input_fixtures/basic/one_blank_line_csv'
3436
WRONG_KEY_JSON = 'input_fixtures/basic/json_input_wrong_key'
3537
EMPTY_HASHES_DICT_JSON = 'input_fixtures/basic/json_input_empty_hashes_dict'

src/tests/component/test_cli_input.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
LARGE_JSON_ANSWER_PATH,
3232
BASIC_JSON_WRONG_HASHLEN,
3333
BASIC_JSON_MALFORMED_FILE,
34+
BLANK_LINES_CSV_INPUT_FILE,
3435
BASIC_INPUT_CSV_WRONG_HASHLEN,
3536
DOES_NOT_EXIST_FILE,
3637
EMPTY_CSV,
38+
ONE_BLANK_LINE_CSV,
3739
# WRONG_KEY_JSON,
3840
EMPTY_HASHES_DICT_JSON
3941
)
@@ -50,7 +52,8 @@ class TestInputFunctions():
5052
"""Unit tests for input.py functions"""
5153
@pytest.mark.parametrize("input_file_path, answer_file_path", [
5254
(BASIC_INPUT_FILE, BASIC_INPUT_ANSWER_PATH),
53-
(LARGE_INPUT_FILE, LARGE_INPUT_ANSWER_PATH)
55+
(LARGE_INPUT_FILE, LARGE_INPUT_ANSWER_PATH),
56+
(BLANK_LINES_CSV_INPUT_FILE, BASIC_INPUT_ANSWER_PATH)
5457
])
5558
def test_csv(self, input_file_path: str, answer_file_path: List[Dict]):
5659
"""Unit testing read_csv function"""
@@ -75,7 +78,8 @@ def test_json(self, input_file_path: str, answer_file_path: List[Dict]):
7578
"Hash should be 64 chars, instead is 63 chars: "
7679
"qqtrqoetfdomjjqnyatgmmbomhtnzqchzqzhxggmxqzgoabcnzysikrmunjgrup"),
7780
(OSError, DOES_NOT_EXIST_FILE, f"[Errno 2] No such file or directory: '{attach_path(DOES_NOT_EXIST_FILE)}'"),
78-
(AssertionError, EMPTY_CSV, f'There are no hashes in File {attach_path(EMPTY_CSV)}')
81+
(AssertionError, EMPTY_CSV, f'There are no hashes in File {attach_path(EMPTY_CSV)}'),
82+
(AssertionError, ONE_BLANK_LINE_CSV, f'There are no hashes in File {attach_path(ONE_BLANK_LINE_CSV)}')
7983
])
8084
def test_csv_exceptions(self, error, input_file_path: str, msg: str):
8185
"""Unit testing read_csv function exceptions"""

0 commit comments

Comments
 (0)