Skip to content

Adding restriction/validation on the allowed domains for LM portal #17

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 1 commit into from
Nov 27, 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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ output {
}
```
You would need either `access_id` and `access_id` both or `bearer_token` for authentication with Logicmonitor.
The portal_domain is the domain of your LM portal. If not set the default is set to `logicmonitor.com`. Eg if your LM portal URL is `https://test.domain.com`, portal_name should be set to `test` and portal_domain to `domain.com`
The portal_domain is the domain of your LM portal. If not set the default is set to `logicmonitor.com`. Eg if your LM portal URL is `https://test.lmgov.us`, portal_name should be set to `test` and portal_domain to `lmgov.us`
The allowed values for portal_domain are ["logicmonitor.com", "lmgov.us", "qa-lmgov.us"]



Expand Down
7 changes: 7 additions & 0 deletions lib/logstash/outputs/lmlogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class InvalidHTTPConfigError < StandardError; end
# For developer debugging.
@@CONSOLE_LOGS = false

ALLOWED_DOMAINS = ["logicmonitor.com", "lmgov.us", "qa-lmgov.us"]

public
def register
@total = 0
Expand All @@ -130,6 +132,11 @@ def register
@portal_domain = "logicmonitor.com"
end

unless ALLOWED_DOMAINS.include?(@portal_domain)
raise LogStash::ConfigurationError, "Invalid portal_domain: #{@portal_domain}. Allowed values are: #{ALLOWED_DOMAINS.join(', ')}"
end
log_debug("Setting LM portal domain ", :portal_domain => portal_domain)

@final_metadata_keys = Hash.new
if @include_metadata_keys.any?
include_metadata_keys.each do | nested_key |
Expand Down
2 changes: 1 addition & 1 deletion lib/logstash/outputs/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module LmLogsLogstashPlugin
VERSION = '2.0.2'
VERSION = '2.0.3'
end