opentelemetry-helpers-sql-obfuscation 0.1.1 → 0.2.1

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: d73e8f546afb1c2ff64b8fdac702fd87ed74f0030e5e2153a5c7982f745d8deb
4
- data.tar.gz: f9ea5e0fa0f7629507a21881c97f0eb6a47f47b4e68772a01bb1425b06e0b3b5
3
+ metadata.gz: 91b2943d08bcbf0f8ff051bc2c71b3d18142de93d9f271c2d7441daa1f14ec17
4
+ data.tar.gz: 519ad0703850b7052b3347afa1979516a86ca6b525025673ee5d18d2f2898da6
5
5
  SHA512:
6
- metadata.gz: bb57af1b773d8e6ed9df1ec2bf9829d13b7802d685f5e82189095dbf36be59f95a0a405a85b8162bccaeaf962c6d1082b1167b14065d8b1a793b06d23ed5b3b4
7
- data.tar.gz: 0326d386a88dff15667b97226aa519b617bae128a296f76a67dac488f7b7044055f48bd0ff9bda74448caa63f571fce8a2ea18e95024f0bd149c560a8108e4c2
6
+ metadata.gz: fcd97acf8e32730d7846a0c3c03a4b305c5efab7c8300eadecbd011d63c91d3efac2595add982b0d05173942c5e319a7e072aff70bf25034596ac13961d7dd42
7
+ data.tar.gz: 813ac28e4a2a563dbea0fd3d624fdbf7bb0ab36348b17a3a061016273941774be77bf1e109950c82b9ba1ecfba1a8cfc789137bb483dc13a553b2262639da1e6
data/CHANGELOG.md CHANGED
@@ -1,8 +1,16 @@
1
- # Release History: opentelemetry-helpers-sql-obfuscation
1
+ # Release History: opentelemetry-helpers-sql-obfuscation
2
+
3
+ ### v0.2.1 / 2024-11-26
4
+
5
+ * (No significant changes)
6
+
7
+ ### v0.2.0 / 2024-09-12
8
+
9
+ - BREAKING CHANGE: Return message when sql is over the obfuscation limit. Fixes a bug where sql statements with prepended comments that hit the obfuscation limit would be sent raw.
2
10
 
3
11
  ### v0.1.1 / 2024-06-18
4
12
 
5
- * FIXED: Relax otel common gem constraints
13
+ - FIXED: Relax otel common gem constraints
6
14
 
7
15
  ### v0.1.0 / 2024-02-08
8
16
 
data/README.md CHANGED
@@ -24,7 +24,8 @@ end
24
24
  ```
25
25
 
26
26
  Make sure the `Instrumentation` class for your gem contains configuration options for:
27
- - `:obfuscation_limit`: the length at which the obfuscated SQL string will be truncated.
27
+
28
+ - `:obfuscation_limit`: the length at which the SQL string will not be obfuscated
28
29
  Example: `option :obfuscation_limit, default: 2000, validate: :integer`
29
30
 
30
31
  If you want to add support for a new adapter, update the following constants to include keys for your adapter:
@@ -48,7 +49,7 @@ OpenTelemetry::Helpers::SqlObfuscation.obfuscate_sql(sql, obfuscation_limit: con
48
49
 
49
50
  The `opentelemetry-helpers-sql-obfuscation` gem source is [on github][repo-github], along with related gems including `opentelemetry-instrumentation-pg` and `opentelemetry-instrumentation-trilogy`.
50
51
 
51
- The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us on our [gitter channel][ruby-gitter] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig].
52
+ The OpenTelemetry Ruby gems are maintained by the OpenTelemetry Ruby special interest group (SIG). You can get involved by joining us on our [GitHub Discussions][discussions-url], [Slack Channel][slack-channel] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig].
52
53
 
53
54
  ## License
54
55
 
@@ -59,4 +60,5 @@ The `opentelemetry-helpers-sql-obfuscation` gem is distributed under the Apache
59
60
  [license-github]: https://github.com/open-telemetry/opentelemetry-ruby-contrib/blob/main/LICENSE
60
61
  [ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
61
62
  [community-meetings]: https://github.com/open-telemetry/community#community-meetings
62
- [ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
63
+ [slack-channel]: https://cloud-native.slack.com/archives/C01NWKKMKMY
64
+ [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Helpers
9
9
  module SqlObfuscation
10
- VERSION = '0.1.1'
10
+ VERSION = '0.2.1'
11
11
  end
12
12
  end
13
13
  end
@@ -94,7 +94,7 @@ module OpenTelemetry
94
94
  # This is a SQL obfuscation utility intended for use in database adapter instrumentation.
95
95
  #
96
96
  # @param sql [String] The SQL to obfuscate.
97
- # @param obfuscation_limit [optional Integer] The maximum length of an obfuscated sql statement.
97
+ # @param obfuscation_limit [optional Integer] the length at which the SQL string will not be obfuscated
98
98
  # @param adapter [optional Symbol] the type of database adapter calling the method. `:default`, `:mysql` and `:postgres` are supported.
99
99
  # @return [String] The SQL query string where the values are replaced with "?". When the sql statement exceeds the obufscation limit
100
100
  # the first matched pair from the SQL statement will be returned, with an appended truncation message. If trunaction is unsuccessful,
@@ -102,6 +102,8 @@ module OpenTelemetry
102
102
  #
103
103
  # @api public
104
104
  def obfuscate_sql(sql, obfuscation_limit: 2000, adapter: :default)
105
+ return "SQL not obfuscated, query exceeds #{obfuscation_limit} characters" if sql.size > obfuscation_limit
106
+
105
107
  regex = case adapter
106
108
  when :mysql
107
109
  MYSQL_COMPONENTS_REGEX
@@ -115,7 +117,6 @@ module OpenTelemetry
115
117
  # https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/160
116
118
  # https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/345
117
119
  sql = OpenTelemetry::Common::Utilities.utf8_encode(sql, binary: true)
118
- return truncate_statement(sql, regex, obfuscation_limit) if sql.size > obfuscation_limit
119
120
 
120
121
  sql = sql.gsub(regex, PLACEHOLDER)
121
122
  return 'Failed to obfuscate SQL query - quote characters remained after obfuscation' if CLEANUP_REGEX[adapter].match(sql)
@@ -124,16 +125,6 @@ module OpenTelemetry
124
125
  rescue StandardError => e
125
126
  OpenTelemetry.handle_error(message: 'Failed to obfuscate SQL', exception: e)
126
127
  end
127
-
128
- # @api private
129
- def truncate_statement(sql, regex, limit)
130
- first_match_index = sql.index(regex)
131
- truncation_message = "SQL truncated (> #{limit} characters)"
132
- return truncation_message unless first_match_index
133
-
134
- truncated_sql = sql[..first_match_index - 1]
135
- "#{truncated_sql}...\n#{truncation_message}"
136
- end
137
128
  end
138
129
  end
139
130
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opentelemetry-helpers-sql-obfuscation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-18 00:00:00.000000000 Z
11
+ date: 2024-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-common
@@ -86,28 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.64.0
89
+ version: 1.68.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.64.0
96
+ version: 1.68.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop-performance
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.21.0
103
+ version: 1.23.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.21.0
110
+ version: 1.23.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: yard
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -155,11 +155,14 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby-contrib
155
155
  licenses:
156
156
  - Apache-2.0
157
157
  metadata:
158
- changelog_uri: https://rubydoc.info/gems/opentelemetry-helpers-sql-obfuscation/0.1.1/file/CHANGELOG.md
158
+ changelog_uri: https://rubydoc.info/gems/opentelemetry-helpers-sql-obfuscation/0.2.1/file/CHANGELOG.md
159
159
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/tree/main/helpers/sql-obfuscation
160
160
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby-contrib/issues
161
- documentation_uri: https://rubydoc.info/gems/opentelemetry-helpers-sql-obfuscation/0.1.1
162
- post_install_message:
161
+ documentation_uri: https://rubydoc.info/gems/opentelemetry-helpers-sql-obfuscation/0.2.1
162
+ post_install_message: |
163
+ Ruby 3.0 has reached EoL 2024-04-23. OTel Ruby Contrib gems will no longer accept new features or bug fixes for Ruby 3.0 after 2025-01-15. Please upgrade to Ruby 3.1 or higher to continue receiving updates.
164
+
165
+ Rails 6.1 has reached EoL 2024-10-01. OTel Ruby Contrib gems will no longer accept new features or bug fixes for Rails 6.1 after 2025-01-15. Please upgrade to Rails 7.0 or higher to continue receiving updates.
163
166
  rdoc_options: []
164
167
  require_paths:
165
168
  - lib