{"id":13540116,"url":"https://github.com/dev-sec/puppet-os-hardening","last_synced_at":"2025-11-23T09:01:32.194Z","repository":{"id":16523154,"uuid":"19276321","full_name":"dev-sec/puppet-os-hardening","owner":"dev-sec","description":"This puppet module provides numerous security-related configurations, providing all-round base protection.","archived":false,"fork":false,"pushed_at":"2025-11-20T18:04:57.000Z","size":503,"stargazers_count":288,"open_issues_count":22,"forks_count":101,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-11-23T01:09:00.920Z","etag":null,"topics":["hardening","linux","puppet","security"],"latest_commit_sha":null,"homepage":"http://dev-sec.io/","language":"Puppet","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dev-sec.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2014-04-29T12:54:22.000Z","updated_at":"2025-11-13T02:29:16.000Z","dependencies_parsed_at":"2024-01-03T13:44:18.377Z","dependency_job_id":"7f47979c-3572-468f-9acb-8e9f6c436e84","html_url":"https://github.com/dev-sec/puppet-os-hardening","commit_stats":{"total_commits":375,"total_committers":48,"mean_commits":7.8125,"dds":0.704,"last_synced_commit":"69e31188992955dcfedb71e6f859c77b74f35d3a"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/dev-sec/puppet-os-hardening","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-sec%2Fpuppet-os-hardening","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-sec%2Fpuppet-os-hardening/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-sec%2Fpuppet-os-hardening/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-sec%2Fpuppet-os-hardening/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dev-sec","download_url":"https://codeload.github.com/dev-sec/puppet-os-hardening/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dev-sec%2Fpuppet-os-hardening/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285926821,"owners_count":27255092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-23T02:00:06.149Z","response_time":135,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hardening","linux","puppet","security"],"created_at":"2024-08-01T09:01:40.843Z","updated_at":"2025-11-23T09:01:32.153Z","avatar_url":"https://github.com/dev-sec.png","language":"Puppet","funding_links":[],"categories":["\u003ca id=\"0abd611fc3e9a4d9744865ca6e47a6b2\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"7a277f8b0e75533e0b50d93c902fb351\"\u003e\u003c/a\u003e未分类-Defense"],"readme":"# Puppet OS hardening\n\n[![Puppet Forge Version](https://img.shields.io/puppetforge/v/hardening/os_hardening.svg)][1]\n[![Puppet Forge Downloads](https://img.shields.io/puppetforge/dt/hardening/os_hardening.svg)][1]\n[![Puppet Forge Endorsement](https://img.shields.io/puppetforge/e/hardening/os_hardening.svg)][1]\n[![Build Status](https://github.com/dev-sec/puppet-os-hardening/workflows/tests/badge.svg)][2]\n\n#### Table of Contents\n\n1. [Module Description - What the module does and why it is useful](#module-description)\n1. [Setup - The basics of getting started with os_hardening](#setup)\n   * [Setup Requirements](#setup-requirements)\n   * [Beginning with os_hardening](#beginning-with-os_hardening)\n1. [Usage - Configuration options and additional functionality](#usage)\n   * [Important for Puppet Enterprise](#important-for-puppet-enterprise)\n   * [Parameters](#parameters)\n   * [Hiera usage](#hiera-usage)\n   * [Note about wanted/unwanted packages and disabled services](#note-about-wantedunwanted-packages-and-disabled-services)\n1. [Limitations - OS compatibility, etc.](#limitations)\n1. [Development - Guide for contributing to the module](#development)\n1. [Testing - Quality gates for your changes in the code](#testing)\n   * [Local Testing](#local-testing)\n   * [PDK Tests](#pdk-tests)\n   * [Integration Tests (Docker)](#integration-tests-docker)\n   * [Integration Tests (DigitalOcean)](#integration-tests-digitalocean)\n   * [CI testing of PRs \u0026 forks](#ci-testing-of-prs--forks)\n1. [Get in touch](#get-in-touch)\n1. [Contributors + Kudos](#contributors--kudos)\n1. [License and Author](#license-and-author)\n\n## Module Description\n\nThis Puppet module provides secure configuration of your base OS with hardening and is part of the [DevSec Hardening Framework](https://dev-sec.io).\n\n## Setup\n\n### Setup Requirements\n\n* Puppet OpenSource or Enterprise\n* [Module stdlib](https://forge.puppet.com/puppetlabs/stdlib)\n* [Module sysctl](https://forge.puppet.com/herculesteam/augeasproviders_sysctl)\n\n### Beginning with os_hardening\n\nAfter adding this module, you can use the class:\n\n```puppet\nclass { 'os_hardening': }\n```\n\nAll parameters are contained within the main `os_hardening` class, so you just have to pass them like this:\n\n```puppet\nclass { 'os_hardening':\n  enable_ipv4_forwarding =\u003e true,\n}\n```\n\n## Usage\n\n### IMPORTANT for Puppet Enterprise\n\n**If you are using this module in a PE environment, you have to set** `pe_environment = true`\nOtherwise puppet will drop an error (duplicate resource)!\n\n### Parameters\n\n* `system_environment = 'default'`\n  define the context in which the system runs. Some options don't work for `docker`/`lxc`\n* `pe_environment = false`\n  set this to true if you are using Puppet Enterprise **IMPORTANT - see above**\n* `extra_user_paths = []`\n  add additional paths to the user's `PATH` variable (default is empty).\n* `umask = undef`\n  umask used for the creation of new home directories by useradd / newusers (e.g. '027')\n* `maildir = undef`\n  path for maildir (e.g. '/var/mail')\n* `usergroups = true`\n  true if you want separate groups for each user, false otherwise\n* `sys_uid_min = undef` and `sys_gid_min = undef`\n  override the default setting for `login.defs`\n* `password_max_age = 60`\n  maximum password age\n* `password_min_age = 7`\n  minimum password age (before allowing any other password change)\n* `password_warn_age = 7`\n  Days warning before password change is due\n* `login_retries = 5`\n  the maximum number of login retries if password is bad (normally overridden by PAM / auth_retries)\n* `login_timeout = 60`\n  authentication timeout in seconds, so login will exit if this time passes\n* `chfn_restrict = ''`\n  which fields may be changed by regular users using chfn\n* `allow_login_without_home = false`\n  true if to allow users without home to login\n* `allow_change_user = false`\n  if a user may use `su` to change his login\n* `ignore_users = []`\n  array of system user accounts that should _not be_ hardened (password disabled and shell set to `/usr/sbin/nologin`)\n* `folders_to_restrict = ['/usr/local/games','/usr/local/sbin','/usr/local/bin','/usr/bin','/usr/sbin','/sbin','/bin']`\n  folders to make sure of that group and world do not have write access to it or any of the contents\n* `ignore_max_files_warnings = false`\n  true if you do not want puppet to log max_files and performance warnings on the recursion of folders with \u003e 1000 files eg /bin /usr/bin\n* `recurselimit = 5`\n  directory depth for recursive permission check\n* `passwdqc_enabled = true`\n  true if you want to use strong password checking in PAM using passwdqc\n* `auth_retries = 5`\n  the maximum number of authentication attempts, before the account is locked for some time\n* `auth_lockout_time = 600`\n  time in seconds that needs to pass, if the account was locked due to too many failed authentication attempts\n* `passwdqc_options = 'min=disabled,disabled,16,12,8'`\n  set to any option line (as a string) that you want to pass to passwdqc\n* `manage_pam_unix = false`\n  true if you want pam_unix managed by this module\n* `enable_pw_history = true`\n  true if you want pam_unix to remember password history to prevent reuse of passwords (requires `manage_pam_unix = true`)\n* `pw_remember_last = 5`\n  the number of last passwords (e.g. 5 will prevent user to reuse any of her last 5 passwords)\n* `only_root_may_su = false`\n  true when only root and member of the group wheel may use su, required to be true for CIS Benchmark compliance\n* `root_ttys = ['console','tty1','tty2','tty3','tty4','tty5','tty6']`\n  registered TTYs for root\n* `whitelist = []`\n  all files which should keep their SUID/SGID bits if set (will be combined with pre-defined whiteliste of files)\n* `blacklist = []`\n  all files which should have their SUID/SGID bits removed if set (will be combined with pre-defined blacklist of files)\n* `remove_from_unknown = false`\n  `true` if you want to remove SUID/SGID bits from any file, that is not explicitly configured in a `blacklist`. This will make every Puppet run search through the mounted filesystems looking for SUID/SGID bits that are not configured in the default and user blacklist. If it finds an SUID/SGID bit, it will be removed, unless this file is in your `whitelist`.\n* `dry_run_on_unknown = false`\n  like `remove_from_unknown` above, only that SUID/SGID bits aren't removed. It will still search the filesystems to look for SUID/SGID bits but it will only print them in your log. This option is only ever recommended, when you first configure `remove_from_unknown` for SUID/SGID bits, so that you can see the files that are being changed and make adjustments to your `whitelist` and `blacklist`.\n* `enable_module_loading = true`\n  true if you want to allowed to change kernel modules once the system is running (eg `modprobe`, `rmmod`)\n* `load_modules = []`\n  load this modules via initramfs if enable_module_loading is false\n* `disable_filesystems = ['cramfs','freevxfs','jffs2','hfs','hfsplus','squashfs','udf']`\n  array of filesystems (kernel modules) that should be disabled\n* `cpu_vendor = 'intel'`\n  only required if `enable_module_loading = false`: set the CPU vendor for modules to load\n* `icmp_ratelimit = '100'`\n  default value '100', allow overwriting, needs String\n* `desktop_enabled = false`\n  true if this is a desktop system, ie Xorg, KDE/GNOME/Unity/etc\n* `enable_ipv4_forwarding = false`\n  true if this system requires packet forwarding in IPv4 (eg Router), false otherwise\n* `manage_ipv6 = true`\n  true to harden ipv6 setup, false to ignore ipv6 completely\n* `enable_ipv6 = false`\n  false to disable ipv6 on this system, true to enable\n* `enable_ipv6_forwarding = false`\n  true if this system requires packet forwarding in IPv6 (eg Router), false otherwise\n* `arp_restricted = true`\n  true if you want the behavior of announcing and replying to ARP to be restricted, false otherwise\n* `arp_ignore_samenet = false`\n  true will drop packets that are not from the same subnet (arp_ignore = 2), false will only check the target ip (arp_ignore = 1)\n* `enable_sysrq = false`\n  true to enable the magic sysrq key, false otherwise\n* `enable_core_dump = false`\n  false to prevent the creation of core dumps, true otherwise\n* `enable_stack_protection = true`\n  for Address Space Layout Randomization. ASLR can help defeat certain types of buffer overflow attacks. ASLR can locate the base, libraries, heap, and stack at random positions in a process's address space, which makes it difficult for an attacking program to predict the memory address of the next instruction.\n* `enable_rpfilter = true`\n  true to enable reverse path filtering (discard bogus packets), false otherwise\n* `rpfilter_loose = false`\n  (only if `enable_rpfilter` is true) *loose mode* (rp_filter = 2) if true, *strict mode* otherwise\n* `enable_log_martians = true`\n  true to enable logging on suspicious / unroutable network packets, false otherwise **WARNING - this might generate huge log files!**\n* `unwanted_packages = []`\n  packages that should be removed from the system\n* `wanted_packages = []`\n  packages that should be added to the system\n* `disabled_services = []`\n  services that should not be enabled\n* `enable_grub_hardening = false`\n  set to true to enable some grub hardening rules\n* `grub_user = 'root'`\n  the grub username that needs to be provided when changing config on the grub prompt\n* `grub_password_hash = ''`\n  a password hash created with `grub-mkpasswd-pbkdf2` that is associated with the grub\\_user\n* `boot_without_password = true`\n  setup Grub so it only requires a password when changing an entry, not when booting an existing entry\n* `system_umask = undef`\n  if this variable is set setup the umask for all user in the system (e.g. '027')\n* `manage_home_permissions = false`\n  set to true to manage local users file and directory permissions (g-w,o-rwx)\n* `ignore_home_users = []`\n  array for users that is not to be restricted by manage_home_permissions\n* `manage_log_permissions = false`\n  set to true to manage log file permissions (g-wx,o-rwx)\n* `restrict_log_dir = ['/var/log/']`\n  set main log dir\n* `ignore_restrict_log_dir = []`\n  array to exclude log dirs under the main log dir\n* `ignore_files_in_folder_to_restrict = []`\n  array to ignore files to hardened in dirs under the folder_to_restrict array\n* `manage_cron_permissions = false`\n  set to true to manage cron file permissions (og-rwx)\n* `enable_sysctl_config = true`\n  set to false to disable sysctl configuration\n* `manage_system_users = true`\n  set to false to disable managing of system users (empty password and setting nologin shell)\n* `shadow_group = undef`\n  override the group ownership of /etc/shadow\n* `shadow_mode = undef`\n  override the file permissions of /etc/shadow\n\n\n### Hiera usage\n\nIt's also possible to set the parameters in Hiera like this:\n\n```puppet\nos_hardening::password_max_age:  90\nos_hardening::password_min_age:  0\nos_hardening::password_warn_age: 14\nos_hardening::unwanted_packages: ['telnet']\nos_hardening::ignore_users:      ['git','githook','ansible','apache','puppetboard']\n```\n\n### Note about wanted/unwanted packages and disabled services\n\nAs the CIS Distribution Independent Linux Benchmark is a good starting point\nregarding hardening of systems, it was deemed appropriate to implement an easy\nway to deal with one-offs for which one doesn't want to write an entire module.\n\nFor instance, to increase CIS DIL compliance on a Debian system, one should set\nthe following:\n\n```puppet\nwanted_packages   =\u003e ['ntp'],\nunwanted_packages =\u003e ['telnet'],\ndisabled_services =\u003e ['rsync'],\n```\n\nThe default settings of NTP are actually pretty good for most situations, so it\nis not immediately necessary to implement a module. However, if you do use a\nmodule to control these services, that is of course preferred.\n\n## Limitations\n\nThis module has been tested and should run on most Linux distributions. For an extensive list of supported operating systems, see [metadata.json](https://github.com/dev-sec/puppet-os-hardening/blob/master/metadata.json)\n\n## Development\n\nIf you want to contribute, please follow our [contribution guide](https://dev-sec.io/contributing/).\n\n## Testing\n\n### Local Testing\n\nYou should have Ruby interpreter installed on your system. It might be a good idea to use [rvm](https://rvm.io) for that purpose. Besides that you have to install the `Puppet Development Kit` [PDK](https://puppet.com/download-puppet-development-kit) and [Docker Community Edition](https://www.docker.com/products/docker-engine), as the integration tests run in Docker containers.\n\nFor all our integration tests we use `test-kitchen`. If you are not familiar with `test-kitchen` please have a look at [their guide](http://kitchen.ci/docs/getting-started).\n\n#### PDK Tests\n\n```bash\n# Syntax \u0026 Lint tests\npdk validate\n\n# Unit Tests\npdk test unit\n```\n\n#### Integration Tests (Docker)\n\nPer default the integration tests will run in docker containers - unfortunately not all tests can run in container environments (e.g. sysctl settings).\n\n```bash\n# Install dependencies\ngem install bundler\nbundle install\n\n# list all test instances\nbundle exec kitchen list\n\n# fast test on one machine\nbundle exec kitchen test ubuntu-16-04-puppet5\n\n# test on all machines\nbundle exec kitchen test\n```\n\n#### Integration Tests (DigitalOcean)\n\nFor complete integration tests with [DigitalOcean](https://cloud.digitalocean.com) you have to get an account there and setup some environment variables:\n\n* `KITCHEN_LOCAL_YAML=kitchen.do.yml`\n* `DIGITALOCEAN_ACCESS_TOKEN` - [access token for DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-api-v2)\n* `DIGITALOCEAN_SSH_KEY_IDS` - ID in DigitalOcean of your ssh key, see [this](https://github.com/test-kitchen/kitchen-digitalocean#installation-and-setup) for more information\n\nThe ssh key has to be named `~/.ssh/do_ci` and added to your profile at DigitalOcean.\nAfter this you're ready to run the tests as described at [Integration Tests (Docker)](#integration-tests-docker).\n\nIf you want to run the full integration tests with Github Actions in your fork, you will have to add these [environment variables](https://docs.github.com/en/actions/reference/encrypted-secrets) in the settings of your fork:\n\n* `KITCHEN_LOCAL_YAML=kitchen.do.yml`\n* `DIGITALOCEAN_ACCESS_TOKEN` - [access token for DigitalOcean](https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-api-v2)\n* `CI_SSH_KEY` - private part of a ssh key, available on DigitalOcean for your instances, in base64 encoded form (e.g. `cat id_rsa | base64 -w0 ; echo`)\n* `DIGITALOCEAN_SSH_KEY_IDS` - ID in DigitalOcean of `CI_SSH_KEY`, see [this](https://github.com/test-kitchen/kitchen-digitalocean#installation-and-setup) for more information\n\n### CI testing of PRs \u0026 forks\n\nYour patches will automatically get tested via Github Actions. The test summary is visible on Github in your PR, details can be found in the linked tests.\n\n## Get in touch\n\nYou can reach us on several ways:\n\n* [@DevSecIO](https://twitter.com/DevSecIO) on Twitter\n* Mailing list for questions and general discussion: devsec@freelists.org [[subscribe]](https://www.freelists.org/list/devsec)\n* Mailing list with release announcements (no posts are possible here): devsec-announce@freelists.org [[subscribe]](https://www.freelists.org/list/devsec-announce)\n\n## Contributors + Kudos\n\n* Dominik Richter [arlimus](https://github.com/arlimus)\n* Edmund Haselwanter [ehaselwanter](https://github.com/ehaselwanter)\n* Christoph Hartmann [chris-rock](https://github.com/chris-rock)\n* Thomas Dütsch [a-tom](https://github.com/a-tom)\n* Patrick Meier [atomic111](https://github.com/atomic111)\n* Artem Sidorenko [artem-sidorenko](https://github.com/artem-sidorenko)\n* Kurt Huwig [kurthuwig](https://github.com/kurthuwig)\n* Matthew Haughton [3flex](https://github.com/3flex)\n* Reik Keutterling [spielkind](https://github.com/spielkind)\n* Daniel Dreier [danieldreier](https://github.com/danieldreier)\n* Timo Goebel [timogoebel](https://github.com/timogoebel)\n* Tristan Helmich [fadenb](https://github.com/fadenb)\n* Michael Geiger [mcgege](https://github.com/mcgege)\n* Timo Bergemann [LooOOooM](https://github.com/LooOOooM)\n\nFor the original port of `chef-os-hardening` to puppet:\n\n* Artem Sidorenko [artem-sidorenko](https://github.com/artem-sidorenko)\n* Frank Kloeker [eumel8](https://github.com/eumel8)\n\nThank you all!!\n\n## License and Author\n\n* Author:: Dominik Richter \u003cdominik.richter@gmail.com\u003e\n* Author:: Deutsche Telekom AG\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n```\n  http://www.apache.org/licenses/LICENSE-2.0\n```\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n[1]: https://forge.puppet.com/hardening/os_hardening\n[2]: https://github.com/dev-sec/puppet-os-hardening/workflows/tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-sec%2Fpuppet-os-hardening","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdev-sec%2Fpuppet-os-hardening","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdev-sec%2Fpuppet-os-hardening/lists"}