activecypher 0.6.1 → 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 +4 -4
- data/lib/active_cypher/bolt/connection.rb +20 -0
- data/lib/active_cypher/connection_adapters/abstract_adapter.rb +9 -0
- data/lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb +14 -1
- data/lib/active_cypher/connection_adapters/registry.rb +4 -2
- data/lib/active_cypher/connection_url_resolver.rb +11 -0
- data/lib/active_cypher/generators/templates/cypher_databases.yml +3 -8
- data/lib/active_cypher/redaction.rb +28 -0
- data/lib/active_cypher/version.rb +9 -1
- data/lib/activecypher.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6586ae8148cfb3d3f1e6ce182fc556a36790d84d0559e95455a57e1534afe4b2
|
4
|
+
data.tar.gz: 634ef2b25e6ba61bb38baf955c30e48fca9c9c6c71e885c5e5a5174d2105a947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
@@ -34,9 +34,22 @@ module ActiveCypher
|
|
34
34
|
{ scheme: 'none' }
|
35
35
|
end
|
36
36
|
|
37
|
+
# Get SSL connection params
|
38
|
+
ssl_params = if config[:url]
|
39
|
+
resolver = ActiveCypher::ConnectionUrlResolver.new(config[:url])
|
40
|
+
resolver.ssl_connection_params
|
41
|
+
else
|
42
|
+
{
|
43
|
+
secure: config[:ssl] ? true : false,
|
44
|
+
verify_cert: config[:ssc] ? false : true
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
37
48
|
@connection = Bolt::Connection.new(
|
38
49
|
host, port, self,
|
39
|
-
auth_token: auth,
|
50
|
+
auth_token: auth,
|
51
|
+
timeout_seconds: config.fetch(:timeout, 15),
|
52
|
+
**ssl_params
|
40
53
|
)
|
41
54
|
@connection.connect
|
42
55
|
validate_connection
|
@@ -81,13 +81,15 @@ module ActiveCypher
|
|
81
81
|
principal: config[:username],
|
82
82
|
credentials: config[:password]
|
83
83
|
}
|
84
|
+
# Get SSL connection params from resolver
|
85
|
+
ssl_params = resolver.ssl_connection_params
|
86
|
+
|
84
87
|
ActiveCypher::Bolt::Driver.new(
|
85
88
|
uri: uri,
|
86
89
|
adapter: adapter,
|
87
90
|
auth_token: auth_token,
|
88
91
|
pool_size: pool_size,
|
89
|
-
|
90
|
-
verify_cert: config[:ssc] ? false : true
|
92
|
+
**ssl_params
|
91
93
|
)
|
92
94
|
end
|
93
95
|
end
|
@@ -62,6 +62,17 @@ module ActiveCypher
|
|
62
62
|
}
|
63
63
|
end
|
64
64
|
|
65
|
+
# Returns SSL/TLS connection parameters based on ssl/ssc flags
|
66
|
+
# @return [Hash] Connection parameters for SSL/TLS
|
67
|
+
def ssl_connection_params
|
68
|
+
return {} unless @parsed
|
69
|
+
|
70
|
+
{
|
71
|
+
secure: @parsed[:ssl] ? true : false,
|
72
|
+
verify_cert: @parsed[:ssc] ? false : true
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
65
76
|
private
|
66
77
|
|
67
78
|
def parse_url(url_string)
|
@@ -1,16 +1,11 @@
|
|
1
1
|
development:
|
2
2
|
primary:
|
3
|
-
|
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:
|
10
|
-
multi_db: false
|
7
|
+
url: ENV["GRAPH_URL"]
|
11
8
|
|
12
9
|
production:
|
13
10
|
primary:
|
14
|
-
|
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
|
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.
|
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
|