Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated PR: Cookstyle Changes #64

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 16 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,30 @@ name: ci
"on":
pull_request:
push:
branches:
- main
branches: [main]

jobs:
delivery:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Run Chef Delivery
uses: actionshub/chef-delivery@main
env:
CHEF_LICENSE: accept-no-persist

yamllint:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Run yaml Lint
uses: actionshub/yamllint@main

mdl:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Run Markdown Lint
uses: actionshub/markdownlint@main
lint-unit:
uses: sous-chefs/.github/.github/workflows/[email protected]

integration:
needs: [mdl, yamllint, delivery]
needs: lint-unit
runs-on: ubuntu-latest
strategy:
matrix:
os:
- 'debian-8'
- 'debian-9'
- 'centos-7'
- 'ubuntu-1604'
- 'ubuntu-1804'
suite:
- 'default'
- almalinux-8
- amazonlinux-2
- centos-7
- centos-stream-8
- debian-10
- debian-11
- fedora-latest
- opensuse-leap-15
- rockylinux-8
- ubuntu-1804
- ubuntu-2004
suite: [default]
fail-fast: false

steps:
Expand Down
4 changes: 0 additions & 4 deletions .overcommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ PreCommit:
enabled: true
required_executable: 'cookstyle'
command: ["cookstyle"]
Delivery:
enabled: true
required_executable: 'delivery'
flags: ['local', 'all']
CommitMsg:
HardTabs:
enabled: true
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ This file is used to list changes made in each version of the snort cookbook.

## Unreleased

- resolved cookstyle error: resources/compile.rb:72:1 refactor: `Chef/Modernize/ClassEvalActionClass`
- resolved cookstyle error: resources/install.rb:127:1 refactor: `Chef/Modernize/ClassEvalActionClass`
- resolved cookstyle error: resources/rules.rb:18:1 refactor: `Chef/Modernize/ClassEvalActionClass`
- resolved cookstyle error: resources/service.rb:5:26 refactor: `Chef/Modernize/UseChefLanguageSystemdHelper`
- resolved cookstyle error: resources/service.rb:18:77 refactor: `Chef/Modernize/UseChefLanguageSystemdHelper`
- resolved cookstyle error: resources/service.rb:30:26 refactor: `Chef/Modernize/UseChefLanguageSystemdHelper`
- resolved cookstyle error: resources/service.rb:44:77 refactor: `Chef/Modernize/UseChefLanguageSystemdHelper`
- resolved cookstyle error: resources/service.rb:48:1 refactor: `Chef/Modernize/ClassEvalActionClass`
- resolved cookstyle error: resources/service.rb:50:8 refactor: `Chef/Modernize/UseChefLanguageSystemdHelper`
- Update tested platforms
- Enable unified_mode

## 5.0.3 - *2022-02-08*

- Remove delivery folder
Expand Down
55 changes: 37 additions & 18 deletions kitchen.dokken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,65 @@
driver:
name: dokken
privileged: true
chef_version: <%= ENV['CHEF_VERSION'] || 'current' %>
env: [CHEF_LICENSE=accept]

transport:
name: dokken

provisioner:
name: dokken
deprecations_as_errors: true

platforms:
- name: debian-8
- name: almalinux-8
driver:
image: dokken/debian-8
image: dokken/almalinux-8
pid_one_command: /usr/lib/systemd/systemd

- name: amazonlinux-2
driver:
image: dokken/amazonlinux-2
pid_one_command: /usr/lib/systemd/systemd

- name: debian-10
driver:
image: dokken/debian-10
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update

- name: debian-9
- name: debian-11
driver:
image: dokken/debian-9
image: dokken/debian-11
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update

- name: centos-7
driver:
image: dokken/centos-7
pid_one_command: /usr/lib/systemd/systemd

- name: ubuntu-16.04
- name: centos-stream-8
driver:
image: dokken/ubuntu-16.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
image: dokken/centos-stream-8
pid_one_command: /usr/lib/systemd/systemd

- name: fedora-latest
driver:
image: dokken/fedora-latest
pid_one_command: /usr/lib/systemd/systemd

- name: ubuntu-18.04
driver:
image: dokken/ubuntu-18.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update

- name: ubuntu-20.04
driver:
image: dokken/ubuntu-20.04
pid_one_command: /bin/systemd

- name: opensuse-leap-15
driver:
image: dokken/opensuse-leap-15
pid_one_command: /usr/lib/systemd/systemd

- name: rockylinux-8
driver:
image: dokken/rockylinux-8
pid_one_command: /usr/lib/systemd/systemd
23 changes: 15 additions & 8 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,29 @@ driver:
name: vagrant

provisioner:
name: chef_zero
name: chef_infra
deprecations_as_errors: true
chef_license: accept
product_name: chef
product_version: <%= ENV['CHEF_VERSION'] || 'latest' %>
install_strategy: once
deprecations_as_errors: true
install_strategy: always
chef_log_level: <%= ENV['CHEF_LOG_LEVEL'] || 'auto' %>

verifier:
name: inspec

platforms:
- name: almalinux-8
- name: amazonlinux-2
- name: centos-7
- name: debian-8
- name: debian-9
- name: fedora-27
- name: ubuntu-14.04
- name: ubuntu-16.04
- name: centos-stream-8
- name: debian-10
- name: debian-11
- name: fedora-latest
- name: opensuse-leap-15
- name: rockylinux-8
- name: ubuntu-18.04
- name: ubuntu-20.04

suites:
- name: default
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache-2.0'
description 'Installs Snort IDS packages'
version '5.0.3'
chef_version '>= 15.0'
chef_version '>= 15.5'
source_url 'https://github.com/sous-chefs/snort'
issues_url 'https://github.com/sous-chefs/snort/issues'

Expand Down
4 changes: 3 additions & 1 deletion resources/compile.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
unified_mode true

property :daq_tar, String, required: true
property :snort_tar, String, required: true
property :snort_version, String, required: true
Expand Down Expand Up @@ -69,7 +71,7 @@
end
end

action_class.class_eval do
action_class do
def daq_path
"#{Chef::Config[:file_cache_path]}/daq"
end
Expand Down
2 changes: 2 additions & 0 deletions resources/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
unified_mode true

property :home_net, String, default: 'any'
property :external_net, String, default: 'any'
property :http_ports, String, default: '80,81,311,383,591,593,901,1220,1414,1741,1830,2301,2381,2809,3037,3128,3702,4343,4848,5250,6988,7000,7001,7144,7145,7510,7777,7779,8000,8008,8014,8028,8080,8085,8088,8090,8118,8123,8180,8181,8243,8280,8300,8800,8888,8899,9000,9060,9080,9090,9091,9443,9999,11371,34443,34444,41080,50002,55555'
Expand Down
22 changes: 3 additions & 19 deletions resources/install.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
#
# Cookbook:: snort
# Resource:: install
#
# Copyright:: 2010-2017, Chef Software, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
unified_mode true

property :database, String, equal_to: %w(none snort-mysql postgresql pgsql postgres), name_property: true
property :home_net, [String, nil], default: lazy {
case node['platform_family']
Expand Down Expand Up @@ -124,6 +108,6 @@
end
end

action_class.class_eval do
action_class do
include SnortCookbook::Helpers
end
4 changes: 3 additions & 1 deletion resources/rules.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
unified_mode true

property :oinkcode, [String, nil] # Supply this to download registered/subscriber rules
property :tar_name, String, default: 'community-rules.tar.gz' # Override this if you have an Oink code and know the tar you want to download
property :conf_dir, String, default: '/etc/snort'
Expand All @@ -15,7 +17,7 @@
end
end

action_class.class_eval do
action_class do
def rules_url
return new_resource.override_url unless new_resource.override_url.nil?

Expand Down
14 changes: 8 additions & 6 deletions resources/service.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
unified_mode true

property :options, Array, default: ['-q']

action :start do
create_init
cleanup_old_service if node['init_package'] == 'systemd'
cleanup_old_service if systemd?

service svc_name do
supports status: true, restart: true
Expand All @@ -15,7 +17,7 @@
supports status: true
action :stop
only_if { ::File.exist?("/etc/init/#{svc_name}.conf") } if node['init_package'] == 'init'
only_if { ::File.exist?("/etc/systemd/system/#{svc_name}.service") } if node['init_package'] == 'systemd'
only_if { ::File.exist?("/etc/systemd/system/#{svc_name}.service") } if systemd?
end
end

Expand All @@ -27,7 +29,7 @@
end

action :enable do
cleanup_old_service if node['init_package'] == 'systemd'
cleanup_old_service if systemd?
create_init

service svc_name do
Expand All @@ -41,13 +43,13 @@
supports status: true
action :disable
only_if { ::File.exist?("/etc/init/tomcat_#{new_resource.instance_name}.conf") } if node['init_package'] == 'init'
only_if { ::File.exist?("/etc/systemd/system/#{svc_name}.service") } if node['init_package'] == 'systemd'
only_if { ::File.exist?("/etc/systemd/system/#{svc_name}.service") } if systemd?
end
end

action_class.class_eval do
action_class do
def create_init
if node['init_package'] == 'systemd'
if systemd?

execute 'Load systemd unit file' do
command 'systemctl daemon-reload'
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'spec_helper'

describe 'Snort Install on Debian 8' do
let(:runner) { ChefSpec::ServerRunner.new(platform: 'debian', version: '8', step_into: ['snort_install']) }
let(:runner) { ChefSpec::ServerRunner.new(platform: 'debian', step_into: ['snort_install']) }

it 'converges successfully' do
expect { :chef_run }.to_not raise_error
Expand Down