ruby-paloalto-client 0.0.3 → 0.0.4
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c9bfb2a7671306eeb62a2c873c54718ee5ca4d8
|
4
|
+
data.tar.gz: d03e30894d70ed3833b9a500cda88e3d84c8175c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04775ad4348c01e7061dd1c232d7b51be10240b43fa1bb4f0eefaf4426d33dbb26df15e2241bea4e71ab67ac62118fa6b418e928216a9d91aeda0cf654fd161b
|
7
|
+
data.tar.gz: 7c2c37510d3a295b953fb64e5eee4aac8eb5c08a81f3affc12cab9b5568a44a6f2f065a11cc91d2e85fbbe161b141fbbdb4255a5453ce61474ae1f9fcf5bba2c
|
@@ -3,19 +3,46 @@ module PaloAlto
|
|
3
3
|
# Currently, Rulebase is a stand-in for "Security"
|
4
4
|
# TODO: Add different Rulebase types (Security, NAT, etc)
|
5
5
|
class Rulebase
|
6
|
-
attr_accessor :name
|
6
|
+
attr_accessor :name, :action, :from_zones, :to_zones, :sources, :destinations,
|
7
|
+
:source_users, :services, :categories, :applications, :hip_profiles,
|
8
|
+
:log_session_start, :log_session_end
|
7
9
|
|
8
10
|
# Create and returns a new PaloAlto::Models::Rulebase instance with the given parameters
|
9
11
|
#
|
10
12
|
# == Attributes
|
11
13
|
#
|
12
|
-
# * +name+
|
14
|
+
# * +name+ - Name of the rulebase
|
15
|
+
# * +action+ - Type of rule (deny, allow, etc)
|
16
|
+
# * +from_zones+ - User-defined source zones
|
17
|
+
# * +to_zones+ - User-defined destination zones
|
18
|
+
# * +sources+ - Source IP addresses or networks
|
19
|
+
# * +destinations+ - Destination IP addresses or networks
|
20
|
+
# * +source_users+ - Users defined for the source
|
21
|
+
# * +services+ - Services defined that the rule applies to
|
22
|
+
# * +categories+ - User-defined categories that the rule applies to
|
23
|
+
# * +applications+ - Applications defined that the rule applies to
|
24
|
+
# * +hip_profiles+ - Host information profile for defined hosts
|
25
|
+
# * +log_session_start+ - Whether to log the session start event for captured traffic
|
26
|
+
# * +log_session_end+ - Whether to log the session end even for captured traffic
|
13
27
|
#
|
14
28
|
# == Example
|
15
29
|
#
|
16
30
|
# PaloAlto::Models::Rulebase.new name: 'rulebase-1'
|
17
|
-
def initialize(name
|
18
|
-
|
31
|
+
def initialize(name:, action:, from_zones:, to_zones:, sources:, destinations:, source_users:,
|
32
|
+
services:, categories:, applications:, hip_profiles:, log_session_start:, log_session_end:)
|
33
|
+
self.name = name
|
34
|
+
self.action = action
|
35
|
+
self.from_zones = from_zones
|
36
|
+
self.to_zones = to_zones
|
37
|
+
self.sources = sources
|
38
|
+
self.destinations = destinations
|
39
|
+
self.source_users = source_users
|
40
|
+
self.services = services
|
41
|
+
self.categories = categories
|
42
|
+
self.applications = applications
|
43
|
+
self.hip_profiles = hip_profiles
|
44
|
+
self.log_session_start = log_session_start
|
45
|
+
self.log_session_end = log_session_end
|
19
46
|
|
20
47
|
self
|
21
48
|
end
|
@@ -62,7 +62,19 @@ module PaloAlto
|
|
62
62
|
# get all rulebase members for the virtual system
|
63
63
|
# TODO: Expand beyond just the security rulebase
|
64
64
|
vsys_entry.xpath('rulebase/security/rules/entry').each do |rulebase_entry|
|
65
|
-
vsys.rulebases << PaloAlto::Models::Rulebase.new(name:
|
65
|
+
vsys.rulebases << PaloAlto::Models::Rulebase.new(name: rulebase_entry.xpath('@name').to_s,
|
66
|
+
action: (action = rulebase_entry.xpath('action')[0]) && action.content,
|
67
|
+
from_zones: (from_zones = rulebase_entry.xpath('from/member')) && from_zones.map{ |z| z.content.strip },
|
68
|
+
to_zones: (to_zones = rulebase_entry.xpath('to/member')) && to_zones.map{ |z| z.content.strip },
|
69
|
+
sources: (sources = rulebase_entry.xpath('source/member')) && sources.map{ |z| z.content.strip },
|
70
|
+
destinations: (destinations = rulebase_entry.xpath('destination/member')) && destinations.map{ |z| z.content.strip },
|
71
|
+
source_users: (users = rulebase_entry.xpath('source-user/member')) && users.map{ |z| z.content.strip },
|
72
|
+
services: (services = rulebase_entry.xpath('service/member')) && services.map{ |z| z.content.strip },
|
73
|
+
categories: (categories = rulebase_entry.xpath('category/member')) && categories.map{ |z| z.content.strip },
|
74
|
+
applications: (applications = rulebase_entry.xpath('application/member')) && applications.map{ |z| z.content.strip },
|
75
|
+
hip_profiles: (profiles = rulebase_entry.xpath('hip_profiles/member')) && profiles.map{ |z| z.content.strip },
|
76
|
+
log_session_start: (log_start = rulebase_entry.xpath('log-start')[0]) && log_start.content || "no",
|
77
|
+
log_session_end: (log_end = rulebase_entry.xpath('log-end')[0]) && log_end.content || "no")
|
66
78
|
end
|
67
79
|
|
68
80
|
virtual_systems_list << vsys
|
@@ -6,6 +6,43 @@
|
|
6
6
|
<security admin="admin" time="2015/03/04 13:46:08">
|
7
7
|
<rules admin="admin" time="2015/03/04 13:46:08">
|
8
8
|
<entry name="DNS" admin="admin" time="2015/03/04 13:46:07">
|
9
|
+
<option>
|
10
|
+
<disable-server-response-inspection>no</disable-server-response-inspection>
|
11
|
+
</option>
|
12
|
+
<from>
|
13
|
+
<member>from1</member>
|
14
|
+
</from>
|
15
|
+
<to>
|
16
|
+
<member>to1</member>
|
17
|
+
<member>to2</member>
|
18
|
+
</to>
|
19
|
+
<source>
|
20
|
+
<member>any</member>
|
21
|
+
</source>
|
22
|
+
<destination>
|
23
|
+
<member>10.11.12.13-1</member>
|
24
|
+
<member>1.2.3.4/32</member>
|
25
|
+
</destination>
|
26
|
+
<source-user>
|
27
|
+
<member>any</member>
|
28
|
+
</source-user>
|
29
|
+
<category>
|
30
|
+
<member>any</member>
|
31
|
+
</category>
|
32
|
+
<application>
|
33
|
+
<member>dns</member>
|
34
|
+
</application>
|
35
|
+
<service>
|
36
|
+
<member>any</member>
|
37
|
+
</service>
|
38
|
+
<hip-profiles>
|
39
|
+
<member>any</member>
|
40
|
+
</hip-profiles>
|
41
|
+
<log-start>no</log-start>
|
42
|
+
<log-end>yes</log-end>
|
43
|
+
<negate-source>no</negate-source>
|
44
|
+
<negate-destination>no</negate-destination>
|
45
|
+
<action>allow</action>
|
9
46
|
</entry>
|
10
47
|
</rules>
|
11
48
|
</security>
|
@@ -1,16 +1,88 @@
|
|
1
1
|
require "palo_alto/models/rulebase"
|
2
2
|
|
3
3
|
describe "PaloAlto::Models::Rulebase" do
|
4
|
-
let(:name)
|
4
|
+
let(:name) { "test-rulebase" }
|
5
|
+
let(:action) { "deny" }
|
6
|
+
let(:from_zones) { [ "a", "b" ] }
|
7
|
+
let(:to_zones) { [ "c", "d" ] }
|
8
|
+
let(:sources) { [ "1.2.3.4", "5.6.7.8/23" ] }
|
9
|
+
let(:destinations) { [ "4.3.2.2", "6.5.3.2/23" ] }
|
10
|
+
let(:source_users) { [ "user1", "user2" ] }
|
11
|
+
let(:services) { [ "service1", "service2" ] }
|
12
|
+
let(:categories) { [ "category1", "category2" ] }
|
13
|
+
let(:applications) { [ "application1", "application2" ] }
|
14
|
+
let(:hip_profiles) { [ "profile1", "profile2" ] }
|
15
|
+
let(:log_session_start) { "true" }
|
16
|
+
let(:log_session_end) { "false" }
|
5
17
|
|
6
18
|
before do
|
7
|
-
@rulebase = PaloAlto::Models::Rulebase.new(name:
|
19
|
+
@rulebase = PaloAlto::Models::Rulebase.new(name: name,
|
20
|
+
action: action,
|
21
|
+
from_zones: from_zones,
|
22
|
+
to_zones: to_zones,
|
23
|
+
sources: sources,
|
24
|
+
destinations: destinations,
|
25
|
+
source_users: source_users,
|
26
|
+
services: services,
|
27
|
+
categories: categories,
|
28
|
+
applications: applications,
|
29
|
+
hip_profiles: hip_profiles,
|
30
|
+
log_session_start: log_session_start,
|
31
|
+
log_session_end: log_session_end)
|
8
32
|
end
|
9
33
|
|
10
34
|
it "has a name attribute" do
|
11
35
|
expect(@rulebase).to respond_to(:name)
|
12
36
|
end
|
13
37
|
|
38
|
+
it "has a action attribute" do
|
39
|
+
expect(@rulebase).to respond_to(:action)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "has a from_zones attribute" do
|
43
|
+
expect(@rulebase).to respond_to(:from_zones)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "has a to_zones attribute" do
|
47
|
+
expect(@rulebase).to respond_to(:to_zones)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "has a sources attribute" do
|
51
|
+
expect(@rulebase).to respond_to(:sources)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "has a destinations attribute" do
|
55
|
+
expect(@rulebase).to respond_to(:destinations)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "has a source_users attribute" do
|
59
|
+
expect(@rulebase).to respond_to(:source_users)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "has a services attribute" do
|
63
|
+
expect(@rulebase).to respond_to(:services)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "has a categories attribute" do
|
67
|
+
expect(@rulebase).to respond_to(:categories)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "has a applications attribute" do
|
71
|
+
expect(@rulebase).to respond_to(:applications)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "has a hip_profiles attribute" do
|
75
|
+
expect(@rulebase).to respond_to(:hip_profiles)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "has a log_session_start attribute" do
|
79
|
+
expect(@rulebase).to respond_to(:log_session_start)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "has a log_session_end attribute" do
|
83
|
+
expect(@rulebase).to respond_to(:log_session_end)
|
84
|
+
end
|
85
|
+
|
14
86
|
describe ".initialize" do
|
15
87
|
it "returns a PaloAlto::Models::Rulebase instance" do
|
16
88
|
expect(@rulebase).to be_instance_of(PaloAlto::Models::Rulebase)
|
@@ -19,5 +91,53 @@ describe "PaloAlto::Models::Rulebase" do
|
|
19
91
|
it "assigns name" do
|
20
92
|
expect(@rulebase.name).to eq(name)
|
21
93
|
end
|
94
|
+
|
95
|
+
it "assigns action" do
|
96
|
+
expect(@rulebase.action).to eq(action)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "assigns from_zones" do
|
100
|
+
expect(@rulebase.from_zones).to eq(from_zones)
|
101
|
+
end
|
102
|
+
|
103
|
+
it "assigns to_zones" do
|
104
|
+
expect(@rulebase.to_zones).to eq(to_zones)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "assigns sources" do
|
108
|
+
expect(@rulebase.sources).to eq(sources)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "assigns destinations" do
|
112
|
+
expect(@rulebase.destinations).to eq(destinations)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "assigns source_users" do
|
116
|
+
expect(@rulebase.source_users).to eq(source_users)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "assigns services" do
|
120
|
+
expect(@rulebase.services).to eq(services)
|
121
|
+
end
|
122
|
+
|
123
|
+
it "assigns categories" do
|
124
|
+
expect(@rulebase.categories).to eq(categories)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "assigns applications" do
|
128
|
+
expect(@rulebase.applications).to eq(applications)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "assigns hip_profiles" do
|
132
|
+
expect(@rulebase.hip_profiles).to eq(hip_profiles)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "assigns log_session_start" do
|
136
|
+
expect(@rulebase.log_session_start).to eq(log_session_start)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "assigns log_session_end" do
|
140
|
+
expect(@rulebase.log_session_end).to eq(log_session_end)
|
141
|
+
end
|
22
142
|
end
|
23
143
|
end
|