Skip to content

Commit

Permalink
Fix SSL issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sxiuyang committed Sep 25, 2024
1 parent 764ae3d commit c73750c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import os

import FncRestClient
from fnc.api.api_client import ApiContext
from fnc.fnc_client import FncClient
from globalVariables import INTEGRATION_NAME
Expand Down Expand Up @@ -78,8 +79,9 @@ def add_events_to_detections(detections, detection_events):
def fetch_and_send_detections(
ctx: ApiContext, event_type: str, start_date: str
):
rest_client = FncRestClient.FncSentinelRestClient()
client = FncClient.get_api_client(
name=INTEGRATION_NAME, api_token=API_TOKEN, domain=DOMAIN
name=INTEGRATION_NAME, api_token=API_TOKEN, domain=DOMAIN, rest_client=rest_client
)
loggerLever = logging.getLevelName(LOGGER_LEVEL.upper())
client.get_logger().set_level(level=loggerLever)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
from datetime import datetime, timezone

import FncRestClient
from fnc.api.api_client import ApiContext
from fnc.fnc_client import FncClient
from globalVariables import INTEGRATION_NAME
Expand Down Expand Up @@ -94,8 +95,9 @@ def add_events_to_detections(detections, detection_events):


def fetch_and_send_detections(ctx: ApiContext, event_type: str, start_date: str):
rest_client = FncRestClient.FncSentinelRestClient()
client = FncClient.get_api_client(
name=INTEGRATION_NAME, api_token=API_TOKEN, domain=DOMAIN
name=INTEGRATION_NAME, api_token=API_TOKEN, domain=DOMAIN, rest_client=rest_client
)
loggerLever = logging.getLevelName(LOGGER_LEVEL.upper())
client.get_logger().set_level(level=loggerLever)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from fnc.api import FncRestClient
from fnc.errors import ErrorMessages, ErrorType, FncClientError
import requests

class FncSentinelRestClient(FncRestClient):
def validate_request(self, req_args: dict):
if not req_args or 'url' not in req_args:
raise FncClientError(
error_type=ErrorType.REQUEST_VALIDATION_ERROR,
error_message=ErrorMessages.REQUEST_URL_NOT_PROVIDED
)

if 'method' not in req_args:
raise FncClientError(
error_type=ErrorType.REQUEST_VALIDATION_ERROR,
error_message=ErrorMessages.REQUEST_METHOD_NOT_PROVIDED
)

def send_request(self, req_args: dict = None):
url = req_args['url']
method = req_args['method']
headers = req_args.get('headers', {})
timeout = req_args.get('timeout', 70)
verify = req_args.get('verify', True)
parameters = req_args.get('params', {})
json = req_args.get('json', None)
data = req_args.get('data', None)
payload = json or data
response = requests.request(method, url, headers=headers, timeout=timeout, params=parameters, json=payload, verify=verify)
return response
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import azure.durable_functions as df
import azure.functions as func
import FncRestClient
from azure.durable_functions.models import DurableOrchestrationStatus
from errors import InputError
from fnc.fnc_client import FncClient
Expand Down Expand Up @@ -124,8 +125,9 @@ def get_detection_args():

# Create detection client to get context for history
# and real time detections
rest_client = FncRestClient.FncSentinelRestClient()
detection_client = FncClient.get_api_client(
name=INTEGRATION_NAME, api_token=API_TOKEN, domain=DOMAIN
name=INTEGRATION_NAME, api_token=API_TOKEN, domain=DOMAIN, rest_client=rest_client
)
h_context, context = detection_client.get_splitted_context(
args=detection_args)
Expand Down

0 comments on commit c73750c

Please sign in to comment.