-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
Unable to get number of errors with regex_number #3446
Comments
I see how it can happen, but it's kinda weird. Do you know if it happened with a previous version? Did the output change, or a new text is printed breaking it? |
@echoix Don't know, just moved to ML from SL. |
But just to make sure of correctly assessing the importance here, does it happen only when there are no problems for real, and is still able to fail when the linter finds errors? (Is the green check correct ?) |
Well, now I am not sure that it was trufflehog. Can you see this log? Now it's after kics. What debug variable I should set to see who's output this? |
It isn't kicks, but more likely ansible:
I'm looking a bit, but not on how to fix your code, on why is the output not matching the regex. But at the linter reports that it is a failure. But the .nice-to-have" error count is not correct |
I wonder if it is ansible/ansible-lint#4007, that was fixed in ansible/ansible-lint#4026 and released in 24.2.1, the same day as our last release, so it wasn't included in yet. Ansible 24.2.1 is in our beta version though (beta is the current build of the main branch). You might want to try it, But you still have 678 fatal violations in the meantime : https://github.com/alexanderbazhenoff/ansible-collection-linux/actions/runs/8410583902/job/23029212065#step:4:1570 |
The warning seems to be hit when preparing the output for the next tool. |
Please check this log, there was no ansible lint. Most of ansible-lint violation comes because these roles are made for Ansible 2.9 and linted for ansible 2.10 max (ansible-lint 5.4.0 using ansible 2.10.17). Since 2022 they add a lot of new ansible-lint rules. I need to lint and test if first on my local installed ansible-core 2.15. So I think that while I'm doing it, there's will be a new version of ML with latest ansible :) Anyway thanks for the quick reaction. |
Ok, that's a different one. It seems that the output format switches to GitHub Actions automatically since 2.16.0, after that format being introduced in 2.15.0 (September 2020). I think that we never caught it since the tests run inside docker, and probably the detection doesn't go through. In your only error, there isn't anything after the line:column that has the text "error", so it never matches. @staticmethod
def github(problem, filename):
line = f'::{problem.level} file={filename},' \
f'line={problem.line},col={problem.column}' \
f'::{problem.line}:{problem.column} '
if problem.rule:
line += f'[{problem.rule}] '
line += problem.desc
return line The problem level never appears after the line:column text. The other output formats are created here: class Format:
@staticmethod
def parsable(problem, filename):
return (f'{filename}:{problem.line}:{problem.column}: '
f'[{problem.level}] {problem.message}')
@staticmethod
def standard(problem, filename):
line = f' {problem.line}:{problem.column}'
line += max(12 - len(line), 0) * ' '
line += problem.level
line += max(21 - len(line), 0) * ' '
line += problem.desc
if problem.rule:
line += f' ({problem.rule})'
return line
@staticmethod
def standard_color(problem, filename):
line = f' \033[2m{problem.line}:{problem.column}\033[0m'
line += max(20 - len(line), 0) * ' '
if problem.level == 'warning':
line += f'\033[33m{problem.level}\033[0m'
else:
line += f'\033[31m{problem.level}\033[0m'
line += max(38 - len(line), 0) * ' '
line += problem.desc
if problem.rule:
line += f' \033[2m({problem.rule})\033[0m'
return line
@staticmethod
def github(problem, filename):
line = f'::{problem.level} file={filename},' \
f'line={problem.line},col={problem.column}' \
f'::{problem.line}:{problem.column} '
if problem.rule:
line += f'[{problem.rule}] '
line += problem.desc
return line So until we either rewrite the regex to accept all their output formats, or impose using a certain output format, you could use either the Are you fluent enough in regex to suggest one that fits the multiple output formats? |
The regex to change is:
What we are testing for: https://github.com/oxsecurity/megalinter/blob/0909ca81b33bcfa31c49413f0778dc6d6126f850/.automation/test/yaml/reports/ERROR-YAML_YAMLLINT.txt https://github.com/oxsecurity/megalinter/blob/0909ca81b33bcfa31c49413f0778dc6d6126f850/.automation/test/yaml/reports/SUCCESS-YAML_YAMLLINT.txt (as the output of the files _good and _bad in https://github.com/oxsecurity/megalinter/tree/0909ca81b33bcfa31c49413f0778dc6d6126f850/.automation/test/yaml
|
Where I can replace this file before linting in my CI? May be path inside of repo or docker, right? It's a good idea to experiment with this regex when I patch all my ten millions code violations :) PS:
This time after kics... 👽 |
The way we manage to use all the linters in a standard way, while they all work differently, is through the descriptors. They are copied into the docker images built. So your approach is quite clever, since they aren't really used to build the containers, they are parsed inside. So it will work to edit them inside the containers. The full dockerfile is here: Lines 771 to 776 in 0909ca8
But we have flavors that are trimmed down, and even individual linters published as images, like this one with just yamllint: megalinter/linters/yaml_yamllint/Dockerfile Lines 139 to 143 in 0909ca8
So inside the containers, the folder containing the files to change is For speeding up your debugging of just one tool (the startup and all), you could use an image with only one linter. If you run locally with mega-linter-runner (a tool that calls docker with all the arguments more easily), for this image: npx mega-linter-runner --flavor only-yaml_yamllint
npx mega-linter-runner --flavor only-yaml_yamllint --release beta
npx mega-linter-runner --image 'oxsecurity/megalinter-only-yaml_yamllint:beta'
npx mega-linter-runner --image 'ghcr.io/oxsecurity/megalinter-only-yaml_yamllint:beta'
npx mega-linter-runner --image 'ghcr.io/oxsecurity/megalinter-only-yaml_yamllint:beta_20240319-2208'
It's not after kicks, it's before ansible-lint. The error occurs when building the summary output, so the extra warning will be before the tool. So the problem is ansible-lint again. |
This issue has been automatically marked as stale because it has not had recent activity. If you think this issue should stay open, please remove the |
Sorry, not enough time to see this. I'll be back a bit later. |
This issue has been automatically marked as stale because it has not had recent activity. If you think this issue should stay open, please remove the |
Hi, not so serious bug, but...
Describe the bug
Here is a actions log where
trufflehog
pass, but still trying to capture number of errors.To Reproduce
I think any success result, but you can try my working branch.
Expected behavior
Expected no tries of getting number of errors :)
Screenshots
The text was updated successfully, but these errors were encountered: