Skip to content

server url must be secure #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion globalConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"meta": {
"name": "bitwarden_event_logs_beta",
"restRoot": "bitwarden_event_logs",
"version": "1.2.0",
"version": "1.2.1",
"displayName": "Bitwarden Event Logs (beta)",
"schemaVersion": "0.0.3",
"_uccVersion": "5.41.0"
Expand Down
1 change: 1 addition & 0 deletions package/appserver/static/javascript/views/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ define(["react", "splunkjs/splunk"], function(react, splunk_js_sdk){
),
]),
e("h3", null, "Self-hosted Bitwarden servers may need to reconfigure their installation's URL."),
e("h4", null, "URLs starting with 'http://' is considered insecure and not allowed in Splunk. Please use 'https://' instead."),
e("label", null, [
"Server URL ",
e("br"),
Expand Down
9 changes: 7 additions & 2 deletions package/appserver/static/javascript/views/setup_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export async function perform(splunk_js_sdk, setup_options) {
{ index: index },
);

if (serverUrl.startsWith("http://")) {
throw new URIError("URLs starting with 'http://' is considered insecure and not allowed in Splunk. " +
"Please use 'https://' instead.");
}

// Update script.conf
const isBitwardenCloud = serverUrl === "https://bitwarden.com" || serverUrl === "bitwarden.com";
const apiUrl = isBitwardenCloud ? "https://api.bitwarden.com" : serverUrl + "/api/";
Expand All @@ -73,7 +78,7 @@ export async function perform(splunk_js_sdk, setup_options) {
await Config.reload_splunk_app(service, app_name);
Config.redirect_to_splunk_app_homepage(app_name);
} catch (error) {
console.log('Error:', error);
alert('Error:' + error);
console.log('Error: ', error);
alert('Error: ' + error);
}
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bitwarden_event_logs"
version = "1.2.0"
version = "1.2.1"
description = "A Splunk app for reporting Bitwarden event logs."
authors = [
"Bitwarden <[email protected]>"
Expand Down
6 changes: 3 additions & 3 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
BitwardenEventsRequest
)
from splunk_api import SplunkApi
from utils import get_logger, set_logging_level, obj_to_json, app_name
from utils import get_logger, set_logging_level, obj_to_json, app_name, secure_url


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

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

return SettingsConfig(api_url=api_url,
identity_url=identity_url,
return SettingsConfig(api_url=secure_url(api_url),
identity_url=secure_url(identity_url),
start_date=start_date,
logging_level=settings_config.get('loggingLevel', None))

Expand Down
11 changes: 11 additions & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

from mappers import datetime_to_str

from urllib.parse import urlparse

app_name = "bitwarden_event_logs_beta"


def read_session_token() -> str:
session_token = sys.stdin.readline(5000).strip()
if session_token is None or session_token == '':
Expand Down Expand Up @@ -54,3 +57,11 @@ def json_serial(obj2):
return json.dumps(obj_dict,
default=json_serial,
separators=(",", ":"))


def secure_url(url: str):
result = urlparse(url, scheme='https')
if result.scheme == 'http':
raise Exception("URLs starting with 'http://' is considered insecure and not allowed in Splunk. "
"Please use 'https://' instead.")
return result.geturl()