-
Notifications
You must be signed in to change notification settings - Fork 238
146 rest binary search #152
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
Conversation
dorpvom
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General code is approved. Please consider the requested issues to improve quality and fix jenkins / codacy.
| if not is_valid_yara_rule_file(data['rule_file']): | ||
| return error_message('Error in YARA rule file', self.URL, request_data=request.data) | ||
|
|
||
| uid = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can some part of be extracted into an additional function to clean up this lengthy function?
| uid = None | ||
| if 'uid' in data: | ||
| with ConnectTo(FrontEndDbInterface, self.config) as db_interface: | ||
| print("type(db_interface):", type(db_interface), db_interface.is_firmware) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug line I guess
| ''' | ||
|
|
||
| if search_id is None: | ||
| return error_message('The search_id was not found. It is needed to fetch the search result', self.URL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not found would suggest not found in database rather than not found in request.
no search_id specified would be more clear. Also, when removing the =None, the GET method can not be called at all without specifying the search_id what might be the intended behavior.
|
|
||
| data = {'rule_file': 'rule rulename {strings: $a = "MyTestRule" condition: $a }'} | ||
| rv = self.test_client.post('/rest/binary_search', data=json.dumps(data), follow_redirects=True) | ||
| result = json.loads(rv.data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jenkins fails on this line since data has type bytes while json.loads expects a str. Suspiciously this does not fail on my local machine. Nevertheless, using .decode() here makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also in line 33
| return error_message('The search_id was not found. It is needed to fetch the search result', self.URL) | ||
|
|
||
| with ConnectTo(InterComFrontEndBinding, self.config) as intercom: | ||
| result, rule = intercom.get_binary_search_result(search_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rule is unused
Codecov Report
@@ Coverage Diff @@
## master #152 +/- ##
==========================================
+ Coverage 95.72% 95.82% +0.09%
==========================================
Files 304 307 +3
Lines 14978 15100 +122
==========================================
+ Hits 14338 14469 +131
+ Misses 640 631 -9
Continue to review full report at Codecov.
|
No description provided.