Skip to content

Commit 7f55486

Browse files
committed
[client] Implement expectations helpers
1 parent c25904c commit 7f55486

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

pyobas/apis/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .collector import * # noqa: F401,F403
33
from .document import * # noqa: F401,F403
44
from .inject import * # noqa: F401,F403
5+
from .inject_expectation import * # noqa: F401,F403
56
from .injector import * # noqa: F401,F403
67
from .kill_chain_phase import * # noqa: F401,F403
78
from .me import * # noqa: F401,F403

pyobas/apis/inject_expectation.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from typing import Any, Dict
2+
3+
from pyobas import exceptions as exc
4+
from pyobas.base import RESTManager, RESTObject
5+
from pyobas.mixins import ListMixin, UpdateMixin
6+
7+
8+
class InjectExpectation(RESTObject):
9+
pass
10+
11+
12+
class InjectExpectationManager(ListMixin, UpdateMixin, RESTManager):
13+
_path = "/injects/expectations"
14+
_obj_cls = InjectExpectation
15+
16+
@exc.on_http_error(exc.OpenBASUpdateError)
17+
def expectations_for_source(self, source_id: str, **kwargs: Any) -> Dict[str, Any]:
18+
path = f"{self.path}/" + source_id
19+
result = self.openbas.http_get(path, **kwargs)
20+
return result

pyobas/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(
6565
self.attack_pattern = apis.AttackPatternManager(self)
6666
self.team = apis.TeamManager(self)
6767
self.user = apis.UserManager(self)
68+
self.inject_expectation = apis.InjectExpectationManager(self)
6869

6970
@staticmethod
7071
def _check_redirects(result: requests.Response) -> None:

pyobas/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import logging
66
import urllib.parse
7-
from typing import Any, Callable, Dict, Iterator, List, Literal, Optional, Tuple, Union
7+
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
88

99
import requests
1010
from pythonjsonlogger import jsonlogger

0 commit comments

Comments
 (0)