From f59a333c9a6f6d59ad638ca0e66b9e671802ed58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Bieli=C5=84ski?= Date: Wed, 29 Nov 2023 08:42:39 +0100 Subject: [PATCH] Bug fix for accessing path to the vault temp directory --- LICENSE | 2 +- release_notes/unreleased.md | 1 + rss_connector.py | 7 +++++-- rss_consts.py | 4 ++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index fe5e893..48fc581 100644 --- a/LICENSE +++ b/LICENSE @@ -198,4 +198,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file + limitations under the License. diff --git a/release_notes/unreleased.md b/release_notes/unreleased.md index fbcb2fd..3b876e3 100644 --- a/release_notes/unreleased.md +++ b/release_notes/unreleased.md @@ -1 +1,2 @@ **Unreleased** +* Updating vault tmp path so that variables are used instead of hardcoded string [PAPP-32424] \ No newline at end of file diff --git a/rss_connector.py b/rss_connector.py index 2df36c7..c0a8c4f 100644 --- a/rss_connector.py +++ b/rss_connector.py @@ -27,6 +27,7 @@ import phantom.rules as ph_rules from phantom.base_connector import BaseConnector from phantom.vault import Vault +from phantom_common import paths import rss_consts as rc from parser_helper import parse_link_contents @@ -103,7 +104,8 @@ def _save_html(self, html_file, name, container_id): if hasattr(Vault, 'get_vault_tmp_dir'): fd, path = tempfile.mkstemp(dir=Vault.get_vault_tmp_dir(), text=True) else: - fd, path = tempfile.mkstemp(dir='/opt/phantom/vault/tmp', text=True) + vault_tmp_dir = os.path.join(paths.PHANTOM_VAULT, rc.RSS_VAULT_TMP_DIRNAME) + fd, path = tempfile.mkstemp(dir=vault_tmp_dir, text=True) os.write(fd, html_file) os.close(fd) @@ -316,7 +318,8 @@ def finalize(self): headers['Referer'] = 'https://127.0.0.1/login' print("Logging into Platform to get the session id") - r2 = requests.post("https://127.0.0.1/login", verify=verify, data=data, headers=headers, timeout=rc.RSS_DEFAULT_TIMEOUT) + r2 = requests.post("https://127.0.0.1/login", verify=verify, data=data, headers=headers, + timeout=rc.RSS_DEFAULT_TIMEOUT) session_id = r2.cookies['sessionid'] except Exception as e: print("Unable to get session id from the platform. Error: " + str(e)) diff --git a/rss_consts.py b/rss_consts.py index c50378a..501e897 100644 --- a/rss_consts.py +++ b/rss_consts.py @@ -18,3 +18,7 @@ RSS_TEST_CONNECTIVITY_FAILED = "Test Connectivity Failed" RSS_ARTIFACTS_CONTAINERS_VALIDATION_FAILED = "Kindly provide a positive integer for max_containers and max_artifacts parameters" RSS_DEFAULT_TIMEOUT = 30 + +# The name of the tmp directory for vault, used to create a path to the vault tmp +# directory as follows: '{phantom_common.paths.PHANTOM_VAULT}/{RSS_VAULT_TMP_DIRNAME}' +RSS_VAULT_TMP_DIRNAME = "tmp"