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

Correction in update_case usage #57

Closed
PavanKotikalapudi opened this issue Jan 9, 2018 · 4 comments
Closed

Correction in update_case usage #57

PavanKotikalapudi opened this issue Jan 9, 2018 · 4 comments
Milestone

Comments

@PavanKotikalapudi
Copy link

Request Type

Bug

Work Environment

Question Answer
OS version (server) Debian, Ubuntu, CentOS, RedHat, ...
OS version (client) XP, Seven, 10, Ubuntu, ...
TheHive4py version / git hash 1.4.2

Problem Description

Describe the problem/bug as clearly as possible.

The current update_case method take an object which contains case id and other fields that need to be updated.

The line shows that you create a case object which unnecessarily update the defaults of the case.

Steps to Reproduce

try to use the update method to update only a particular field of the case.

Possible Solutions

either change the update_case method parameter to accept case_id and attributes of case to update as **kwargs or create a pojo for the update_case.

@nadouani
Copy link
Contributor

Hi @npratley, can you take a look to this issue please? Thanks

@npratley
Copy link

Hi @PavanKotikalapudi thanks for the report. I don't fully understand though, the line linked to just creates the case for example purposes, update_case itself shouldn't modify case defaults. Can you please provide sample code showing what you would like update_case to do and what it is not doing correctly? Thanks!

@PavanKotikalapudi
Copy link
Author

PavanKotikalapudi commented Jan 16, 2018

Sure.

As per current example

// Create a new case
case = thehive.case.create(title='From TheHive4Py', description='N/A', tlp=3, flag=True,
tags=['TheHive4Py', 'sample'], tasks=[])

// Save the new case's ID for later use
case_id = case.id

// Change some attributes of the new case
case.tlp = 1
case.severity = 1
case.flag = False

// Update the case
thehive.update_case(case)

the above code would update the title, description and other details though we only need to update tlp, severity and flag.

Instead if we can change the method to

def update_case(self, case_id, **attributes):

or creating a object like this

classs ModifiedCase(object):

def __init__(self, caseId, **attributes_to_update):
 storing isntance variables here

then we can use current method without modifying

thehive.update_case( ModifiedCase( 'SomeCaseID', tlp=1)

@nadouani
Copy link
Contributor

nadouani commented Feb 7, 2018

The solution we will implement to make sure the changes will not break the existing tools that use this library, we will add an optional parameter to the update_case method, to list the fields we want to update, example:

api.update_case(case, ['status', 'resolutionStatus', 'impactStatus', 'tags', 'summary'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants