Skip to content

Commit

Permalink
Merge pull request #1118 from SEKOIA-IO/feat/sekoia_bump_sdk
Browse files Browse the repository at this point in the history
feat(Sekoia.io): Bump SDK
  • Loading branch information
Darkheir authored Oct 4, 2024
2 parents 86badfa + b383e7f commit be39d53
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 48 deletions.
6 changes: 6 additions & 0 deletions Sekoia.io/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 2024-10-04 - 2.64.3

### Changed

- Bump SDK

## 2024-10-03 - 2.64.2

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Sekoia.io/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"name": "Sekoia.io",
"uuid": "92d8bb47-7c51-445d-81de-ae04edbb6f0a",
"slug": "sekoia.io",
"version": "2.64.2",
"version": "2.64.3",
"categories": [
"Generic"
]
Expand Down
260 changes: 235 additions & 25 deletions Sekoia.io/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Sekoia.io/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = []
[tool.poetry.dependencies]
python = ">=3.10,<3.12"
requests = "*"
sekoia-automation-sdk = "^1.14.0"
sekoia-automation-sdk = "^1.15.1"
kafka-python = "*"
tenacity = "*"
ujson = "*"
Expand Down
1 change: 0 additions & 1 deletion Sekoia.io/sekoiaio/operation_center/get_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class GetEvents(BaseGetEvents):

def run(self, arguments):
limit = min(self.MAX_LIMIT, arguments.get("limit") or self.DEFAULT_LIMIT)
self.configure_http_session()
Expand Down
28 changes: 9 additions & 19 deletions Sekoia.io/tests/test_actions_rules.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from urllib.parse import unquote as url_decoder

import requests_mock

from tenacity import wait_none
from sekoiaio.operation_center import GetRule, EnableRule, DisableRule, DeleteRule, CreateRule, UpdateRule

module_base_url = "http://fake.url/"
Expand All @@ -10,7 +10,6 @@


def test_get_rule_success():

action: GetRule = GetRule()
action.module.configuration = {"base_url": module_base_url, "api_key": apikey}

Expand Down Expand Up @@ -52,9 +51,9 @@ def test_get_rule_success():


def test_enable_rule_failure():

action: EnableRule = EnableRule()
action.module.configuration = {"base_url": module_base_url, "api_key": apikey}
action._wait_param = lambda: wait_none()

ressource = "conf/rules-catalog/rules/fake_uuid"
expected_response = None
Expand All @@ -64,49 +63,47 @@ def test_enable_rule_failure():
mock.put(f"{base_url}{ressource}/enabled", json=expected_response, status_code=500)
results: dict = action.run(arguments)
assert results == expected_response
assert mock.call_count == 1
history = mock.request_history
assert history[0].method == "PUT"
assert url_decoder(history[0].url) == f"{base_url}{ressource}/enabled"


def test_get_rule_failure():

action: GetRule = GetRule()
action.module.configuration = {"base_url": module_base_url, "api_key": apikey}
action._wait_param = lambda: wait_none()

ressource = "conf/rules-catalog/rules/fake_uuid"
expected_response = None
with requests_mock.Mocker() as mock:
mock.get(f"{base_url}{ressource}", json=expected_response, status_code=500)
results: dict = action.run({"uuid": "fake_uuid"})
assert results == expected_response
assert mock.call_count == 1
history = mock.request_history
assert history[0].method == "GET"
assert url_decoder(history[0].url) == f"{base_url}{ressource}"


def test_delete_rule_failure():

action: DeleteRule = DeleteRule()
action.module.configuration = {"base_url": module_base_url, "api_key": apikey}
action._wait_param = lambda: wait_none()
ressource = "conf/rules-catalog/rules/fake_uuid"
expected_response = None
arguments = {"uuid": "fake_uuid"}
with requests_mock.Mocker() as mock:
mock.delete(f"{base_url}{ressource}", json=expected_response, status_code=500)
results: dict = action.run(arguments)
assert results == expected_response
assert mock.call_count == 1
history = mock.request_history
assert history[0].method == "DELETE"
assert url_decoder(history[0].url) == f"{base_url}{ressource}"


def test_create_rule_failure():

action: CreateRule = CreateRule()
action.module.configuration = {"base_url": module_base_url, "api_key": apikey}
action._wait_param = lambda: wait_none()
ressource = "conf/rules-catalog/rules"
expected_response = None
arguments = {
Expand Down Expand Up @@ -137,16 +134,15 @@ def test_create_rule_failure():
mock.post(f"{base_url}{ressource}", json=expected_response, status_code=500)
results: dict = action.run(arguments)
assert results == expected_response
assert mock.call_count == 1
history = mock.request_history
assert history[0].method == "POST"
assert url_decoder(history[0].url) == f"{base_url}{ressource}"


def test_update_rule_failure():

action: UpdateRule = UpdateRule()
action.module.configuration = {"base_url": module_base_url, "api_key": apikey}
action._wait_param = lambda: wait_none()
ressource = "conf/rules-catalog/rules/fake_uuid"
expected_response = None
arguments = {
Expand Down Expand Up @@ -179,16 +175,15 @@ def test_update_rule_failure():
mock.put(f"{base_url}{ressource}", json=expected_response, status_code=500)
results: dict = action.run(arguments)
assert results == expected_response
assert mock.call_count == 1
history = mock.request_history
assert history[0].method == "PUT"
assert url_decoder(history[0].url) == f"{base_url}{ressource}"


def test_disable_rule_failure():

action: DisableRule = DisableRule()
action.module.configuration = {"base_url": module_base_url, "api_key": apikey}
action._wait_param = lambda: wait_none()

ressource = "conf/rules-catalog/rules/fake_uuid"
expected_response = None
Expand All @@ -199,16 +194,15 @@ def test_disable_rule_failure():
results: dict = action.run(arguments)

assert results == expected_response
assert mock.call_count == 1
history = mock.request_history
assert history[0].method == "PUT"
assert url_decoder(history[0].url) == f"{base_url}{ressource}/disabled"


def test_delete_rule_success():

action: DeleteRule = DeleteRule()
action.module.configuration = {"base_url": module_base_url, "api_key": apikey}
action._wait_param = lambda: wait_none()

ressource = "conf/rules-catalog/rules/fake_uuid"
expected_response = {"message": "Rule deleted successfully"}
Expand All @@ -226,7 +220,6 @@ def test_delete_rule_success():


def test_create_rule_success():

action: CreateRule = CreateRule()
action.module.configuration = {"base_url": module_base_url, "api_key": apikey}

Expand Down Expand Up @@ -295,7 +288,6 @@ def test_create_rule_success():


def test_update_rule_success():

action: UpdateRule = UpdateRule()
action.module.configuration = {"base_url": module_base_url, "api_key": apikey}

Expand Down Expand Up @@ -367,7 +359,6 @@ def test_update_rule_success():


def test_enable_rule_success():

action: EnableRule = EnableRule()
action.module.configuration = {"base_url": module_base_url, "api_key": apikey}

Expand Down Expand Up @@ -411,7 +402,6 @@ def test_enable_rule_success():


def test_disable_rule_success():

action: DisableRule = DisableRule()
action.module.configuration = {"base_url": module_base_url, "api_key": apikey}

Expand Down
3 changes: 2 additions & 1 deletion Sekoia.io/tests/test_post_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest
import requests_mock

from tenacity import wait_none
from sekoiaio.intelligence_center.actions import PostBundleAction


Expand Down Expand Up @@ -66,6 +66,7 @@ def test_post_bundle_file(stix_bundle, symphony_storage):
@patch.object(PostBundleAction, "error")
def test_post_bundle_error(error_mock, stix_bundle):
action = PostBundleAction()
action._wait_param = lambda: wait_none()

action.module.configuration = {
"base_url": "http://fake.url/",
Expand Down

0 comments on commit be39d53

Please sign in to comment.