appmap 0.66.1 → 0.66.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 555d4e55395c91b5beff0d992e97dc2db617db875473db4e2adc7521e902ad74
4
- data.tar.gz: d2c75227d4d600d702d818eaf3416610f9200969c458acc0362d1ddd3f4360d3
3
+ metadata.gz: 2dd5295e0bbe8c9a4281b27bd712b61640672e93a03d6c3e31af3e201c9ca592
4
+ data.tar.gz: 8fb74d28bb2367918831c6d3af029440591da8ee694f1645fc2ef8baf5b28b60
5
5
  SHA512:
6
- metadata.gz: 681aa6437aa1632ada6f67be308953936dbda5bd8c383049e81b73ada9c8999c9e8222d5204a1195042ae73d1c1f0b37d41009d1774208724a20726acd5a0d6f
7
- data.tar.gz: 27587ac886bd8467604278fb9918f4b420f3f8642bb5b42e507f094a1d41365395e06bbd70ddaea94529afef5ecab2343f955078c0e248da46885718f31e79db
6
+ metadata.gz: ef07a3169b2d1f4dcabb406296275506250840cc767440b60a106f48ad5ee251017a9e9f7cd9769e7d0d133a3b9704f76bfef571fd69feef85163979cec80a80
7
+ data.tar.gz: 34c9c18e230dc46d868b759422eb7aeaba79b99fd1cca610bbc1a8bdc70a7cfa18e34a064a43cc50847c8c452bf267a6003a5b98cb3a2e2e8fa40028552fe112
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ dist: bionic
2
3
 
3
4
  rbenv:
4
5
  - 2.6
@@ -15,6 +16,7 @@ services:
15
16
  - docker
16
17
 
17
18
  before_install:
19
+ - sudo apt-get update && sudo apt-get install apt-transport-https ca-certificates -y && sudo update-ca-certificates
18
20
  # see https://blog.travis-ci.com/docker-rate-limits
19
21
  # and also https://www.docker.com/blog/what-you-need-to-know-about-upcoming-docker-hub-rate-limiting/
20
22
  # if we do not use authorized account,
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [0.66.2](https://github.com/applandinc/appmap-ruby/compare/v0.66.1...v0.66.2) (2021-10-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * fix Travis for Ruby 3.0 ([8ec7359](https://github.com/applandinc/appmap-ruby/commit/8ec7359287f5b204ae9fb0724d8b683adfb79df5))
7
+ * Fix warning of circular import ([84d456d](https://github.com/applandinc/appmap-ruby/commit/84d456d8ac26ef3fc7a81ca6517e4363aac9916d))
8
+ * Properly handle headers which aren't mangled by Rack ([8e78e13](https://github.com/applandinc/appmap-ruby/commit/8e78e138776cb563f984e3592cf5024af16da2b7))
9
+ * replace deprecated File.exists? method ([80ce5b5](https://github.com/applandinc/appmap-ruby/commit/80ce5b59fd010a806ca6320365f453f1e74f095d))
10
+ * Validate presence package configuration ([f478d6b](https://github.com/applandinc/appmap-ruby/commit/f478d6b60a786608c21217755cec9a8185e084d3))
11
+
1
12
  ## [0.66.1](https://github.com/applandinc/appmap-ruby/compare/v0.66.0...v0.66.1) (2021-09-29)
2
13
 
3
14
 
data/lib/appmap/config.rb CHANGED
@@ -176,8 +176,8 @@ module AppMap
176
176
  package_hooks('actionpack',
177
177
  [
178
178
  method_hook('ActionDispatch::Request::Session', %i[[] dig values fetch], %w[http.session.read]),
179
- method_hook('ActionDispatch::Request::Session', %i[destroy[]= clear update delete merge], %w[http.session.write]),
180
- method_hook('ActionDispatch::Cookies::CookieJar', %i[[]= clear update delete recycle], %w[http.session.read]),
179
+ method_hook('ActionDispatch::Request::Session', %i[destroy []= clear update delete merge], %w[http.session.write]),
180
+ method_hook('ActionDispatch::Cookies::CookieJar', %i[[] fetch], %w[http.session.read]),
181
181
  method_hook('ActionDispatch::Cookies::CookieJar', %i[[]= clear update delete recycle], %w[http.session.write]),
182
182
  method_hook('ActionDispatch::Cookies::EncryptedCookieJar', %i[[]= clear update delete recycle], %w[http.cookie crypto.encrypt])
183
183
  ],
@@ -287,7 +287,7 @@ module AppMap
287
287
  LOGO
288
288
  end
289
289
 
290
- config_present = true if File.exists?(config_file_name)
290
+ config_present = true if File.exist?(config_file_name)
291
291
 
292
292
  config_data = if config_present
293
293
  YAML.safe_load(::File.read(config_file_name))
@@ -360,6 +360,7 @@ module AppMap
360
360
  gem = package['gem']
361
361
  path = package['path']
362
362
  raise %q(AppMap config 'package' element should specify 'gem' or 'path', not both) if gem && path
363
+ raise %q(AppMap config 'package' element should specify 'gem' or 'path') unless gem || path
363
364
 
364
365
  if gem
365
366
  shallow = package['shallow']
@@ -63,7 +63,7 @@ module AppMap
63
63
  removed = []
64
64
  out_of_date_appmaps.each do |appmap_path|
65
65
  mtime_path = File.join(appmap_path, 'mtime')
66
- next unless File.exists?(mtime_path)
66
+ next unless File.exist?(mtime_path)
67
67
 
68
68
  appmap_mtime = File.read(mtime_path).to_i
69
69
  if appmap_mtime < since_ms
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'appmap'
4
-
5
3
  module AppMap
6
4
  module Depends
7
5
  class Configuration
@@ -16,7 +16,7 @@ module AppMap
16
16
  def delete_appmap(appmap_path)
17
17
  FileUtils.rm_rf(appmap_path)
18
18
  appmap_file_path = [ appmap_path, 'appmap.json' ].join('.')
19
- File.unlink(appmap_file_path) if File.exists?(appmap_file_path)
19
+ File.unlink(appmap_file_path) if File.exist?(appmap_file_path)
20
20
  rescue
21
21
  warn "Unable to delete AppMap: #{$!}"
22
22
  end
@@ -27,7 +27,7 @@ module AppMap
27
27
 
28
28
  self.request_method = request.method
29
29
  self.url = url
30
- self.headers = AppMap::Util.select_headers(NetHTTP.request_headers(request))
30
+ self.headers = NetHTTP.copy_headers(request)
31
31
  self.params = Rack::Utils.parse_nested_query(query)
32
32
  end
33
33
 
@@ -55,7 +55,7 @@ module AppMap
55
55
  end
56
56
 
57
57
  class HTTPClientResponse < AppMap::Event::MethodReturnIgnoreValue
58
- attr_accessor :status, :mime_type, :headers
58
+ attr_accessor :status, :headers
59
59
 
60
60
  def initialize(response, parent_id, elapsed)
61
61
  super AppMap::Event.next_id_counter, :return, Thread.current.object_id
@@ -63,14 +63,13 @@ module AppMap
63
63
  self.status = response.code.to_i
64
64
  self.parent_id = parent_id
65
65
  self.elapsed = elapsed
66
- self.headers = AppMap::Util.select_headers(NetHTTP.response_headers(response))
66
+ self.headers = NetHTTP.copy_headers(response)
67
67
  end
68
68
 
69
69
  def to_h
70
70
  super.tap do |h|
71
71
  h[:http_client_response] = {
72
72
  status_code: status,
73
- mime_type: mime_type,
74
73
  headers: headers
75
74
  }.compact
76
75
  end
@@ -79,17 +78,15 @@ module AppMap
79
78
 
80
79
  class NetHTTP
81
80
  class << self
82
- def request_headers(request)
81
+ def copy_headers(obj)
83
82
  {}.tap do |headers|
84
- request.each_header do |k,v|
85
- key = [ 'HTTP', Util.underscore(k).upcase ].join('_')
86
- headers[key] = v
83
+ obj.each_header do |key, value|
84
+ key = key.split('-').map(&:capitalize).join('-')
85
+ headers[key] = value
87
86
  end
88
87
  end
89
88
  end
90
-
91
- alias response_headers request_headers
92
-
89
+
93
90
  def handle_call(defined_class, hook_method, receiver, args)
94
91
  # request will call itself again in a start block if it's not already started.
95
92
  return unless receiver.started?
@@ -9,16 +9,14 @@ module AppMap
9
9
  module Rails
10
10
  module RequestHandler
11
11
  class HTTPServerRequest < AppMap::Event::MethodEvent
12
- attr_accessor :normalized_path_info, :request_method, :path_info, :params, :mime_type, :headers, :authorization
12
+ attr_accessor :normalized_path_info, :request_method, :path_info, :params, :headers
13
13
 
14
14
  def initialize(request)
15
15
  super AppMap::Event.next_id_counter, :call, Thread.current.object_id
16
16
 
17
17
  self.request_method = request.request_method
18
18
  self.normalized_path_info = normalized_path(request)
19
- self.mime_type = request.headers['Content-Type']
20
- self.headers = AppMap::Util.select_headers(request.env)
21
- self.authorization = request.headers['Authorization']
19
+ self.headers = AppMap::Util.select_rack_headers(request.env)
22
20
  self.path_info = request.path_info.split('?')[0]
23
21
  # ActionDispatch::Http::ParameterFilter is deprecated
24
22
  parameter_filter_cls = \
@@ -35,9 +33,7 @@ module AppMap
35
33
  h[:http_server_request] = {
36
34
  request_method: request_method,
37
35
  path_info: path_info,
38
- mime_type: mime_type,
39
36
  normalized_path_info: normalized_path_info,
40
- authorization: authorization,
41
37
  headers: headers,
42
38
  }.compact
43
39
 
@@ -72,23 +68,21 @@ module AppMap
72
68
  end
73
69
 
74
70
  class HTTPServerResponse < AppMap::Event::MethodReturnIgnoreValue
75
- attr_accessor :status, :mime_type, :headers
71
+ attr_accessor :status, :headers
76
72
 
77
73
  def initialize(response, parent_id, elapsed)
78
74
  super AppMap::Event.next_id_counter, :return, Thread.current.object_id
79
75
 
80
76
  self.status = response.status
81
- self.mime_type = response.headers['Content-Type']
82
77
  self.parent_id = parent_id
83
78
  self.elapsed = elapsed
84
- self.headers = AppMap::Util.select_headers(response.headers)
79
+ self.headers = response.headers.dup
85
80
  end
86
81
 
87
82
  def to_h
88
83
  super.tap do |h|
89
84
  h[:http_server_response] = {
90
85
  status_code: status,
91
- mime_type: mime_type,
92
86
  headers: headers
93
87
  }.compact
94
88
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
 
3
5
  module AppMap
data/lib/appmap/util.rb CHANGED
@@ -108,8 +108,18 @@ module AppMap
108
108
  event
109
109
  end
110
110
 
111
- def select_headers(env)
111
+ def select_rack_headers(env)
112
+ finalize_headers = lambda do |headers|
113
+ blank?(headers) ? nil : headers
114
+ end
115
+
112
116
  # Rack prepends HTTP_ to all client-sent headers.
117
+
118
+ if !env['rack.version']
119
+ warn "Request headers does not contain rack.version. HTTP_ prefix is not expected."
120
+ return finalize_headers.call(env.dup)
121
+ end
122
+
113
123
  matching_headers = env
114
124
  .select { |k,v| k.start_with? 'HTTP_'}
115
125
  .reject { |k,v| blank?(v) }
@@ -118,7 +128,7 @@ module AppMap
118
128
  value = kv[1]
119
129
  memo[key] = value
120
130
  end
121
- blank?(matching_headers) ? nil : matching_headers
131
+ finalize_headers.call(matching_headers)
122
132
  end
123
133
 
124
134
  def normalize_path(path)
@@ -3,7 +3,7 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.66.1'
6
+ VERSION = '0.66.2'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.5.1'
9
9
 
@@ -93,9 +93,9 @@ describe 'Depends API' do
93
93
 
94
94
  test_report.clean_appmaps
95
95
 
96
- expect(File.exists?(new_spec_file)).to be_falsey
96
+ expect(File.exist?(new_spec_file)).to be_falsey
97
97
  ensure
98
- FileUtils.rm_f new_spec_file if File.exists?(new_spec_file)
98
+ FileUtils.rm_f new_spec_file if File.exist?(new_spec_file)
99
99
  FileUtils.rm_rf new_spec_file.split('.')[0]
100
100
  end
101
101
  end
@@ -0,0 +1,3 @@
1
+ name: name
2
+ packages:
3
+ - dogs: are friendly
@@ -58,7 +58,7 @@ describe 'Rails' do
58
58
  hash_including(
59
59
  'http_server_response' => hash_including(
60
60
  'status_code' => 201,
61
- 'mime_type' => 'application/json; charset=utf-8',
61
+ 'headers' => hash_including('Content-Type' => 'application/json; charset=utf-8'),
62
62
  )
63
63
  )
64
64
  )
@@ -6,6 +6,7 @@ class AgentSetupValidateTest < Minitest::Test
6
6
  NON_EXISTING_CONFIG_FILENAME = '123.yml'
7
7
  INVALID_YAML_CONFIG_FILENAME = 'spec/fixtures/config/invalid_yaml_config.yml'
8
8
  INVALID_CONFIG_FILENAME = 'spec/fixtures/config/invalid_config.yml'
9
+ MISSING_PATH_OR_GEM_CONFIG_FILENAME = 'spec/fixtures/config/missing_path_or_gem.yml'
9
10
 
10
11
  def test_init_when_config_exists
11
12
  output = `./exe/appmap-agent-validate`
@@ -72,4 +73,22 @@ class AgentSetupValidateTest < Minitest::Test
72
73
  ])
73
74
  assert_equal expected, output.strip
74
75
  end
76
+
77
+ def test_init_with_missing_package_key
78
+ output = `./exe/appmap-agent-validate -c #{MISSING_PATH_OR_GEM_CONFIG_FILENAME}`
79
+ assert_equal 0, $CHILD_STATUS.exitstatus
80
+ expected = JSON.pretty_generate([
81
+ {
82
+ level: :error,
83
+ message: 'AppMap auto-configuration is currently not available for non Rails projects'
84
+ },
85
+ {
86
+ level: :error,
87
+ filename: MISSING_PATH_OR_GEM_CONFIG_FILENAME,
88
+ message: "AppMap configuration #{MISSING_PATH_OR_GEM_CONFIG_FILENAME} could not be loaded",
89
+ detailed_message: "AppMap config 'package' element should specify 'gem' or 'path'"
90
+ }
91
+ ])
92
+ assert_equal expected, output.strip
93
+ end
75
94
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.66.1
4
+ version: 0.66.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-29 00:00:00.000000000 Z
11
+ date: 2021-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -3462,6 +3462,7 @@ files:
3462
3462
  - spec/fixtures/config/incomplete_config.yml
3463
3463
  - spec/fixtures/config/invalid_config.yml
3464
3464
  - spec/fixtures/config/invalid_yaml_config.yml
3465
+ - spec/fixtures/config/missing_path_or_gem.yml
3465
3466
  - spec/fixtures/config/valid_config.yml
3466
3467
  - spec/fixtures/depends/.gitignore
3467
3468
  - spec/fixtures/depends/app/controllers/api/api_keys_controller.rb
@@ -3738,7 +3739,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
3738
3739
  - !ruby/object:Gem::Version
3739
3740
  version: '0'
3740
3741
  requirements: []
3741
- rubygems_version: 3.0.8
3742
+ rubygems_version: 3.0.6
3742
3743
  signing_key:
3743
3744
  specification_version: 4
3744
3745
  summary: Record the operation of a Ruby program, using the AppLand 'AppMap' format.