mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 14:17:58 -04:00
Fixes #8657 Part 1: API and JavaKeyStore implementation (#8657) Introduces the API to read/write/delete sensitive data from a secure store and includes a Java KeyStore implementation. Note - this commit does NOT integrate with the Logstash configuration or settings. Part 2: Secret Store: SecretStoreFactory, SecureConfig, Obfuscation and X-JVM support (#8659) * Secret Store: SecretStoreFactory, SecureConfig, Obfuscation and X-JVM support * Introduce a SecretStoreFactory to allow runtime definition of SecretStore implementation. * Introduce a SecureConfig to allow simple configuration of different SecretStore implementaiton. * Introduce random default password plus obfuscation. Best attempt at security through obscurity. * Corrections / better support for x-JVM modification. Part 3: Secret Store: SecretStore, SecretStoreFactory, JavaKeystore - refacactor (#8745) * Adds more CRUD like operations for SecretStore API * SecretStoreFactory Mirror API's CRUD operations * Adds 'exists' to API to allow command line warning 'Overwrite ?' * Minor readabiliy Part 4: Integrate secret store with Logstash core (#8905) This change introduces the command line tooling and hooks needed to allow Logstash to use the secret store. This change hooks into the same logic that the does the environment variable substitution. The commnad line mirrors the Elasticsearch command line, and is implemented primarily in Java. Part 5: Hardening and test fixes (this PR) Fixes #8935
43 lines
No EOL
1.6 KiB
Ruby
43 lines
No EOL
1.6 KiB
Ruby
$LOAD_PATH.push(File.expand_path(File.dirname(__FILE__) + "/../../logstash-core/lib"))
|
|
require_relative "../bootstrap/environment"
|
|
LogStash::Bundler.setup!({:without => [:build, :development]})
|
|
|
|
require "logstash/namespace"
|
|
require "logstash-core/logstash-core"
|
|
require "logstash/util/settings_helper"
|
|
require "logstash/util/secretstore"
|
|
|
|
java_import "org.logstash.secret.store.SecretStoreFactory"
|
|
java_import "org.logstash.secret.SecretIdentifier"
|
|
java_import "org.logstash.secret.store.SecureConfig"
|
|
java_import "org.logstash.secret.cli.SecretStoreCli"
|
|
java_import "org.logstash.secret.cli.Terminal"
|
|
|
|
# Thin wrapper to the Java SecretStore Command Line Interface
|
|
class LogStash::SecretStoreCli
|
|
include LogStash::Util::Loggable
|
|
|
|
begin
|
|
index = ARGV.find_index("--path.settings")
|
|
# strip out any path.settings from the command line
|
|
unless index.nil?
|
|
path_settings_value = ARGV.slice!(index, 2)[1]
|
|
if path_settings_value.nil?
|
|
logger.error("''--path.settings' found, but it is empty. Please remove '--path.settings' from arguments or provide a value") if path_settings_value.nil?
|
|
exit 1
|
|
end
|
|
end
|
|
|
|
LogStash::Util::SettingsHelper.pre_process
|
|
LogStash::Util::SettingsHelper.from_yaml(["--path.settings", path_settings_value])
|
|
LogStash::Util::SettingsHelper.post_process
|
|
secure_config = LogStash::Util::SecretStore.get_config
|
|
cli = SecretStoreCli.new(Terminal.new)
|
|
cli.command(ARGV[0], secure_config, ARGV[1])
|
|
exit 0
|
|
rescue => e
|
|
logger.error(e.message, :cause => e.cause, :backtrace => e.backtrace)
|
|
exit 1
|
|
end
|
|
|
|
end |