logstash-core 5.6.16-java → 6.0.0.alpha1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/gemspec_jars.rb +4 -7
  3. data/lib/logstash-core/logstash-core.jar +0 -0
  4. data/lib/logstash-core/version.rb +4 -8
  5. data/lib/logstash-core_jars.rb +12 -26
  6. data/lib/logstash/agent.rb +261 -246
  7. data/lib/logstash/api/commands/default_metadata.rb +1 -1
  8. data/lib/logstash/api/commands/hot_threads_reporter.rb +5 -11
  9. data/lib/logstash/api/commands/node.rb +3 -2
  10. data/lib/logstash/api/commands/stats.rb +3 -2
  11. data/lib/logstash/bootstrap_check/bad_java.rb +16 -0
  12. data/lib/logstash/bootstrap_check/bad_ruby.rb +12 -0
  13. data/lib/logstash/bootstrap_check/default_config.rb +17 -0
  14. data/lib/logstash/compiler.rb +38 -0
  15. data/lib/logstash/compiler/lscl.rb +566 -0
  16. data/lib/logstash/compiler/lscl/lscl_grammar.rb +3503 -0
  17. data/lib/logstash/compiler/treetop_monkeypatches.rb +92 -0
  18. data/lib/logstash/config/config_ast.rb +4 -82
  19. data/lib/logstash/config/mixin.rb +73 -41
  20. data/lib/logstash/config/pipeline_config.rb +48 -0
  21. data/lib/logstash/config/source/base.rb +16 -0
  22. data/lib/logstash/config/source/local.rb +215 -0
  23. data/lib/logstash/config/source_loader.rb +125 -0
  24. data/lib/logstash/converge_result.rb +103 -0
  25. data/lib/logstash/environment.rb +6 -19
  26. data/lib/logstash/errors.rb +2 -0
  27. data/lib/logstash/execution_context.rb +4 -7
  28. data/lib/logstash/filter_delegator.rb +6 -9
  29. data/lib/logstash/inputs/base.rb +0 -2
  30. data/lib/logstash/instrument/collector.rb +5 -7
  31. data/lib/logstash/instrument/metric_store.rb +12 -12
  32. data/lib/logstash/instrument/metric_type/mean.rb +0 -5
  33. data/lib/logstash/instrument/namespaced_metric.rb +0 -4
  34. data/lib/logstash/instrument/namespaced_null_metric.rb +0 -4
  35. data/lib/logstash/instrument/null_metric.rb +0 -10
  36. data/lib/logstash/instrument/periodic_poller/cgroup.rb +85 -168
  37. data/lib/logstash/instrument/periodic_poller/jvm.rb +5 -5
  38. data/lib/logstash/instrument/periodic_poller/pq.rb +3 -7
  39. data/lib/logstash/instrument/periodic_pollers.rb +1 -3
  40. data/lib/logstash/instrument/wrapped_write_client.rb +24 -33
  41. data/lib/logstash/logging/logger.rb +15 -47
  42. data/lib/logstash/namespace.rb +0 -1
  43. data/lib/logstash/output_delegator.rb +5 -7
  44. data/lib/logstash/outputs/base.rb +0 -2
  45. data/lib/logstash/pipeline.rb +159 -87
  46. data/lib/logstash/pipeline_action.rb +13 -0
  47. data/lib/logstash/pipeline_action/base.rb +29 -0
  48. data/lib/logstash/pipeline_action/create.rb +47 -0
  49. data/lib/logstash/pipeline_action/reload.rb +48 -0
  50. data/lib/logstash/pipeline_action/stop.rb +23 -0
  51. data/lib/logstash/plugin.rb +0 -1
  52. data/lib/logstash/plugins/hooks_registry.rb +6 -0
  53. data/lib/logstash/plugins/registry.rb +0 -1
  54. data/lib/logstash/program.rb +14 -0
  55. data/lib/logstash/queue_factory.rb +5 -1
  56. data/lib/logstash/runner.rb +58 -80
  57. data/lib/logstash/settings.rb +3 -27
  58. data/lib/logstash/state_resolver.rb +41 -0
  59. data/lib/logstash/util/java_version.rb +6 -0
  60. data/lib/logstash/util/safe_uri.rb +12 -148
  61. data/lib/logstash/util/thread_dump.rb +4 -7
  62. data/lib/logstash/util/wrapped_acked_queue.rb +36 -39
  63. data/lib/logstash/util/wrapped_synchronous_queue.rb +29 -39
  64. data/lib/logstash/version.rb +10 -8
  65. data/locales/en.yml +3 -54
  66. data/logstash-core.gemspec +8 -35
  67. data/spec/{logstash/api/modules → api/lib/api}/logging_spec.rb +10 -1
  68. data/spec/{logstash/api/modules → api/lib/api}/node_plugins_spec.rb +2 -1
  69. data/spec/{logstash/api/modules → api/lib/api}/node_spec.rb +3 -3
  70. data/spec/{logstash/api/modules → api/lib/api}/node_stats_spec.rb +3 -7
  71. data/spec/{logstash/api/modules → api/lib/api}/plugins_spec.rb +3 -4
  72. data/spec/{logstash/api/modules → api/lib/api}/root_spec.rb +2 -2
  73. data/spec/api/lib/api/support/resource_dsl_methods.rb +87 -0
  74. data/spec/{logstash/api/commands/stats_spec.rb → api/lib/commands/stats.rb} +2 -7
  75. data/spec/{logstash/api → api/lib}/errors_spec.rb +1 -1
  76. data/spec/{logstash/api → api/lib}/rack_app_spec.rb +0 -0
  77. data/spec/api/spec_helper.rb +106 -0
  78. data/spec/logstash/agent/converge_spec.rb +286 -0
  79. data/spec/logstash/agent/metrics_spec.rb +244 -0
  80. data/spec/logstash/agent_spec.rb +213 -225
  81. data/spec/logstash/compiler/compiler_spec.rb +584 -0
  82. data/spec/logstash/config/config_ast_spec.rb +8 -47
  83. data/spec/logstash/config/mixin_spec.rb +2 -42
  84. data/spec/logstash/config/pipeline_config_spec.rb +75 -0
  85. data/spec/logstash/config/source/local_spec.rb +395 -0
  86. data/spec/logstash/config/source_loader_spec.rb +122 -0
  87. data/spec/logstash/converge_result_spec.rb +179 -0
  88. data/spec/logstash/event_spec.rb +0 -66
  89. data/spec/logstash/execution_context_spec.rb +8 -12
  90. data/spec/logstash/filter_delegator_spec.rb +12 -24
  91. data/spec/logstash/inputs/base_spec.rb +7 -5
  92. data/spec/logstash/instrument/periodic_poller/cgroup_spec.rb +92 -225
  93. data/spec/logstash/instrument/periodic_poller/jvm_spec.rb +1 -1
  94. data/spec/logstash/instrument/periodic_poller/os_spec.rb +32 -29
  95. data/spec/logstash/instrument/wrapped_write_client_spec.rb +33 -33
  96. data/spec/logstash/legacy_ruby_event_spec.rb +13 -4
  97. data/spec/logstash/output_delegator_spec.rb +11 -20
  98. data/spec/logstash/outputs/base_spec.rb +7 -5
  99. data/spec/logstash/pipeline_action/create_spec.rb +83 -0
  100. data/spec/logstash/pipeline_action/reload_spec.rb +83 -0
  101. data/spec/logstash/pipeline_action/stop_spec.rb +37 -0
  102. data/spec/logstash/pipeline_pq_file_spec.rb +1 -1
  103. data/spec/logstash/pipeline_spec.rb +81 -137
  104. data/spec/logstash/plugin_spec.rb +2 -1
  105. data/spec/logstash/plugins/hooks_registry_spec.rb +6 -0
  106. data/spec/logstash/queue_factory_spec.rb +13 -1
  107. data/spec/logstash/runner_spec.rb +29 -140
  108. data/spec/logstash/settings/writable_directory_spec.rb +10 -13
  109. data/spec/logstash/settings_spec.rb +0 -91
  110. data/spec/logstash/state_resolver_spec.rb +156 -0
  111. data/spec/logstash/timestamp_spec.rb +2 -6
  112. data/spec/logstash/util/java_version_spec.rb +22 -0
  113. data/spec/logstash/util/safe_uri_spec.rb +0 -56
  114. data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +22 -0
  115. data/spec/support/helpers.rb +9 -11
  116. data/spec/support/matchers.rb +96 -6
  117. data/spec/support/mocks_classes.rb +80 -0
  118. data/spec/support/shared_contexts.rb +2 -27
  119. metadata +100 -149
  120. data/lib/logstash/config/loader.rb +0 -107
  121. data/lib/logstash/config/modules_common.rb +0 -103
  122. data/lib/logstash/config/source/modules.rb +0 -55
  123. data/lib/logstash/config/string_escape.rb +0 -27
  124. data/lib/logstash/dependency_report.rb +0 -131
  125. data/lib/logstash/dependency_report_runner.rb +0 -17
  126. data/lib/logstash/elasticsearch_client.rb +0 -142
  127. data/lib/logstash/instrument/global_metrics.rb +0 -13
  128. data/lib/logstash/instrument/periodic_poller/dlq.rb +0 -24
  129. data/lib/logstash/modules/cli_parser.rb +0 -74
  130. data/lib/logstash/modules/elasticsearch_config.rb +0 -22
  131. data/lib/logstash/modules/elasticsearch_importer.rb +0 -37
  132. data/lib/logstash/modules/elasticsearch_resource.rb +0 -10
  133. data/lib/logstash/modules/file_reader.rb +0 -36
  134. data/lib/logstash/modules/kibana_base.rb +0 -24
  135. data/lib/logstash/modules/kibana_client.rb +0 -124
  136. data/lib/logstash/modules/kibana_config.rb +0 -105
  137. data/lib/logstash/modules/kibana_dashboards.rb +0 -36
  138. data/lib/logstash/modules/kibana_importer.rb +0 -17
  139. data/lib/logstash/modules/kibana_resource.rb +0 -10
  140. data/lib/logstash/modules/kibana_settings.rb +0 -40
  141. data/lib/logstash/modules/logstash_config.rb +0 -120
  142. data/lib/logstash/modules/resource_base.rb +0 -38
  143. data/lib/logstash/modules/scaffold.rb +0 -52
  144. data/lib/logstash/modules/settings_merger.rb +0 -23
  145. data/lib/logstash/modules/util.rb +0 -17
  146. data/lib/logstash/util/dead_letter_queue_manager.rb +0 -61
  147. data/lib/logstash/util/environment_variables.rb +0 -43
  148. data/spec/logstash/config/loader_spec.rb +0 -38
  149. data/spec/logstash/config/string_escape_spec.rb +0 -24
  150. data/spec/logstash/instrument/periodic_poller/dlq_spec.rb +0 -17
  151. data/spec/logstash/modules/logstash_config_spec.rb +0 -56
  152. data/spec/logstash/modules/scaffold_spec.rb +0 -234
  153. data/spec/logstash/pipeline_dlq_commit_spec.rb +0 -109
  154. data/spec/logstash/settings/splittable_string_array_spec.rb +0 -51
  155. data/spec/logstash/util/wrapped_acked_queue_spec.rb +0 -49
  156. data/versions-gem-copy.yml +0 -12
@@ -1,107 +0,0 @@
1
- require "logstash/config/defaults"
2
-
3
- module LogStash; module Config; class Loader
4
- def initialize(logger)
5
- @logger = logger
6
- @config_debug = LogStash::SETTINGS.get_value("config.debug")
7
- end
8
-
9
- def format_config(config_path, config_string)
10
- config_string = config_string.to_s
11
- if config_path
12
- # Append the config string.
13
- # This allows users to provide both -f and -e flags. The combination
14
- # is rare, but useful for debugging.
15
- loaded_config = load_config(config_path)
16
- if loaded_config.empty? && config_string.empty?
17
- # If loaded config from `-f` is empty *and* if config string is empty we raise an error
18
- fail(I18n.t("logstash.runner.configuration.file-not-found", :path => config_path))
19
- end
20
-
21
- # tell the user we are merging, otherwise it is very confusing
22
- if !loaded_config.empty? && !config_string.empty?
23
- @logger.info("Created final config by merging config string and config path", :path => config_path)
24
- end
25
-
26
- config_string = config_string + loaded_config
27
- else
28
- # include a default stdin input if no inputs given
29
- if config_string !~ /input *{/
30
- config_string += LogStash::Config::Defaults.input
31
- end
32
- # include a default stdout output if no outputs given
33
- if config_string !~ /output *{/
34
- config_string += LogStash::Config::Defaults.output
35
- end
36
- end
37
- config_string
38
- end
39
-
40
- def load_config(path)
41
- begin
42
- uri = URI.parse(path)
43
-
44
- case uri.scheme
45
- when nil then
46
- local_config(path)
47
- when /http/ then
48
- fetch_config(uri)
49
- when "file" then
50
- local_config(uri.path)
51
- else
52
- fail(I18n.t("logstash.runner.configuration.scheme-not-supported", :path => path))
53
- end
54
- rescue URI::InvalidURIError
55
- # fallback for windows.
56
- # if the parsing of the file failed we assume we can reach it locally.
57
- # some relative path on windows arent parsed correctly (.\logstash.conf)
58
- local_config(path)
59
- end
60
- end
61
-
62
- def local_config(path)
63
- path = ::File.expand_path(path)
64
- path = ::File.join(path, "*") if ::File.directory?(path)
65
-
66
- config = ""
67
- if Dir.glob(path).length == 0
68
- @logger.info("No config files found in path", :path => path)
69
- return config
70
- end
71
-
72
- encoding_issue_files = []
73
- Dir.glob(path).sort.each do |file|
74
- next unless ::File.file?(file)
75
- if file.match(/~$/)
76
- @logger.debug("NOT reading config file because it is a temp file", :config_file => file)
77
- next
78
- end
79
- @logger.debug("Reading config file", :config_file => file)
80
- cfg = ::File.read(file)
81
- if !cfg.ascii_only? && !cfg.valid_encoding?
82
- encoding_issue_files << file
83
- end
84
- config << cfg + "\n"
85
- if @config_debug
86
- @logger.debug? && @logger.debug("\nThe following is the content of a file", :config_file => file.to_s)
87
- @logger.debug? && @logger.debug("\n" + cfg + "\n\n")
88
- end
89
- end
90
- if encoding_issue_files.any?
91
- fail("The following config files contains non-ascii characters but are not UTF-8 encoded #{encoding_issue_files}")
92
- end
93
- if @config_debug
94
- @logger.debug? && @logger.debug("\nThe following is the merged configuration")
95
- @logger.debug? && @logger.debug("\n" + config + "\n\n")
96
- end
97
- return config
98
- end # def load_config
99
-
100
- def fetch_config(uri)
101
- begin
102
- Net::HTTP.get(uri) + "\n"
103
- rescue Exception => e
104
- fail(I18n.t("logstash.runner.configuration.fetch-failed", :path => uri.to_s, :message => e.message))
105
- end
106
- end
107
- end end end
@@ -1,103 +0,0 @@
1
- # encoding: utf-8
2
- require "logstash/util/loggable"
3
- require "logstash/elasticsearch_client"
4
- require "logstash/modules/kibana_client"
5
- require "logstash/modules/elasticsearch_importer"
6
- require "logstash/modules/kibana_importer"
7
- require "logstash/modules/settings_merger"
8
- require "logstash/errors"
9
-
10
- module LogStash module Config
11
- class ModulesCommon # extracted here for bwc with 5.x
12
- include LogStash::Util::Loggable
13
-
14
- MODULES_MAX_PIPELINES = 1
15
-
16
- def self.pipeline_configs(settings)
17
- pipelines = []
18
- plugin_modules = LogStash::PLUGIN_REGISTRY.plugins_with_type(:modules)
19
-
20
- cli_settings = settings.get("modules.cli")
21
- yml_settings = settings.get("modules")
22
-
23
- modules_array = if !(cli_settings.empty? && yml_settings.empty?)
24
- LogStash::Modules::SettingsMerger.merge(cli_settings, yml_settings)
25
- elsif cli_settings.empty?
26
- yml_settings
27
- else
28
- cli_settings
29
- end
30
-
31
- if modules_array.empty?
32
- # no specifed modules
33
- return pipelines
34
- end
35
- logger.debug("Specified modules", :modules_array => modules_array.to_s)
36
-
37
- module_names = modules_array.collect {|module_hash| module_hash["name"]}
38
- if module_names.size > MODULES_MAX_PIPELINES
39
- error_message = I18n.t("logstash.modules.configuration.modules-too-many-specified", :max => MODULES_MAX_PIPELINES, :specified_modules => module_names.join(', '))
40
- raise LogStash::ConfigLoadingError, error_message
41
- end
42
-
43
- if module_names.length > module_names.uniq.length
44
- duplicate_modules = module_names.group_by(&:to_s).select { |_,v| v.size > 1 }.keys
45
- raise LogStash::ConfigLoadingError, I18n.t("logstash.modules.configuration.modules-must-be-unique", :duplicate_modules => duplicate_modules)
46
- end
47
-
48
- available_module_names = plugin_modules.map(&:module_name)
49
- specified_and_available_names = module_names & available_module_names
50
-
51
- if (specified_and_available_names).empty?
52
- i18n_opts = {:specified_modules => module_names, :available_modules => available_module_names}
53
- raise LogStash::ConfigLoadingError, I18n.t("logstash.modules.configuration.modules-unavailable", i18n_opts)
54
- end
55
-
56
- specified_and_available_names.each do |module_name|
57
- connect_fail_args = {}
58
- begin
59
- module_settings = settings.clone
60
-
61
- module_hash = modules_array.find {|m| m["name"] == module_name}
62
- current_module = plugin_modules.find { |allmodules| allmodules.module_name == module_name }
63
-
64
- alt_name = "module-#{module_name}"
65
- pipeline_id = alt_name
66
- module_settings.set("pipeline.id", pipeline_id)
67
- current_module.with_settings(module_hash)
68
- config_test = settings.get("config.test_and_exit")
69
- modul_setup = settings.get("modules_setup")
70
- # Only import data if it's not a config test and --setup is true
71
- if !config_test && modul_setup
72
- esclient = LogStash::ElasticsearchClient.build(module_hash)
73
- kbnclient = LogStash::Modules::KibanaClient.new(module_hash)
74
- esconnected = esclient.can_connect?
75
- kbnconnected = kbnclient.can_connect?
76
- if esconnected && kbnconnected
77
- current_module.add_kibana_version(kbnclient.version_parts)
78
- current_module.import(
79
- LogStash::Modules::ElasticsearchImporter.new(esclient),
80
- LogStash::Modules::KibanaImporter.new(kbnclient)
81
- )
82
- else
83
- connect_fail_args[:module_name] = module_name
84
- connect_fail_args[:elasticsearch_hosts] = esclient.host_settings
85
- connect_fail_args[:kibana_hosts] = kbnclient.host_settings
86
- end
87
- end
88
- config_string = current_module.config_string
89
- pipelines << {"pipeline_id" => pipeline_id, "alt_name" => alt_name, "config_string" => config_string, "settings" => module_settings}
90
- rescue => e
91
- new_error = LogStash::ConfigLoadingError.new(I18n.t("logstash.modules.configuration.parse-failed", :error => e.message))
92
- new_error.set_backtrace(e.backtrace)
93
- raise new_error
94
- end
95
-
96
- if !connect_fail_args.empty?
97
- raise LogStash::ConfigLoadingError, I18n.t("logstash.modules.configuration.elasticsearch_connection_failed", connect_fail_args)
98
- end
99
- end
100
- pipelines
101
- end
102
- end
103
- end end
@@ -1,55 +0,0 @@
1
- # encoding: utf-8
2
- require "logstash/config/source/base"
3
- require "logstash/config/modules_common"
4
- require "logstash/config/pipeline_config"
5
- require "logstash/util/loggable"
6
- require "logstash/errors"
7
-
8
- module LogStash module Config module Source
9
- class Modules < Base
10
- include LogStash::Util::Loggable
11
- def pipeline_configs
12
- if config_conflict? # double check
13
- raise ConfigurationError, @conflict_messages.join(", ")
14
- end
15
-
16
- pipelines = LogStash::Config::ModulesCommon.pipeline_configs(@settings)
17
- pipelines.map do |hash|
18
- PipelineConfig.new(self, hash["pipeline_id"].to_sym,
19
- org.logstash.common.SourceWithMetadata.new("module", hash["alt_name"], 0, 0, hash["config_string"]),
20
- hash["settings"])
21
- end
22
- end
23
-
24
- def match?
25
- # see basic settings predicates and getters defined in the base class
26
- (modules_cli? || modules?) && !(config_string? || config_path?) && !automatic_reload_with_modules?
27
- end
28
-
29
- def config_conflict?
30
- @conflict_messages.clear
31
- # Make note that if modules are configured in both cli and logstash.yml that cli module
32
- # settings will overwrite the logstash.yml modules settings
33
- if modules_cli? && modules?
34
- logger.info(I18n.t("logstash.runner.cli-module-override"))
35
- end
36
-
37
- if automatic_reload_with_modules?
38
- @conflict_messages << I18n.t("logstash.runner.reload-with-modules")
39
- end
40
-
41
- # Check if config (-f or -e) and modules are configured
42
- if (modules_cli? || modules?) && (config_string? || config_path?)
43
- @conflict_messages << I18n.t("logstash.runner.config-module-exclusive")
44
- end
45
-
46
- @conflict_messages.any?
47
- end
48
-
49
- private
50
-
51
- def automatic_reload_with_modules?
52
- (modules_cli? || modules?) && config_reload_automatic?
53
- end
54
- end
55
- end end end
@@ -1,27 +0,0 @@
1
-
2
-
3
- module LogStash; module Config; module StringEscape
4
- class << self
5
- def process_escapes(input)
6
- input.gsub(/\\./) do |value|
7
- process(value)
8
- end
9
- end
10
-
11
- private
12
- def process(value)
13
- case value[1]
14
- when '"', "'", "\\"
15
- value[1]
16
- when "n"
17
- "\n"
18
- when "r"
19
- "\r"
20
- when "t"
21
- "\t"
22
- else
23
- value
24
- end
25
- end
26
- end
27
- end end end
@@ -1,131 +0,0 @@
1
- # encoding: utf-8
2
- Thread.abort_on_exception = true
3
- Encoding.default_external = Encoding::UTF_8
4
- $DEBUGLIST = (ENV["DEBUG"] || "").split(",")
5
-
6
- require "clamp"
7
- require "logstash/namespace"
8
- require "rubygems"
9
- require "jars/gemspec_artifacts"
10
-
11
- class LogStash::DependencyReport < Clamp::Command
12
- option [ "--csv" ], "OUTPUT_PATH", "The path to write the dependency report in csv format.",
13
- :required => true, :attribute_name => :output_path
14
-
15
- def execute
16
- require "csv"
17
- CSV.open(output_path, "wb", :headers => [ "name", "version", "url", "license" ], :write_headers => true) do |csv|
18
- puts "Finding gem dependencies"
19
- gems.each { |d| csv << d }
20
- puts "Finding java/jar dependencies"
21
- jars.each { |d| csv << d }
22
- end
23
-
24
- # Copy in COPYING.csv which is a best-effort, hand-maintained file of dependency license information.
25
- File.open(output_path, "a+") do |file|
26
- extra = File.join(File.dirname(__FILE__), "..", "..", "..", "COPYING.csv")
27
- file.write(IO.read(extra))
28
- end
29
- nil
30
- end
31
-
32
- def gems
33
- # @mgreau requested `logstash-*` dependencies be removed from this list:
34
- # https://github.com/elastic/logstash/pull/8837#issuecomment-351859433
35
- Gem::Specification.reject { |g| g.name =~ /^logstash-/ }.collect do |gem|
36
- licenses = ("UNKNOWN" if gem.licenses.empty?) || (gem.licenses.map { |l| SPDX.map(l) }.join("|") if !gem.licenses.empty?)
37
- [gem.name, gem.version.to_s, gem.homepage, licenses]
38
- end
39
- end
40
-
41
- def jars
42
- jars = []
43
- # For any gems with jar dependencies,
44
- # Look at META-INF/MANIFEST.MF for any jars in each gem
45
- # Note any important details.
46
- Gem::Specification.select { |g| g.requirements && g.requirements.any? { |r| r =~ /^jar / } }.collect do |gem|
47
-
48
- # Where is the gem installed
49
- root = gem.full_gem_path
50
-
51
- Dir.glob(File.join(root, "**", "*.jar")).collect do |path|
52
- jar = java.util.jar.JarFile.new(path)
53
- manifest = jar.getManifest
54
-
55
- pom_entries = jar.entries.select { |t| t.getName.start_with?("META-INF/maven/") && t.getName.end_with?("/pom.properties") }
56
-
57
- # Some jar files have multiple maven pom.properties files. It is unclear how to know what is correct?
58
- # TODO(sissel): Maybe we should use all pom.properties files? None of the pom.properties/pom.xml files have license information, though.
59
- # TODO(sissel): In some cases, there are META-INF/COPYING and
60
- # META-INF/NOTICE.txt files? Can we use these somehow? There is no
61
- # common syntax for parsing these files, though...
62
- pom_map = if pom_entries.count == 1
63
- pom_in = jar.getInputStream(pom_entries.first)
64
- pom_content = pom_in.available.times.collect { pom_in.read }.pack("C*")
65
- # Split non-comment lines by `key=val` into a map { key => val }
66
- Hash[pom_content.split(/\r?\n/).grep(/^[^#]/).map { |line| line.split("=", 2) }]
67
- else
68
- {}
69
- end
70
-
71
- next if manifest.nil?
72
- # convert manifest attributes to a map w/ keys .to_s
73
- # without this, the attribute keys will be `Object#inspect` values
74
- # like #<Java::JavaUtilJar::Attributes::Name0xabcdef0>
75
- attributes = Hash[manifest.getMainAttributes.map { |k,v| [k.to_s, v] }]
76
-
77
- begin
78
- # Prefer the maven/pom groupId when it is available.
79
- artifact = pom_map.fetch("artifactId", attributes.fetch("Implementation-Title"))
80
- group = pom_map.fetch("groupId", attributes.fetch("Implementation-Vendor-Id"))
81
- jars << [
82
- group + ":" + artifact,
83
- attributes.fetch("Bundle-Version"),
84
- attributes.fetch("Bundle-DocURL"),
85
- SPDX.map(attributes.fetch("Bundle-License")),
86
- ]
87
- rescue KeyError => e
88
- # The jar is missing a required manifest field, it may not have any useful manifest data.
89
- # Ignore it and move on.
90
- end
91
- end
92
- end
93
- jars.uniq.sort
94
- end
95
-
96
- module SPDX
97
- # This is a non-exhaustive, best effort list of licenses as they map to SPDX identifiers.
98
- ALIASES = {
99
- "Apache-2.0" => [
100
- "Apache 2",
101
- "apache-2.0",
102
- "Apache 2.0",
103
- "Apache License (2.0)",
104
- "Apache License 2.0",
105
- "https://www.apache.org/licenses/LICENSE-2.0.txt",
106
- "http://www.apache.org/licenses/LICENSE-2.0.txt",
107
- ],
108
- "Artistic-2.0" => [
109
- "Artistic 2.0"
110
- ],
111
- "BSD-2-Clause" => [
112
- "2-clause BSDL",
113
- "2-clause"
114
- ],
115
- "GPL-2.0" => [
116
- "GPL-2"
117
- ]
118
- }
119
-
120
- # Get a map of name => spdx
121
- MAP_APACHE2 = Hash[ALIASES.map { |spdx,aliases| aliases.map { |value| [value, spdx] } }[0]]
122
- MAP_ARTISTIC2 = Hash[ALIASES.map { |spdx,aliases| aliases.map { |value| [value, spdx] } }[1]]
123
- MAP_BSD = Hash[ALIASES.map { |spdx,aliases| aliases.map { |value| [value, spdx] } }[2]]
124
- MAP_GPL2 = Hash[ALIASES.map { |spdx,aliases| aliases.map { |value| [value, spdx] } }[3]]
125
-
126
- module_function
127
- def map(value)
128
- MAP_APACHE2[value] || MAP_ARTISTIC2[value] || MAP_BSD[value] || MAP_GPL2[value] || value
129
- end
130
- end
131
- end
@@ -1,17 +0,0 @@
1
- require_relative "../../../lib/bootstrap/environment"
2
-
3
- if $0 == __FILE__
4
- begin
5
- LogStash::Bundler.setup!({:without => [:build, :development]})
6
- rescue => Bundler::GemfileNotFound
7
- $stderr.puts("No Gemfile found. Maybe you need to run `rake artifact:tar`?")
8
- raise
9
- end
10
-
11
- require "logstash/namespace"
12
- require_relative "../../../lib/bootstrap/patches/jar_dependencies"
13
- require "logstash/dependency_report"
14
-
15
- exit_status = LogStash::DependencyReport.run
16
- exit(exit_status || 0)
17
- end
@@ -1,142 +0,0 @@
1
- # encoding: utf-8
2
- require "logstash/namespace"
3
- require "logstash/logging"
4
- require "elasticsearch"
5
- require "elasticsearch/transport/transport/http/manticore"
6
-
7
- module LogStash class ElasticsearchClient
8
- include LogStash::Util::Loggable
9
-
10
- class Response
11
- # duplicated here from Elasticsearch::Transport::Transport::Response
12
- # to create a normalised response across different client IMPL
13
- attr_reader :status, :body, :headers
14
- def initialize(status, body, headers={})
15
- @status, @body, @headers = status, body, headers
16
- @body = body.force_encoding('UTF-8') if body.respond_to?(:force_encoding)
17
- end
18
- end
19
-
20
- def self.build(settings)
21
- new(RubyClient.new(settings, logger))
22
- end
23
-
24
- class RubyClient
25
- def initialize(settings, logger)
26
- @settings = settings
27
- @logger = logger
28
- @client_args = client_args
29
-
30
- ssl_options = {}
31
-
32
- if @settings["var.elasticsearch.ssl.enabled"] == "true"
33
- ssl_options[:verify] = @settings.fetch("var.elasticsearch.ssl.verification_mode", true)
34
- ssl_options[:ca_file] = @settings.fetch("var.elasticsearch.ssl.certificate_authority", nil)
35
- ssl_options[:client_cert] = @settings.fetch("var.elasticsearch.ssl.certificate", nil)
36
- ssl_options[:client_key] = @settings.fetch("var.elasticsearch.ssl.key", nil)
37
- end
38
-
39
- @client_args[:ssl] = ssl_options
40
-
41
- username = @settings["var.elasticsearch.username"]
42
- password = @settings["var.elasticsearch.password"]
43
- if username
44
- @client_args[:transport_options] = { :headers => { "Authorization" => 'Basic ' + Base64.encode64( "#{username}:#{password}" ).chomp } }
45
- end
46
-
47
- @client = Elasticsearch::Client.new(@client_args)
48
- end
49
-
50
- def can_connect?
51
- begin
52
- head(SecureRandom.hex(32).prepend('_'))
53
- rescue Elasticsearch::Transport::Transport::Errors::BadRequest
54
- true
55
- rescue Manticore::SocketException
56
- false
57
- end
58
- end
59
-
60
- def host_settings
61
- @client_args[:hosts]
62
- end
63
-
64
- def delete(path)
65
- begin
66
- normalize_response(@client.perform_request('DELETE', path, {}, nil))
67
- rescue Exception => e
68
- if is_404_error?(e)
69
- Response.new(404, "", {})
70
- else
71
- raise e
72
- end
73
- end
74
- end
75
-
76
- def put(path, content)
77
- normalize_response(@client.perform_request('PUT', path, {}, content))
78
- end
79
-
80
- def head(path)
81
- begin
82
- normalize_response(@client.perform_request('HEAD', path, {}, nil))
83
- rescue Exception => e
84
- if is_404_error?(e)
85
- Response.new(404, "", {})
86
- else
87
- raise e
88
- end
89
- end
90
- end
91
-
92
- private
93
-
94
- def is_404_error?(error)
95
- error.class.to_s =~ /NotFound/ || error.message =~ /Not\s*Found|404/i
96
- end
97
-
98
- def normalize_response(response)
99
- Response.new(response.status, response.body, response.headers)
100
- end
101
-
102
- def client_args
103
- {
104
- :transport_class => Elasticsearch::Transport::Transport::HTTP::Manticore,
105
- :hosts => [*unpack_hosts],
106
- # :logger => @logger, # silence the client logging
107
- }
108
- end
109
-
110
- def unpack_hosts
111
- setting = @settings.fetch("var.elasticsearch.hosts", "localhost:9200")
112
- if setting.is_a?(String)
113
- return setting.split(',').map(&:strip)
114
- end
115
- setting
116
- end
117
- end
118
-
119
- def initialize(client)
120
- @client = client
121
- end
122
-
123
- def delete(path)
124
- @client.delete(path)
125
- end
126
-
127
- def put(path, content)
128
- @client.put(path, content)
129
- end
130
-
131
- def head(path)
132
- @client.head(path)
133
- end
134
-
135
- def can_connect?
136
- @client.can_connect?
137
- end
138
-
139
- def host_settings
140
- @client.host_settings
141
- end
142
- end end