Skip to content
This repository was archived by the owner on Sep 17, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class IssueTableComponent extends PaginatedTable implements ScopeAware {
'regions': '',
'technologies': '',
'accounts': '',
'accounttypes': '',
'names': '',
'arns': '',
'active': null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<th>Item Name</th>
<th>Technology</th>
<th>Account</th>
<th>Account Type</th>
<th>Region</th>
<th>Issue</th>
<th>Notes</th>
Expand All @@ -44,6 +45,7 @@
<td><a href="#/viewitem/{{issue.item_id}}">{{issue.item.name}}</a></td>
<td>{{issue.item.technology}}</td>
<td>{{issue.item.account}}</td>
<td>{{issue.item.account_type}}</td>
<td>{{issue.item.region}}</td>
<td>{{issue.issue}}</td>
<td>{{issue.notes}}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ItemTableComponent extends PaginatedTable implements DetachAware {
'regions': '',
'technologies': '',
'accounts': '',
'accounttypes': '',
'names': '',
'arns': '',
'active': null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class JustifiedTableComponent extends PaginatedTable implements ScopeAware {
'regions': '',
'technologies': '',
'accounts': '',
'accounttypes': '',
'names': '',
'arns': '',
'active': null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<th>Item Name</th>
<th>Technology</th>
<th>Account</th>
<th>Account Type</th>
<th>Region</th>
<th>Issue</th>
<th>Notes</th>
Expand All @@ -34,6 +35,7 @@
<td><a href="#/viewitem/{{issue.item_id}}">{{issue.item.name}}</a></td>
<td>{{issue.item.technology}}</td>
<td>{{issue.item.account}}</td>
<td>{{issue.item.account_type}}</td>
<td>{{issue.item.region}}</td>
<td>{{issue.issue}}</td>
<td>{{issue.notes}}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class RevisionTableComponent extends PaginatedTable implements DetachAware {
'regions': '',
'technologies': '',
'accounts': '',
'accounttypes': '',
'names': '',
'arns': '',
'active': null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<th>Active</th>
<th>Technology</th>
<th>Account</th>
<th>Account Type</th>
<th>Region</th>
<th>Name</th>
<th>Date</th>
Expand All @@ -58,6 +59,7 @@
<td ng-switch-when="false"><div class="text-center"><i class="glyphicon glyphicon-remove"></i></div></td>
<td>{{rev.item.technology}}</td>
<td>{{rev.item.account}}</td>
<td>{{rev.item.account_type}}</td>
<td>{{rev.item.region}}</td>
<td><a href="#/viewitem/{{rev.item_id}}/{{rev.id}}">{{rev.item.name}}</a></td>
<td>{{rev.date_created | date:'medium'}}</td>
Expand Down Expand Up @@ -89,4 +91,4 @@
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
9 changes: 8 additions & 1 deletion security_monkey/views/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from security_monkey.views import ITEM_LINK_FIELDS
from security_monkey.datastore import Item
from security_monkey.datastore import Account
from security_monkey.datastore import AccountType
from security_monkey.datastore import Technology
from security_monkey.datastore import ItemRevision
from security_monkey import rbac
Expand Down Expand Up @@ -138,7 +139,7 @@ def get(self, item_id):


# Returns a list of items optionally filtered by
# account, region, name, ctype or id.
# account, account_type, region, name, ctype or id.
class ItemList(AuthenticatedService):
decorators = [rbac.allow(['View'], ["GET"])]

Expand Down Expand Up @@ -197,6 +198,7 @@ def get(self):
self.reqparse.add_argument('page', type=int, default=1, location='args')
self.reqparse.add_argument('regions', type=str, default=None, location='args')
self.reqparse.add_argument('accounts', type=str, default=None, location='args')
self.reqparse.add_argument('accounttypes', type=str, default=None, location='args')
self.reqparse.add_argument('active', type=str, default=None, location='args')
self.reqparse.add_argument('names', type=str, default=None, location='args')
self.reqparse.add_argument('arns', type=str, default=None, location='args')
Expand Down Expand Up @@ -224,6 +226,11 @@ def get(self):
accounts = args['accounts'].split(',')
query = query.join((Account, Account.id == Item.account_id))
query = query.filter(Account.name.in_(accounts))
if 'accounttypes' in args:
accounttypes = args['accounttypes'].split(',')
query = query.join((Account, Account.id == Item.account_id))
query = query.join((AccountType, AccountType.id == Account.account_type_id))
query = query.filter(AccountType.name.in_(accounttypes))
if 'technologies' in args:
technologies = args['technologies'].split(',')
query = query.join((Technology, Technology.id == Item.tech_id))
Expand Down
10 changes: 10 additions & 0 deletions security_monkey/views/item_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from security_monkey.datastore import ItemAudit
from security_monkey.datastore import Item
from security_monkey.datastore import Account
from security_monkey.datastore import AccountType
from security_monkey.datastore import Technology
from security_monkey.datastore import ItemRevision
from security_monkey.datastore import AuditorSettings
Expand Down Expand Up @@ -59,6 +60,7 @@ def get(self):
items: [
{
account: "example_account",
account_type: "AWS",
justification: null,
name: "example_name",
technology: "s3",
Expand Down Expand Up @@ -88,6 +90,7 @@ def get(self):
self.reqparse.add_argument('page', type=int, default=1, location='args')
self.reqparse.add_argument('regions', type=str, default=None, location='args')
self.reqparse.add_argument('accounts', type=str, default=None, location='args')
self.reqparse.add_argument('accounttypes', type=str, default=None, location='args')
self.reqparse.add_argument('technologies', type=str, default=None, location='args')
self.reqparse.add_argument('names', type=str, default=None, location='args')
self.reqparse.add_argument('arns', type=str, default=None, location='args')
Expand All @@ -112,6 +115,11 @@ def get(self):
accounts = args['accounts'].split(',')
query = query.join((Account, Account.id == Item.account_id))
query = query.filter(Account.name.in_(accounts))
if 'accounttypes' in args:
accounttypes = args['accounttypes'].split(',')
query = query.join((Account, Account.id == Item.account_id))
query = query.join((AccountType, AccountType.id == Account.account_type_id))
query = query.filter(AccountType.name.in_(accounttypes))
if 'technologies' in args:
technologies = args['technologies'].split(',')
query = query.join((Technology, Technology.id == Item.tech_id))
Expand Down Expand Up @@ -161,6 +169,7 @@ def get(self):
item_marshaled = marshal(issue.item.__dict__, ITEM_FIELDS)
issue_marshaled = marshal(issue.__dict__, AUDIT_FIELDS)
account_marshaled = {'account': issue.item.account.name}
accounttype_marshaled = {'account_type': issue.item.account.account_type.name}
technology_marshaled = {'technology': issue.item.technology.name}

links = []
Expand All @@ -178,6 +187,7 @@ def get(self):
item_marshaled.items() +
issue_marshaled.items() +
account_marshaled.items() +
accounttype_marshaled.items() +
technology_marshaled.items())
items_marshaled.append(merged_marshaled)

Expand Down
10 changes: 10 additions & 0 deletions security_monkey/views/revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from security_monkey.views import ITEM_FIELDS
from security_monkey.datastore import Item
from security_monkey.datastore import Account
from security_monkey.datastore import AccountType
from security_monkey.datastore import Technology
from security_monkey.datastore import ItemRevision
from security_monkey import rbac
Expand Down Expand Up @@ -149,6 +150,7 @@ def get(self):
"items": [
{
"account": "example_account",
"accounttype": "AWS",
"name": "Example Name",
"region": "us-east-1",
"item_id": 144,
Expand All @@ -175,6 +177,7 @@ def get(self):
self.reqparse.add_argument('active', type=str, default=None, location='args')
self.reqparse.add_argument('regions', type=str, default=None, location='args')
self.reqparse.add_argument('accounts', type=str, default=None, location='args')
self.reqparse.add_argument('accounttypes', type=str, default=None, location='args')
self.reqparse.add_argument('names', type=str, default=None, location='args')
self.reqparse.add_argument('arns', type=str, default=None, location='args')
self.reqparse.add_argument('technologies', type=str, default=None, location='args')
Expand All @@ -195,6 +198,11 @@ def get(self):
accounts = args['accounts'].split(',')
query = query.join((Account, Account.id == Item.account_id))
query = query.filter(Account.name.in_(accounts))
if 'accounttypes' in args:
accounttypes = args['accounttypes'].split(',')
query = query.join((Account, Account.id == Item.account_id))
query = query.join((AccountType, AccountType.id == Account.account_type_id))
query = query.filter(AccountType.name.in_(accounttypes))
if 'technologies' in args:
technologies = args['technologies'].split(',')
query = query.join((Technology, Technology.id == Item.tech_id))
Expand Down Expand Up @@ -225,11 +233,13 @@ def get(self):
item_marshaled = marshal(revision.item.__dict__, ITEM_FIELDS)
revision_marshaled = marshal(revision.__dict__, REVISION_FIELDS)
account_marshaled = {'account': revision.item.account.name}
accounttype_marshaled = {'account_type': revision.item.account.account_type.name}
technology_marshaled = {'technology': revision.item.technology.name}
merged_marshaled = dict(
item_marshaled.items() +
revision_marshaled.items() +
account_marshaled.items() +
accounttype_marshaled.items() +
technology_marshaled.items())
items_marshaled.append(merged_marshaled)

Expand Down