Lots of minor fixes

This commit is contained in:
kevgliss 2015-08-03 15:52:39 -07:00
parent 7d169f7c4c
commit a873e5c7ea
7 changed files with 63 additions and 13 deletions

View File

@ -9,10 +9,12 @@
""" """
from flask import g from flask import g
from flask import current_app
from lemur import database from lemur import database
from lemur.authorities.models import Authority from lemur.authorities.models import Authority
from lemur.roles import service as role_service from lemur.roles import service as role_service
from lemur.notifications import service as notification_service
from lemur.roles.models import Role from lemur.roles.models import Role
from lemur.certificates.models import Certificate from lemur.certificates.models import Certificate
@ -56,9 +58,15 @@ def create(kwargs):
cert.description = "This is the ROOT certificate for the {0} certificate authority".format(kwargs.get('caName')) cert.description = "This is the ROOT certificate for the {0} certificate authority".format(kwargs.get('caName'))
cert.user = g.current_user cert.user = g.current_user
cert.notifications = notification_service.create_default_expiration_notifications(
'DEFAULT_SECURITY',
current_app.config.get('LEMUR_SECURITY_TEAM_EMAIL')
)
# we create and attach any roles that the issuer gives us # we create and attach any roles that the issuer gives us
role_objs = [] role_objs = []
for r in issuer_roles: for r in issuer_roles:
role = role_service.create( role = role_service.create(
r['name'], r['name'],
password=r['password'], password=r['password'],

View File

@ -180,7 +180,7 @@ def sync_sources(labels, view):
information it discovers. information it discovers.
""" """
if view: if view:
sys.stdout.write("Active", "Label", "Description") sys.stdout.write("Active\tLabel\tDescription\n")
for source in source_service.get_all(): for source in source_service.get_all():
sys.stdout.write( sys.stdout.write(
"[{active}]\t{label}\t{description}!\n".format( "[{active}]\t{label}\t{description}!\n".format(
@ -199,10 +199,10 @@ def sync_sources(labels, view):
sync_lock.acquire(timeout=10) # wait up to 10 seconds sync_lock.acquire(timeout=10) # wait up to 10 seconds
if labels: if labels:
sys.stdout.write("[+] Staring to sync sources: {labels}!\n".format(labels)) sys.stdout.write("[+] Staring to sync sources: {labels}!\n".format(labels=labels))
labels = labels.split(",") labels = labels.split(",")
else: else:
sys.stdout.write("[+] Starting to sync ALL sources!\n".format(labels)) sys.stdout.write("[+] Starting to sync ALL sources!\n")
sync(labels=labels) sync(labels=labels)
sys.stdout.write( sys.stdout.write(

View File

@ -180,13 +180,22 @@ def create_default_expiration_notifications(name, recipients):
""" """
options = [ options = [
{ {
'name': 'recipients', 'name': 'unit',
'value': ','.join(recipients) 'type': 'select',
'required': True,
'validation': '',
'available': ['days', 'weeks', 'months'],
'helpMessage': 'Interval unit',
'value': 'days',
}, },
{ {
'name': 'unit', 'name': 'recipients',
'value': 'days' 'type': 'str',
} 'required': True,
'validation': '^([\w+-.%]+@[\w-.]+\.[A-Za-z]{2,4},?)+$',
'helpMessage': 'Comma delimited list of email addresses',
'value': ','.join(recipients)
},
] ]
intervals = current_app.config.get("LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS") intervals = current_app.config.get("LEMUR_DEFAULT_EXPIRATION_NOTIFICATION_INTERVALS")
@ -195,10 +204,16 @@ def create_default_expiration_notifications(name, recipients):
for i in intervals: for i in intervals:
n = get_by_label("{name}_{interval}_DAY".format(name=name, interval=i)) n = get_by_label("{name}_{interval}_DAY".format(name=name, interval=i))
if not n: if not n:
inter = [{ inter = [
'name': 'interval', {
'value': i, 'name': 'interval',
}] 'type': 'int',
'required': True,
'validation': '^\d+$',
'helpMessage': 'Number of days to be alert before expiration.',
'value': i,
}
]
inter.extend(options) inter.extend(options)
n = create( n = create(
label="{name}_{interval}_DAY".format(name=name, interval=i), label="{name}_{interval}_DAY".format(name=name, interval=i),

View File

@ -29,7 +29,7 @@ class AWSDestinationPlugin(DestinationPlugin):
options = [ options = [
{ {
'name': 'accountNumber', 'name': 'accountNumber',
'type': 'int', 'type': 'str',
'required': True, 'required': True,
'validation': '/^[0-9]{12,12}$/', 'validation': '/^[0-9]{12,12}$/',
'helpMessage': 'Must be a valid AWS account number!', 'helpMessage': 'Must be a valid AWS account number!',

View File

@ -23,6 +23,15 @@ angular.module('lemur')
.controller('DestinationsEditController', function ($scope, $modalInstance, DestinationService, DestinationApi, PluginService, editId) { .controller('DestinationsEditController', function ($scope, $modalInstance, DestinationService, DestinationApi, PluginService, editId) {
DestinationApi.get(editId).then(function (destination) { DestinationApi.get(editId).then(function (destination) {
$scope.destination = destination; $scope.destination = destination;
PluginService.getByType('destination').then(function (plugins) {
$scope.plugins = plugins;
_.each($scope.plugins, function (plugin) {
if (plugin.slug === $scope.destination.pluginName) {
plugin.pluginOptions = $scope.destination.destinationOptions;
$scope.destination.plugin = plugin;
}
});
});
}); });
PluginService.getByType('destination').then(function (plugins) { PluginService.getByType('destination').then(function (plugins) {

View File

@ -29,6 +29,15 @@ angular.module('lemur')
.controller('NotificationsEditController', function ($scope, $modalInstance, NotificationService, NotificationApi, PluginService, CertificateService, editId) { .controller('NotificationsEditController', function ($scope, $modalInstance, NotificationService, NotificationApi, PluginService, CertificateService, editId) {
NotificationApi.get(editId).then(function (notification) { NotificationApi.get(editId).then(function (notification) {
$scope.notification = notification; $scope.notification = notification;
PluginService.getByType('notification').then(function (plugins) {
$scope.plugins = plugins;
_.each($scope.plugins, function (plugin) {
if (plugin.slug === $scope.notification.pluginName) {
plugin.pluginOptions = $scope.notification.notificationOptions;
$scope.notification.plugin = plugin;
}
});
});
NotificationService.getCertificates(notification); NotificationService.getCertificates(notification);
}); });

View File

@ -23,6 +23,15 @@ angular.module('lemur')
.controller('SourcesEditController', function ($scope, $modalInstance, SourceService, SourceApi, PluginService, editId) { .controller('SourcesEditController', function ($scope, $modalInstance, SourceService, SourceApi, PluginService, editId) {
SourceApi.get(editId).then(function (source) { SourceApi.get(editId).then(function (source) {
$scope.source = source; $scope.source = source;
PluginService.getByType('source').then(function (plugins) {
$scope.plugins = plugins;
_.each($scope.plugins, function (plugin) {
if (plugin.slug === $scope.source.pluginName) {
plugin.pluginOptions = $scope.source.sourceOptions;
$scope.source.plugin = plugin;
}
});
});
}); });
PluginService.getByType('source').then(function (plugins) { PluginService.getByType('source').then(function (plugins) {