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: Allow active_only_if_file_found to work in specified subdirectory (_DIRECTORY) #3323

Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- New linters

- Fixes
- Allow active_only_if_file_found to work in specified subdirectory (_DIRECTORY), fixes [#2873](https://github.com/oxsecurity/megalinter/issues/2873)
- Activate CI servers reporters only if we find a related default env variable

- Doc
Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/css_scss_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ description: How to use scss-lint (configure, ignore files, ignore errors, help

> This linter has been deprecated.
>
> <https://github.com/sds/scss-lint#notice-consider-other-tools-before-adopting-scss-lint>
> https://github.com/sds/scss-lint#notice-consider-other-tools-before-adopting-scss-lint
>
> You should disable scss-lint by adding it in DISABLE_LINTERS property.
>
Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/repository_semgrep.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description: How to use semgrep (configure, ignore files, ignore errors, help &

[![GitHub stars](https://img.shields.io/github/stars/returntocorp/semgrep?cacheSeconds=3600)](https://github.com/returntocorp/semgrep) ![sarif](https://shields.io/badge/-SARIF-orange) [![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/returntocorp/semgrep?sort=semver)](https://github.com/returntocorp/semgrep/releases) [![GitHub last commit](https://img.shields.io/github/last-commit/returntocorp/semgrep)](https://github.com/returntocorp/semgrep/commits) [![GitHub commit activity](https://img.shields.io/github/commit-activity/y/returntocorp/semgrep)](https://github.com/returntocorp/semgrep/graphs/commit-activity/) [![GitHub contributors](https://img.shields.io/github/contributors/returntocorp/semgrep)](https://github.com/returntocorp/semgrep/graphs/contributors/)

**Disabled until <https://github.com/semgrep/semgrep/issues/9632> is solved**
**Disabled until https://github.com/semgrep/semgrep/issues/9632 is solved**

To use SemGrep in MegaLinter you must define a list of rulesets to use.

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/xml_xmllint.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To apply file formatting you must set `XML_XMLLINT_CLI_LINT_MODE: file` and `XML
| Variable | Description | Default value |
|-----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|
| XML_XMLLINT_AUTOFORMAT | If set to `true`, it will reformat and reindent the output | `false` |
| XML_XMLLINT_INDENT | The number of indentation spaces when `XML_XMLLINT_AUTOFORMAT` is `true` | `` |
| XML_XMLLINT_INDENT | The number of indentation spaces when `XML_XMLLINT_AUTOFORMAT` is `true` | ` ` |
| XML_XMLLINT_ARGUMENTS | User custom arguments to add in linter CLI call<br/>Ex: `-s --foo "bar"` | |
| XML_XMLLINT_COMMAND_REMOVE_ARGUMENTS | User custom arguments to remove from command line before calling the linter<br/>Ex: `-s --foo "bar"` | |
| XML_XMLLINT_FILTER_REGEX_INCLUDE | Custom regex including filter<br/>Ex: `(src\|lib)` | Include every file |
Expand Down
9 changes: 8 additions & 1 deletion megalinter/Linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,20 @@ def __init__(self, params=None, linter_config=None):
file_to_check, prop = file_to_check.split(":")
if os.path.isfile(f"{self.workspace}{os.path.sep}{file_to_check}"):
found_file = f"{self.workspace}{os.path.sep}{file_to_check}"
if os.path.isfile(
elif os.path.isfile(
f"{self.workspace}{os.path.sep}{self.linter_rules_path}{os.path.sep}{file_to_check}"
):
found_file = (
f"{self.workspace}{os.path.sep}{self.linter_rules_path}"
+ f"{os.path.sep}{file_to_check}"
)
elif os.path.isfile(
f"{self.workspace}{os.path.sep}{self.files_sub_directory}{os.path.sep}{file_to_check}"
):
found_file = (
f"{self.workspace}{os.path.sep}{self.files_sub_directory}"
+ f"{os.path.sep}{file_to_check}"
)
# filename case
if found_file is not None and prop is None:
is_found = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"properties": {
"active_only_if_file_found": {
"$id": "#/properties/active_only_if_file_found",
"description": "Names of the config files to be found (at least one), else descriptor will be deactivated",
"description": "Names of the config files to be found (at least one), else descriptor will be deactivated. Search in workspace, linter rules path, and files_sub_directory",
"examples": [
[
".editorconfig",
Expand Down
Loading