enfcli 5.0.0.pre.alpha → 5.0.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: 29f4309503935f6931b068e80a850488b2f8833474734c05e8455a04f84293e0
4
- data.tar.gz: 2488271b45ee7c7e5b96cc95546d2f625fb1c503d9ad6720f62649073d4a1874
3
+ metadata.gz: 2f52dc569750edcf380a6f64241fd985decde7de862ca0700e00b8a411548a4b
4
+ data.tar.gz: c3bd0fdbbf27ccc877e82c4ac663118b1710dcf2ccfdeffe2abe91a7930d44fb
5
5
  SHA512:
6
- metadata.gz: 033366cb4db237f61526ddf357bbdfd57d60b482398d21eee798413b5afc91b51a6baae60526b957f07a80f01dea5b47372d72193d40b0af20a98fb88de1cd51
7
- data.tar.gz: e7bd3d1c7da7a861a89f242bd5a2d2f898e5e5b4f848c2412fa9a1b5acb7ac73fb5c679979e80b9b7d1e81ba87de761f157141d49eda2d6c3c5d55b1b315c249
6
+ metadata.gz: 5ced4fe396b61814d1d4b6bd377cf2d913899c8ddf78041e97897f17de7adb526f1e9f1cab24de0443adedda7975ede9545ea720dc9a198cddfa00c6a4c7e257
7
+ data.tar.gz: 375a32dd626c0ccf6b17ca876598791883c6f1fd41a26f9fdc66432a5a750607a960a463ed8eae51c772407cfb15fd9c258c14b69f191a9994840f0ceed1dfc4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enfcli (5.0.0.pre.alpha)
4
+ enfcli (5.0.3)
5
5
  clipboard
6
6
  ffi
7
7
  readline
@@ -15,13 +15,13 @@ GEM
15
15
  addressable (2.7.0)
16
16
  public_suffix (>= 2.0.2, < 5.0)
17
17
  bump (0.8.0)
18
- clipboard (1.3.3)
18
+ clipboard (1.3.4)
19
19
  crack (0.4.3)
20
20
  safe_yaml (~> 1.0.0)
21
21
  diff-lcs (1.3)
22
22
  domain_name (0.5.20190701)
23
23
  unf (>= 0.0.5, < 1.0.0)
24
- ffi (1.12.2)
24
+ ffi (1.13.1)
25
25
  fuubar (2.5.0)
26
26
  rspec-core (~> 3.0)
27
27
  ruby-progressbar (~> 1.4)
@@ -29,16 +29,16 @@ GEM
29
29
  http-accept (1.7.0)
30
30
  http-cookie (1.0.3)
31
31
  domain_name (~> 0.5)
32
- io-console (0.5.5)
32
+ io-console (0.5.6)
33
33
  mime-types (3.3.1)
34
34
  mime-types-data (~> 3.2015)
35
- mime-types-data (3.2019.1009)
35
+ mime-types-data (3.2020.0512)
36
36
  netrc (0.11.0)
37
37
  public_suffix (4.0.3)
38
38
  rake (10.5.0)
39
39
  readline (0.0.2)
40
40
  reline
41
- reline (0.1.2)
41
+ reline (0.1.4)
42
42
  io-console (~> 0.5)
43
43
  rest-client (2.1.0)
44
44
  http-accept (>= 1.7.0, < 2.0)
@@ -68,8 +68,8 @@ GEM
68
68
  thor (0.20.3)
69
69
  unf (0.1.4)
70
70
  unf_ext
71
- unf_ext (0.0.7.6)
72
- unicode-display_width (1.6.1)
71
+ unf_ext (0.0.7.7)
72
+ unicode-display_width (1.7.0)
73
73
  vcr (5.0.0)
74
74
  webmock (3.7.6)
75
75
  addressable (>= 2.3.6)
@@ -92,4 +92,4 @@ DEPENDENCIES
92
92
  webmock
93
93
 
94
94
  BUNDLED WITH
95
- 2.1.4
95
+ 2.2.4
@@ -21,17 +21,24 @@ module EnfApi
21
21
  include Singleton
22
22
 
23
23
  def list_firewall_rules(network)
24
- EnfApi::API.instance.get "/api/xfw/v1/#{network}/rule"
24
+ EnfApi::API.instance.get "/api/xfw/v2/#{network}/rule"
25
25
  end
26
26
 
27
27
  def add_firewall_rule(network, rule)
28
28
  rule_json = EnfApi::to_json(rule)
29
- EnfApi::API.instance.post "/api/xfw/v1/#{network}/rule", rule_json
29
+
30
+ if network
31
+ url = "/api/xfw/v2/#{network}/rule"
32
+ else
33
+ url = "/api/xfw/v2/rule"
34
+ end
35
+
36
+ EnfApi::API.instance.post url, rule_json
30
37
  end
31
38
 
32
39
  def delete_firewall_rules(network, id = nil)
33
40
  # Same method to call to delete all firewall rules in a network. if id is nil
34
- EnfApi::API.instance.delete "/api/xfw/v1/#{network}/rule/#{id}"
41
+ EnfApi::API.instance.delete "/api/xfw/v2/#{network}/rule/#{id}"
35
42
  end
36
43
  end
37
44
  end
data/lib/enfcli.rb CHANGED
@@ -22,6 +22,7 @@ require "ipaddr"
22
22
  require "clipboard"
23
23
  require "json"
24
24
  require "securerandom"
25
+ require "io/console"
25
26
 
26
27
  require "rubygems/commands/update_command"
27
28
  require "rubygems/commands/search_command"
@@ -111,21 +112,9 @@ module EnfCli
111
112
  end
112
113
 
113
114
  def self.ask_password(prompt = nil)
114
- begin
115
- prompt ||= "Enter Password:"
116
- print prompt
117
- # We hide the entered characters before to ask for the password
118
- system "stty -echo"
119
- password = $stdin.gets.chomp
120
- system "stty echo"
121
- puts ""
122
- return password
123
- rescue NoMethodError, Interrupt
124
- # When the process is exited, we display the characters again
125
- # And we exit
126
- system "stty echo"
127
- exit
128
- end
115
+ prompt ||= "Enter Password: "
116
+ password = IO::console.getpass prompt
117
+ return password
129
118
  end
130
119
 
131
120
  def self.generate_ec_cert(key, ipv6)
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright 2018 Xaptum,Inc
2
+ # Copyright 2018-2020 Xaptum,Inc
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -44,7 +44,8 @@ module EnfCli
44
44
  def list_firewall_rules
45
45
  try_with_rescue_in_session do
46
46
  # call the api
47
- rules = EnfApi::Firewall.instance.list_firewall_rules options[:network]
47
+ data = EnfApi::Firewall.instance.list_firewall_rules options[:network]
48
+ rules = data[:data]
48
49
 
49
50
  # display empty table and return
50
51
  if rules.length == 0
@@ -90,7 +91,7 @@ module EnfCli
90
91
  end
91
92
 
92
93
  desc "add-firewall-rule", "Add a firewall rule to a /64 network"
93
- method_option :network, :type => :string, :required => true
94
+ method_option :network, :type => :string
94
95
  method_option :priority, :type => :numeric, :required => true
95
96
  method_option :protocol, :type => :string, :required => true, :enum => ["TCP", "UDP", "ICMP6", "6", "17", "58"]
96
97
  method_option :source_ip, :type => :string
@@ -117,10 +118,12 @@ module EnfCli
117
118
  }
118
119
 
119
120
  # call the api
120
- EnfApi::Firewall.instance.add_firewall_rule options[:network], rule
121
+ data = EnfApi::Firewall.instance.add_firewall_rule options[:network], rule
122
+ rules = data[:data]
121
123
 
122
124
  # print success
123
125
  say "Created firewall rule!", :green
126
+ display_firewall_rules rules
124
127
  end
125
128
  end
126
129
 
@@ -14,5 +14,5 @@
14
14
  # limitations under the License.
15
15
  #
16
16
  module EnfCli
17
- VERSION = "5.0.0-alpha"
17
+ VERSION = "5.0.3"
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enfcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.pre.alpha
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Venkatakumar Srinivasan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-17 00:00:00.000000000 Z
11
+ date: 2021-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -269,9 +269,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
269
269
  version: '0'
270
270
  required_rubygems_version: !ruby/object:Gem::Requirement
271
271
  requirements:
272
- - - ">"
272
+ - - ">="
273
273
  - !ruby/object:Gem::Version
274
- version: 1.3.1
274
+ version: '0'
275
275
  requirements: []
276
276
  rubygems_version: 3.0.3
277
277
  signing_key: