ruby-paloalto-client 0.0.1 → 0.0.2

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +40 -0
  3. data/lib/{palo-alto → palo_alto}/client/version.rb +1 -1
  4. data/lib/{palo-alto → palo_alto}/client.rb +3 -3
  5. data/lib/{palo-alto/common/base-api.rb → palo_alto/common/base_api.rb} +0 -0
  6. data/lib/{palo-alto → palo_alto}/helpers/rest.rb +1 -1
  7. data/lib/{palo-alto → palo_alto}/models/address.rb +0 -0
  8. data/lib/{palo-alto/models/address-group.rb → palo_alto/models/address_group.rb} +0 -0
  9. data/lib/{palo-alto → palo_alto}/models/device.rb +0 -0
  10. data/lib/palo_alto/models/log_entry.rb +93 -0
  11. data/lib/{palo-alto → palo_alto}/models/rulebase.rb +0 -0
  12. data/lib/palo_alto/models/system_log_entry.rb +29 -0
  13. data/lib/palo_alto/models/traffic_log_entry.rb +33 -0
  14. data/lib/{palo-alto/models/virtual-system.rb → palo_alto/models/virtual_system.rb} +0 -0
  15. data/lib/{palo-alto/v6/address-api.rb → palo_alto/v6/address_api.rb} +1 -1
  16. data/lib/{palo-alto/v6/address-group-api.rb → palo_alto/v6/address_group_api.rb} +2 -2
  17. data/lib/{palo-alto → palo_alto}/v6/api.rb +6 -4
  18. data/lib/{palo-alto/v6/device-api.rb → palo_alto/v6/device_api.rb} +2 -2
  19. data/lib/palo_alto/v6/log_api.rb +189 -0
  20. data/lib/{palo-alto/v6/virtual-system-api.rb → palo_alto/v6/virtual_system_api.rb} +4 -4
  21. data/ruby-paloalto-client.gemspec +1 -1
  22. data/spec/fixtures/blank_traffic_logs.xml +27 -0
  23. data/spec/fixtures/log_complete.xml +81 -0
  24. data/spec/fixtures/log_in_progress.xml +28 -0
  25. data/spec/fixtures/log_job.xml +8 -0
  26. data/spec/fixtures/missing_type_logs.xml +29 -0
  27. data/spec/fixtures/pending_traffic_logs.xml +23 -0
  28. data/spec/fixtures/system_logs.xml +61 -0
  29. data/spec/fixtures/traffic_logs.xml +139 -0
  30. data/spec/fixtures/unsupported_log_attribute.xml +33 -0
  31. data/spec/fixtures/unsupported_logs.xml +32 -0
  32. data/spec/lib/palo-alto/client_spec.rb +1 -1
  33. data/spec/lib/palo-alto/common/base_api_spec.rb +2 -2
  34. data/spec/lib/palo-alto/helpers/rest_spec.rb +2 -2
  35. data/spec/lib/palo-alto/models/address_group_spec.rb +1 -1
  36. data/spec/lib/palo-alto/models/address_spec.rb +1 -1
  37. data/spec/lib/palo-alto/models/device_spec.rb +1 -1
  38. data/spec/lib/palo-alto/models/log_entry_spec.rb +86 -0
  39. data/spec/lib/palo-alto/models/rulebase_spec.rb +1 -1
  40. data/spec/lib/palo-alto/models/system_log_entry_spec.rb +18 -0
  41. data/spec/lib/palo-alto/models/traffic_log_entry_spec.rb +18 -0
  42. data/spec/lib/palo-alto/models/virtual_system_spec.rb +1 -1
  43. data/spec/lib/palo-alto/v6/address_api_spec.rb +2 -2
  44. data/spec/lib/palo-alto/v6/address_group_api_spec.rb +4 -4
  45. data/spec/lib/palo-alto/v6/api_spec.rb +1 -1
  46. data/spec/lib/palo-alto/v6/device_api_spec.rb +3 -3
  47. data/spec/lib/palo-alto/v6/log_api_spec.rb +218 -0
  48. data/spec/lib/palo-alto/v6/virtual_system_api_spec.rb +2 -2
  49. data/spec/spec_helper.rb +1 -0
  50. metadata +48 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdc9c84ff0f1d1f1e1abde649da826eba4e47288
4
- data.tar.gz: ae3c9a3e01f7d336561c33e2754423192b6b159b
3
+ metadata.gz: 891c7018edef362497d303ebdc67fa8bb8302f3a
4
+ data.tar.gz: 57b28f4a5d6e4efe54cf3477aa6a3ac85cd9f893
5
5
  SHA512:
6
- metadata.gz: bd186bd765e99f2398e47dded35b8d79d552691d4d002922e95c17722ba7ae6fbb7eb8a76d44b2ff313e31f70616c473cb5cae534d81d7e4e5756e6dd47fc250
7
- data.tar.gz: 7274bf968c19fba909e672ffe1ea65a2ca38b474dfe33cfb9cbfb44feff0340d9318714c28e65d139a6af3e33bb55de8fddeeb9694cdb8cb013279b05e62a041
6
+ metadata.gz: 8590c3367f11adab04ffe41ef95522921e830d3493b0c5db0821552f4755cd6ac76b9c143fdc656759b1b7a12c7fe664f0d08f099454aee64396eb1390b0279a
7
+ data.tar.gz: e1ca7bc8ca9189e0a14cac849e1780e467ac91e3021c2375e1d9872327857b05c69a7b4b43e5c872f82d7872525698360e32b54a5700d6e27bb8027e5381757f
data/README.md CHANGED
@@ -150,3 +150,43 @@ address_groups = pa_client.address_groups
150
150
 
151
151
  address_group = address_groups[0]
152
152
  ```
153
+
154
+ ### Logs
155
+
156
+ The logs interface allows capturing logs from the PaloAlto device. This process is an asynchronous task and requires
157
+ triggering a job on the PaloAlto device to generate the logs, and then fetching the logs from the device when the
158
+ job has been completed. If the log job has not yet completed, an Exception is raised indicating that the Job
159
+ has not yet completed and the logs are not yet available.
160
+
161
+ #### Traffic Logs
162
+
163
+ To capture traffic logs from the PaloAlto device, perform the following:
164
+
165
+ ```bash
166
+ # create log generation job and capture the job_id
167
+ log_job_id = pa_client.generate_logs(log_type: "traffic")
168
+
169
+ # query for the logs - job has not yet completed, Exception is raised
170
+ pa_client.get_logs(job_id: log_job_id)
171
+
172
+ => Exception: "Log job with ID '12345' is still in progress"
173
+
174
+ # query for the logs - job has completed, log array is returned
175
+ pa_client.get_logs(job_id: log_job_id)
176
+
177
+ => [#<PaloAlto::Models::TrafficLogEntry:0x0000000295ec30 @id="6143315061768195499", @serial="001606017466", @seqno="3936876", @type="TRAFFIC", @domain="1", @receive_time="2015/04/30 08:44:51", @actionflags="0x0", @subtype="end", @config_ver="1", @time_generated="2015/04/30 08:44:51", @src="192.168.5.156", @dst="192.168.4.3", @rule="allow global-protect-ssl", @srcloc="CN", @dstloc="US", @app="insufficient-data", @vsys="vsys1", @from="outside", @to="outside", @inbound_if="ethernet1/3", @outbound_if="ethernet1/3", @time_received="2015/04/30 08:44:51", @sessionid="3396", @repeatcnt="1", @sport="60000", @dport="5632", @natsport="0", @natdport="0", @flags="0", @flag_pcap="no", @flag_flagged="no", @flag_proxy="no", @flag_url_denied="no", @flag_nat="no", @captive_portal="no", @exported="no", @transaction="no", @pbf_c2s="no", @pbf_s2c="no", @temporary_match="no", @sym_return="no", @decrypt_mirror="no", @proto="udp", @action="allow", @cpadding="0", @bytes="60", @bytes_sent="60", @bytes_received="0", @packets="1", @start="2015/04/30 08:43:51", @elapsed="0", @category="any", @padding="0", @pkts_sent="1", @pkts_received="0">]
178
+ ```
179
+
180
+ #### System Logs
181
+
182
+ To capture system logs from the PaloAlto device, perform the following:
183
+
184
+ ```bash
185
+ # create log generation job and capture the job_id
186
+ log_job_id = pa_client.generate_logs(log_type: "system")
187
+
188
+ # query for the logs - job has completed, log array is returned
189
+ pa_client.get_logs(job_id: log_job_id)
190
+
191
+ => [#<PaloAlto::Models::SystemLogEntry:0x000000020535c8 @log_id="6143315061768192081", @serial="001606017466", @seqno="122200", @type="SYSTEM", @domain="1", @receive_time="2015/04/30 09:16:23", @actionflags="0x0", @subtype="general", @config_ver="0", @time_generated="2015/04/30 09:16:23", @eventid="general", @fmt="0", @id="0", @module="general", @severity="informational", @opaque="User jkarimi logged out via Web from 10.0.0.4">, #<PaloAlto::Models::SystemLogEntry:0x0000000204ae28 @log_id="6143315061768192080", @serial="001606017466", @seqno="122199", @type="SYSTEM", @domain="1", @receive_time="2015/04/30 09:16:23", @actionflags="0x0", @subtype="general", @config_ver="0", @time_generated="2015/04/30 09:16:23", @eventid="general", @fmt="0", @id="0", @module="general", @severity="informational", @opaque="User jkarimi logged in via Web from 10.0.0.4 using https">, #<PaloAlto::Models::SystemLogEntry:0x00000002042840 @log_id="6143315061768192079", @serial="001606017466", @seqno="122198", @type="SYSTEM", @domain="1", @receive_time="2015/04/30 09:16:23", @actionflags="0x0", @subtype="general", @config_ver="0", @time_generated="2015/04/30 09:16:23", @eventid="auth-success", @fmt="0", @id="0", @module="general", @severity="informational", @opaque="User 'jkarimi' authenticated. Profile Active Directory via ACS in an authentication sequence Radius-then-Local succeeded. From: 10.0.0.4.">]
192
+ ```
@@ -1,5 +1,5 @@
1
1
  module PaloAlto
2
2
  module Client
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
- require "palo-alto/client/version"
2
- require "palo-alto/common/base-api"
3
- require "palo-alto/helpers/rest"
1
+ require "palo_alto/client/version"
2
+ require "palo_alto/common/base_api"
3
+ require "palo_alto/helpers/rest"
4
4
 
5
5
  module PaloAlto
6
6
  module Client
@@ -1,4 +1,4 @@
1
- require "rest-client"
1
+ require "rest_client"
2
2
 
3
3
  module PaloAlto
4
4
  module Helpers
File without changes
File without changes
@@ -0,0 +1,93 @@
1
+ module PaloAlto
2
+ module Models
3
+ class LogEntry
4
+ attr_accessor :log_id, :serial, :seqno, :type
5
+
6
+ SUPPORTED_TYPES = [ "traffic", "system", "data" ]
7
+
8
+ # Create and returns a new PaloAlto::Models::LogEntry instance with the given parameters
9
+ #
10
+ # == Attributes
11
+ #
12
+ # * +log_id+ - Unique ID of the log
13
+ # * +serial+ - Serial number of the log
14
+ # * +seqno+ - Sequence number of the log
15
+ # * +type+ - Type of log
16
+ # * +add_attrs+ - Additional attributes to create setters/getters for
17
+ #
18
+ # == Example
19
+ #
20
+ # PaloAlto::Models::LogEntry.new serial: '9390235701',
21
+ # seqno: '2',
22
+ # type: 'TRAFFIC'
23
+ def initialize(log_id:, serial:, seqno:, type:, addl_attrs: [])
24
+ self.log_id = log_id
25
+ self.serial = serial
26
+ self.seqno = seqno
27
+ self.type = type
28
+
29
+ # dynamically create setter/getter methods
30
+ addl_attrs.each do |attr|
31
+ self.instance_eval("def #{attr}; @#{attr}; end")
32
+ self.instance_eval("def #{attr}=(val); @#{attr}=val; end")
33
+ end
34
+
35
+ self
36
+ end
37
+
38
+ # Construct a log from the incoming Nokogiri XML data type
39
+ #
40
+ # == Attributes
41
+ #
42
+ # * +log_xml+ - Nokogiri element containing the log element
43
+ #
44
+ # == Example
45
+ #
46
+ # PaloAlto::Models::LogEntry.from_xml xml_data: log_xml
47
+ def self.from_xml(xml_data:)
48
+ log_instance = nil
49
+ log_type = xml_data.xpath('.//type')[0]
50
+
51
+ if log_type.nil? or (log_type_string = log_type.content).nil?
52
+ raise "Log type is unknown"
53
+ else
54
+ # construct the log instance based on supported known log types
55
+ begin
56
+ # get the minimum required attributes for creating any log type
57
+ log_id = xml_data.xpath('@logid')[0].content
58
+ serial_number = xml_data.xpath('.//serial')[0].content
59
+ sequence_number = xml_data.xpath('.//seqno')[0].content
60
+
61
+ case log_type_string.downcase
62
+ when "traffic"
63
+ log_instance = PaloAlto::Models::TrafficLogEntry.new(log_id: log_id, serial: serial_number, seqno: sequence_number)
64
+ when "system"
65
+ log_instance = PaloAlto::Models::SystemLogEntry.new(log_id: log_id, serial: serial_number, seqno: sequence_number)
66
+ else
67
+ raise "Log type '#{log_type_string}' is unsupported at this time"
68
+ end
69
+ rescue Exception => e
70
+ raise "Could not find a required attribute for the specified log type: #{e.message}"
71
+ end
72
+
73
+ begin
74
+ # normalize the attributes and dynamically assign them based on the XML data
75
+ xml_data.xpath('.//*').each do |attr|
76
+ unless [ "log_id", "serial", "seqno", "type" ].include?(attr.name)
77
+ log_instance.send("#{attr.name.gsub('-', '_')}=", attr.content)
78
+ end
79
+ end
80
+ rescue Exception => e
81
+ raise "Unsupported attribute type: #{e.message}"
82
+ end
83
+ end
84
+
85
+ return log_instance
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ # load required libraries - required after definition to avoid potential circular dependencies
92
+ require "palo_alto/models/traffic_log_entry"
93
+ require "palo_alto/models/system_log_entry"
File without changes
@@ -0,0 +1,29 @@
1
+ require "palo_alto/models/log_entry"
2
+
3
+ module PaloAlto
4
+ module Models
5
+ class SystemLogEntry < PaloAlto::Models::LogEntry
6
+ attr_accessor :domain, :receive_time, :actionflags, :subtype, :config_ver, :time_generated,
7
+ :eventid, :fmt, :id, :module, :severity, :opaque, :object
8
+
9
+ # Create and returns a new PaloAlto::Models::LogEntry instance with the given parameters
10
+ #
11
+ # == Attributes
12
+ #
13
+ # * +log_id+ - ID of the log
14
+ # * +serial+ - Serial number of the log
15
+ # * +seqno+ - Sequence number of the log
16
+ #
17
+ # == Example
18
+ #
19
+ # PaloAlto::Models::SystemLogEntry.new log_id: '23954702',
20
+ # serial: '9390235701',
21
+ # seqno: '2'
22
+ def initialize(log_id:, serial:, seqno:)
23
+ super(log_id: log_id, serial: serial, seqno: seqno, type: 'SYSTEM')
24
+
25
+ self
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,33 @@
1
+ require "palo_alto/models/log_entry"
2
+
3
+ module PaloAlto
4
+ module Models
5
+ class TrafficLogEntry < PaloAlto::Models::LogEntry
6
+ attr_accessor :domain, :receive_time, :actionflags, :subtype, :config_ver, :time_generated, :src, :dst,
7
+ :rule, :srcloc, :dstloc, :app, :vsys, :from, :to, :inbound_if, :outbound_if, :time_received,
8
+ :sessionid, :repeatcnt, :sport, :dport, :natsport, :natdport, :flags, :flag_pcap, :pcap_file, :flag_flagged,
9
+ :flag_proxy, :flag_url_denied, :flag_nat, :captive_portal, :exported, :transaction, :pbf_c2s, :natdst,
10
+ :pbf_s2c, :temporary_match, :sym_return, :decrypt_mirror, :proto, :action, :cpadding, :bytes, :natsrc,
11
+ :bytes_sent, :bytes_received, :packets, :start, :elapsed, :category, :padding, :pkts_sent, :pkts_received
12
+
13
+ # Create and returns a new PaloAlto::Models::LogEntry instance with the given parameters
14
+ #
15
+ # == Attributes
16
+ #
17
+ # * +log_id+ - Unique ID of the log
18
+ # * +serial+ - Serial number of the log
19
+ # * +seqno+ - Sequence number of the log
20
+ #
21
+ # == Example
22
+ #
23
+ # PaloAlto::Models::TrafficLogEntry.new log_id: '23954702',
24
+ # serial: '9390235701',
25
+ # seqno: '2'
26
+ def initialize(log_id:, serial:, seqno:)
27
+ super(log_id: log_id, serial: serial, seqno: seqno, type: 'TRAFFIC')
28
+
29
+ self
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,4 +1,4 @@
1
- require "palo-alto/models/address"
1
+ require "palo_alto/models/address"
2
2
 
3
3
  module PaloAlto
4
4
  module V6
@@ -1,5 +1,5 @@
1
- require "palo-alto/models/address-group"
2
- require "palo-alto/models/address"
1
+ require "palo_alto/models/address_group"
2
+ require "palo_alto/models/address"
3
3
 
4
4
  module PaloAlto
5
5
  module V6
@@ -1,7 +1,8 @@
1
- require "palo-alto/v6/device-api"
2
- require "palo-alto/v6/virtual-system-api"
3
- require "palo-alto/v6/address-api"
4
- require "palo-alto/v6/address-group-api"
1
+ require "palo_alto/v6/device_api"
2
+ require "palo_alto/v6/virtual_system_api"
3
+ require "palo_alto/v6/address_api"
4
+ require "palo_alto/v6/address_group_api"
5
+ require "palo_alto/v6/log_api"
5
6
 
6
7
  module PaloAlto
7
8
  module V6
@@ -11,6 +12,7 @@ module PaloAlto
11
12
  include PaloAlto::V6::VirtualSystemApi
12
13
  include PaloAlto::V6::AddressApi
13
14
  include PaloAlto::V6::AddressGroupApi
15
+ include PaloAlto::V6::LogApi
14
16
  end
15
17
  end
16
18
  end
@@ -1,5 +1,5 @@
1
- require "palo-alto/models/device"
2
- require "palo-alto/models/virtual-system"
1
+ require "palo_alto/models/device"
2
+ require "palo_alto/models/virtual_system"
3
3
 
4
4
  module PaloAlto
5
5
  module V6
@@ -0,0 +1,189 @@
1
+ require "palo_alto/models/log_entry"
2
+
3
+ module PaloAlto
4
+ module V6
5
+ module LogApi
6
+ MIN_LOG_REQUEST = 20
7
+ MAX_LOG_REQUEST = 5000
8
+
9
+ # Kicks off a job to generate logs asynchronously
10
+ #
11
+ # == Parameters
12
+ #
13
+ # * +log_type+ - Type of log to generate
14
+ # * +query+ - Query string to use for log generation
15
+ # * +num_logs+ - Number of log entries to query for (check MIN/MAX range for specifics)
16
+ #
17
+ # == Returns
18
+ #
19
+ # * +String+ - String containing the Job ID
20
+ #
21
+ # == Raises
22
+ #
23
+ # * +Exception+ - Raises an exception if the request is unsuccessful or an
24
+ # invalid log_type parameter is passed
25
+ def generate_logs(log_type:, query: "", num_logs: MIN_LOG_REQUEST)
26
+ raise "Invalid log_type - must be one of #{PaloAlto::Models::LogEntry::SUPPORTED_TYPES}" unless PaloAlto::Models::LogEntry::SUPPORTED_TYPES.include?(log_type)
27
+ raise "num_logs must be within range (#{MIN_LOG_REQUEST}..#{MAX_LOG_REQUEST})" unless (MIN_LOG_REQUEST..MAX_LOG_REQUEST) === num_logs
28
+
29
+ log_job_id = ''
30
+
31
+ # configure options for the request
32
+ options = {}
33
+ options[:url] = self.endpoint
34
+ options[:method] = :post
35
+ options[:payload] = { :type => "log",
36
+ :'log-type' => log_type,
37
+ :key => self.auth_key,
38
+ :query => query,
39
+ :nlogs => num_logs.to_s }
40
+
41
+ html_result = Helpers::Rest.make_request(options)
42
+
43
+ raise "Error obtaining log job XML" if html_result.nil?
44
+
45
+ # parse the XML data
46
+ data = Nokogiri::XML(html_result)
47
+ response_code = data.xpath('//response/@status').to_s
48
+
49
+ if response_code == "success"
50
+ log_job_id = data.xpath('//response/result/job')[0].content.to_s
51
+ else
52
+ raise "Error in response XML: #{data.inspect}"
53
+ end
54
+
55
+ log_job_id
56
+ end
57
+
58
+ # Gets the status of a log job based on the Job ID
59
+ #
60
+ # == Parameters
61
+ #
62
+ # * +job_id+ - ID of the job that is generating the logs
63
+ #
64
+ # == Returns
65
+ #
66
+ # * +Boolean+ - True if job is complete, false if job is still processing
67
+ #
68
+ # == Raises
69
+ #
70
+ # * +Exception+ - Raises an exception if the request is unsuccessful
71
+ def log_job_complete?(job_id:)
72
+ status = false
73
+ xml_data = get_log_xml(job_id: job_id)
74
+ response_code = get_log_xml_response_code(xml_data: xml_data)
75
+
76
+ if response_code == "success"
77
+ job_status = get_log_job_status(xml_data: xml_data)
78
+ status = true if job_status == "FIN"
79
+ else
80
+ raise "Error in response XML: #{data.inspect}"
81
+ end
82
+
83
+ status
84
+ end
85
+
86
+ # Gets a set of logs based on the Job ID
87
+ #
88
+ # == Parameters
89
+ #
90
+ # * +job_id+ - ID of the job that generated the logs
91
+ #
92
+ # == Returns
93
+ #
94
+ # * +Array+ - Array of Strings that are the log messages
95
+ #
96
+ # == Raises
97
+ #
98
+ # * +Exception+ - Raises an exception if the request is unsuccessful
99
+ def get_logs(job_id:)
100
+ logs = []
101
+ xml_data = get_log_xml(job_id: job_id)
102
+ response_code = get_log_xml_response_code(xml_data: xml_data)
103
+
104
+ if response_code == "success"
105
+ job_status = get_log_job_status(xml_data: xml_data)
106
+
107
+ if job_status == "FIN"
108
+ xml_data.xpath('//response/result/log/logs/*').each do |log_xml|
109
+ logs << PaloAlto::Models::LogEntry.from_xml(xml_data: log_xml)
110
+ end
111
+ else
112
+ raise "Log job with ID '#{job_id}' is still in progress"
113
+ end
114
+ else
115
+ raise "Error in response XML: #{data.inspect}"
116
+ end
117
+
118
+ logs
119
+ end
120
+
121
+ private
122
+
123
+ # Retrieves the XML file for a given Job ID and returns the data in XML format
124
+ #
125
+ # == Parameters
126
+ #
127
+ # * +job_id+ - ID of the job to retrieve data for
128
+ #
129
+ # == Returns
130
+ #
131
+ # * +Nokogiri::XML::Document+ - XML data structure containing the response data from the job request
132
+ #
133
+ # == Raises
134
+ #
135
+ # * +Exception+ - Raises an exception if the request is unsuccessful
136
+ def get_log_xml(job_id:)
137
+ options = {}
138
+ options[:url] = self.endpoint
139
+ options[:method] = :post
140
+ options[:payload] = { :type => "log",
141
+ :action => :get,
142
+ :'job-id' => job_id,
143
+ :key => self.auth_key }
144
+
145
+ html_result = Helpers::Rest.make_request(options)
146
+
147
+ raise "Error obtaining log job XML" if html_result.nil?
148
+
149
+ Nokogiri::XML(html_result)
150
+ end
151
+
152
+ # Retrieves the response code from an XML data object
153
+ #
154
+ # == Parameters
155
+ #
156
+ # * +xml_data+ - Nokogiri::XML::Document object containing the XML data to parse
157
+ #
158
+ # == Returns
159
+ #
160
+ # * +String+ - String containing the response code returned in the XML data
161
+ #
162
+ # == Raises
163
+ #
164
+ # * +Exception+ - Raises an exception if the input data is not a valid Nokogiri::XML::Document
165
+ def get_log_xml_response_code(xml_data:)
166
+ raise "xml_data must be a valid Nokogiri::XML::Document type" unless xml_data.is_a?(Nokogiri::XML::Document)
167
+ xml_data.xpath('//response/@status').to_s
168
+ end
169
+
170
+ # Retrieves the job status from an XML data object
171
+ #
172
+ # == Parameters
173
+ #
174
+ # * +xml_data+ - Nokogiri::XML::Document object containing the XML data to parse
175
+ #
176
+ # == Returns
177
+ #
178
+ # * +String+ - String containing the job status returned in the XML data
179
+ #
180
+ # == Raises
181
+ #
182
+ # * +Exception+ - Raises an exception if the input data is not a valid Nokogiri::XML::Document
183
+ def get_log_job_status(xml_data:)
184
+ raise "xml_data must be a valid Nokogiri::XML::Document type" unless xml_data.is_a?(Nokogiri::XML::Document)
185
+ xml_data.xpath('//response/result/job/status')[0].content.to_s
186
+ end
187
+ end
188
+ end
189
+ end
@@ -1,7 +1,7 @@
1
- require "palo-alto/models/virtual-system"
2
- require "palo-alto/models/address"
3
- require "palo-alto/models/address-group"
4
- require "palo-alto/models/rulebase"
1
+ require "palo_alto/models/virtual_system"
2
+ require "palo_alto/models/address"
3
+ require "palo_alto/models/address_group"
4
+ require "palo_alto/models/rulebase"
5
5
 
6
6
  module PaloAlto
7
7
  module V6
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'palo-alto/client/version'
4
+ require 'palo_alto/client/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "ruby-paloalto-client"
@@ -0,0 +1,27 @@
1
+ <response status="success">
2
+ <result>
3
+ <job>
4
+ <tenq>12:18:28</tenq>
5
+ <tdeq>12:18:28</tdeq>
6
+ <tlast>12:18:32</tlast>
7
+ <status>FIN</status>
8
+ <id>2023</id>
9
+ </job>
10
+ <log>
11
+ <logs count="0" progress="100">
12
+ </logs>
13
+ </log>
14
+ <meta>
15
+ <devices>
16
+ <entry name="localhost.localdomain">
17
+ <hostname>localhost.localdomain</hostname>
18
+ <vsys>
19
+ <entry name="vsys1">
20
+ <display-name>vsys1</display-name>
21
+ </entry>
22
+ </vsys>
23
+ </entry>
24
+ </devices>
25
+ </meta>
26
+ </result>
27
+ </response>
@@ -0,0 +1,81 @@
1
+ <response status="success"><result>
2
+ <job>
3
+ <tenq>15:00:31</tenq>
4
+ <tdeq>15:00:31</tdeq>
5
+ <tlast>15:00:32</tlast>
6
+ <status>FIN</status>
7
+ <id>2015</id>
8
+ </job>
9
+ <log>
10
+ <logs count="1" progress="100">
11
+ <entry logid="6155931957696928918">
12
+ <domain>1</domain>
13
+ <receive_time>2015/06/03 15:00:13</receive_time>
14
+ <serial>001606017466</serial>
15
+ <seqno>4086925</seqno>
16
+ <actionflags>0x0</actionflags>
17
+ <type>TRAFFIC</type>
18
+ <subtype>end</subtype>
19
+ <config_ver>1</config_ver>
20
+ <time_generated>2015/06/03 15:00:13</time_generated>
21
+ <src>192.168.80.50</src>
22
+ <dst>192.168.80.51</dst>
23
+ <rule>temp allow ping</rule>
24
+ <srcloc>10.0.0.0-10.255.255.255</srcloc>
25
+ <dstloc>192.168.0.0-192.168.255.255</dstloc>
26
+ <app>insufficient-data</app>
27
+ <vsys>vsys1</vsys>
28
+ <from>inside</from>
29
+ <to>outside</to>
30
+ <inbound_if>ethernet1/2</inbound_if>
31
+ <outbound_if>ethernet1/3</outbound_if>
32
+ <time_received>2015/06/03 15:00:13</time_received>
33
+ <sessionid>22301</sessionid>
34
+ <repeatcnt>1</repeatcnt>
35
+ <sport>388</sport>
36
+ <dport>546</dport>
37
+ <natsport>0</natsport>
38
+ <natdport>0</natdport>
39
+ <flags>0</flags>
40
+ <flag-pcap>no</flag-pcap>
41
+ <flag-flagged>no</flag-flagged>
42
+ <flag-proxy>no</flag-proxy>
43
+ <flag-url-denied>no</flag-url-denied>
44
+ <flag-nat>no</flag-nat>
45
+ <captive-portal>no</captive-portal>
46
+ <exported>no</exported>
47
+ <transaction>no</transaction>
48
+ <pbf-c2s>no</pbf-c2s>
49
+ <pbf-s2c>no</pbf-s2c>
50
+ <temporary-match>no</temporary-match>
51
+ <sym-return>no</sym-return>
52
+ <decrypt-mirror>no</decrypt-mirror>
53
+ <proto>udp</proto>
54
+ <action>allow</action>
55
+ <cpadding>0</cpadding>
56
+ <bytes>476</bytes>
57
+ <bytes_sent>476</bytes_sent>
58
+ <bytes_received>0</bytes_received>
59
+ <packets>2</packets>
60
+ <start>2015/06/03 14:59:40</start>
61
+ <elapsed>3</elapsed>
62
+ <category>any</category>
63
+ <padding>0</padding>
64
+ <pkts_sent>2</pkts_sent>
65
+ <pkts_received>0</pkts_received>
66
+ </entry>
67
+ </logs>
68
+ </log>
69
+ <meta>
70
+ <devices>
71
+ <entry name="localhost.localdomain">
72
+ <hostname>localhost.localdomain</hostname>
73
+ <vsys>
74
+ <entry name="vsys1">
75
+ <display-name>vsys1</display-name>
76
+ </entry>
77
+ </vsys>
78
+ </entry>
79
+ </devices>
80
+ </meta>
81
+ </result></response>
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0"?>
2
+ <response status="success">
3
+ <result>
4
+ <job>
5
+ <tenq>15:22:46</tenq>
6
+ <tdeq>15:22:46</tdeq>
7
+ <tlast>19:00:00</tlast>
8
+ <status>ACT</status>
9
+ <id>2015</id>
10
+ </job>
11
+ <log>
12
+ <logs count="0" progress="0">
13
+ </logs>
14
+ </log>
15
+ <meta>
16
+ <devices>
17
+ <entry name="localhost.localdomain">
18
+ <hostname>localhost.localdomain</hostname>
19
+ <vsys>
20
+ <entry name="vsys1">
21
+ <display-name>vsys1</display-name>
22
+ </entry>
23
+ </vsys>
24
+ </entry>
25
+ </devices>
26
+ </meta>
27
+ </result>
28
+ </response>
@@ -0,0 +1,8 @@
1
+ <response status="success" code="19">
2
+ <result>
3
+ <msg>
4
+ <line>query job enqueued with jobid 2014</line>
5
+ </msg>
6
+ <job>2014</job>
7
+ </result>
8
+ </response>