这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@jstucke
Copy link
Collaborator

@jstucke jstucke commented Aug 6, 2018

No description provided.

@jstucke jstucke requested a review from dorpvom August 6, 2018 15:33
Copy link
Member

@dorpvom dorpvom left a 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
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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.

Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rule is unused

@codecov-io
Copy link

codecov-io commented Aug 8, 2018

Codecov Report

Merging #152 into master will increase coverage by 0.09%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/web_interface/rest/rest_binary_search.py 100% <100%> (ø)
src/web_interface/rest/rest_base.py 100% <100%> (ø) ⬆️
src/test/common_helper.py 95.04% <100%> (+0.62%) ⬆️
...unit/web_interface/rest/test_rest_binary_search.py 100% <100%> (ø)
...test/acceptance/rest/test_rest_analyze_firmware.py 100% <100%> (ø) ⬆️
...rc/test/acceptance/rest/test_rest_binary_search.py 100% <100%> (ø)
...test/integration/scheduler/test_cycle_with_tags.py 98.11% <0%> (-1.89%) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ea44a4...51d470f. Read the comment docs.

@dorpvom dorpvom merged commit dcb6e80 into master Aug 10, 2018
@weidenba weidenba deleted the 146-rest-binary-search branch August 14, 2018 11:54
weidenba pushed a commit that referenced this pull request Oct 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants