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 current_app
from lemur import database
from lemur.authorities.models import Authority
from lemur.roles import service as role_service
from lemur.notifications import service as notification_service
from lemur.roles.models import Role
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.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
role_objs = []
for r in issuer_roles:
role = role_service.create(
r['name'],
password=r['password'],

View File

@ -180,7 +180,7 @@ def sync_sources(labels, view):
information it discovers.
"""
if view:
sys.stdout.write("Active", "Label", "Description")
sys.stdout.write("Active\tLabel\tDescription\n")
for source in source_service.get_all():
sys.stdout.write(
"[{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
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(",")
else:
sys.stdout.write("[+] Starting to sync ALL sources!\n".format(labels))
sys.stdout.write("[+] Starting to sync ALL sources!\n")
sync(labels=labels)
sys.stdout.write(

View File

@ -180,13 +180,22 @@ def create_default_expiration_notifications(name, recipients):
"""
options = [
{
'name': 'recipients',
'value': ','.join(recipients)
'name': 'unit',
'type': 'select',
'required': True,
'validation': '',
'available': ['days', 'weeks', 'months'],
'helpMessage': 'Interval unit',
'value': 'days',
},
{
'name': 'unit',
'value': 'days'
}
'name': 'recipients',
'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")
@ -195,10 +204,16 @@ def create_default_expiration_notifications(name, recipients):
for i in intervals:
n = get_by_label("{name}_{interval}_DAY".format(name=name, interval=i))
if not n:
inter = [{
'name': 'interval',
'value': i,
}]
inter = [
{
'name': 'interval',
'type': 'int',
'required': True,
'validation': '^\d+$',
'helpMessage': 'Number of days to be alert before expiration.',
'value': i,
}
]
inter.extend(options)
n = create(
label="{name}_{interval}_DAY".format(name=name, interval=i),

View File

@ -29,7 +29,7 @@ class AWSDestinationPlugin(DestinationPlugin):
options = [
{
'name': 'accountNumber',
'type': 'int',
'type': 'str',
'required': True,
'validation': '/^[0-9]{12,12}$/',
'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) {
DestinationApi.get(editId).then(function (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) {

View File

@ -29,6 +29,15 @@ angular.module('lemur')
.controller('NotificationsEditController', function ($scope, $modalInstance, NotificationService, NotificationApi, PluginService, CertificateService, editId) {
NotificationApi.get(editId).then(function (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);
});

View File

@ -23,6 +23,15 @@ angular.module('lemur')
.controller('SourcesEditController', function ($scope, $modalInstance, SourceService, SourceApi, PluginService, editId) {
SourceApi.get(editId).then(function (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) {