~openstack-charmers-next/charms/xenial/swift-storage/trunk

« back to all changes in this revision

Viewing changes to charmhelpers/contrib/hardening/ssh/checks/__init__.py

  • Committer: Edward Hope-Morley
  • Date: 2016-03-24 11:11:58 UTC
  • Revision ID: edward.hope-morley@canonical.com-20160324111158-4whr78jd2v9yihw2
Add hardening support

Add charmhelpers.contrib.hardening and calls to install,
config-changed, upgrade-charm and update-status hooks.
Also add new config option to allow one or more hardening
modules to be applied at runtime.

Change-Id: If0d1e10b58ed506e0aca659f30120b8d5c96c04f

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2016 Canonical Limited.
 
2
#
 
3
# This file is part of charm-helpers.
 
4
#
 
5
# charm-helpers is free software: you can redistribute it and/or modify
 
6
# it under the terms of the GNU Lesser General Public License version 3 as
 
7
# published by the Free Software Foundation.
 
8
#
 
9
# charm-helpers is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU Lesser General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU Lesser General Public License
 
15
# along with charm-helpers.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
 
17
from charmhelpers.core.hookenv import (
 
18
    log,
 
19
    DEBUG,
 
20
)
 
21
from charmhelpers.contrib.hardening.ssh.checks import config
 
22
 
 
23
 
 
24
def run_ssh_checks():
 
25
    log("Starting SSH hardening checks.", level=DEBUG)
 
26
    checks = config.get_audits()
 
27
    for check in checks:
 
28
        log("Running '%s' check" % (check.__class__.__name__), level=DEBUG)
 
29
        check.ensure_compliance()
 
30
 
 
31
    log("SSH hardening checks complete.", level=DEBUG)