-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .client import XSOARClient | ||
from .config import XSOARConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from .config import XSOARConfig | ||
|
||
|
||
class XSOARClient(object): | ||
"""XSOAR REST API client | ||
referenc: https://cortex-panw.stoplight.io/docs/cortex-xsoar-8/kjn2q21a7yrbm-get-started-with-cortex-xsoar-8-ap-is | ||
""" | ||
|
||
def __init__(self, host: str = None, token: str = None, config: XSOARConfig = None): | ||
self.config = config or XSOARConfig(host=host, token=token) | ||
|
||
def is_ready(self): | ||
if self.config.is_ready(): | ||
return True | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from automon import environ | ||
|
||
|
||
class XSOARConfig(object): | ||
"""XSOAR REST API client config""" | ||
|
||
def __init__(self, host: str = None, api_key: str = None, api_key_id: str = None): | ||
self.host = host or environ('XSOAR_FQDN') | ||
self.api_key = api_key or environ('XSOAR_API_KEY') | ||
self.api_key_id = api_key_id or environ('XSOAR_API_KEY_ID') | ||
|
||
def is_ready(self) -> bool: | ||
if self.host and self.api_key and self.api_key_id: | ||
return True | ||
return False | ||
|
||
def headers(self): | ||
return { | ||
'': f'Authorization:{self.api_key}', | ||
'': f'x-xdr-auth-id:{self.api_key_id}' | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import unittest | ||
|
||
from automon.integrations.xsoar import XSOARClient | ||
|
||
|
||
class MyTestCase(unittest.TestCase): | ||
test = XSOARClient() | ||
|
||
if test.is_ready(): | ||
def test_auth(self): | ||
self.assertTrue(self.test.is_ready()) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import unittest | ||
|
||
from automon.integrations.xsoar import XSOARConfig | ||
|
||
|
||
class MyTestCase(unittest.TestCase): | ||
test = XSOARConfig() | ||
|
||
if test.is_ready(): | ||
def test_config(self): | ||
self.assertTrue(self.test.is_ready()) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,3 +147,8 @@ VDS_PASSWORD= | |
|
||
# Wdutil | ||
WDUTIL_PASSWORD= | ||
|
||
# XSOAR | ||
XSOAR_FQDN= | ||
XSOAR_API_KEY= | ||
XSOAR_API_KEY_ID= |