Devskim total counter errors fix#8061
Draft
The-Loeki wants to merge 1 commit into
Draft
Conversation
DevSkim -E exits >0 when only non-errors are found. Only exit code <0 denotes errors.
Author
|
https://github.com/oxsecurity/megalinter/blob/main/megalinter/Linter.py#L885 hm is it by design that only the "file" mode will check for exit >0 for errors, while all others will check for != 0? |
Member
yes, because in other modes we can not know the status by file so we just do not record it ^^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Add a wrapper to Devskim execution to maximize exit code to 0.
Devskim invoked with -E exits with positive number for warnings, negative for errors.
Linter run() must have 0 for only warnings, or throws errors for not being able to find errors in the SARIF results:
[SARIF Reporter] Generated REPOSITORY_DEVSKIM report: report/megalinter-reports/sarif/REPOSITORY_DEVSKIM.sarif Unable to get total errors from SARIF output. SARIF:{'$schema': 'https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.6.json', 'runs': [{'columnKind': 'utf16CodeUnits', 'properties': {'megalinter': {'docUrl': 'https://megalinter.io/9.5.0/descriptors/repository_devskim', 'linterKey': 'REPOSITORY_DEVSKIM', 'linterVersion': '1.0.70'}}, 'results': [{'level': 'note', 'locations': [{'physicalLocation': {'artifactLocation': {'uri': '.cicd/devenv.sh'}, 'region': {'charLength': 9, 'charOffset': 799, 'endColumn': 12, 'endLine': 28, 'snippet': {'rendered': {'markdown': 'localhost', 'text': 'localhost'}, 'text': 'localhost'}, 'sourceLanguage': 'shellscript', 'startColumn': 3, 'startLine': 28}}}], 'message': {'text': 'Do not leave debug code in production'}, 'properties': {'DevSkimConfidence': 'High', 'DevSkimSeverity': 'ManualReview', 'tags': ['Hygiene.Network.AccessingLocalhost']}, 'ruleId': 'DS162092'}], 'tool': {'driver': {'fullName': 'Microsoft DevSkim Command Line Interface', 'informationUri': 'https://github.com/microsoft/DevSkim/', 'name': 'devskim (MegaLinter REPOSITORY_DEVSKIM)', 'rules': [{'defaultConfiguration': {'level': 'note'}, 'fullDescription': {'text': 'Do not leave debug code in production: Accessing localhost could indicate debug code, or could hinder scaling.'}, 'help': {'markdown': 'Visit [https://github.com/Microsoft/DevSkim/blob/main/guidance/DS162092.md](https://github.com/Microsoft/DevSkim/blob/main/guidance/DS162092.md) for additional guidance on this issue.', 'text': 'Accessing localhost could indicate debug code, or could hinder scaling.'}, 'helpUri': 'https://github.com/Microsoft/DevSkim/blob/main/guidance/DS162092.md', 'id': 'DS162092', 'name': 'DoNotLeaveDebugCodeInProduction', 'properties': {'DevSkimConfidence': 'High', 'DevSkimSeverity': 'ManualReview', 'precision': 'high', 'problem.severity': 'recommendation'}, 'shortDescription': {'text': 'Accessing localhost could indicate debug code, or could hinder scaling.'}}], 'version': '1.0.70+d69541fde7'}}}], 'version': '2.1.0'}Readiness Checklist
Author/Contributor
Reviewing Maintainer
breakingif this is a large fundamental changeautomation,bug,documentation,enhancement,infrastructure, orperformance