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

Allow Terrascan to lint in file lint mode #4498

Merged
merged 2 commits into from
Jan 16, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ linters:
- COPY --link --from=tflint /usr/local/bin/tflint /usr/bin/

# TERRASCAN
- linter_name: terrascan
- class: TerrascanLinter
linter_name: terrascan
can_output_sarif: true
name: TERRAFORM_TERRASCAN
descriptor_flavors:
Expand Down
17 changes: 17 additions & 0 deletions megalinter/linters/TerrascanLinter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python3
"""
Use TerrascanLinter to lint tf files
"""

from megalinter import Linter


class TerrascanLinter(Linter):
# Build the CLI command to call to lint a file
def build_lint_command(self, file=None):
cmd = super().build_lint_command(file)

if self.cli_lint_mode == "file":
cmd += ["--iac-file", f"{file}"]

return cmd
Loading