Skip to content

Commit cc2386c

Browse files
authored
[client] Add cve endpoints
1 parent c41f303 commit cc2386c

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

pyobas/apis/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .attack_pattern import * # noqa: F401,F403
22
from .collector import * # noqa: F401,F403
3+
from .cve import * # noqa: F401,F403
34
from .document import * # noqa: F401,F403
45
from .endpoint import * # noqa: F401,F403
56
from .inject import * # noqa: F401,F403

pyobas/apis/collector.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from typing import Any, Dict
2+
3+
from pyobas import exceptions as exc
14
from pyobas.base import RESTManager, RESTObject
25
from pyobas.mixins import CreateMixin, GetMixin, ListMixin, UpdateMixin
36
from pyobas.utils import RequiredOptional
@@ -18,3 +21,9 @@ class CollectorManager(GetMixin, ListMixin, CreateMixin, UpdateMixin, RESTManage
1821
"collector_period",
1922
)
2023
)
24+
25+
@exc.on_http_error(exc.OpenBASUpdateError)
26+
def get(self, collector_id: str, **kwargs: Any) -> Dict[str, Any]:
27+
path = f"{self.path}/" + collector_id
28+
result = self.openbas.http_get(path, **kwargs)
29+
return result

pyobas/apis/cve.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from typing import Any, Dict
2+
3+
from pyobas import exceptions as exc
4+
from pyobas.base import RESTManager, RESTObject
5+
6+
7+
class Cve(RESTObject):
8+
_id_attr = "cve_id"
9+
10+
11+
class CveManager(RESTManager):
12+
_path = "/cves"
13+
14+
@exc.on_http_error(exc.OpenBASUpdateError)
15+
def upsert(self, data: Dict[str, Any], **kwargs: Any) -> Dict[str, Any]:
16+
path = f"{self.path}/bulk"
17+
result = self.openbas.http_post(path, post_data=data, **kwargs)
18+
return result

pyobas/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def __init__(
5959
self.organization = apis.OrganizationManager(self)
6060
self.injector = apis.InjectorManager(self)
6161
self.collector = apis.CollectorManager(self)
62+
self.cve = apis.CveManager(self)
6263
self.inject = apis.InjectManager(self)
6364
self.document = apis.DocumentManager(self)
6465
self.kill_chain_phase = apis.KillChainPhaseManager(self)

0 commit comments

Comments
 (0)