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

Undowngrade devskim #2748

Merged
merged 9 commits into from
Jun 18, 2023
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ ENV PATH="~/.raku/bin:/opt/rakudo-pkg/bin:/opt/rakudo-pkg/share/perl6/site/bin:$
# && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest
# Next line commented because already managed by another linter
# ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet"
RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI --version 0.7.104 \
RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI \

# dustilock installation
# Managed with COPY --link --from=dustilock /usr/bin/dustilock /usr/bin/dustilock
Expand Down
2 changes: 1 addition & 1 deletion flavors/security/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ RUN printf '#!/bin/bash \n\nif [[ -x "$1" ]]; then exit 0; else echo "Error: Fil
&& ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest

ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet"
RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI --version 0.7.104 \
RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI \

# dustilock installation
# Managed with COPY --link --from=dustilock /usr/bin/dustilock /usr/bin/dustilock
Expand Down
2 changes: 1 addition & 1 deletion linters/repository_devskim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh
&& ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest

ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet"
RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI --version 0.7.104
RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI

#OTHER__END

Expand Down
12 changes: 12 additions & 0 deletions megalinter/Linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,18 @@ def get_total_number_errors(self, stdout: str):
total_errors = sum(
not line.isspace() and line != "" for line in stdout.splitlines()
)
# Count number of results in sarif format
elif self.cli_lint_errors_count == "sarif":
sarif = None
sarif_stdout = utils.find_json_in_stdout(stdout)
try:
sarif = json.loads(sarif_stdout)
except ValueError as e:
logging.warning(f"Unable to parse sarif ({str(e)}):" + stdout)
if sarif and sarif["runs"] and sarif["runs"][0]["results"]:
total_errors = len(sarif["runs"][0]["results"])
else:
logging.warning("Unable to find results in :" + stdout)
# Return result if found, else default value according to status
if total_errors > 0:
return total_errors
Expand Down
10 changes: 6 additions & 4 deletions megalinter/descriptors/repository.megalinter-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,19 @@ linters:
- --file-format
- sarif
cli_lint_extra_args_after:
- --source-code
- "."
- -E
- --skip-git-ignored-files
- --ignore-globs
- "**/megalinter-reports/**"
cli_lint_errors_count: regex_count
cli_lint_errors_regex: "(\\[.*\\])"
cli_help_arg_name: --help
cli_version_arg_name: --version
cli_lint_errors_count: sarif
test_folder: devskim
examples:
- "devskim analyze ."
- "devskim analyze --file-format sarif ."
downgraded_version: true
install:
apk:
- icu-libs
Expand All @@ -94,7 +96,7 @@ linters:
&& chmod +x dotnet-install.sh \
&& ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest
- ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet"
- RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI --version 0.7.104
- RUN dotnet tool install --global Microsoft.CST.DevSkim.CLI
ide:
vscode:
- name: VSCode DevSkim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,8 @@
"regex_number",
"regex_count",
"regex_sum",
"total_lines"
"total_lines",
"sarif"
],
"examples": [
"regex_number",
Expand Down