chef / cookstyle

A linting tool that helps you to write better Chef Infra cookbooks and InSpec profiles by detecting and automatically correcting style, syntax, and logic mistakes in your code.
Apache License 2.0
107 stars 54 forks source link

[CHEF-1116] - Fixed the false positive issue with CronDFileOrTemplate and Updated the required Ruby version to 2.7 #959

Closed ashiqueps closed 1 year ago

ashiqueps commented 1 year ago

Description

The following recipe will raise the CronDFileOrTemplate cop due to the regex matching in the same class.

file '/etc/cron.deny' do 
  action :delete
end

I've updated the regex so that cron.deny will no longer treated as a cron file and the current scenarios will work as it is. The samples of the regex are below.

3.1.0 :001 > exp = %r{/etc/cron\.d\b}i
 => /\/etc\/cron\.d\b/i
3.1.0 :002 > "/etc/cron.d/".match?(exp)
 => true
3.1.0 :003 > "/etc/cron.d".match?(exp)
 => true
3.1.0 :004 > "/etc/cron.d/backup".match?(exp)
 => true
3.1.0 :005 > "/etc/cron.deny".match?(exp)
 => false
3.1.0 :006 > "/etc/cron.allow".match?(exp)
 => false

Related Issue

Types of changes

Checklist:

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

ashiqueps commented 1 year ago

The pending workflow is for Ruby 2.6 which was removed in this PR itself. Merging the PR since all other workflows are green.

vkarve-chef commented 1 year ago

appears to address https://github.com/chef/cookstyle/issues/946