Skip to content

Commit

Permalink
fix(deps): Simplify dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
phantom-jacob committed Jan 15, 2025
1 parent 6c5f7c3 commit 189c029
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/phantomcyber/dev-cicd-tools
rev: v1.23
rev: v1.24
hooks:
- id: org-hook
- id: package-app-dependencies
Expand Down
5 changes: 1 addition & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
python-dateutil==2.8.1
pytz==2021.1
simplejson==3.17.2
splunk-sdk==2.0.1
splunk-sdk==2.1.0
22 changes: 3 additions & 19 deletions splunk.json
Original file line number Diff line number Diff line change
Expand Up @@ -1289,17 +1289,9 @@
"module": "pyparsing",
"input_file": "wheels/py3/pyparsing-3.1.4-py3-none-any.whl"
},
{
"module": "pytz",
"input_file": "wheels/shared/pytz-2021.1-py2.py3-none-any.whl"
},
{
"module": "simplejson",
"input_file": "wheels/py36/simplejson-3.17.2-cp36-cp36m-manylinux2010_x86_64.manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
},
{
"module": "splunk_sdk",
"input_file": "wheels/py3/splunk_sdk-2.0.1-py3-none-any.whl"
"input_file": "wheels/py3/splunk_sdk-2.1.0-py3-none-any.whl"
}
]
},
Expand All @@ -1311,19 +1303,11 @@
},
{
"module": "packaging",
"input_file": "wheels/py3/packaging-24.1-py3-none-any.whl"
},
{
"module": "pytz",
"input_file": "wheels/shared/pytz-2021.1-py2.py3-none-any.whl"
},
{
"module": "urllib3",
"input_file": "wheels/shared/urllib3-1.26.12-py2.py3-none-any.whl"
"input_file": "wheels/py3/packaging-24.2-py3-none-any.whl"
},
{
"module": "splunk_sdk",
"input_file": "wheels/py3/splunk_sdk-2.0.1-py3-none-any.whl"
"input_file": "wheels/py3/splunk_sdk-2.1.0-py3-none-any.whl"
}
]
}
Expand Down
38 changes: 15 additions & 23 deletions splunk_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,35 @@
#

import hashlib
import json
import os
import re
import ssl
import sys
import tempfile
import time
import traceback
from builtins import map # noqa
from builtins import range # noqa
from builtins import str # noqa
from datetime import datetime
from datetime import datetime, timezone
from io import BytesIO
from typing import Optional
from urllib.error import HTTPError as UrllibHTTPError # noqa
from urllib.error import URLError # noqa
from urllib.parse import urlencode, urlparse # noqa
from urllib.request import ProxyHandler # noqa
from urllib.request import Request # noqa
from urllib.request import build_opener # noqa
from urllib.request import install_opener # noqa
from urllib.request import urlopen # noqa
from urllib.error import HTTPError as UrllibHTTPError
from urllib.error import URLError
from urllib.request import ProxyHandler, Request, build_opener, install_opener, urlopen
from zoneinfo import ZoneInfo

import phantom.app as phantom
import phantom.rules as soar_vault
import pytz
import requests
import simplejson as json
import splunklib.binding as splunk_binding
import splunklib.client as splunk_client
import splunklib.results as splunk_results
import xmltodict
from bs4 import BeautifulSoup, UnicodeDammit
from bs4 import BeautifulSoup
from bs4.dammit import UnicodeDammit
from dateutil.parser import ParserError
from dateutil.parser import parse as dateutil_parse
from past.utils import old_div # noqa
from phantom.base_connector import BaseConnector
from phantom.vault import Vault
from pytz import timezone
from splunklib.binding import HTTPError

import splunk_consts as consts
Expand Down Expand Up @@ -1079,7 +1070,7 @@ def _get_event_start(self, start_time):
# convert to Splunk SOAR timestamp format
# '%Y-%m-%dT%H:%M:%S.%fZ
datetime_obj = dateutil_parse(start_time)
return datetime_obj.astimezone(pytz.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
return datetime_obj.astimezone(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ")
except ParserError as parse_err:
self._dump_error_log(parse_err, "ParserError while parsing _time.")
error_text = consts.SPLUNK_EXCEPTION_ERR_MESSAGE.format(
Expand Down Expand Up @@ -1184,19 +1175,20 @@ def _handle_run_query(self, param):
return action_result.set_status(phantom.APP_ERROR, "Error occurred while parsing the search query")

self.debug_print("search_query: {0}".format(search_query))
return self._run_query(search_query, action_result, attach_result=attach_result,
kwargs_create=kwargs, parse_only=po, add_raw_field=add_raw)
return self._run_query(
search_query, action_result, attach_result=attach_result, kwargs_create=kwargs, parse_only=po, add_raw_field=add_raw
)

def _get_tz_str_from_epoch(self, time_format_str, epoch_milli):

# Need to convert from UTC to the device's timezone, get the device's tz from config
config = self.get_config()
device_tz_sting = config[consts.SPLUNK_JSON_TIMEZONE]

to_tz = timezone(device_tz_sting)
to_tz = ZoneInfo(device_tz_sting)

utc_dt = datetime.utcfromtimestamp(old_div(epoch_milli / 1000)).replace(tzinfo=pytz.utc)
to_dt = to_tz.normalize(utc_dt.astimezone(to_tz))
utc_dt = datetime.fromtimestamp(epoch_milli // 1000, tz=timezone.utc)
to_dt = utc_dt.astimezone(to_tz)

# return utc_dt.strftime('%Y-%m-%d %H:%M:%S')
return to_dt.strftime(time_format_str)
Expand Down
Binary file removed wheels/py3/packaging-24.1-py3-none-any.whl
Binary file not shown.
Binary file added wheels/py3/packaging-24.2-py3-none-any.whl
Binary file not shown.
Binary file removed wheels/py3/splunk_sdk-2.0.1-py3-none-any.whl
Binary file not shown.
Binary file added wheels/py3/splunk_sdk-2.1.0-py3-none-any.whl
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed wheels/shared/pytz-2021.1-py2.py3-none-any.whl
Binary file not shown.

0 comments on commit 189c029

Please sign in to comment.