Skip to content
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

BugFix for multiple responses of different type adding bulk attributes #433

Closed
wants to merge 1 commit into from

Conversation

kirzaks
Copy link

@kirzaks kirzaks commented Aug 5, 2019

Main problem is when I would like insert multiple attributes and one of attributes have error of "A similar attribute already exists for this event". MISP is sending back error message where KeyError occurs in IF sections

ipdb> new_attribute                                                                                                                                                                                                
{'Attribute': {'id': '472', 'event_id': '63', 'object_id': '0', 'object_relation': None, 'category': 'Network activity', 'type': 'hostname', 'value1': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbb.com', 'value2': '', 'to_ids': True, 'uuid': '5d3b198a-02d0-4b50-8d28-16f5c0a8383e', 'timestamp': '1564154250', 'distribution': '5', 'sharing_group_id': '0', 'comment': '', 'deleted': False, 'disable_correlation': False, 'value': 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbb.com'}, 'errors': {'attribute_0': {'value': ['A similar attribute already exists for this event.']}}}
ipdb> new_attribute["errors"]                                                                                                                                                                                      
{'attribute_0': {'value': ['A similar attribute already exists for this event.']}}
ipdb> type(new_attribute["errors"])                                                                                                                                                                                
<class 'dict'>
ipdb> new_attribute['errors'][0]                                                                                                                                                                                   
*** KeyError: 0


@coveralls
Copy link

Coverage Status

Coverage decreased (-0.05%) to 39.438% when pulling 2d057b9 on kirzaks:master into 549e3a5 on MISP:master.

@Rafiot Rafiot self-assigned this Aug 5, 2019
@Rafiot
Copy link
Member

Rafiot commented Aug 6, 2019

Wow, wait. value1 and value2 should be discarded by MISP, that's not a valid way to push multiple attributes.

@Rafiot
Copy link
Member

Rafiot commented Aug 6, 2019

Sorry, that's something else.

Which version of MISP are you using?

@kirzaks
Copy link
Author

kirzaks commented Aug 6, 2019 via email

@Rafiot
Copy link
Member

Rafiot commented Aug 6, 2019

Alright, makes sense, I can reproduce. Bugfix incoming.

@Rafiot
Copy link
Member

Rafiot commented Aug 6, 2019

FYI, there is a bug on MISP side so we're fixing it over there too, I cannot promise you 100% that it will be out today.

@Rafiot
Copy link
Member

Rafiot commented Aug 6, 2019

Sooo, I'll have a fix on PyMISP side that avoid the exception and directly return the response from MISP.

Important point tho: the actual output returned by MISP will change starting in 2.4.113 (the current one is broken, see MISP/MISP#4959)

@Rafiot Rafiot closed this in e993886 Aug 6, 2019
@kirzaks
Copy link
Author

kirzaks commented Aug 6, 2019

Thanks!

@Rafiot
Copy link
Member

Rafiot commented Aug 6, 2019

You're welcome, let me know if you have any problem.

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.

None yet

3 participants