whatdidconsole 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +10 -0
- data/README.md +38 -0
- data/Rakefile +12 -0
- data/lib/whatdidconsole.rb +77 -0
- data/lib/whatdidconsole/version.rb +5 -0
- data/whatdidconsole.gemspec +21 -0
- metadata +51 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c247af95074912f38dc0539f80302061f6c95d2070c73edcbe9aedcaf84c0572
|
4
|
+
data.tar.gz: 95c893c6c6a677d4333350969955e813928b13ae7698a59aed33fb1c53bc15aa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 05d05f50862f69548ad3c8ad1fe0a707117958b89d7ec33eb71709ff5fcf7c8714337ff6df82a77003235debff4fe3a6dbf34ffee7c40fb61d66a5741ebcc7c6
|
7
|
+
data.tar.gz: 2449043f6a781150ac2767041a3355343dfdf8f5cb33616237c5700a9035e6efbb33d39270fac1ed37367b7e1033631b099230346036d80b81f666d5704dec5b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Whatdidconsole gem
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'whatdidconsole'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle install
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install whatdidconsole
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Add the following file to your Rails project:
|
22
|
+
|
23
|
+
```rb
|
24
|
+
Whatdidconsole.configure do |config|
|
25
|
+
config.application_id = "<APP_ID>"
|
26
|
+
config.access_token = "<APP_TOKEN>"
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
## Development
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
33
|
+
|
34
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/HonestEngineering/whatdidconsole-gem.
|
data/Rakefile
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require("irb")
|
4
|
+
require("net/http")
|
5
|
+
require("uri")
|
6
|
+
require("json")
|
7
|
+
require("socket")
|
8
|
+
|
9
|
+
module Whatdidconsole
|
10
|
+
def self.configure
|
11
|
+
$wdc_config = Struct.new(:application_id, :access_token).new
|
12
|
+
yield($wdc_config)
|
13
|
+
|
14
|
+
$wdc_commands = []
|
15
|
+
$wdc_session_id = ""
|
16
|
+
|
17
|
+
IRB::Context.class_eval do
|
18
|
+
alias wdc_old_evaluate evaluate
|
19
|
+
alias wdc_old_initialize initialize
|
20
|
+
alias wdc_old_exit exit
|
21
|
+
|
22
|
+
def initialize(irb, workspace = nil, input_method = nil)
|
23
|
+
begin
|
24
|
+
uri =
|
25
|
+
URI::HTTP.build(
|
26
|
+
scheme: "https",
|
27
|
+
host: "api.whatdidconsole.com",
|
28
|
+
port: "443",
|
29
|
+
path: "/api/v0/applications/sessions"
|
30
|
+
)
|
31
|
+
|
32
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
33
|
+
http.use_ssl = true
|
34
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
35
|
+
request["Content-Type"] = "application/json"
|
36
|
+
request.basic_auth($wdc_config.application_id, $wdc_config.access_token)
|
37
|
+
request.body = JSON.generate({ hostname: Socket.gethostname })
|
38
|
+
response = http.request(request)
|
39
|
+
data = JSON.parse(response.body)
|
40
|
+
$wdc_session_id = data.fetch("session").fetch("id")
|
41
|
+
rescue StandardError => e
|
42
|
+
puts "Failed to initialize Whatdidconsole: #{e}"
|
43
|
+
end
|
44
|
+
wdc_old_initialize(irb, workspace, input_method)
|
45
|
+
end
|
46
|
+
|
47
|
+
def evaluate(line, line_no, exception: nil)
|
48
|
+
$wdc_commands << { line: line, error: false, duration: 42 }
|
49
|
+
wdc_old_evaluate(line, line_no, exception: exception)
|
50
|
+
end
|
51
|
+
|
52
|
+
def exit(ret = 0)
|
53
|
+
begin
|
54
|
+
uri =
|
55
|
+
URI::HTTP.build(
|
56
|
+
scheme: "https",
|
57
|
+
host: "api.whatdidconsole.com",
|
58
|
+
port: "443",
|
59
|
+
path: "/api/v0/applications/sessions/#{$wdc_session_id}/close"
|
60
|
+
)
|
61
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
62
|
+
http.use_ssl = true
|
63
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
64
|
+
request["Content-Type"] = "application/json"
|
65
|
+
request.basic_auth($wdc_config.application_id, $wdc_config.access_token)
|
66
|
+
request.body =
|
67
|
+
JSON.generate({ hostname: Socket.gethostname, commands: $wdc_commands })
|
68
|
+
response = http.request(request)
|
69
|
+
rescue StandardError => e
|
70
|
+
puts "Failed to push session to Whatdidconsole: #{e}"
|
71
|
+
end
|
72
|
+
|
73
|
+
wdc_old_exit(ret)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/whatdidconsole/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'whatdidconsole'
|
7
|
+
s.version = Whatdidconsole::VERSION
|
8
|
+
s.summary = "Never wonder how changes happened in Rails production console again."
|
9
|
+
s.description = "Keep track of production accesses and actions. Your team get notified of any production changes, making it easier to mitigate security issues and production bugs."
|
10
|
+
s.authors = ["Bryan FRIMIN, Charly POLY, David RUYER"]
|
11
|
+
s.email = 'support@whatdidconsole.com'
|
12
|
+
s.files = Dir.chdir(File.expand_path(__dir__)) do
|
13
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
14
|
+
end
|
15
|
+
s.bindir = "exe"
|
16
|
+
s.executables = s.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.homepage = 'https://whatdidconsole.com/'
|
19
|
+
s.license = '© 2021 - Honest Engineering product'
|
20
|
+
s.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: whatdidconsole
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bryan FRIMIN, Charly POLY, David RUYER
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Keep track of production accesses and actions. Your team get notified
|
14
|
+
of any production changes, making it easier to mitigate security issues and production
|
15
|
+
bugs.
|
16
|
+
email: support@whatdidconsole.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- Gemfile
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- lib/whatdidconsole.rb
|
26
|
+
- lib/whatdidconsole/version.rb
|
27
|
+
- whatdidconsole.gemspec
|
28
|
+
homepage: https://whatdidconsole.com/
|
29
|
+
licenses:
|
30
|
+
- "© 2021 - Honest Engineering product"
|
31
|
+
metadata: {}
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.4.0
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubygems_version: 3.2.15
|
48
|
+
signing_key:
|
49
|
+
specification_version: 4
|
50
|
+
summary: Never wonder how changes happened in Rails production console again.
|
51
|
+
test_files: []
|