|
1 | 1 | # @summary Prometheus Security Exporter |
2 | 2 | # |
| 3 | +# Collects installed packages and sends them to a Vuls server for |
| 4 | +# vulnerability scanning. Exposes CVE metrics via Prometheus. |
| 5 | +# |
3 | 6 | # @param enable Boolean flag to enable or disable the exporter. Defaults to false. |
4 | 7 | # |
5 | 8 | # @param noop_value Eit_types::Noop_Value flag to run in noop mode. Defaults to $common::monitor::exporter::noop_value. |
6 | 9 | # |
7 | | -# @param host The host certificate name. Defaults to $trusted['certname']. |
| 10 | +# @param host The host certificate name, used for mTLS and scrape target. Defaults to $trusted['certname']. |
8 | 11 | # |
9 | 12 | # @param listen_host The host to listen on. Defaults to '127.254.254.254'. |
10 | 13 | # |
11 | 14 | # @param listen_port The port to listen on. Defaults to 63396. |
12 | 15 | # |
| 16 | +# @param vuls_server_url The URL of the Vuls server to send package lists to. Defaults to 'https://vuls.obmondo.com'. |
| 17 | +# |
13 | 18 | # @param config_file Path to the configuration YAML file. Defaults to "${common::monitor::exporter::config_dir}/security_exporter.yaml". |
14 | 19 | # |
15 | 20 | # @groups settings enable, noop_value |
16 | 21 | # |
17 | 22 | # @groups network host, listen_host, listen_port |
18 | 23 | # |
19 | | -# @groups configuration config_file |
| 24 | +# @groups configuration vuls_server_url, config_file |
20 | 25 | # |
21 | 26 | class common::monitor::exporter::security ( |
22 | | - Boolean $enable = false, |
23 | | - Eit_types::Noop_Value $noop_value = $common::monitor::exporter::noop_value, |
24 | | - Eit_types::Certname $host = $trusted['certname'], |
25 | | - Stdlib::Host $listen_host = '127.254.254.254', |
26 | | - Stdlib::Port $listen_port = 63396, |
27 | | - Stdlib::Absolutepath $config_file = "${common::monitor::exporter::config_dir}/security_exporter.yaml" |
| 27 | + Boolean $enable = false, |
| 28 | + Eit_types::Noop_Value $noop_value = $common::monitor::exporter::noop_value, |
| 29 | + Eit_types::Certname $host = $trusted['certname'], |
| 30 | + Stdlib::Host $listen_host = '127.254.254.254', |
| 31 | + Stdlib::Port $listen_port = 63396, |
| 32 | + Stdlib::HTTPUrl $vuls_server_url = 'https://vuls.obmondo.com', |
| 33 | + Stdlib::Absolutepath $config_file = "${common::monitor::exporter::config_dir}/security_exporter.yaml", |
28 | 34 | ) { |
29 | 35 |
|
30 | 36 | unless $enable { return() } |
|
47 | 53 | noop => $noop_value, |
48 | 54 | } |
49 | 55 |
|
50 | | - if (($facts['os']['name'] == 'RedHat' or $facts['os']['name'] == 'CentOS') and (Integer($facts['os']['release']['major']) < 7)){ |
51 | | - package { 'yum-plugin-changelog': |
52 | | - ensure => ensure_latest($enable), |
53 | | - } |
54 | | - |
55 | | - package { 'yum-plugin-security': |
56 | | - ensure => ensure_latest($enable), |
57 | | - } |
58 | | - } |
59 | | - |
60 | 56 | service { "${service_name}.service": |
61 | 57 | ensure => ensure_service($enable), |
62 | 58 | enable => $enable, |
|
72 | 68 | package_ensure => ensure_latest($enable), |
73 | 69 | init_style => $facts['service_provider'], |
74 | 70 | install_method => 'package', |
| 71 | + options => "-config=${config_file}", |
75 | 72 | tag => $::trusted['certname'], |
76 | 73 | notify_service => Service[$service_name], |
77 | 74 | group => 'root', |
|
85 | 82 | scrape_job_labels => { 'certname' => $::trusted['certname'] }, |
86 | 83 | } |
87 | 84 |
|
88 | | - $_service = @("EOT"/$n) |
89 | | - # THIS FILE IS MANAGED BY OBMONDO. CHANGES WILL BE LOST. |
90 | | - [Service] |
91 | | - ExecStart= |
92 | | - ExecStart=/opt/obmondo/bin/obmondo-security-exporter -config=${config_file} |
93 | | - | EOT |
94 | | - |
95 | | - systemd::dropin_file { "${service_name}_dropin": |
96 | | - ensure => ensure_file($enable), |
97 | | - filename => "${service_name}-override.conf", |
98 | | - unit => "${service_name}.service", |
99 | | - content => $_service, |
100 | | - notify => Service["${service_name}.service"], |
101 | | - } |
102 | | - |
103 | 85 | file { $config_file: |
104 | 86 | ensure => ensure_file($enable), |
105 | 87 | owner => 'root', |
106 | 88 | group => 'root', |
107 | 89 | mode => '0640', |
108 | | - content => epp( |
109 | | - 'common/monitor/exporter/security_exporter.yaml.epp', { |
110 | | - cve_api_url => 'https://services.nvd.nist.gov', |
111 | | - server_host => $listen_host, |
112 | | - server_port => $listen_port, |
113 | | - cron_expr => '00 23 * * *', |
| 90 | + content => stdlib::to_yaml({ |
| 91 | + 'vuls_server' => { |
| 92 | + 'url' => $vuls_server_url, |
| 93 | + 'timeout' => '30s', |
| 94 | + 'cert_file' => "/etc/puppetlabs/puppet/ssl/certs/${host}.pem", |
| 95 | + 'key_file' => "/etc/puppetlabs/puppet/ssl/private_keys/${host}.pem", |
| 96 | + 'ca_file' => '/etc/puppetlabs/puppet/ssl/certs/ca.pem', |
114 | 97 | }, |
115 | | - ), |
| 98 | + 'listen_address' => "${listen_host}:${listen_port}", |
| 99 | + 'push_interval' => '12h', |
| 100 | + }), |
116 | 101 | notify => Service["${service_name}.service"], |
117 | 102 | } |
118 | 103 |
|
|
0 commit comments