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

[BUG] Unable to create Alert #207

Closed
Rodionc opened this issue Dec 11, 2020 · 2 comments
Closed

[BUG] Unable to create Alert #207

Rodionc opened this issue Dec 11, 2020 · 2 comments
Assignees
Milestone

Comments

@Rodionc
Copy link

Rodionc commented Dec 11, 2020

Request Type

Bug

Work Environment

Question Answer
OS version (server) Ubuntu 20.04.1 LTS
OS version (client) Ubuntu 20.04.1 LTS
TheHive4py version / git hash 1.8.0

Problem Description

Unable to create Alert from Samples/test-alert-create.py. Running fail with python error in models.py

Steps to Reproduce

  1. Add APIKey to test-alert-create.py
  2. Run python3 test-alert-create.py -> Got error
  3. Remove 1.8.0 vesrion: pip3 uninstall thehive4py
  4. Install 1.7.1 version: pip3 install thehive4py==1.7.1
  5. Run python3 test-alert-create.py -> Alert created successfully

Possible Solutions

Temporary solution: downgrade thehive4py

Complementary information

Error:

Traceback (most recent call last):
File "test-alert-create.py", line 20, in
AlertArtifact(dataType='file', data='pic.png'),
File "/home/user/.local/lib/python3.8/site-packages/thehive4py/models.py", line 697, in init
file_object = open(data[0], 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'p'

@nadouani nadouani self-assigned this Jan 4, 2021
@nadouani nadouani added this to the 1.8.1 milestone Jan 4, 2021
@nadouani
Copy link
Contributor

nadouani commented Jan 4, 2021

Hello @Rodionc thanks for this issue. In fact it looks like a regression related to alerts with file artifacts.

I'll fix it in a 1.8.1 patch release

nadouani added a commit that referenced this issue Jan 5, 2021
…le observables consistent + updating docs accordingly
@nadouani
Copy link
Contributor

nadouani commented Jan 5, 2021

Fixed this issue to make sure the code below is correct:

For Alert Artifacts

inmemory_file = open("hello.txt", "rb")
artifacts = [
    AlertArtifact(dataType='file', data='sample.txt'),
    AlertArtifact(dataType='file', data=(inmemory_file, 'hello.txt'))
]

For Case Observables

CaseObservable(dataType='file', data='sample.txt', tags=['thehive4py'])

inmemory_file = open("hello.txt", "rb")
CaseObservable(dataType='file', data=(inmemory_file, 'hello.txt'), tags=['thehive4py'])

@nadouani nadouani closed this as completed Jan 5, 2021
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

2 participants