palo_alto 0.1.2 → 0.1.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: d8a6152aa6eb0aa5b5a8ba4e6a31149b45ed06646ac2cbd12907e390ecfc4812
4
- data.tar.gz: f1b8cc362bcad0902ddbdbc4eb38db276cabeee8b4cbc9155003f3e86a4b7ca1
3
+ metadata.gz: ad314eed2154013cd0dd81166c795481debf4762a5d5b5b47f0943d8db612f98
4
+ data.tar.gz: 02ba2cb368a2bae0a3bc7c4c121d79628b600df89e70f837a613871e1db041c6
5
5
  SHA512:
6
- metadata.gz: 5813d1df939b84e47cb15138d82442f153e24165d0fc9efd50df726922b0f7bb9aa88d7266ec9523d84fe2bd9debae8a840967e4867c3039f04da57f91939037
7
- data.tar.gz: '09a3c66024510102688e1fa27dc3b4bebecdab9b3e7511c2fc5669eb6e50ecbad8e2fe82aed5e2b6c8e6da58b9a39c44dbbb93b5c36151927084a3db1d380cae'
6
+ metadata.gz: a63062907d61012d713da785791526c167370d39248190a356f17f3bc4392ba3010e9ace8a1bd25fd693914bca6440a97ae03c95ce7d81296c275157299e370c
7
+ data.tar.gz: c752bc2dce7f2e325708d4284d74a0c167ae4b623569dd4254a93636fefbf2df0e2f72a247ac4207791c4edcf4c05ef1a0d10d72b95acb703a554d62e6c2d9bb
data/README.md CHANGED
@@ -0,0 +1,3 @@
1
+ Works for me :)
2
+
3
+ You can find examples on how to use this module in the examples/ directory
@@ -0,0 +1,4 @@
1
+ require 'palo_alto'
2
+
3
+ xml = PaloAlto::XML.new(host: "panorama-test", port: "443", username: "admin", password: "Admin123!", debug: [:sent, :received, :statistics])
4
+
@@ -0,0 +1,50 @@
1
+ require 'palo_alto'
2
+ require "byebug"
3
+
4
+ xml = PaloAlto::XML.new(host: "panorama-test", port: "443", username: "admin", password: "Admin123!", debug: [:sent, :received, :statistics])
5
+
6
+ #rules=xml.config.devices.entry(name:'localhost.localdomain').device_group.entry(name: 'PLAYGROUND').pre_rulebase.security.rules.entry{(child(:source).child(:member).text=="VPN_Net_10.1.1.0-24").or(child(:destination).child(:member).text == 'VPN_Net_10.1.1.0-24')}.get_all
7
+
8
+ rules=xml.config.devices.entry(name:'localhost.localdomain').device_group.entry(name: 'PLAYGROUND').pre_rulebase.security.rules.entry{}.get_all
9
+
10
+ pp rules
11
+ pp rules.length
12
+
13
+
14
+
15
+
16
+ tag_name='vpn:test'
17
+
18
+ tag = xml.config.devices.entry(name:'localhost.localdomain').device_group.entry(name: dg).tag.entry(name:tag_name).create!
19
+ tag.color = "color23"
20
+ tag.push!
21
+
22
+
23
+
24
+ dg='PLAYGROUND'
25
+ rules=xml.config.devices.entry(name:'localhost.localdomain').device_group.entry(name: dg).pre_rulebase.security.rules.entry{}.get_all
26
+ rules.reject!{|rule| rule.api_attributes['loc'] != dg}
27
+
28
+ pp rules.first.api_attributes # attributes like uuid and loc
29
+ pp rules.first.values()
30
+
31
+ r = rules.first
32
+ r.tag.member = [tag.name]
33
+ r.group_tag = tag.name
34
+ r.description += "...."
35
+ r.push!
36
+
37
+ puts r.to_xpath
38
+ r.rename!("Test 1")
39
+ puts r.to_xpath
40
+ pp r.name
41
+
42
+ exit 0
43
+
44
+ # create a new template with persisted subclasses
45
+ new_template = xml.config.devices.entry(name:'localhost.localdomain').template.entry(name: 'testtemplate').create!
46
+ new_template.push!
47
+
48
+
49
+
50
+
@@ -0,0 +1,27 @@
1
+ require 'palo_alto'
2
+
3
+ xml = PaloAlto::XML.new(host: "panorama-test", port: "443", username: "admin", password: "Admin123!", debug: [:statistics, :warnings, :_sent, :_received])
4
+
5
+ query = "( full-path contains '/config/devices/entry[@name=\\'localhost.localdomain\\']/device-group/entry[@name=\\'gr\\']/address/entry[@name=\\'Blah_19\\']' )"
6
+ l=xml.log(query: query, log_type: 'config', nlogs: 50, show_detail: true, days: nil)
7
+
8
+ pp l.count
9
+ x = l.first
10
+ pp x
11
+
12
+
13
+ #################
14
+
15
+
16
+
17
+ ritm = 'RITM1234567'
18
+
19
+ def quote_string(v)
20
+ "'" + v.to_s.gsub(/'/, "\\\\'") + "'"
21
+ end
22
+
23
+ query = "( ( cmd eq edit ) or ( cmd eq audit-commit ) ) and ( comment contains #{quote_string(ritm)} )"
24
+
25
+ l=xml.log(query: query, log_type: 'config', nlogs: 50, show_detail: true, days: nil)
26
+
27
+ pp l.count
@@ -0,0 +1,127 @@
1
+ require 'palo_alto'
2
+
3
+ a= {commit: { partial:[
4
+ {'admin': ['admin']},
5
+ 'no-template',
6
+ 'no-template-stack',
7
+ 'no-log-collector',
8
+ 'no-log-collector-group',
9
+ 'no-wildfire-appliance',
10
+ 'no-wildfire-appliance-cluster',
11
+ {'device-and-network': 'excluded'},
12
+ {'shared-object': 'excluded'}
13
+ ]}}
14
+
15
+ b= { show: {devices: 'all' } }
16
+
17
+ c = {revert: { config: {
18
+ partial:[
19
+ {'admin': ['admin']},
20
+ 'no-template',
21
+ 'no-template-stack',
22
+ 'no-log-collector',
23
+ 'no-log-collector-group',
24
+ 'no-wildfire-appliance',
25
+ 'no-wildfire-appliance-cluster',
26
+ {'device-and-network': 'excluded'},
27
+ {'shared-object': 'excluded'}
28
+ ]}}}
29
+
30
+ d = {commit: nil}
31
+
32
+ e = 'commit'
33
+
34
+ f = {revert: 'config'}
35
+
36
+ g= {show: 'templates'}
37
+
38
+ h= {show: 'devicegroups'}
39
+
40
+ j={show: {jobs: {id: 12431}}}
41
+
42
+ k={check: 'full-commit-required'}
43
+
44
+ push_to_device={ 'commit-all': { 'shared-policy': { 'device-group': [{name:'TEST-DG'}]}}}
45
+
46
+ #validate:
47
+ p={ 'commit-all':
48
+ {
49
+ 'shared-policy': [
50
+ {'device-group': [{name:'PLAYGROUND'}]},
51
+ {'include-template':'yes'},
52
+ {'merge-with-candidate-cfg':'yes'},
53
+ {'force-template-values':'no'},
54
+ {'validate-only':'yes'}
55
+ ]
56
+ }
57
+ }
58
+
59
+ i = {show: {query: {result: {id: 10438 }}}}
60
+
61
+
62
+ # hit counts:
63
+ device_group = 'PLAYGROUND'
64
+
65
+ l = {
66
+ show: {
67
+ 'rule-hit-count': [{
68
+ 'device-group': [{
69
+ entry: [{
70
+ name: device_group
71
+ }, {
72
+ "pre-rulebase": [{
73
+ entry: [{
74
+ name: 'security'
75
+ }, {
76
+ 'rules': 'all'
77
+ }]
78
+ }]
79
+ }]
80
+ }]
81
+ }]
82
+ }
83
+ }
84
+
85
+ # hit count for one rule, with more details:
86
+ rule_name = "Rule 27"
87
+ l = {
88
+ show: {
89
+ 'rule-hit-count': [{
90
+ 'device-group': [{
91
+ entry: [{
92
+ name: device_group
93
+ }, {
94
+ "pre-rulebase": [{
95
+ entry: [{
96
+ name: 'security'
97
+ }, {
98
+ 'rules': {
99
+ "rule-name": [{
100
+ entry: [{
101
+ name: rule_name
102
+ }]
103
+ }]
104
+ }
105
+ }]
106
+ }]
107
+ }]
108
+ }]
109
+ }]
110
+ }
111
+ }
112
+
113
+
114
+ xml = PaloAlto::XML.new(host: "panorama-test", port: "443", username: "admin", password: "Admin123!", debug: [:sent, :received])
115
+
116
+ #pp xml.op.execute(a)
117
+ #pp xml.op.execute(b)
118
+ #pp xml.op.execute(c)
119
+ pp xml.op.execute(d)
120
+ puts "---------------------------"
121
+ pp xml.op.execute(e)
122
+ puts "---------------------------"
123
+
124
+ #pp xml.op.execute(f)
125
+
126
+ pp xml.op.execute(k)
127
+
data/lib/palo_alto/log.rb CHANGED
@@ -1,5 +1,3 @@
1
- require "pp"
2
-
3
1
  module PaloAlto
4
2
  class XML
5
3
 
@@ -23,7 +21,6 @@ module PaloAlto
23
21
  @count=nil
24
22
  @skip=0
25
23
  @first_result = fetch_result
26
- #pp @current_result
27
24
  super
28
25
  end
29
26
 
data/lib/palo_alto/op.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "nokogiri"
2
- require "pp"
3
2
 
4
3
  module PaloAlto
5
4
  class XML
@@ -49,9 +48,7 @@ module PaloAlto
49
48
  section = obj.keys.first
50
49
  data = obj[section]
51
50
  else
52
- puts "----------"
53
- pp obj
54
- raise
51
+ raise obj.pretty_inspect
55
52
  end
56
53
 
57
54
  unless ops.has_key?(section.to_s)
@@ -60,9 +57,6 @@ module PaloAlto
60
57
  end
61
58
 
62
59
  ops_tree = ops[section.to_s]
63
- #pp [:ops, ops_tree]
64
- #pp [:obj, obj]
65
- #puts "****************** build #{section} (#{ops_tree[:obj]})"
66
60
 
67
61
  section = escape_xpath_tag(section)
68
62
 
@@ -104,8 +98,7 @@ module PaloAlto
104
98
  xml_builder(xml, ops_tree, v)
105
99
  }
106
100
  else
107
- pp ops_tree[:obj]
108
- raise
101
+ raise ops_tree[:obj].pretty_inspect
109
102
  end
110
103
  xml
111
104
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaloAlto
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
data/lib/palo_alto.rb CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'openssl'
4
4
  require 'nokogiri'
5
+ require 'net/http'
6
+ require 'pp'
5
7
 
6
8
  require_relative 'palo_alto/version'
7
9
 
@@ -10,7 +12,6 @@ require_relative 'palo_alto/log'
10
12
  require_relative 'palo_alto/op'
11
13
 
12
14
  module PaloAlto
13
-
14
15
  class PermanentException < StandardError
15
16
  end
16
17
 
data/palo_alto.gemspec CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |spec|
14
14
  spec.required_ruby_version = '>= 2.7.0'
15
15
 
16
16
  spec.metadata['homepage_uri'] = spec.homepage
17
- spec.metadata["source_code_uri"] = 'https://github.com/Sebbb/palo_alto'
18
- spec.metadata["changelog_uri"] = 'https://github.com/Sebbb/palo_alto/blob/main/README.md'
17
+ spec.metadata["source_code_uri"] = 'https://github.com/Sebbb/palo_alto/'
18
+ spec.metadata["changelog_uri"] = 'https://github.com/Sebbb/palo_alto/blob/main/CHANGELOG.md'
19
19
 
20
20
  # Specify which files should be added to the gem when it is released.
21
21
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: palo_alto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Roesner
@@ -37,6 +37,10 @@ files:
37
37
  - LICENSE.txt
38
38
  - README.md
39
39
  - Rakefile
40
+ - examples/connecttest.rb
41
+ - examples/test_config.rb
42
+ - examples/test_log.rb
43
+ - examples/test_op.rb
40
44
  - lib/palo_alto.rb
41
45
  - lib/palo_alto/config.rb
42
46
  - lib/palo_alto/log.rb
@@ -48,8 +52,8 @@ licenses:
48
52
  - artistic-2.0
49
53
  metadata:
50
54
  homepage_uri: https://github.com/Sebbb/
51
- source_code_uri: https://github.com/Sebbb/palo_alto
52
- changelog_uri: https://github.com/Sebbb/palo_alto/blob/main/README.md
55
+ source_code_uri: https://github.com/Sebbb/palo_alto/
56
+ changelog_uri: https://github.com/Sebbb/palo_alto/blob/main/CHANGELOG.md
53
57
  post_install_message:
54
58
  rdoc_options: []
55
59
  require_paths: