-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[report-converter] Support sarif format and gcc analyzer
Fixes #1797. Based on a commit authored by @csordasmarton. Credit goes to him! We've long wanted to support sarif (https://sarifweb.azurewebsites.net/), and finally, this is the first real step towards it! This patch can both parse and export to sarif. My intent is that the code is self explanatory (because I explained things in the code!), there are two things I'd like to highlight: 1. I strugged a LOT with mypy, which lead me to express a things things in a rather cumbersome manner. I left comments around these parts 2. I copied all example tests from https://github.com/microsoft/sarif-tutorials/ to tools/report-converter/tests/unit/parser/sarif/sarif_test_files/. These examples come with an MIT licence, which I also copied over.
- Loading branch information
1 parent
6d7351e
commit 1d56191
Showing
64 changed files
with
3,621 additions
and
80 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ lxml==4.9.2 | |
portalocker==2.2.1 | ||
psutil==5.8.0 | ||
PyYAML==6.0.1 | ||
sarif-tools==1.0.0 | ||
mypy_extensions==0.4.3 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ mkdocs==1.2.3 | |
PyYAML==6.0.1 | ||
mypy_extensions==0.4.3 | ||
coverage==5.5.0 | ||
sarif-tools==1.0.0 |
This file contains 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
This file contains 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
This file contains 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
7 changes: 7 additions & 0 deletions
7
tools/report-converter/codechecker_report_converter/analyzers/gcc/__init__.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# ------------------------------------------------------------------------- | ||
# | ||
# Part of the CodeChecker project, under the Apache License v2.0 with | ||
# LLVM Exceptions. See LICENSE for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# ------------------------------------------------------------------------- |
34 changes: 34 additions & 0 deletions
34
tools/report-converter/codechecker_report_converter/analyzers/gcc/analyzer_result.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# ------------------------------------------------------------------------- | ||
# | ||
# Part of the CodeChecker project, under the Apache License v2.0 with | ||
# LLVM Exceptions. See LICENSE for license information. | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
# | ||
# ------------------------------------------------------------------------- | ||
|
||
import logging | ||
from typing import List | ||
|
||
from codechecker_report_converter.report import Report | ||
from codechecker_report_converter.report.parser import sarif | ||
|
||
from ..analyzer_result import AnalyzerResultBase | ||
|
||
|
||
LOG = logging.getLogger('report-converter') | ||
|
||
|
||
class AnalyzerResult(AnalyzerResultBase): | ||
""" Transform analyzer result of the GCC Static Analyzer. """ | ||
|
||
TOOL_NAME = 'gcc' | ||
NAME = 'GNU Compiler Collection Static Analyzer' | ||
URL = 'https://gcc.gnu.org/wiki/StaticAnalyzer' | ||
|
||
def __init__(self): | ||
super(AnalyzerResult, self).__init__() | ||
|
||
def get_reports(self, result_file_path: str) -> List[Report]: | ||
""" Get reports from the given analyzer result file. """ | ||
|
||
return sarif.Parser().get_reports(result_file_path) |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.