Skip to content

Commit 3373a99

Browse files
authored
server url must be secure (#41)
* server url must be secure * server url must be secure wording * server url must be secure better error handling
1 parent 38755e0 commit 3373a99

File tree

6 files changed

+24
-7
lines changed

6 files changed

+24
-7
lines changed

globalConfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"meta": {
2424
"name": "bitwarden_event_logs_beta",
2525
"restRoot": "bitwarden_event_logs",
26-
"version": "1.2.0",
26+
"version": "1.2.1",
2727
"displayName": "Bitwarden Event Logs (beta)",
2828
"schemaVersion": "0.0.3",
2929
"_uccVersion": "5.41.0"

package/appserver/static/javascript/views/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ define(["react", "splunkjs/splunk"], function(react, splunk_js_sdk){
7070
),
7171
]),
7272
e("h3", null, "Self-hosted Bitwarden servers may need to reconfigure their installation's URL."),
73+
e("h4", null, "URLs starting with 'http://' is considered insecure and not allowed in Splunk. Please use 'https://' instead."),
7374
e("label", null, [
7475
"Server URL ",
7576
e("br"),

package/appserver/static/javascript/views/setup_page.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ export async function perform(splunk_js_sdk, setup_options) {
5353
{ index: index },
5454
);
5555

56+
if (serverUrl.startsWith("http://")) {
57+
throw new URIError("URLs starting with 'http://' is considered insecure and not allowed in Splunk. " +
58+
"Please use 'https://' instead.");
59+
}
60+
5661
// Update script.conf
5762
const isBitwardenCloud = serverUrl === "https://bitwarden.com" || serverUrl === "bitwarden.com";
5863
const apiUrl = isBitwardenCloud ? "https://api.bitwarden.com" : serverUrl + "/api/";
@@ -73,7 +78,7 @@ export async function perform(splunk_js_sdk, setup_options) {
7378
await Config.reload_splunk_app(service, app_name);
7479
Config.redirect_to_splunk_app_homepage(app_name);
7580
} catch (error) {
76-
console.log('Error:', error);
77-
alert('Error:' + error);
81+
console.log('Error: ', error);
82+
alert('Error: ' + error);
7883
}
7984
}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "bitwarden_event_logs"
3-
version = "1.2.0"
3+
version = "1.2.1"
44
description = "A Splunk app for reporting Bitwarden event logs."
55
authors = [
66
"Bitwarden <[email protected]>"

src/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
BitwardenEventsRequest
99
)
1010
from splunk_api import SplunkApi
11-
from utils import get_logger, set_logging_level, obj_to_json, app_name
11+
from utils import get_logger, set_logging_level, obj_to_json, app_name, secure_url
1212

1313

1414
class Config:
@@ -87,8 +87,8 @@ def __parse_settings_config(cls, settings: Optional[Dict[str, Dict[str, Any]]])
8787

8888
start_date = datetime_from_str(settings_config.get('startDate', None))
8989

90-
return SettingsConfig(api_url=api_url,
91-
identity_url=identity_url,
90+
return SettingsConfig(api_url=secure_url(api_url),
91+
identity_url=secure_url(identity_url),
9292
start_date=start_date,
9393
logging_level=settings_config.get('loggingLevel', None))
9494

src/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99

1010
from mappers import datetime_to_str
1111

12+
from urllib.parse import urlparse
13+
1214
app_name = "bitwarden_event_logs_beta"
1315

16+
1417
def read_session_token() -> str:
1518
session_token = sys.stdin.readline(5000).strip()
1619
if session_token is None or session_token == '':
@@ -54,3 +57,11 @@ def json_serial(obj2):
5457
return json.dumps(obj_dict,
5558
default=json_serial,
5659
separators=(",", ":"))
60+
61+
62+
def secure_url(url: str):
63+
result = urlparse(url, scheme='https')
64+
if result.scheme == 'http':
65+
raise Exception("URLs starting with 'http://' is considered insecure and not allowed in Splunk. "
66+
"Please use 'https://' instead.")
67+
return result.geturl()

0 commit comments

Comments
 (0)