You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.4 KiB

# Copyright (C) 2005-2025 Splunk Inc. All Rights Reserved.
import sys
import os
try:
from splunk.clilib.bundle_paths import make_splunkhome_path
except ImportError:
# Added the below method for DATF compatibility
def make_splunkhome_path(path_list):
relpath = os.path.normpath(os.path.join(*path_list))
splunk_home = os.environ.get("SPLUNK_HOME", '')
fullpath = os.path.normpath(os.path.join(splunk_home, relpath))
# Check that we haven't escaped from intended parent directories.
if os.path.relpath(fullpath, splunk_home)[0:2] == '..':
raise ValueError('Illegal escape from parent directory "%s": %s' %
(splunk_home, fullpath))
return fullpath
def add_to_sys_path(paths, prepend=False):
for path in paths:
if prepend:
if path in sys.path:
sys.path.remove(path)
sys.path.insert(0, path)
elif path not in sys.path:
sys.path.append(path)
# Add lib path to import paths for packages
add_to_sys_path([make_splunkhome_path(['etc', 'apps', 'SA-ITOA', 'lib'])])
# Ensure the following paths are resolved first to avoid potential conflicts from other apps
add_to_sys_path([make_splunkhome_path(['etc', 'apps', 'SA-ITOA', 'lib', 'SA_ITOA_app_common'])], prepend=True)
add_to_sys_path([make_splunkhome_path(['etc', 'apps', 'SA-UserAccess', 'lib'])])