• Stars
    star
    4,472
  • Rank 9,283 (Top 0.2 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Detect compliance and security violations across Infrastructure as Code to mitigate risk before provisioning cloud native infrastructure.

Terrascan

GitHub release License: Apache 2.0 PRs Welcome CI Quality Gate Status AUR package codecov Documentation Status Contributor Covenant GitHub all releases

Introduction

Terrascan is a static code analyzer for Infrastructure as Code. Terrascan allows you to:

  • Seamlessly scan infrastructure as code for misconfigurations.
  • Monitor provisioned cloud infrastructure for configuration changes that introduce posture drift, and enables reverting to a secure posture.
  • Detect security vulnerabilities and compliance violations.
  • Mitigate risks before provisioning cloud native infrastructure.
  • Offers flexibility to run locally or integrate with your CI\CD.

Resources

Join Tenable community 👇

Key features

  • 500+ Policies for security best practices
  • Scanning of Terraform (HCL2)
  • Scanning of AWS CloudFormation Templates (CFT)
    • Scanning of Azure Resource Manager (ARM)
  • Scanning of Kubernetes (JSON/YAML), Helm v3, and Kustomize
  • Scanning of Dockerfiles
  • Support for AWS, Azure, GCP, Kubernetes, Dockerfile, and GitHub
  • Integrates with docker image vulnerability scanning for AWS, Azure, GCP, Harbor container registries.

Quick Start

  1. Install
  2. Scan
  3. Integrate

Step 1: Install

Terrascan supports multiple ways to install and is also available as a Docker image. See Terrascan's releases page for the latest version of builds in all supported platforms. Select the correct binary for your platform.

Install as a native executable

$ curl -L "$(curl -s https://api.github.com/repos/tenable/terrascan/releases/latest | grep -o -E "https://.+?_Darwin_x86_64.tar.gz")" > terrascan.tar.gz
$ tar -xf terrascan.tar.gz terrascan && rm terrascan.tar.gz
$ install terrascan /usr/local/bin && rm terrascan
$ terrascan

Install on ArchLinux / Manjaro via AUR

ArchLinux and Manjaro users can install by:

yay -S terrascan

Install via brew

Homebrew users can install by:

$ brew install terrascan

Docker image

Terrascan is also available as a Docker image and can be used as follows

$ docker run tenable/terrascan

Refer to documentation for information.

Step 2: Scan

To scan your code for security issues you can run the following (defaults to scanning Terraform).

$ terrascan scan

Note: Terrascan will exit with an error code if any errors or violations are found during a scan.

List of possible Exit Codes

Scenario Exit Code
scan summary has errors and violations 5
scan summary has errors but no violations 4
scan summary has violations but no errors 3
scan summary has no violations or errors 0
scan command errors out due to invalid inputs 1

Step 3: Integrate with CI\CD

Terrascan can be integrated into CI/CD pipelines to enforce security best practices. Please refer to our documentation to integrate with your pipeline.

Terrascan Commands

You can use the terrascan command with the following options:

$ terrascan
Terrascan

Usage:
  terrascan [command]

Available Commands:
  help        Help about any command
  init        Initialize Terrascan
  scan        Detect compliance and security violations across Infrastructure as Code.
  server      Run Terrascan as an API server
  version     Terrascan version

Flags:
  -c, --config-path string   config file path
  -h, --help                 help for terrascan
  -l, --log-level string     log level (debug, info, warn, error, panic, fatal) (default "info")
  -x, --log-type string      log output type (console, json) (default "console")
  -o, --output string        output type (human, json, yaml, xml) (default "human")

Use "terrascan [command] --help" for more information about a command.

Policies

Terrascan policies are written using the Rego policy language. Every rego includes a JSON "rule" file which defines metadata for the policy. By default, Terrascan downloads policies from Terrascan repositories while scanning for the first time. However, if you want to download the latest policies, you need to run the Initialization process. See Usage for information about the Initialization process.

Note: The scan command will implicitly run the initialization process if there are no policies found.

Docker Image Vulnerabilities

You can use the --find-vuln flag to collect vulnerabilities as reported in its registry as part of Terrascan's output. Currently Terrascan supports Elastic Container Registry (ECR), Azure Container Registry, Google Container Registry, and Google Artifact Registry.

The --find-vuln flag can be used when scanning IaC files as follows:

$ terrascan scan -i <IaC provider> --find-vuln

For more information and explanation of how to setup your environment to authenticate with the registry's APIs see the usage documentation.

Customizing scans

By default, Terrascan scans your entire configuration against all policies. However, Terrascan supports granular configuration of policies and resources.

Read more about in-file instrumentation and the config file on our documentation site.

For now, some quick tips:

How to exclude a policy while scanning a resource

You can configure Terrascan to skip a particular policy (rule) while scanning a resource. Follow these steps depending on your platform:

Terraform

Use Terraform scripts to configure Terrascan to skip rules by inserting a comment with the phrase "ts:skip=<RULENAME><SKIP_REASON>". The comment should be included inside the resource as shown in the example below.

tf

Kubernetes

In Kubernetes yamls, you can configure Terrascan to skip policies by adding an annotation as seen in the snippet below.

k8s

How to include or exclude specific policies or resources from being scanned

Use the Terrascan config file to manually select the policies which should be included or excluded from the entire scan. This is suitable for edge use cases. Use the "in-file" suppression option to specify resources that should be excluded from being tested against selected policies. This ensures that the policies are skipped only for particular resources, rather than all of the resources.

config

Sample scan output

Terrascan's default output is a list of violations present in the scanned IaC. A sample output:

Screenshot 2021-01-19 at 10 52 47 PM

Building Terrascan

Terrascan can be built locally. This is helpful if you want to be on the latest version or when developing Terrascan. gcc and Go 1.19 or above are required.

$ git clone [email protected]:tenable/terrascan.git
$ cd terrascan
$ make build
$ ./bin/terrascan

To build your own docker, refer to this example (Alpine Linux):

FROM golang:alpine AS build-env

RUN apk add --update git

RUN git clone https://github.com/tenable/terrascan && cd terrascan \
  && CGO_ENABLED=0 GO111MODULE=on go build -o /go/bin/terrascan cmd/terrascan/main.go

Developing Terrascan

To learn more about developing and contributing to Terrascan, refer to the contributing guide.

Code of Conduct

We believe having an open and inclusive community benefits all of us. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

Terrascan is licensed under the Apache 2.0 License.

Stargazers

Stargazers @tenable/terrascan

Forkers

Forkers @tenable/terrascan

More Repositories

1

poc

Proof of Concepts
Python
1,181
star
2

routeros

RouterOS Security Research Tooling and Proof of Concepts
C++
838
star
3

nessrest

A python library for using the new Nessus REST API.
Python
386
star
4

pyTenable

Python Library for interfacing into Tenable's platform APIs
Python
332
star
5

ghidra_tools

A collection of Ghidra scripts, including the GPT-3 powered code analyser and annotator, G-3PO.
Python
288
star
6

awesome-llm-cybersecurity-tools

A curated list of large language model tools for cybersecurity research.
278
star
7

pi_sniffer

The pocket-sized wireless sniffer
C++
202
star
8

router_badusb

BadUSB in Routers
Shell
190
star
9

upnp_info

A simple script for discovery and analysis of UPnP servers
Python
158
star
10

esp32_image_parser

A toolkit for helping you reverse engineer ESP32 firmware.
Python
137
star
11

DiscordClient

Python
96
star
12

Posh-Nessus

PowerShell Module for automating Tenable Nessus Vulnerability Scanner.
PowerShell
88
star
13

KaiMonkey

KaiMonkey provides vulnerable infrastructure as code (IaC) to help explore and understand common cloud security threats exposed via IaC.
HCL
85
star
14

Tenable.io-SDK-for-Python

Tenable.io SDK offers a scalable and safe way to integrate with the Tenable.io platform.
Python
83
star
15

EscalateGPT

An AI-powered tool for discovering privilege escalation opportunities in AWS IAM configurations.
Python
81
star
16

audit_scripts

Scripts to help work with configuration audit files
Python
76
star
17

Burp-extension-for-GPT

an extension for Burp Suite to allow researchers to utilize GPT for analys is of HTTP requests and responses
Python
74
star
18

integration-jira-cloud

Python
65
star
19

yara-rules

Repository of yara rules
YARA
55
star
20

terrascan-action

Terrascan GitHub action. Scan infrastructure as code including Terraform, Kubernetes, Helm, and Kustomize file for security best practices.
Shell
47
star
21

nasl

A parser for NASL.
Ruby
43
star
22

flask-logging-demo

Demo files for 'The Boring Stuff - Flask Logging' blog post
Python
34
star
23

mIDA

C++
32
star
24

audit_files

Nessus Audit files
31
star
25

Security-Hub

For use in our Tenable.IO to AWS Security Hub integration
Python
24
star
26

terrascan-rego-editor

Visual Studio Code extension for writing Terrascan Rego policies
TypeScript
18
star
27

nasldoc

A documentation generator for NASL.
Ruby
17
star
28

pedant

A static analysis framework for NASL.
Ruby
14
star
29

sublimetext-nasl

13
star
30

accurics-action

The Accurics GitHub Action scans Infrastructure as Code files checked into the respository to help ensure that cloud resources are secure and compliant from creation.
Shell
13
star
31

Kastle

A purely functional, effectful, resource-safe, kafka library for Scala
Scala
12
star
32

csup

Tenable.io Container Security Uploading and Reporting Commandline Tool
Python
11
star
33

microfrontend-demo-app

JavaScript
11
star
34

SinCity

Python
11
star
35

integration-asc

Python
10
star
36

vim-nasl

Vim extensions for programming in NASL
Vim Script
9
star
37

runterrascan.io

CSS
8
star
38

golden-ami-pipeline-with-tenable-sample

The golden AMI pipeline enables creation, distribution, verification, launch-compliance, and decommissioning of the golden AMI out of the box. This version of the pipeline integrates with Tenable.io for vulnerability assessments.
6
star
39

container-security-action

Tenable's Container security action which helps scan docker images.
Python
6
star
40

notepadpp-nasl

5
star
41

integration-cef

Python
5
star
42

was-action

Github action to trigger WAS
Python
5
star
43

cloud-snapshot-automation

Templates for creating Cloud Snapshots
HCL
4
star
44

splunk-app-pvs

This app provides Splunk dashboards and reporting for Tenable PVS
HTML
4
star
45

presentations

4
star
46

integrations-ibm-cloudpak-for-security

Python
4
star
47

Tenable.ad-EventsLogs-Subscriber

Tenable.ad IOA module event logs listener
Rust
4
star
48

entra-id-federation-abuse-research-required-roles

PowerShell
4
star
49

UncoverDCShadow

PowerShell
3
star
50

integration-cscc

Tenable.io to Google Cloud Security Command Center Bridge
Python
3
star
51

emacs-nasl

Emacs Lisp
3
star
52

tenablecs_demo

HCL
2
star
53

asm-python-examples

Bit Discovery REST API scripts
Python
2
star
54

labs

1
star
55

accurics-vscode

TypeScript
1
star
56

WSUSpendu

PowerShell
1
star
57

nasl-layer

Spacemacs layer for NASL
1
star
58

asm-asset-importer

Scripts to integrate BitDiscovery data with Tenable
Python
1
star
59

atom-grammar-nessuskb

Grammar file for Nessus KB files.
CoffeeScript
1
star
60

accurics-orb

The Accurics CircleCI Orb scans IaC (Infrastructure as Code) to help identify vulnerabilities prior to cloud deployment.
Shell
1
star
61

helm-charts

Smarty
1
star