paraxial 0.2.0 → 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/lib/paraxial/cli.rb +28 -2
- data/lib/paraxial/helpers.rb +7 -0
- data/lib/paraxial/initializers/startup.rb +47 -38
- data/lib/paraxial/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea5f2156685b5204495019d6a72ad0f433326438abfef4e70e26b39ab62bf58b
|
4
|
+
data.tar.gz: 4dd855ada83c429df5422b42177af07863041ef94feb14912375df5f8d18e807
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f458988de37e4a6c9c0a8f8e1489b613925faf48d11dc59c1addbcca49acc740292cddae12bd675c25c8c640a2f45133e5ed6d9232c8319f74fe868c2e2396e
|
7
|
+
data.tar.gz: 81504558ae7231a7f5f5397f6ca640faf63532c15686d61942d54a306c0d28b865f3e11e8c17973729a1b200c74ad3246f149ca46a53635e91dfa229fe57a998
|
data/lib/paraxial/cli.rb
CHANGED
@@ -4,6 +4,8 @@ require 'net/http'
|
|
4
4
|
require 'uri'
|
5
5
|
require 'json'
|
6
6
|
require 'time'
|
7
|
+
require 'yaml'
|
8
|
+
require_relative 'helpers'
|
7
9
|
|
8
10
|
module Paraxial
|
9
11
|
class CLI < Thor
|
@@ -16,6 +18,13 @@ module Paraxial
|
|
16
18
|
|
17
19
|
def scan
|
18
20
|
puts '[Paraxial] Scan starting...'
|
21
|
+
if check_rubocop_configuration
|
22
|
+
puts '[Paraxial] .rubocop.yml contains the required paraxial configuration.'
|
23
|
+
else
|
24
|
+
puts '[Paraxial] .rubocop.yml does not contain the required paraxial configuration.'
|
25
|
+
puts '[Paraxial] How to configure: TODO_URL'
|
26
|
+
exit
|
27
|
+
end
|
19
28
|
|
20
29
|
if ENV['PARAXIAL_API_KEY'].nil?
|
21
30
|
puts '[Paraxial] Environment variable PARAXIAL_API_KEY not found'
|
@@ -30,7 +39,7 @@ module Paraxial
|
|
30
39
|
rubocop = `rubocop --only #{cops} --format json`
|
31
40
|
lockfile = File.read('./Gemfile.lock')
|
32
41
|
api_key = ENV['PARAXIAL_API_KEY']
|
33
|
-
uri = URI.parse(
|
42
|
+
uri = URI.parse(Paraxial::Helpers.get_paraxial_url + '/api/ruby_scan')
|
34
43
|
headers = { 'Content-Type': 'application/json' }
|
35
44
|
|
36
45
|
body = { rubocop:, lockfile:, api_key:, timestamp: Paraxial.get_timestamp }
|
@@ -60,7 +69,7 @@ module Paraxial
|
|
60
69
|
|
61
70
|
censored_backend_map['api_key'] = api_key
|
62
71
|
backend_map = censored_backend_map
|
63
|
-
parax_uri = URI.parse(
|
72
|
+
parax_uri = URI.parse(Paraxial::Helpers.get_paraxial_url + '/api/github_app')
|
64
73
|
github_pr_url = "https://github.com/#{repo_owner}/#{repo_name}/pull/#{pr_number}"
|
65
74
|
|
66
75
|
rr = Net::HTTP.post(parax_uri, backend_map.to_json, headers)
|
@@ -75,5 +84,22 @@ module Paraxial
|
|
75
84
|
end
|
76
85
|
end
|
77
86
|
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def check_rubocop_configuration
|
91
|
+
rubocop_file = File.join(Dir.pwd, '.rubocop.yml')
|
92
|
+
|
93
|
+
return false unless File.exist?(rubocop_file)
|
94
|
+
|
95
|
+
config = YAML.load_file(rubocop_file)
|
96
|
+
required_key = 'require'
|
97
|
+
|
98
|
+
if config.is_a?(Hash) && config[required_key].is_a?(Array)
|
99
|
+
config[required_key].include?('paraxial')
|
100
|
+
else
|
101
|
+
false
|
102
|
+
end
|
103
|
+
end
|
78
104
|
end
|
79
105
|
end
|
@@ -1,57 +1,66 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
require 'paraxial'
|
3
3
|
require 'rpatricia'
|
4
|
+
require_relative '../helpers'
|
4
5
|
|
5
6
|
Bundler.setup
|
6
7
|
|
7
8
|
Rails.application.config.to_prepare do
|
8
|
-
|
9
|
-
puts '[Paraxial] Runtime start'
|
9
|
+
puts '[Paraxial] Init start'
|
10
10
|
api_key = ENV['PARAXIAL_API_KEY']
|
11
11
|
|
12
12
|
if api_key.nil?
|
13
|
-
puts '[Paraxial] PARAXIAL_API_KEY key not set, agent not started'
|
14
|
-
elsif ENV['PARAXIAL_URL'].nil?
|
15
|
-
puts '[Paraxial] PARAXIAL_URL key not set, agent not started'
|
13
|
+
puts '[Paraxial] Init PARAXIAL_API_KEY key not set, agent not started'
|
16
14
|
elsif Rails.env.test?
|
17
|
-
puts '[Paraxial] Test environment detected, agent not started'
|
15
|
+
puts '[Paraxial] Init Test environment detected, agent not started'
|
18
16
|
else
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
17
|
+
begin
|
18
|
+
puts '[Paraxial] Init config valid, agent starting'
|
19
|
+
deps_and_licenses = []
|
20
|
+
Bundler.load.specs.each do |spec|
|
21
|
+
# Print the gem name and license
|
22
|
+
h = { name: spec.name, version: spec.version.to_s, description: Paraxial.trim_dep(spec.description),
|
23
|
+
license: spec.license || 'None' }
|
24
|
+
deps_and_licenses << h
|
25
|
+
end
|
26
|
+
deps_and_licenses << { name: 'ruby', version: RUBY_VERSION, description: 'The Ruby Programming Language',
|
27
|
+
license: 'Ruby' }
|
28
|
+
uri = URI.parse(Paraxial::Helpers.get_paraxial_url + '/api/ruby_app_lic')
|
29
|
+
headers = { 'Content-Type': 'application/json' }
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
Net::HTTP.
|
34
|
-
end
|
31
|
+
body = { app_lic: deps_and_licenses, api_key:, timestamp: Paraxial.get_timestamp }
|
32
|
+
cloud_uri = URI.parse(Paraxial::Helpers.get_paraxial_url + '/api/cloud_ip_list')
|
33
|
+
response = Net::HTTP.get(cloud_uri)
|
35
34
|
|
36
|
-
|
37
|
-
|
35
|
+
Thread.new do
|
36
|
+
Net::HTTP.post(uri, body.to_json, headers)
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
39
|
+
# https://github.com/jkitching/rpatricia
|
40
|
+
pt_v4 = Patricia.new
|
41
|
+
pt_v6 = Patricia.new(:AF_INET6)
|
42
|
+
cloud_list = JSON.parse(response)
|
43
|
+
cloud_list.each do |k, v|
|
44
|
+
if k.include?('::')
|
45
|
+
pt_v6.add(k, v)
|
46
|
+
else
|
47
|
+
pt_v4.add(k, v)
|
48
|
+
end
|
48
49
|
end
|
50
|
+
# puts '[Paraxial] pt_v4.num_nodes'
|
51
|
+
# puts pt_v4.num_nodes
|
52
|
+
# puts 'pt_v6.num_nodes'
|
53
|
+
# puts pt_v6.num_nodes
|
54
|
+
PARAXIAL_IPV4 = pt_v4
|
55
|
+
PARAXIAL_IPV6 = pt_v6
|
56
|
+
rescue Errno::ECONNREFUSED => _e
|
57
|
+
puts '[Paraxial] Init HTTP request failed, check configuration'
|
58
|
+
PARAXIAL_IPV4 = Patricia.new
|
59
|
+
PARAXIAL_IPV6 = Patricia.new(:AF_INET6)
|
60
|
+
rescue StandardError => _e
|
61
|
+
puts '[Paraxial] Init error, check configuration'
|
62
|
+
PARAXIAL_IPV4 = Patricia.new
|
63
|
+
PARAXIAL_IPV6 = Patricia.new(:AF_INET6)
|
49
64
|
end
|
50
|
-
# puts '[Paraxial] pt_v4.num_nodes'
|
51
|
-
# puts pt_v4.num_nodes
|
52
|
-
# puts 'pt_v6.num_nodes'
|
53
|
-
# puts pt_v6.num_nodes
|
54
|
-
PARAXIAL_IPV4 = pt_v4
|
55
|
-
PARAXIAL_IPV6 = pt_v6
|
56
65
|
end
|
57
66
|
end
|
data/lib/paraxial/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paraxial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Lubas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/paraxial.rb
|
83
83
|
- lib/paraxial/cli.rb
|
84
84
|
- lib/paraxial/engine.rb
|
85
|
+
- lib/paraxial/helpers.rb
|
85
86
|
- lib/paraxial/initializers/startup.rb
|
86
87
|
- lib/paraxial/version.rb
|
87
88
|
- lib/rubocop/cop/paraxial/constantize.rb
|