1 ##############################################################################
2 # Copyright (c) 2019 AT&T Intellectual Property. #
3 # Copyright (c) 2019 Nokia. #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you maynot use this file except in compliance with the License. #
8 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ##############################################################################
19 Documentation Validation, Auditing Hardening Compliance
21 Library OperatingSystem
24 Suite Setup Run Keywords
25 ... Open Connection And Log In
27 Test Teardown Download Logs
28 Suite Teardown Run Keywords
30 ... Close All Connections
33 ${FULL_SUITE} ${SUITE_NAME.replace(' ','_')}
36 Run Lynis Audit System
37 [Documentation] Run Lynis
38 ${log} = Set Variable ${OUTPUT DIR}${/}${FULL_SUITE}.${TEST NAME.replace(' ','_')}.log
39 ${stdout} ${rc} = Execute Command cd lynis && sudo ./lynis audit system --quick return_rc=True
40 Append To File ${log} ${stdout}${\n}
41 Should Be Equal As Integers ${rc} 0
43 ${status} = Evaluate "Great, no warnings" in """${stdout}"""
44 Run Keyword If '${status}' == 'False' FAIL Warnings discovered
48 Open Connection And Log In
49 Open Connection ${HOST}
50 Login With Public Key ${USERNAME} ${SSH_KEYFILE}
53 [Documentation] Install Lynis
54 Put File /opt/akraino/lynis-remote.tar.gz
55 Execute Command tar xzf lynis-remote.tar.gz && sudo chown -R 0:0 lynis
58 [Documentation] Uninstall Lynis
59 Execute Command rm lynis-remote.tar.gz
60 Execute Command rm -rf ~/lynis /var/log/lynis.log /var/log/lynis-report.dat sudo=True
63 [Documentation] Downloading logs and removing them
64 Execute Command chmod +r /var/log/lynis.log sudo=True
65 SSHLibrary.Get File /var/log/lynis.log ${OUTPUT DIR}/lynis.log
66 Execute Command rm /var/log/lynis.log sudo=True
67 Execute Command chmod +r /var/log/lynis-report.dat sudo=True
68 SSHLibrary.Get File /var/log/lynis-report.dat ${OUTPUT DIR}/lynis-report.dat
69 Execute Command rm /var/log/lynis-report.dat sudo=True