Git Product home page Git Product logo

xlab-si / iac-scan-runner Goto Github PK

View Code? Open in Web Editor NEW
46.0 46.0 3.0 536 KB

Service that scans your Infrastructure as Code for common vulnerabilities

Home Page: https://xlab-si.github.io/iac-scanner-docs/02-runner.html

License: Apache License 2.0

Dockerfile 0.51% Ruby 0.05% Shell 2.79% Python 92.28% HTML 2.91% CSS 0.25% Java 0.69% JavaScript 0.14% HCL 0.13% TypeScript 0.25%
devsecops iac runner scan scanner scanning security vulnerability

iac-scan-runner's People

Contributors

anzoman avatar luka-wernig avatar penenadpi avatar redekg avatar sstanovnik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

iac-scan-runner's Issues

Establish SAST on IaC Scan Runner project code

To keep our code clean and secure we should use SAST tools to do linting and check security.

I propose tools like pylint, flake8, mypy, pydocstyle, bandit and others.

For the development process I suggest creating a new shell script that would allow developers to run sanity, unit and integration tests before pushing anything.

I propose something similar to https://gitlab.com/gaia-x/data-infrastructure-federation-services/orc/ppr/-/blob/main/dev.sh#L20.

Add support for scan result persistence

For each of the user scan runs, the results should be persisted in a database (at least for a limited time), so they can be later retrieved at some point in future. The following capabilities related of persistence are required:

  • insertion of scan record
  • querying for particular scan record by id
  • deleting scan record
  • showing/retrieving scan records
  • periodic cleanup job deleting old scans (for instance, after 14 days)

Changing hard-coded paths with parameters

Code related to output generation currently uses some of paths which are hard-coded as strings. They should be changed with parameters that could be set externally, such as environment variables.

Organize scan tasks into projects and add configuration capabilities

  • It is necessary to provide functionalities that would give the ability to group several scan tasks into project with unique ID that would be also persisted into database, together with other scan results.
  • Include IaC archive name within scan results
  • Persist configuration info for distinct projects

Update CLI to call API

With the IaC Scan Runner CLI it is currently possible to retrieve the OpenAPI Specification or to run the REST API. The next feature would be mapping the API commands so that the CLI would call the specified API endpoint and this would enable new mode of interaction as the IaC Scan Runner could be used within consoles and CI/CD pipelines.

Terrascan static code analyzer returns not found error

Terrascan static code analyzer returns not found error
"/bin/sh: 1: /iac-scan-runner/tools/terrascan: not found\n"

To replicate this error run:
curl -X 'POST' 'http://127.0.0.1:8080/scan' -H 'Content-Type: multipart/form-data' -F 'iac=@test_tf_hw.zip' -F 'checks=terrascan'

Used the same cmd and .zip file on tflint and tfsec and it works perfectly fine.

Originally posted by @jenkoj in #6 (comment)

Update API endpoints

We need to updated several API endpoints to improve readability and make them more user-friendly. These changes should make it easier for developers to use our API and understand how the different endpoints relate to each other.

Scan workflow execution exploiting multi-threading

During the TELFOR conference, some of the participants asked if distinct chain tools are executed in parallel within different threads. This way, the overall scanning time should be reduced, as multiple scans would be executed at the same time instead one by one.

Docker image build error

After running docker build -t . inside project's directory, the following error is reported, as shown.
image

**inflating: /iac-scan-runner/tools/tmp/sonar-scanner-4.7.0.2747/lib/sonar-scanner-cli-4.7.0.2747.jar
ERROR: npm v9.2.0 is known not to run on Node.js v12.22.12. You'll need to
upgrade to a newer Node.js version in order to use this version of npm. This
version of npm supports the following node versions: `^14.17.0 || ^16.13.0 ||

=18.0.0`. You can find the latest version at https://nodejs.org/.
:
/usr/local/lib/node_modules/npm/lib/utils/exit-handler.js:22
const hasLoadedNpm = npm?.config.loaded
^

SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at module.exports (/usr/local/lib/node_modules/npm/lib/cli.js:76:23)
at Object. (/usr/local/lib/node_modules/npm/bin/npm-cli.js:2:25)
at Module._compile (internal/modules/cjs/loader.js:999:30)
The command '/bin/sh -c cd /iac-scan-runner && apt-get update && apt-get -y install --no-install-recommends build-essential bash gcc git curl wget openjdk-17-jre ruby2.7 nodejs npm unzip python3 python3-pip python3-venv && apt-get update && mkdir -p /usr/share/man/man1 && npm i npm@latest -g && python3 -m venv .venv && . .venv/bin/activate && pip3 install --upgrade pip && pip install -r requirements.txt && ./install-checks.sh && npm uninstall npm && apt-get -y remove build-essential gcc npm curl wget && apt-get autoremove -y && apt-get autoclean -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/* && rm -rf /root/.cache/' returned a non-zero code: 1
ERROR:
/usr/local/lib/node_modules/npm/lib/utils/exit-handler.js:22
const hasLoadedNpm = npm?.config.loaded
^

SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at module.exports (/usr/local/lib/node_modules/npm/lib/cli.js:76:23)
at Object. (/usr/local/lib/node_modules/npm/bin/npm-cli.js:2:25)
at Module._compile (internal/modules/cjs/loader.js:999:30)
The command '/bin/sh -c cd /iac-scan-runner && apt-get update && apt-get -y install --no-install-recommends build-essential bash gcc git curl wget openjdk-17-jre ruby2.7 nodejs npm unzip python3 python3-pip python3-venv && apt-get update && mkdir -p /usr/share/man/man1 && npm i npm@latest -g && python3 -m venv .venv && . .venv/bin/activate && pip3 install --upgrade pip && pip install -r requirements.txt && ./install-checks.sh && npm uninstall npm && apt-get -y remove build-essential gcc npm curl wget && apt-get autoremove -y && apt-get autoclean -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/* && rm -rf /root/.cache/' returned a non-zero code: 1**

Resolve problems with checks (ShellCheck, hadolint, pylint)

Currently we are experiencing the following problems with checks that are part of IaC Scan Runner:

  • ShellCheck does not find schell scripts
  • hadolint does not find Dockerfiles (but terrascan does?!)
  • pylint complains about not finding __init__.py

xOpera TOSCA Parser does not find files

xOpera TOSCA Parser does function properly when running it with the following command
curl -X 'POST' 'http://127.0.0.1:8080/scan' -H 'Content-Type: multipart/form-data' -F '[email protected]' -F 'checks=opera-tosca-parser'

These are contents of given .zip file
Screenshot from 2022-11-28 15-30-11

parser returns no files error, even though service.yaml is present.

Usage of previously stored tool configurations

Despite that tool configuration is currently able to be persisted within the database and later loaded, there are still several aspects that are missing, when it comes to usage of tool-specific configuration parameters.
Therefore, it should be explored which tool require such parameters (such as tokens or some preferences) and extend IaC Scan Runner with means that would enable exploiting them in appropriate way for each of the tools.

Documentation updates required

The documentation needs to be published a bit:

  • Steampunk scanner -> Steampunk spotter
  • IaC Scan Runner SaaS -> maybe we remove this for now?

Updating examples

In examples directory, self-contained, standalone examples should be added in order to check whether the tool is properly installed or no. After that, the existing ones might be removed or updated as well.

Update API responses

All the API calls should be modified, so each of them would return JSON objects which can be easily processed further.

Update steampunk scanner

Steampunk scanner does not work since it changed it's name to Spotter. Rename all variables to the new naming convention.

Handle unsupported file scenario

Considering many TODOs related to extension for specific file types, it is still needed to properly handle all the situations when IaC archive contains file/script which is currently partially or not supported.

Extensibility flow: Automatic approach to adding new scan workflow tools

As it was mentioned on GA in Milano, it is desirable to provide the functionality that would enable intuitive method for adding new check tools to the scan workflow in future, even by end-users. Therefore, the means that would automate the tool encapsulation, integration and import steps should be provided.

Extend the compatibility matrix with all the missing check tools

Some of the currently integrated tools are not fully supported when it comes to advanced result visualization and compatibility matrix. Furthermore, apart from adding the tools into compatibility matrix, the output of all the checks which are not present should be parsed in order to determine the outcome: passed or problems detected.

Current progress can be summarized as follows:

image

Removing escape and blank characters from scan result logs dump

Some of the scan check tools, such as tfsec, return logs containing irrelevant symbols (either scape or white symbols, such as spaces, return and new line characters) which reduce the overall visibility. Therefore, a mechanism should be implemented to filter the logs and remove such characters. An example of such situation within HTML result page is depicted below.
image

Use Steampunk Scanner for scanning Ansible

Apart from ansible-lint, we don't have any other scanner for scanning Ansible playbooks and there are not many available.

The Steampunk Scanner is a quality scanner for Ansible playbooks, where you can scan the playbook and get an instant quality score with tips on how to improve it. The steampunk-scanner CLI enables the use of Ansible scanner from the console with the ability to scan Ansible task files, playbooks, roles and collections.

As of xlab-steampunk/steampunk-scanner-cli#14 the CLI supports scanning IaC directories, so we are now able to add it to our IaC Scan Runner.

Clean code and apply formatting

The current code seems to have some formatting issues. There are also places where the code can be simplified and/or cleaned.

Prevent adding invalid or duplicate check to project

Currently, it is not checked whether the provided name of check which is about to be added to the list is either an existing check (already in the list). Moreover, it is also possible to add strings that don't represent valid check names, which should be prevented as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.