Puppet Class: cis_security_hardening::rules::apt_unused

Defined in:
manifests/rules/apt_unused.pp

Summary

Ensure the Advance Package Tool removes all software components after updated versions have been installed

Overview

The Ubuntu operating system must be configured so that Advance Package Tool (APT) removes all software components after updated versions have been installed.

Rationale: Previous versions of software components that are not removed from the information system after updates have been installed may be exploited by adversaries. Some information technology products may remove older versions of software automatically from the information system.

Examples:

class { 'cis_security_hardening::rules::apt_unused':
  ensure => true,
}

Parameters:

  • enforce (Boolean) (defaults to: false)

    Enforce autoremove

  • files (Array) (defaults to: ['/etc/apt/apt.conf.d/50unattended-upgrades'])

    List of files to check



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'manifests/rules/apt_unused.pp', line 23

class cis_security_hardening::rules::apt_unused (
  Boolean $enforce = false,
  Array $files = ['/etc/apt/apt.conf.d/50unattended-upgrades']
) {
  if $enforce {
    $files.each |$file| {
      file { $file:
        ensure => file,
        owner  => 'root',
        group  => 'root',
        mode   => '0644',
      }

      file_line { 'add Unattended-Upgrade::Remove-Unused-Dependencies':
        ensure             => present,
        path               => $file,
        match              => '^Unattended-Upgrade::Remove-Unused-Dependencies',
        line               => 'Unattended-Upgrade::Remove-Unused-Dependencies "true";',
        append_on_no_match => true,
      }

      file_line { 'add Unattended-Upgrade::Remove-Unused-Kernel-Packages':
        ensure             => present,
        path               => $file,
        match              => '^Unattended-Upgrade::Remove-Unused-Kernel-Packages',
        line               => 'Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";',
        append_on_no_match => true,
      }
    }
  }
}