bson 5.0.0-java → 5.0.1-java

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: 4a402a1cf7ac93f6d12ed5acaad7ae5aa04fe0dacdfb7571392d09d35f6eaf9b
4
- data.tar.gz: e3afd667f703c5cd401ef6231a4cf055fd835908546ba4b6503e7418beafc57c
3
+ metadata.gz: 8abd0210ffaac5ff6d506ec5a872ad8230f9a4253be7bb26d7b5726ff5f4f0e1
4
+ data.tar.gz: 2abc7512e12d5ebd109038a22e1a71d1174df6e86d82a43bd52dc5f2ae368c4b
5
5
  SHA512:
6
- metadata.gz: 78a555961d750296ea66c0808edef55c1e2a5dcd24ff8761e0497ab671c8fe9dbc2d44f4e8ada2b2b0ec642ae347d62abe3358dc0f55cc5c81563900cd5cfb6b
7
- data.tar.gz: '049eed7dbb37c42142a468566d44ee531f0a4ac0ac585d4e3a67b9e0ddcd3ba26c90e4f50650ec3544b5a51cb73a55c9882409c58ea6cebfb937cebe2f3b10af'
6
+ metadata.gz: bb55a15f35cb6700df2a3f45f13dae8525714adb796037db59cab549d21ae299c1999321e33c1e74b4f6eb1731e84972fd77e1814392f38e62ab7398ea35b7af
7
+ data.tar.gz: 52af2ff9e32b7f935b3abbfc482044eb5f62b2b4b1e70a85154ea32b7f36913dabbc183831864589d56b4293458d7b9290eeed15b2e535ac5f1301b8ecd2104c
data/README.md CHANGED
@@ -1,16 +1,54 @@
1
1
  BSON
2
2
  [![Gem Version][rubygems-img]][rubygems-url]
3
3
  [![Build Status][ghactions-img]][ghactions-url]
4
- [![Coverage Status][coveralls-img]][coveralls-url]
5
- [![Inline docs][inch-img]][inch-url]
6
4
  ====
7
5
 
8
6
  An implementation of the BSON specification in Ruby.
9
7
 
8
+ Installation
9
+ ------------
10
+
11
+ BSON can be installed via RubyGems:
12
+
13
+ ```
14
+ > gem install bson
15
+ ```
16
+
17
+ Or by adding it to your project's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'bson'
21
+ ```
22
+
23
+ ### Release Integrity
24
+
25
+ Each release of the BSON library for Ruby after version 5.0.0 has been automatically built and signed using the team's GPG key.
26
+
27
+ To verify the bson gem file:
28
+
29
+ 1. [Download the GPG key](https://pgp.mongodb.com/ruby-driver.asc).
30
+ 2. Import the key into your GPG keyring with `gpg --import ruby-driver.asc`.
31
+ 3. Download the gem file (if you don't already have it). You can download it from RubyGems with `gem fetch bson`, or you can download it from the [releases page](https://github.com/mongodb/bson-ruby/releases) on GitHub.
32
+ 4. Download the corresponding detached signature file from the [same release](https://github.com/mongodb/bson-ruby/releases). Look at the bottom of the release that corresponds to the gem file, under the 'Assets' list, for a `.sig` file with the same version number as the gem you wish to install.
33
+ 5. Verify the gem with `gpg --verify bson-X.Y.Z.gem.sig bson-X.Y.Z.gem` (replacing `X.Y.Z` with the actual version number).
34
+
35
+ You are looking for text like "Good signature from "MongoDB Ruby Driver Release Signing Key <packaging@mongodb.com>" in the output. If you see that, the signature was found to correspond to the given gem file.
36
+
37
+ (Note that other output, like "This key is not certified with a trusted signature!", is related to *web of trust* and depends on how strongly you, personally, trust the `ruby-driver.asc` key that you downloaded from us. To learn more, see https://www.gnupg.org/gph/en/manual/x334.html)
38
+
39
+ ### Why not use RubyGems' gem-signing functionality?
40
+
41
+ RubyGems' own gem signing is problematic, most significantly because there is no established chain of trust related to the keys used to sign gems. RubyGems' own documentation admits that "this method of signing gems is not widely used" (see https://guides.rubygems.org/security/). Discussions about this in the RubyGems community have been off-and-on for more than a decade, and while a solution will eventually arrive, we have settled on using GPG instead for the following reasons:
42
+
43
+ 1. Many of the other driver teams at MongoDB are using GPG to sign their product releases. Consistency with the other teams means that we can reuse existing tooling for our own product releases.
44
+ 2. GPG is widely available and has existing tools and procedures for dealing with web of trust (though they are admittedly quite arcane and intimidating to the uninitiated, unfortunately).
45
+
46
+ Ultimately, most users do not bother to verify gems, and will not be impacted by our choice of GPG over RubyGems' native method.
47
+
10
48
  Compatibility
11
49
  -------------
12
50
 
13
- BSON is tested against MRI (2.6) and JRuby (9.2+).
51
+ BSON is tested against MRI (2.7+) and JRuby (9.3+).
14
52
 
15
53
  Documentation
16
54
  -------------
@@ -29,6 +67,56 @@ BSON Specification
29
67
 
30
68
  The [BSON specification](http://bsonspec.org) is at bsonspec.org.
31
69
 
70
+ ## Bugs & Feature Requests
71
+
72
+ To report a bug in the `bson` gem or request a feature:
73
+
74
+ 1. Visit [our issue tracker](https://jira.mongodb.org/) and login
75
+ (or create an account if you do not have one already).
76
+ 2. Navigate to the [RUBY project](https://jira.mongodb.org/browse/RUBY).
77
+ 3. Click 'Create Issue' and fill out all of the applicable form fields, making
78
+ sure to select `BSON` in the _Component/s_ field.
79
+
80
+ When creating an issue, please keep in mind that all information in JIRA
81
+ for the RUBY project, as well as the core server (the SERVER project),
82
+ is publicly visible.
83
+
84
+ **PLEASE DO:**
85
+
86
+ - Provide as much information as possible about the issue.
87
+ - Provide detailed steps for reproducing the issue.
88
+ - Provide any applicable code snippets, stack traces and log data.
89
+ - Specify version numbers of the `bson` gem and/or Ruby driver and MongoDB
90
+ server.
91
+
92
+ **PLEASE DO NOT:**
93
+
94
+ - Provide any sensitive data or server logs.
95
+ - Report potential security issues publicly (see 'Security Issues' below).
96
+
97
+ ## Security Issues
98
+
99
+ If you have identified a potential security-related issue in the `bson` gem
100
+ (or any other MongoDB product), please report it by following the
101
+ [instructions here](https://www.mongodb.com/docs/manual/tutorial/create-a-vulnerability-report).
102
+
103
+ ## Product Feature Requests
104
+
105
+ To request a feature which is not specific to the `bson` gem, or which
106
+ affects more than the `bson` gem and/or Ruby driver alone (for example, a
107
+ feature which requires MongoDB server support), please submit your idea through
108
+ the [MongoDB Feedback Forum](https://feedback.mongodb.com/forums/924286-drivers).
109
+
110
+ ## Maintenance and Bug Fix Policy
111
+
112
+ New library functionality is generally added in a backwards-compatible manner
113
+ and results in new minor releases. Bug fixes are generally made on
114
+ master first and are backported to the current minor library release. Exceptions
115
+ may be made on a case-by-case basis, for example security fixes may be
116
+ backported to older stable branches. Only the most recent minor release
117
+ is officially supported. Customers should use the most recent release in
118
+ their applications.
119
+
32
120
  Versioning
33
121
  ----------
34
122
 
@@ -56,7 +144,3 @@ limitations under the License.
56
144
  [rubygems-url]: http://badge.fury.io/rb/bson
57
145
  [ghactions-img]: https://github.com/mongodb/bson-ruby/actions/workflows/bson-ruby.yml/badge.svg?query=branch%3Amaster
58
146
  [ghactions-url]: https://github.com/mongodb/bson-ruby/actions/workflows/bson-ruby.yml?query=branch%3Amaster
59
- [coveralls-img]: https://coveralls.io/repos/mongodb/bson-ruby/badge.svg?branch=master
60
- [coveralls-url]: https://coveralls.io/r/mongodb/bson-ruby?branch=master
61
- [inch-img]: http://inch-ci.org/github/mongodb/bson-ruby.svg?branch=master
62
- [inch-url]: http://inch-ci.org/github/mongodb/bson-ruby
data/Rakefile CHANGED
@@ -47,28 +47,37 @@ else
47
47
  end
48
48
  end
49
49
 
50
- require "bson/version"
50
+ RSpec::Core::RakeTask.new(:rspec)
51
51
 
52
- def extension
53
- RUBY_PLATFORM =~ /darwin/ ? "bundle" : "so"
52
+ desc 'Build the bson gem'
53
+ task :build => [ :clean_all, *(jruby? ? :compile : nil) ] do
54
+ output = "--output=#{ENV['GEM_FILE_NAME']}" if ENV['GEM_FILE_NAME']
55
+ system "gem build #{output} bson.gemspec"
54
56
  end
55
57
 
56
- require_relative "perf/bench"
57
-
58
- RSpec::Core::RakeTask.new(:rspec)
58
+ # `rake version` is used by the deployment system so get the release version
59
+ # of the product beng deployed. It must do nothing more than just print the
60
+ # product version number.
61
+ desc 'Print the current version of the Ruby-BSON library'
62
+ task :version do
63
+ require 'bson/version'
64
+ puts BSON::VERSION
65
+ end
59
66
 
60
- if jruby?
61
- task :build => [ :clean_all, :compile ] do
62
- system "gem build bson.gemspec"
63
- end
64
- else
65
- task :build => :clean_all do
66
- system "gem build bson.gemspec"
67
- end
67
+ # `rake gem_file_name` is used by the deployment system so get the name of
68
+ # the gem file to be generated. It must do nothing more than just print the
69
+ # name of the gem file to generate.
70
+ desc 'Print the name of the gem file to generate.'
71
+ task :gem_file_name do
72
+ require 'bson/version'
73
+ base = "bson-#{BSON::VERSION}"
74
+ base << '-java' if jruby?
75
+ puts "#{base}.gem"
68
76
  end
69
77
 
70
78
  task :clean_all => :clean do
71
- FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson_native.#{extension}"))
79
+ FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson_native.bundle"))
80
+ FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson_native.so"))
72
81
  FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson_native.o"))
73
82
  FileUtils.rm_f(File.join(File.dirname(__FILE__), 'lib', "bson-ruby.jar"))
74
83
  end
@@ -77,49 +86,63 @@ task :spec => :compile do
77
86
  Rake::Task["rspec"].invoke
78
87
  end
79
88
 
80
- # Run bundle exec rake release with mri and jruby. Ex:
81
- #
82
- # rvm use 2.1.0@bson
83
- # bundle exec rake release
84
- # rvm use jruby@bson
85
- # bundle exec rake release
86
- task :release => :build do
87
- system "git tag -a v#{BSON::VERSION} -m 'Tagging release: #{BSON::VERSION}'"
88
- system "git push --tags"
89
- if jruby?
90
- system "gem push bson-#{BSON::VERSION}-java.gem"
91
- system "rm bson-#{BSON::VERSION}-java.gem"
92
- else
93
- system "gem push bson-#{BSON::VERSION}.gem"
94
- system "rm bson-#{BSON::VERSION}.gem"
89
+ # overrides the default Bundler-provided `release` task, which also
90
+ # builds the gem. Our release process assumes the gem has already
91
+ # been built (and signed via GPG), so we just need `rake release` to
92
+ # push the gem to rubygems.
93
+ task :release do
94
+ require 'bson/version'
95
+
96
+ # confirm: there ought to be two gems, one for MRI, and one for Java. These
97
+ # will have been previously generated by the 'BSON Release' GitHub action.
98
+ gems = Dir['*.gem']
99
+ if gems.length != 2
100
+ abort "Expected two gem files to be ready to release; got #{gems.length}"
101
+ end
102
+
103
+ if ENV['GITHUB_ACTION'].nil?
104
+ abort <<~WARNING
105
+ `rake release` must be invoked from the `BSON Release` GitHub action,
106
+ and must not be invoked locally. This ensures the gem is properly signed
107
+ and distributed by the appropriate user.
108
+
109
+ Note that it is the `rubygems/release-gem@v1` step in the `BSON Release`
110
+ action that invokes this task. Do not rename or remove this task, or the
111
+ release-gem step will fail. Reimplement this task with caution.
112
+
113
+ NO GEMS were pushed to RubyGems.
114
+ WARNING
115
+ end
116
+
117
+ gems.each do |gem|
118
+ system 'gem', 'push', gem
95
119
  end
96
120
  end
97
121
 
98
122
  namespace :benchmark do
99
123
 
100
- task :ruby => :clean_all do
124
+ task :prep do
125
+ require_relative "perf/bench"
126
+ end
127
+
128
+ task ruby: [ :clean_all, 'benchmark:prep' ] do
101
129
  puts "Benchmarking pure Ruby..."
102
- require "bson"
103
130
  benchmark!
104
131
  end
105
132
 
106
- task :native => :compile do
133
+ task native: [ :compile, 'benchmark:prep' ] do
107
134
  puts "Benchmarking with native extensions..."
108
- require "bson"
109
135
  benchmark!
110
136
  end
111
137
 
112
138
  namespace :decimal128 do
113
-
114
- task :from_string do
139
+ task from_string: 'benchmark:prep' do
115
140
  puts "Benchmarking creating Decimal128 objects from a string"
116
- require 'bson'
117
141
  benchmark_decimal128_from_string!
118
142
  end
119
143
 
120
- task :to_string do
144
+ task to_string: 'benchmark:prep' do
121
145
  puts "Benchmarking getting a string representation of a Decimal128"
122
- require 'bson'
123
146
  benchmark_decimal128_to_string!
124
147
  end
125
148
  end
@@ -133,6 +156,7 @@ task :docs => 'docs:yard'
133
156
  namespace :docs do
134
157
  desc "Generate yard documention"
135
158
  task :yard do
159
+ require 'bson/version'
136
160
  out = File.join('yard-docs', BSON::VERSION)
137
161
  FileUtils.rm_rf(out)
138
162
  system "yardoc -o #{out} --title bson-#{BSON::VERSION}"
@@ -156,7 +156,7 @@ module BSON
156
156
  # @return [ Regex ] The regex for a valid decimal128 string.
157
157
  #
158
158
  # @since 4.2.0
159
- VALID_DECIMAL128_STRING_REGEX = /^[\-\+]?(\d+(\.\d*)?|\.\d+)(E[\-\+]?\d+)?$/i
159
+ VALID_DECIMAL128_STRING_REGEX = /\A[\-\+]?(\d+(\.\d*)?|\.\d+)(E[\-\+]?\d+)?\Z/i
160
160
 
161
161
  # Initialize the FromString Builder object.
162
162
  #
@@ -356,12 +356,22 @@ module BSON
356
356
  block_given? ? yield(object) : object
357
357
  end
358
358
 
359
+ # The largest numeric value that can be converted to an integer by MRI's
360
+ # NUM2UINT. Further, the spec dictates that the time component of an
361
+ # ObjectID must be no more than 4 bytes long, so the spec itself is
362
+ # constrained in this regard.
363
+ MAX_INTEGER = 2 ** 32
364
+
359
365
  # Returns an integer timestamp (seconds since the Epoch). Primarily used
360
366
  # by the generator to produce object ids.
361
367
  #
368
+ # @note This value is guaranteed to be no more than 4 bytes in length. A
369
+ # time value far enough in the future to require a larger integer than
370
+ # 4 bytes will be truncated to 4 bytes.
371
+ #
362
372
  # @return [ Integer ] the number of seconds since the Epoch.
363
373
  def timestamp
364
- ::Time.now.to_i
374
+ ::Time.now.to_i % MAX_INTEGER
365
375
  end
366
376
  end
367
377
 
data/lib/bson/version.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  # rubocop:todo all
3
+
3
4
  # Copyright (C) 2009-2020 MongoDB Inc.
4
5
  #
5
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,5 +16,5 @@
15
16
  # limitations under the License.
16
17
 
17
18
  module BSON
18
- VERSION = "5.0.0"
19
+ VERSION = "5.0.1"
19
20
  end
data/lib/bson-ruby.jar CHANGED
Binary file
@@ -622,6 +622,20 @@ describe BSON::ObjectId do
622
622
  end
623
623
  end
624
624
 
625
+ context 'when the timestamp is larger than a 32-bit integer' do
626
+ let(:distant_future) { Time.at(2 ** 32) }
627
+
628
+ before do
629
+ allow(Time).to receive(:now).and_return(distant_future)
630
+ end
631
+
632
+ let(:object_id) { BSON::ObjectId.new }
633
+
634
+ it 'wraps the timestamp to 0' do
635
+ expect(object_id.to_time).to be == Time.at(0)
636
+ end
637
+ end
638
+
625
639
  context 'when fork changes the pid' do
626
640
  before do
627
641
  skip 'requires Process.fork' unless Process.respond_to?(:fork)