How to Add Support for a New Tool to Super-Linter

If you want to propose a Pull Request to add new language support or a new tool, follow these steps.

Update Documentation

  • Ensure the README.md is updated to reflect the new linter, including its entry in the supported linters table.

Provide Test Cases

  1. Create a new directory: test/linters/<LANGUAGE_NAME>.
  2. Provide at least one test case with a file that is supposed to pass validation (e.g., test/linters/<LANGUAGE_NAME>/<name-of-tool>-good.<ext>).
  3. Provide at least one test case with a file that is supposed to fail validation (e.g., test/linters/<LANGUAGE_NAME>/<name-of-tool>-bad.<ext>). If the tool supports fix mode, the failing test case should contain only violations that can be automatically fixed.
  4. Update expected summary reports in test/data/super-linter-summary.
  5. If the tool supports fix mode, add the <LANGUAGE> to the LANGUAGES_WITH_FIX_MODE array in test/testUtils.sh.

Update the Test Suite

Update the InSpec test suite to check for the newly installed packages and commands:

  • test/inspec/super-linter/controls/super_linter.rb

Install the Tool

All tools are installed via the main Dockerfile. The method depends on the tool's ecosystem:

  • PyPi Packages: Add a dependencies/python/<tool-name>.txt file, update the PATH in the Dockerfile, and add it to the dependabot.yml configuration.
  • NPM Packages: Update dependencies/package.json and dependencies/package-lock.json.
  • Ruby Gems: Update dependencies/Gemfile and dependencies/Gemfile.lock.
  • Java/Gradle Packages: Create a dependencies/<tool-name> directory with a build.gradle file and an associated scripts/install-<tool-name>.sh script to handle the installation.
  • Container Images: Add a new build stage in the Dockerfile using FROM your/image:version as <tool-name> and COPY --from=<tool-name> to copy the binary into the final image. Add the new dependency to dependabot.yml.

Integrate the Tool

Update the core orchestration scripts to run the new tool:

  • lib/globals/languages.sh: Add a new entry to the LANGUAGES_ARRAY.
  • lib/functions/linterCommands.sh: Define the command to invoke the tool in a new LINTER_COMMANDS_ARRAY_<LANGUAGE_NAME> variable.
  • lib/globals/linterCommandsOptions.sh: If the tool supports it, add options for "check-only" and "fix" modes.

Configure the New Tool

  • lib/globals/linterRules.sh: Define a variable for the tool's configuration file name.
  • TEMPLATES/: Add a default, minimal configuration file for the new tool.
  • lib/functions/linterCommands.sh: Update the command to pass the configuration file path to the tool.

File Detection and List Building

  • lib/functions/buildFileList.sh: Add logic to identify and categorize files that should be processed by the new linter.
  • scripts/linterVersions.sh: Add logic to retrieve and record the tool's version.
  • lib/functions/detectFiles.sh: If necessary, add more complex logic to detect if a file should be processed by this tool.