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

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

Merged
merged 4 commits into from
Mar 21, 2023

Conversation

ashiqueps
Copy link
Contributor

@ashiqueps ashiqueps commented Mar 13, 2023

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

Signed-off-by: Ashique P S <Ashique.saidalavi@progress.com>
@ashiqueps ashiqueps requested review from a team as code owners March 13, 2023 13:29
Signed-off-by: Ashique P S <Ashique.saidalavi@progress.com>
Signed-off-by: Ashique P S <Ashique.saidalavi@progress.com>
Signed-off-by: Ashique P S <Ashique.saidalavi@progress.com>
@sonarcloud
Copy link

sonarcloud bot commented Mar 20, 2023

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 ashiqueps changed the title [CHEF-1116] - Fixed the false positive issue with CronDFileOrTemplate [CHEF-1116] - Fixed the false positive issue with CronDFileOrTemplate and Updated the required Ruby version to 2.7 Mar 21, 2023
@ashiqueps
Copy link
Contributor Author

ashiqueps commented Mar 21, 2023

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

@ashiqueps ashiqueps merged commit cf18af8 into chef:main Mar 21, 2023
@vkarve-chef
Copy link

appears to address #946

dafyddcrosby added a commit to dafyddcrosby/cookstyle that referenced this pull request Jun 14, 2024
chef#959 fixed this, but the regression test was missing

Signed-off-by: David Crosby <dcrosby@fb.com>
dafyddcrosby added a commit to dafyddcrosby/cookstyle that referenced this pull request Jun 14, 2024
chef#959 fixed this, but the regression tests were missing

Signed-off-by: David Crosby <dcrosby@fb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants