Skip to content

Commit

Permalink
Bug fix for accessing path to the vault temp directory
Browse files Browse the repository at this point in the history
  • Loading branch information
bbielinski-splunk committed Nov 30, 2023
1 parent 4ffb665 commit f59a333
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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.
limitations under the License.
1 change: 1 addition & 0 deletions release_notes/unreleased.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**Unreleased**
* Updating vault tmp path so that variables are used instead of hardcoded string [PAPP-32424]
7 changes: 5 additions & 2 deletions rss_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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))
Expand Down
4 changes: 4 additions & 0 deletions rss_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit f59a333

Please sign in to comment.