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

fix: add empty glob error when no files match #1259

Merged
merged 1 commit into from
Dec 29, 2024

Conversation

gantony
Copy link
Contributor

@gantony gantony commented Dec 20, 2024

Implements #1250.

What

This PR adds an "empty glob" error when trying to include files using a glob pattern, but the pattern does not match any file.

Why

If a user specifies a config file with Include rules./*.conf, the intent is that a number of files will be parsed (at least 1 😅).
If for some reason the glob pattern does not match any file, we should return an error so that the user realizes there is a problem with the configuration.
The user can then fix the glob pattern (or remove it if not needed), instead of assuming that the expected configuration files have been loaded.

Checklist

@gantony gantony requested a review from a team as a code owner December 20, 2024 12:02
Copy link
Member

@fzipi fzipi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gantony for your contribution!

Feel free to keep reporting and sending PRs! 💪

@fzipi fzipi changed the title Add empty glob error when no files match fix: add empty glob error when no files match Dec 20, 2024
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.68%. Comparing base (dcdbc28) to head (cfcf29e).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1259   +/-   ##
=======================================
  Coverage   81.68%   81.68%           
=======================================
  Files         168      168           
  Lines        9762     9765    +3     
=======================================
+ Hits         7974     7977    +3     
  Misses       1537     1537           
  Partials      251      251           
Flag Coverage Δ
coraza.rule.case_sensitive_args_keys 81.64% <100.00%> (+<0.01%) ⬆️
coraza.rule.multiphase_valuation 81.68% <100.00%> (+<0.01%) ⬆️
coraza.rule.no_regex_multiline 81.62% <100.00%> (+<0.01%) ⬆️
default 81.68% <100.00%> (+<0.01%) ⬆️
examples+ 16.54% <0.00%> (-0.01%) ⬇️
examples+coraza.rule.case_sensitive_args_keys 81.64% <100.00%> (+<0.01%) ⬆️
examples+coraza.rule.multiphase_valuation 81.52% <100.00%> (+<0.01%) ⬆️
examples+coraza.rule.no_regex_multiline 81.54% <100.00%> (+<0.01%) ⬆️
examples+memoize_builders 81.64% <100.00%> (+<0.01%) ⬆️
examples+no_fs_access 80.97% <100.00%> (+<0.01%) ⬆️
ftw 81.68% <100.00%> (+<0.01%) ⬆️
memoize_builders 81.78% <100.00%> (+<0.01%) ⬆️
no_fs_access 81.13% <100.00%> (+<0.01%) ⬆️
tinygo 81.65% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jcchavezs jcchavezs requested a review from M4tteoP December 21, 2024 07:59
@jcchavezs
Copy link
Member

Just to confirm, what is the behavior of modsec on this?

@fzipi
Copy link
Member

fzipi commented Dec 29, 2024

I think this is the exact same behavior as the Include method above for both versions, and we should replicate.

There could be a new IncludeOptional directive if we want to add it, but that's for a followup issue + PR, IMHO.

@fzipi fzipi merged commit 842b8f6 into corazawaf:main Dec 29, 2024
71 checks passed
@gantony gantony deleted the empty_glob_error branch December 30, 2024 11:01
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.

3 participants