pry-auditlog 0.2.1 → 0.3.0
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/.rubocop.yml +23 -0
- data/.travis.yml +9 -0
- data/Gemfile +0 -5
- data/LICENSE.txt +1 -1
- data/README.md +12 -7
- data/Rakefile +7 -0
- data/bin/example.rb +9 -0
- data/lib/ext/pry/repl.rb +1 -1
- data/lib/pry-auditlog.rb +3 -2
- data/lib/pry-auditlog/logger.rb +14 -18
- data/lib/pry-auditlog/output.rb +4 -6
- data/lib/pry-auditlog/version.rb +1 -1
- data/pry-auditlog.gemspec +9 -5
- metadata +58 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 035c74c0fdf31df8ae21d8bac8b19d845e7fc8d8
|
4
|
+
data.tar.gz: 0740c1a1c39bea29a3c6cf7f246c0f77c3d0fa9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b75e8f845ca663f6924da9c05ff93f5bf464b533c29fdc472256b7081d9c7571dded1d2e2e798c9832f19c3c2f32671bbbd082d357509c597aad4cc327aec4c9
|
7
|
+
data.tar.gz: 609716ddfae232cc18e3b64eb97de38b155991c12e56d260220c5952744a9a928cab6bd7f9cfe6d02f1027558ea9a2de5bba4b79820d59a8d345167435fa48d6
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
MethodLength:
|
2
|
+
Max: 50
|
3
|
+
|
4
|
+
LineLength:
|
5
|
+
Max: 160
|
6
|
+
|
7
|
+
AbcSize:
|
8
|
+
Max: 75
|
9
|
+
|
10
|
+
FileName:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
PerceivedComplexity:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
CyclomaticComplexity:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Style/Documentation:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/CaseEquality:
|
23
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# PryAuditlog
|
2
2
|
|
3
|
+
[](https://travis-ci.org/mgreensmith/pry-auditlog)
|
4
|
+
[](http://badge.fury.io/rb/pry-auditlog)
|
5
|
+
|
3
6
|
PryAuditlog is a plugin for the [Pry](http://pry.github.com) REPL that enables logging of any combination of Pry input and output to a configured audit log file.
|
4
7
|
|
5
8
|
It modifies the `read` method of the REPL class to read input statements to Pry, and it inserts itself into the `output` mechanism to scrape a copy of all emitted data. It also redirects `$stdout` and `$stderr` during the Pry session in order to capture all output emitted from any `puts` or similar statements.
|
@@ -18,19 +21,21 @@ Set appropriate config values and then require the plugin in your `.pryrc` or an
|
|
18
21
|
|
19
22
|
```
|
20
23
|
# The auditlog must be explicitly enabled
|
21
|
-
Pry.config.auditlog_enabled = true
|
24
|
+
Pry.config.auditlog_enabled = true # default: false
|
22
25
|
|
23
|
-
#
|
24
|
-
Pry.config.auditlog_file = '/path/to/file'
|
26
|
+
# Path to audit log destination and optional file mode
|
27
|
+
Pry.config.auditlog_file = '/path/to/file' # default: '/dev/null'
|
28
|
+
Pry.config.auditlog_file_mode = 0644 # default: 0600
|
25
29
|
|
26
30
|
# We log both input and output by default
|
27
|
-
Pry.config.auditlog_log_input = false
|
28
|
-
Pry.config.auditlog_log_output = false
|
31
|
+
Pry.config.auditlog_log_input = false # default: true
|
32
|
+
Pry.config.auditlog_log_output = false # default: true
|
29
33
|
|
30
34
|
# Set all config values *before* requiring the plugin
|
31
35
|
require 'pry-auditlog'
|
32
36
|
```
|
33
37
|
|
34
|
-
|
38
|
+
## Copyright
|
35
39
|
|
36
|
-
Matt Greensmith
|
40
|
+
Copyright (c) 2014-2015 Matt Greensmith and Cozy Services Ltd. See [LICENSE.txt](LICENSE.txt) for
|
41
|
+
further details.
|
data/Rakefile
ADDED
data/bin/example.rb
ADDED
data/lib/ext/pry/repl.rb
CHANGED
data/lib/pry-auditlog.rb
CHANGED
@@ -3,6 +3,7 @@ require 'pry-auditlog/version'
|
|
3
3
|
|
4
4
|
Pry.config.auditlog_enabled = false unless defined?(Pry.config.auditlog_enabled)
|
5
5
|
Pry.config.auditlog_file = '/dev/null' unless defined?(Pry.config.auditlog_file)
|
6
|
+
Pry.config.auditlog_file_mode = 0600 unless defined?(Pry.config.auditlog_file_mode)
|
6
7
|
Pry.config.auditlog_log_input = true unless defined?(Pry.config.auditlog_log_input)
|
7
8
|
Pry.config.auditlog_log_output = true unless defined?(Pry.config.auditlog_log_output)
|
8
9
|
|
@@ -17,14 +18,14 @@ if Pry.config.auditlog_enabled
|
|
17
18
|
|
18
19
|
Pry.config.original_output = Pry.config.output
|
19
20
|
Pry.config.output = PryAuditlog::Output.new
|
20
|
-
Pry.config.output.
|
21
|
+
Pry.config.output._original_output = Pry.config.original_output
|
21
22
|
end
|
22
23
|
|
23
24
|
local_hooks = Pry::Hooks.new
|
24
25
|
|
25
26
|
local_hooks.add_hook(:before_session, :prepare_auditlog) do
|
26
27
|
$stdout = $stderr = Pry.config.output if Pry.config.auditlog_log_output
|
27
|
-
PryAuditlog::Logger.
|
28
|
+
PryAuditlog::Logger.session_token = Time.now.to_i
|
28
29
|
PryAuditlog::Logger.log('AUDIT LOG', 'Pry session started')
|
29
30
|
end
|
30
31
|
|
data/lib/pry-auditlog/logger.rb
CHANGED
@@ -1,29 +1,25 @@
|
|
1
1
|
module PryAuditlog
|
2
2
|
class Logger
|
3
|
-
|
4
|
-
|
5
|
-
begin
|
6
|
-
if Pry.config.auditlog_file
|
7
|
-
@@audit_file = File.open(Pry.config.auditlog_file, 'a', 0600).tap { |f| f.sync = true }
|
8
|
-
else
|
9
|
-
@@audit_file = false
|
10
|
-
end
|
11
|
-
rescue Errno::EACCES, Errno::ENOENT
|
12
|
-
@@audit_file = false
|
3
|
+
class << self
|
4
|
+
attr_accessor :audit_file, :prompt, :session_token
|
13
5
|
end
|
14
6
|
|
15
|
-
|
16
|
-
|
17
|
-
end
|
7
|
+
@prompt = ''
|
8
|
+
@session_token = ''
|
18
9
|
|
19
|
-
|
20
|
-
|
10
|
+
begin
|
11
|
+
if Pry.config.auditlog_file
|
12
|
+
@audit_file = File.open(File.expand_path(Pry.config.auditlog_file), 'a', Pry.config.auditlog_file_mode).tap { |f| f.sync = true }
|
13
|
+
end
|
14
|
+
rescue Errno::EACCES, Errno::ENOENT => e
|
15
|
+
Pry.output.print "Failed to open audit log file, audit logging is disabled: #{e.message}\n"
|
16
|
+
@audit_file = nil
|
21
17
|
end
|
22
18
|
|
23
19
|
def self.log(type, line)
|
24
|
-
line = "#{
|
25
|
-
log_line = "[#{Time.now
|
26
|
-
|
20
|
+
line = "#{@prompt}#{line}" if type == 'I'
|
21
|
+
log_line = "[#{Time.now}][#{@session_token}][#{type}] #{line}"
|
22
|
+
@audit_file.puts log_line if @audit_file && !line.strip.empty?
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
data/lib/pry-auditlog/output.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
module PryAuditlog
|
2
2
|
class Output < StringIO
|
3
|
-
|
4
|
-
@original_output = orig
|
5
|
-
end
|
3
|
+
attr_accessor :_original_output
|
6
4
|
|
7
5
|
def print(line)
|
8
6
|
PryAuditlog::Logger.log('O', line)
|
9
|
-
@
|
7
|
+
@_original_output.print(line)
|
10
8
|
end
|
11
|
-
|
12
|
-
|
9
|
+
alias_method :<<, :print
|
10
|
+
alias_method :write, :print
|
13
11
|
end
|
14
12
|
end
|
data/lib/pry-auditlog/version.rb
CHANGED
data/pry-auditlog.gemspec
CHANGED
@@ -6,14 +6,18 @@ require 'pry-auditlog/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'pry-auditlog'
|
8
8
|
spec.version = PryAuditlog::VERSION
|
9
|
-
spec.authors = ['Cozy Services Ltd.'
|
10
|
-
spec.email = ['opensource@cozy.co']
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage = 'http://github.com/
|
9
|
+
spec.authors = ['Matt Greensmith', 'Cozy Services Ltd.']
|
10
|
+
spec.email = ['matt@mattgreensmith.net', 'opensource@cozy.co']
|
11
|
+
spec.summary = 'Adds audit log capability to Pry'
|
12
|
+
spec.description = 'PryAuditlog is a plugin for the Pry REPL that enables logging of any combination of Pry input and output to a configured audit file.'
|
13
|
+
spec.homepage = 'http://github.com/mgreensmith/pry-auditlog'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
|
18
18
|
spec.add_dependency 'pry', '~> 0.10'
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
21
|
+
spec.add_development_dependency 'rake'
|
22
|
+
spec.add_development_dependency 'rubocop'
|
19
23
|
end
|
metadata
CHANGED
@@ -1,49 +1,96 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-auditlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Cozy Services Ltd.
|
8
7
|
- Matt Greensmith
|
8
|
+
- Cozy Services Ltd.
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-06-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pry
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0.10'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0.10'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.6'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.6'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rubocop
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
28
70
|
description: PryAuditlog is a plugin for the Pry REPL that enables logging of any
|
29
|
-
combination of Pry input and output to a configured audit
|
71
|
+
combination of Pry input and output to a configured audit file.
|
30
72
|
email:
|
73
|
+
- matt@mattgreensmith.net
|
31
74
|
- opensource@cozy.co
|
32
75
|
executables: []
|
33
76
|
extensions: []
|
34
77
|
extra_rdoc_files: []
|
35
78
|
files:
|
36
|
-
- .gitignore
|
79
|
+
- ".gitignore"
|
80
|
+
- ".rubocop.yml"
|
81
|
+
- ".travis.yml"
|
37
82
|
- Gemfile
|
38
83
|
- LICENSE.txt
|
39
84
|
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/example.rb
|
40
87
|
- lib/ext/pry/repl.rb
|
41
88
|
- lib/pry-auditlog.rb
|
42
89
|
- lib/pry-auditlog/logger.rb
|
43
90
|
- lib/pry-auditlog/output.rb
|
44
91
|
- lib/pry-auditlog/version.rb
|
45
92
|
- pry-auditlog.gemspec
|
46
|
-
homepage: http://github.com/
|
93
|
+
homepage: http://github.com/mgreensmith/pry-auditlog
|
47
94
|
licenses:
|
48
95
|
- MIT
|
49
96
|
metadata: {}
|
@@ -53,17 +100,17 @@ require_paths:
|
|
53
100
|
- lib
|
54
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
55
102
|
requirements:
|
56
|
-
- -
|
103
|
+
- - ">="
|
57
104
|
- !ruby/object:Gem::Version
|
58
105
|
version: '0'
|
59
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
107
|
requirements:
|
61
|
-
- -
|
108
|
+
- - ">="
|
62
109
|
- !ruby/object:Gem::Version
|
63
110
|
version: '0'
|
64
111
|
requirements: []
|
65
112
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.4.5
|
67
114
|
signing_key:
|
68
115
|
specification_version: 4
|
69
116
|
summary: Adds audit log capability to Pry
|