Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
55cd39eb
authored
Apr 30, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: show rule details RESTful url endpoint added
parent
40c3dccf
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
195 additions
and
98 deletions
+195
-98
cloud/urls.py
+2
-0
firewall_gui/static/js/project.js
+20
-1
firewall_gui/static/partials/rule-edit.html
+22
-0
firewall_gui/views.py
+151
-97
No files found.
cloud/urls.py
View file @
55cd39eb
...
@@ -103,4 +103,6 @@ urlpatterns = patterns('',
...
@@ -103,4 +103,6 @@ urlpatterns = patterns('',
url
(
r'^firewall/domains/$'
,
'firewall_gui.views.list_domains'
),
url
(
r'^firewall/domains/$'
,
'firewall_gui.views.list_domains'
),
url
(
r'^firewall/records/$'
,
'firewall_gui.views.list_records'
),
url
(
r'^firewall/records/$'
,
'firewall_gui.views.list_records'
),
url
(
r'^firewall/blacklists/$'
,
'firewall_gui.views.list_blacklists'
),
url
(
r'^firewall/blacklists/$'
,
'firewall_gui.views.list_blacklists'
),
url
(
r'^firewall/rules/(?P<id>\d+)/$'
,
'firewall_gui.views.show_rule'
),
)
)
firewall_gui/static/js/project.js
View file @
55cd39eb
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* @type {Array}
* @type {Array}
*/
*/
var
listControllers
=
[
'rule'
,
'host'
,
'vlan'
,
'vlangroup'
,
'hostgroup'
,
'firewall'
,
'domain'
,
'record'
,
'blacklist'
];
var
listControllers
=
[
'rule'
,
'host'
,
'vlan'
,
'vlangroup'
,
'hostgroup'
,
'firewall'
,
'domain'
,
'record'
,
'blacklist'
];
var
entityControllers
=
[
'rule'
];
var
module
=
angular
.
module
(
'firewall'
,
[]).
config
(
var
module
=
angular
.
module
(
'firewall'
,
[]).
config
(
[
'$routeProvider'
,
function
(
$routeProvider
)
{
[
'$routeProvider'
,
function
(
$routeProvider
)
{
for
(
var
i
in
listControllers
)
{
for
(
var
i
in
listControllers
)
{
...
@@ -16,6 +16,13 @@ var module = angular.module('firewall', []).config(
...
@@ -16,6 +16,13 @@ var module = angular.module('firewall', []).config(
controller
:
ListController
(
'/firewall/'
+
c
+
's/'
)
controller
:
ListController
(
'/firewall/'
+
c
+
's/'
)
});
});
}
}
for
(
var
i
in
entityControllers
)
{
var
c
=
entityControllers
[
i
];
$routeProvider
.
when
(
'/'
+
c
+
's/:id/'
,
{
templateUrl
:
'/static/partials/'
+
c
+
'-edit.html'
,
controller
:
EntityController
(
'/firewall/'
+
c
+
's/'
)
});
}
$routeProvider
.
otherwise
({
$routeProvider
.
otherwise
({
redirectTo
:
'/rules/'
redirectTo
:
'/rules/'
});
});
...
@@ -77,3 +84,15 @@ function ListController(url) {
...
@@ -77,3 +84,15 @@ function ListController(url) {
});
});
}
}
}
}
function
EntityController
(
url
)
{
console
.
log
(
'creatin...'
,
url
);
return
function
(
$scope
,
$http
,
$routeParams
)
{
var
id
=
$routeParams
.
id
;
console
.
log
(
'foooooo'
);
$http
.
get
(
url
+
id
+
'/'
).
success
(
function
success
(
data
)
{
console
.
log
(
data
);
$scope
.
rule
=
data
;
});
}
}
firewall_gui/static/partials/rule-edit.html
0 → 100644
View file @
55cd39eb
<form
class=
"form-horizontal"
>
<div
class=
"control-group"
>
<label
class=
"control-label"
for=
"ID"
>
ID
</label>
<div
class=
"controls"
>
<input
class=
"input-mini"
type=
"text"
id=
"ID"
placeholder=
"ID"
value=
"{{rule.id}}"
disabled=
"disabled"
>
</div>
</div>
<div
class=
"control-group"
>
<label
class=
"control-label"
for=
"inputPassword"
>
Password
</label>
<div
class=
"controls"
>
<input
type=
"password"
id=
"inputPassword"
placeholder=
"Password"
>
</div>
</div>
<div
class=
"control-group"
>
<div
class=
"controls"
>
<label
class=
"checkbox"
>
<input
type=
"checkbox"
>
Remember me
</label>
<button
type=
"submit"
class=
"btn"
>
Sign in
</button>
</div>
</div>
</form>
firewall_gui/views.py
View file @
55cd39eb
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
get_object_or_404
from
firewall.fw
import
*
from
firewall.fw
import
*
from
firewall.models
import
*
from
firewall.models
import
*
...
@@ -48,143 +48,197 @@ def list_rules(request):
...
@@ -48,143 +48,197 @@ def list_rules(request):
'accept'
:
rule
.
accept
,
'accept'
:
rule
.
accept
,
'description'
:
rule
.
description
,
'description'
:
rule
.
description
,
}
for
rule
in
Rule
.
objects
.
all
()]
}
for
rule
in
Rule
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
rules
),
content_type
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
rules
),
content_type
=
'application/json'
)
def
list_hosts
(
request
):
def
list_hosts
(
request
):
hosts
=
[{
hosts
=
[{
"id"
:
host
.
id
,
'id'
:
host
.
id
,
"reverse"
:
host
.
reverse
,
'reverse'
:
host
.
reverse
,
"name"
:
host
.
hostname
,
'name'
:
host
.
hostname
,
"ipv4"
:
host
.
ipv4
,
'ipv4'
:
host
.
ipv4
,
"pub"
:
"foo"
,
#ide kell valami!
'pub'
:
'foo'
,
#ide kell valami!
"shared_ip"
:
host
.
shared_ip
,
'shared_ip'
:
host
.
shared_ip
,
"description"
:
host
.
description
,
'description'
:
host
.
description
,
"comment"
:
host
.
comment
,
'comment'
:
host
.
comment
,
"location"
:
host
.
location
,
'location'
:
host
.
location
,
"vlan"
:
{
'vlan'
:
{
"name"
:
host
.
vlan
.
name
,
'name'
:
host
.
vlan
.
name
,
"id"
:
host
.
vlan
.
id
'id'
:
host
.
vlan
.
id
},
},
"owner"
:
{
'owner'
:
{
"name"
:
str
(
host
.
owner
),
'name'
:
str
(
host
.
owner
),
"id"
:
host
.
owner
.
id
'id'
:
host
.
owner
.
id
},
},
"created_at"
:
host
.
created_at
.
isoformat
(),
'created_at'
:
host
.
created_at
.
isoformat
(),
"modified_at"
:
host
.
modified_at
.
isoformat
(),
'modified_at'
:
host
.
modified_at
.
isoformat
(),
"groups"
:
[{
'groups'
:
[{
"name"
:
group
.
name
,
'name'
:
group
.
name
,
"id"
:
group
.
id
,
'id'
:
group
.
id
,
}
for
group
in
host
.
groups
.
all
()]
}
for
group
in
host
.
groups
.
all
()]
}
for
host
in
Host
.
objects
.
all
()]
}
for
host
in
Host
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
hosts
),
content_type
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
hosts
),
content_type
=
'application/json'
)
def
list_vlans
(
request
):
def
list_vlans
(
request
):
vlans
=
[{
vlans
=
[{
"id"
:
vlan
.
id
,
'id'
:
vlan
.
id
,
"vid"
:
vlan
.
vid
,
'vid'
:
vlan
.
vid
,
"name"
:
vlan
.
name
,
'name'
:
vlan
.
name
,
"ipv4"
:
vlan
.
ipv4
+
"/"
+
str
(
vlan
.
prefix4
),
'ipv4'
:
vlan
.
ipv4
+
'/'
+
str
(
vlan
.
prefix4
),
"ipv6"
:
vlan
.
ipv6
+
"/"
+
str
(
vlan
.
prefix6
),
'ipv6'
:
vlan
.
ipv6
+
'/'
+
str
(
vlan
.
prefix6
),
"nat"
:
vlan
.
snat_ip
,
'nat'
:
vlan
.
snat_ip
,
"description"
:
vlan
.
description
,
'description'
:
vlan
.
description
,
"domain"
:
{
'domain'
:
{
"id"
:
vlan
.
domain
.
id
,
'id'
:
vlan
.
domain
.
id
,
"name"
:
vlan
.
domain
.
name
,
'name'
:
vlan
.
domain
.
name
,
}
}
}
for
vlan
in
Vlan
.
objects
.
all
()]
}
for
vlan
in
Vlan
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
vlans
),
content_type
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
vlans
),
content_type
=
'application/json'
)
def
list_vlangroups
(
request
):
def
list_vlangroups
(
request
):
vlangroups
=
[{
vlangroups
=
[{
"id"
:
group
.
id
,
'id'
:
group
.
id
,
"name"
:
group
.
name
,
'name'
:
group
.
name
,
"vlans"
:
[{
'vlans'
:
[{
"id"
:
vlan
.
id
,
'id'
:
vlan
.
id
,
"name"
:
vlan
.
name
'name'
:
vlan
.
name
}
for
vlan
in
group
.
vlans
.
all
()],
}
for
vlan
in
group
.
vlans
.
all
()],
"description"
:
group
.
description
,
'description'
:
group
.
description
,
"owner"
:
{
'owner'
:
{
"id"
:
group
.
owner
.
id
,
'id'
:
group
.
owner
.
id
,
"name"
:
str
(
group
.
owner
)
'name'
:
str
(
group
.
owner
)
},
},
"created_at"
:
group
.
created_at
.
isoformat
(),
'created_at'
:
group
.
created_at
.
isoformat
(),
"modified_at"
:
group
.
modified_at
.
isoformat
(),
'modified_at'
:
group
.
modified_at
.
isoformat
(),
}
for
group
in
VlanGroup
.
objects
.
all
()]
}
for
group
in
VlanGroup
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
vlangroups
),
content_type
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
vlangroups
),
content_type
=
'application/json'
)
def
list_hostgroups
(
request
):
def
list_hostgroups
(
request
):
groups
=
[{
groups
=
[{
"id"
:
group
.
id
,
'id'
:
group
.
id
,
"name"
:
group
.
name
,
'name'
:
group
.
name
,
"description"
:
group
.
description
,
'description'
:
group
.
description
,
"owner"
:
{
'owner'
:
{
"id"
:
group
.
owner
.
id
,
'id'
:
group
.
owner
.
id
,
"name"
:
str
(
group
.
owner
),
'name'
:
str
(
group
.
owner
),
},
},
"created_at"
:
group
.
created_at
.
isoformat
(),
'created_at'
:
group
.
created_at
.
isoformat
(),
"modified_at"
:
group
.
modified_at
.
isoformat
()
'modified_at'
:
group
.
modified_at
.
isoformat
()
}
for
group
in
Group
.
objects
.
all
()]
}
for
group
in
Group
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
groups
),
content_type
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
groups
),
content_type
=
'application/json'
)
def
list_firewalls
(
request
):
def
list_firewalls
(
request
):
firewalls
=
[{
firewalls
=
[{
"id"
:
firewall
.
id
,
'id'
:
firewall
.
id
,
"name"
:
firewall
.
name
,
'name'
:
firewall
.
name
,
}
for
firewall
in
Firewall
.
objects
.
all
()]
}
for
firewall
in
Firewall
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
firewalls
),
content_type
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
firewalls
),
content_type
=
'application/json'
)
def
list_domains
(
request
):
def
list_domains
(
request
):
domains
=
[{
domains
=
[{
"id"
:
domain
.
id
,
'id'
:
domain
.
id
,
"name"
:
domain
.
name
,
'name'
:
domain
.
name
,
"created_at"
:
domain
.
created_at
.
isoformat
(),
'created_at'
:
domain
.
created_at
.
isoformat
(),
"modified_at"
:
domain
.
modified_at
.
isoformat
(),
'modified_at'
:
domain
.
modified_at
.
isoformat
(),
"ttl"
:
domain
.
ttl
,
'ttl'
:
domain
.
ttl
,
"description"
:
domain
.
description
,
'description'
:
domain
.
description
,
"owner"
:
{
'owner'
:
{
"id"
:
domain
.
owner
.
id
,
'id'
:
domain
.
owner
.
id
,
"name"
:
str
(
domain
.
owner
)
'name'
:
str
(
domain
.
owner
)
}
}
}
for
domain
in
Domain
.
objects
.
all
()]
}
for
domain
in
Domain
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
domains
),
content_type
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
domains
),
content_type
=
'application/json'
)
def
list_records
(
request
):
def
list_records
(
request
):
records
=
[{
records
=
[{
"id"
:
record
.
id
,
'id'
:
record
.
id
,
"name"
:
record
.
name
,
'name'
:
record
.
name
,
"domain"
:
{
'domain'
:
{
"id"
:
record
.
domain
.
id
,
'id'
:
record
.
domain
.
id
,
"name"
:
record
.
domain
.
name
,
'name'
:
record
.
domain
.
name
,
},
},
"host"
:
{
'host'
:
{
"id"
:
record
.
host
.
id
,
'id'
:
record
.
host
.
id
,
"name"
:
record
.
host
.
hostname
,
'name'
:
record
.
host
.
hostname
,
}
if
record
.
host
else
None
,
}
if
record
.
host
else
None
,
"type"
:
record
.
type
,
'type'
:
record
.
type
,
"address"
:
record
.
address
,
'address'
:
record
.
address
,
"ttl"
:
record
.
ttl
,
'ttl'
:
record
.
ttl
,
"owner"
:
{
'owner'
:
{
"id"
:
record
.
owner
.
id
,
'id'
:
record
.
owner
.
id
,
"name"
:
str
(
record
.
owner
)
'name'
:
str
(
record
.
owner
)
},
},
"description"
:
record
.
description
,
'description'
:
record
.
description
,
"created_at"
:
record
.
created_at
.
isoformat
(),
'created_at'
:
record
.
created_at
.
isoformat
(),
"modified_at"
:
record
.
modified_at
.
isoformat
()
'modified_at'
:
record
.
modified_at
.
isoformat
()
}
for
record
in
Record
.
objects
.
all
()]
}
for
record
in
Record
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
records
),
content_type
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
records
),
content_type
=
'application/json'
)
def
list_blacklists
(
request
):
def
list_blacklists
(
request
):
blacklists
=
[{
blacklists
=
[{
"id"
:
blacklist
.
id
,
'id'
:
blacklist
.
id
,
"host"
:
{
'host'
:
{
"id"
:
blacklist
.
host
.
id
,
'id'
:
blacklist
.
host
.
id
,
"name"
:
blacklist
.
host
.
hostname
,
'name'
:
blacklist
.
host
.
hostname
,
}
if
blacklist
.
host
else
None
,
}
if
blacklist
.
host
else
None
,
"reason"
:
blacklist
.
reason
,
'reason'
:
blacklist
.
reason
,
"snort_message"
:
blacklist
.
snort_message
,
'snort_message'
:
blacklist
.
snort_message
,
"type"
:
blacklist
.
type
,
'type'
:
blacklist
.
type
,
"created_at"
:
blacklist
.
created_at
.
isoformat
(),
'created_at'
:
blacklist
.
created_at
.
isoformat
(),
"modified_at"
:
blacklist
.
modified_at
.
isoformat
(),
'modified_at'
:
blacklist
.
modified_at
.
isoformat
(),
"ipv4"
:
blacklist
.
ipv4
'ipv4'
:
blacklist
.
ipv4
}
for
blacklist
in
Blacklist
.
objects
.
all
()]
}
for
blacklist
in
Blacklist
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
blacklists
),
content_type
=
"application/json"
)
return
HttpResponse
(
json
.
dumps
(
blacklists
),
content_type
=
'application/json'
)
def
show_rule
(
request
,
id
):
rule
=
get_object_or_404
(
Rule
,
id
=
id
)
rule
=
{
'id'
:
rule
.
id
,
'target'
:
{
'name'
:
rule
.
vlan
.
name
,
'id'
:
rule
.
vlan
.
id
,
'type'
:
'vlan'
,
}
if
rule
.
vlan
else
{
'name'
:
rule
.
vlangroup
.
name
,
'id'
:
rule
.
vlangroup
.
id
,
'type'
:
'vlangroup'
,
}
if
rule
.
vlangroup
else
{
'name'
:
rule
.
hostgroup
.
name
,
'id'
:
rule
.
hostgroup
.
id
,
'type'
:
'hostgroup'
,
}
if
rule
.
hostgroup
else
{
'name'
:
rule
.
firewall
.
name
,
'id'
:
rule
.
firewall
.
id
,
'type'
:
'firewall'
,
}
if
rule
.
firewall
else
{
'name'
:
rule
.
host
.
hostname
,
'id'
:
rule
.
host
.
id
,
'type'
:
'host'
,
},
'type'
:
rule
.
r_type
,
'direction'
:
{
'value'
:
rule
.
direction
,
'choices'
:
Rule
.
_meta
.
get_field_by_name
(
'direction'
)[
0
]
.
choices
,
},
'proto'
:
{
'value'
:
rule
.
proto
,
'choices'
:
Rule
.
_meta
.
get_field_by_name
(
'proto'
)[
0
]
.
choices
,
},
'owner'
:
{
'name'
:
str
(
rule
.
owner
),
'id'
:
rule
.
owner
.
id
},
'foreignNetwork'
:
{
'name'
:
rule
.
foreign_network
.
name
,
'id'
:
rule
.
foreign_network
.
id
,
},
'created_at'
:
rule
.
created_at
.
isoformat
(),
'modified_at'
:
rule
.
modified_at
.
isoformat
(),
'nat'
:
rule
.
nat
,
'accept'
:
rule
.
accept
,
'description'
:
rule
.
description
,
'dport'
:
rule
.
dport
,
'sport'
:
rule
.
sport
,
'extra'
:
rule
.
extra
,
'nat_dport'
:
rule
.
nat_dport
}
return
HttpResponse
(
json
.
dumps
(
rule
),
content_type
=
'application/json'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment