activecypher 0.6.2 → 0.6.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d9c41285d4f1a84779d72a479b329e6c397d4630473d369691456e35f4337fc
4
- data.tar.gz: 1673192a6552da378dfd625114f8bc8eee8e973eb17583d802de8fcbcd609c70
3
+ metadata.gz: 6586ae8148cfb3d3f1e6ce182fc556a36790d84d0559e95455a57e1534afe4b2
4
+ data.tar.gz: 634ef2b25e6ba61bb38baf955c30e48fca9c9c6c71e885c5e5a5174d2105a947
5
5
  SHA512:
6
- metadata.gz: 6feecb3dbad832f8f8253f64b3ccb030d2fe99194824d57bf5087db7caee2e335a4e7a6b21646e7ba098250812f3b05d4a5c812b7d8b0cc5b8e93e23f1c56ebb
7
- data.tar.gz: f389ab164a37e002523c55e050abc1bee7c20df6e5c6e11e311f2a5f6200a33d27ac4512f676f36eebd155ce2f71f21c87a08f9431f0fe641d1051f09aee21be
6
+ metadata.gz: 9ea71245757351c9e2d503078721ee431a1525faa84ea83634ff9d0ed9b2ad486d7001941ef1de608ec86cf0141676bd9a1bbe6ebe1ed215094203a1efe98f01
7
+ data.tar.gz: c445c1430312284afd41a91dd8b25478066ce5f93284f249cdedd5256ed62eb02fa09161eda7ff3298d0f33c6a233e858bc75b1f780153ea218096c3ec911036
@@ -17,6 +17,26 @@ module ActiveCypher
17
17
  attr_reader :host, :port, :timeout_seconds, :socket,
18
18
  :protocol_version, :server_agent, :connection_id, :adapter
19
19
 
20
+ # Override inspect to redact sensitive information
21
+ def inspect
22
+ filtered_auth = ActiveCypher::Redaction.filter_hash(@auth_token)
23
+
24
+ attributes = {
25
+ host: @host.inspect,
26
+ port: @port.inspect,
27
+ auth_token: filtered_auth.inspect,
28
+ timeout_seconds: @timeout_seconds.inspect,
29
+ secure: @secure.inspect,
30
+ verify_cert: @verify_cert.inspect,
31
+ connected: @connected.inspect,
32
+ protocol_version: @protocol_version.inspect,
33
+ server_agent: @server_agent.inspect,
34
+ connection_id: @connection_id.inspect
35
+ }
36
+
37
+ "#<#{self.class.name}:0x#{object_id.to_s(16)} #{attributes.map { |k, v| "@#{k}=#{v}" }.join(', ')}>"
38
+ end
39
+
20
40
  SUPPORTED_VERSIONS = [5.8, 5.2].freeze
21
41
 
22
42
  # Initializes a new Bolt connection.
@@ -82,6 +82,15 @@ module ActiveCypher
82
82
  # @return [Array<Hash>] The processed rows
83
83
  def process_records(rows) = rows.map { |r| deep_symbolize(r) }
84
84
 
85
+ # Override inspect to hide sensitive information
86
+ # @return [String] Safe representation of the adapter
87
+ def inspect
88
+ filtered_config = ActiveCypher::Redaction.filter_hash(config)
89
+
90
+ # Return a safe representation
91
+ "#<#{self.class}:0x#{object_id.to_s(16)} @config=#{filtered_config.inspect}>"
92
+ end
93
+
85
94
  private
86
95
 
87
96
  # Recursively turns everything into symbols, because that's what all the cool kids do.
@@ -1,16 +1,11 @@
1
1
  development:
2
2
  primary:
3
- adapter: neo4j # Because you like your graphs with a touch of existential dread
4
- url: neo4j://neo4j:neo4j@localhost:7687 # VIP port, VIP credentials (change them, seriously)
5
- multi_db: false # One DB to rule them all
3
+ url: ENV["GRAPH_URL"]
6
4
 
7
5
  test:
8
6
  primary:
9
- url: neo4j://neo4j:neo4j@localhost:9876 # Different port, same chaos
10
- multi_db: false
7
+ url: ENV["GRAPH_URL"]
11
8
 
12
9
  production:
13
10
  primary:
14
- adapter: memgraph # Yes, still memgraph... for now...
15
- url: memgraph+ssc://<%= ENV["MG_USER"] %>:<%= ENV["MG_PASS"] %>@<%= ENV["MG_HOST"] %>:7687
16
- multi_db: <%= ENV.fetch("MG_MULTI_DB", "false") %> # Because complexity is a luxury
11
+ url: ENV["GRAPH_URL"]
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveCypher
4
+ # Shared constants and utilities for redacting sensitive information in inspection output
5
+ module Redaction
6
+ # The mask to use for sensitive information
7
+ MASK = '[HUNTER2]'
8
+
9
+ # Common sensitive parameter keys
10
+ SENSITIVE_KEYS = %i[password credentials auth_token principal url].freeze
11
+
12
+ # Create a parameter filter with the default mask and keys
13
+ # @param additional_keys [Array<Symbol>] Additional keys to redact
14
+ # @return [ActiveSupport::ParameterFilter] The configured filter
15
+ def self.create_filter(additional_keys = [])
16
+ keys = SENSITIVE_KEYS + additional_keys
17
+ ActiveSupport::ParameterFilter.new(keys, mask: MASK)
18
+ end
19
+
20
+ # Filter a hash to redact sensitive information
21
+ # @param hash [Hash] The hash to filter
22
+ # @param additional_keys [Array<Symbol>] Additional keys to redact
23
+ # @return [Hash] The filtered hash
24
+ def self.filter_hash(hash, additional_keys = [])
25
+ create_filter(additional_keys).filter(hash)
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveCypher
4
- VERSION = '0.6.2'
4
+ VERSION = '0.6.3'
5
+
6
+ def self.gem_version
7
+ Gem::Version.new VERSION
8
+ end
9
+
10
+ class << self
11
+ alias version gem_version
12
+ end
5
13
  end
data/lib/activecypher.rb CHANGED
@@ -4,6 +4,7 @@ require 'active_support'
4
4
  require 'zeitwerk'
5
5
  require_relative 'cyrel'
6
6
  require_relative 'active_cypher/version'
7
+ require_relative 'active_cypher/redaction'
7
8
 
8
9
  # ActiveCypher is a Ruby gem that provides an ActiveRecord-like interface for
9
10
  # interacting with Neo4j databases using Cypher queries.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activecypher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
@@ -154,6 +154,7 @@ files:
154
154
  - lib/active_cypher/model/persistence.rb
155
155
  - lib/active_cypher/model/querying.rb
156
156
  - lib/active_cypher/railtie.rb
157
+ - lib/active_cypher/redaction.rb
157
158
  - lib/active_cypher/relation.rb
158
159
  - lib/active_cypher/relationship.rb
159
160
  - lib/active_cypher/runtime_registry.rb