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

(Parent) directory matcher #667

Open
JaneX8 opened this issue Dec 6, 2024 · 1 comment
Open

(Parent) directory matcher #667

JaneX8 opened this issue Dec 6, 2024 · 1 comment

Comments

@JaneX8
Copy link

JaneX8 commented Dec 6, 2024

Is your feature request related to a problem? Please describe.

In projects that have a certain folder structure I would like certain rules to apply not only on a specific file type but also to the consider the folder the file is in.

For example MVC structure. A rule that can be applied only on files with a certain file extension inside the views folder. Preferably within definable X depth up, to allow for some recursion (like globs). Or through defining multiple allowed paths like:

paths : [
  "*/views/",
  "*/views/*/",
  "*/views/**"
]

Describe the solution you'd like
A (parent) directory matcher.

Describe alternatives you've considered
None.

@gfs
Copy link
Contributor

gfs commented Dec 6, 2024

I think there's two ways you can do this already.

  1. By specifying the applies_to_file_regex field (https://github.com/microsoft/ApplicationInspector/blob/c84796ae8120f835165bc98d182fa9fb9540e87d/AppInspector.RulesEngine/Rule.cs#L83-L92) which is executed against the full path of the file: https://github.com/microsoft/ApplicationInspector/blob/c84796ae8120f835165bc98d182fa9fb9540e87d/AppInspector.RulesEngine/RuleProcessor.cs#L291. Take care to consider different path separators between operating systems - this field should ideally would be globs instead of regex for this reason.
  2. Or by specifying the --ignore-globs argument, however this will exclude the specified files from any rules being executed against them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants