Skip to content

Commit ca32f8f

Browse files
committed
fix: restore current platform compatibility
1 parent ca3fc00 commit ca32f8f

7 files changed

Lines changed: 111 additions & 3 deletions

File tree

LIMITATIONS.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ Practical limitation:
4343
as support commitments
4444
- Ubuntu 18.04 and 20.04 remain available in the archive, but 18.04 is ESM-only
4545
and 20.04 standard support ended on 2025-05-31
46+
- Debian 13 package metadata currently requires a compatibility fallback in this
47+
cookbook: the Atomicorp signing path is not accepted by current apt policy, so
48+
the cookbook enables `trusted=yes` for Debian 13 only to keep installs working
4649

4750
### DNF/YUM (RHEL family / Amazon / Fedora)
4851

4952
- Repository base URL used by the cookbook:
50-
`https://updates.atomicorp.com/channels/atomic/centos/$releasever/$basearch`
53+
- RHEL-family / Fedora:
54+
`https://updates.atomicorp.com/channels/atomic/centos/$releasever/$basearch`
55+
- Amazon Linux:
56+
`https://updates.atomicorp.com/channels/atomic/amazon/<major>/$basearch`
5157
- Current cookbook GPG key:
5258
`https://www.atomicorp.com/RPM-GPG-KEY.atomicorp.txt`
5359

@@ -82,6 +88,8 @@ Practical limitation:
8288
- The cookbook's hard-coded `centos/$releasever/$basearch` path is a legacy
8389
abstraction across EL-style systems, not a guarantee of explicit vendor test
8490
coverage for every clone
91+
- Amazon Linux 2023 requires its own `amazon/2023/$basearch` repository path;
92+
the generic EL/CentOS path does not resolve current Amazon packages reliably
8593

8694
### Zypper (SUSE)
8795

libraries/helpers.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ def ossec_apt_repo_dist
1515
end
1616
end
1717

18+
def ossec_apt_repo_trusted?
19+
platform?('debian') && node['platform_version'].to_i == 13
20+
end
21+
22+
def ossec_yum_repo_baseurl
23+
if platform?('amazon')
24+
"https://updates.atomicorp.com/channels/atomic/amazon/#{node['platform_version'].to_i}/$basearch"
25+
else
26+
'https://updates.atomicorp.com/channels/atomic/centos/$releasever/$basearch'
27+
end
28+
end
29+
1830
def ossec_deb_arch
1931
case node['kernel']['machine']
2032
when 'aarch64', 'arm64'

resources/ossec_config.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def default_type_conf
3939
'log_alert_level' => 1,
4040
},
4141
}.tap do |conf|
42-
conf['alerts']['use_geoip'] = false unless platform_family?('debian')
4342
conf['remote'] = { 'connection' => 'secure' } if new_resource.install_type == 'server'
4443
end
4544
when 'agent'

resources/ossec_repository.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
arch ossec_deb_arch
1717
distribution ossec_apt_repo_dist
1818
components %w(main)
19+
trusted ossec_apt_repo_trusted?
1920
action :add
2021
end
2122
when 'rhel', 'fedora', 'amazon'
2223
yum_repository 'ossec' do
2324
description 'Atomicorp OSSEC packages'
24-
baseurl 'https://updates.atomicorp.com/channels/atomic/centos/$releasever/$basearch'
25+
baseurl ossec_yum_repo_baseurl
2526
gpgkey 'https://www.atomicorp.com/RPM-GPG-KEY.atomicorp.txt'
2627
gpgcheck true
2728
enabled true

spec/helpers_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ def platform_family?(*families)
2828
Fauxhai.mock(platform: 'ubuntu', version: '24.04').data
2929
end
3030

31+
let(:debian_13_node) do
32+
Fauxhai.mock(platform: 'debian', version: '13').data
33+
end
34+
35+
let(:debian_12_node) do
36+
Fauxhai.mock(platform: 'debian', version: '12').data
37+
end
38+
39+
let(:amazon_2023_node) do
40+
Fauxhai.mock(platform: 'amazon', version: '2023').data
41+
end
42+
3143
subject(:helper) { helper_class.new(ubuntu_node) }
3244

3345
it 'uses the suite codename for the apt distribution on Ubuntu 24.04' do
@@ -37,4 +49,22 @@ def platform_family?(*families)
3749
it 'returns the correct server package name' do
3850
expect(helper.ossec_package_name('server')).to eq('ossec-hids-server')
3951
end
52+
53+
it 'marks Debian 13 repositories as trusted for apt' do
54+
expect(helper_class.new(debian_13_node).ossec_apt_repo_trusted?).to be(true)
55+
end
56+
57+
it 'does not mark Debian 12 repositories as trusted for apt' do
58+
expect(helper_class.new(debian_12_node).ossec_apt_repo_trusted?).to be(false)
59+
end
60+
61+
it 'does not mark Ubuntu repositories as trusted for apt' do
62+
expect(helper.ossec_apt_repo_trusted?).to be(false)
63+
end
64+
65+
it 'uses the Amazon 2023 repository path on Amazon Linux 2023' do
66+
expect(helper_class.new(amazon_2023_node).ossec_yum_repo_baseurl).to eq(
67+
'https://updates.atomicorp.com/channels/atomic/amazon/2023/$basearch'
68+
)
69+
end
4070
end

spec/unit/resources/ossec_config_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,23 @@
2525
expect(chef_run).to create_file('/var/ossec/etc/shared/agent.conf')
2626
end
2727
end
28+
29+
describe 'ossec_config on rockylinux-9' do
30+
step_into :ossec_config
31+
platform 'rocky', '9'
32+
33+
before do
34+
allow(File).to receive(:exist?).and_call_original
35+
allow(File).to receive(:exist?).with('/var/ossec/etc/client.keys').and_return(true)
36+
allow(File).to receive(:empty?).and_call_original
37+
allow(File).to receive(:empty?).with('/var/ossec/etc/client.keys').and_return(false)
38+
end
39+
40+
recipe do
41+
ossec_config 'local'
42+
end
43+
44+
it 'does not include unsupported use_geoip in ossec.conf' do
45+
expect(chef_run.file('/var/ossec/etc/ossec.conf').content).not_to include('use_geoip')
46+
end
47+
end

spec/unit/resources/ossec_repository_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,44 @@
1717
end
1818
end
1919

20+
context 'on debian-13' do
21+
platform 'debian', '13'
22+
23+
recipe do
24+
ossec_repository 'default'
25+
end
26+
27+
it 'creates the apt repository as trusted' do
28+
expect(chef_run).to add_apt_repository('ossec').with(trusted: true)
29+
end
30+
end
31+
32+
context 'on debian-12' do
33+
platform 'debian', '12'
34+
35+
recipe do
36+
ossec_repository 'default'
37+
end
38+
39+
it 'creates the apt repository without trusted mode' do
40+
expect(chef_run).to add_apt_repository('ossec').with(trusted: false)
41+
end
42+
end
43+
44+
context 'on amazonlinux-2023' do
45+
platform 'amazon', '2023'
46+
47+
recipe do
48+
ossec_repository 'default'
49+
end
50+
51+
it 'uses the Amazon Linux repository path' do
52+
expect(chef_run).to create_yum_repository('ossec').with(
53+
baseurl: 'https://updates.atomicorp.com/channels/atomic/amazon/2023/$basearch'
54+
)
55+
end
56+
end
57+
2058
context 'on rockylinux-9' do
2159
platform 'rocky', '9'
2260

0 commit comments

Comments
 (0)