GithubHelp home page GithubHelp logo

wanghe-fit2cloud / kubescape Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kubescape/kubescape

0.0 2.0 0.0 2.92 MB

Kubescape is the first open-source tool for testing if Kubernetes is deployed securely according to multiple frameworks: regulatory, customized company policies and DevSecOps best practices, such as the NSA-CISA and the MITRE ATT&CK®.

License: Apache License 2.0

Go 95.18% Shell 1.01% Dockerfile 0.59% HTML 0.35% Python 2.04% PowerShell 0.84%

kubescape's Introduction

logo

build Go Report Card

Kubescape is the first open-source tool for testing if Kubernetes is deployed securely according to multiple frameworks: regulatory, customized company policies and DevSecOps best practices, such as the NSA-CISA and the MITRE ATT&CK® .
Kubescape scans K8s clusters, YAML files, and HELM charts, and detect misconfigurations and software vulnerabilities at early stages of the CI/CD pipeline and provides a risk score instantly and risk trends over time. Kubescape integrates natively with other DevOps tools, including Jenkins, CircleCI and Github workflows.


TL;DR

Install:

curl -s https://raw.githubusercontent.com/armosec/kubescape/master/install.sh | /bin/bash

Install on windows

Install on macOS

Run:

kubescape scan framework nsa

Click 👍 if you want us to continue to develop and improve Kubescape 😀

Being part of the team

We invite you to our team! We are excited about this project and want to return the love we get.

Want to contribute? Want to discuss something? Have an issue?

  • Open a issue, we are trying to respond within 48 hours
  • Join us in a discussion on our discord server!

logo

Options and examples

Install on Windows

Requires powershell v5.0+

iwr -useb https://raw.githubusercontent.com/armosec/kubescape/master/install.ps1 | iex

Note: if you get an error you might need to change the execution policy (i.e. enable Powershell) with

Set-ExecutionPolicy RemoteSigned -scope CurrentUser

Install on macOS

  1.  brew tap armosec/kubescape
    
  2.  brew install kubescape
    

Flags

flag default description options
-e/--exclude-namespaces Scan all namespaces Namespaces to exclude from scanning. Recommended to exclude kube-system and kube-public namespaces
-s/--silent Display progress messages Silent progress messages
-t/--fail-threshold 0 (do not fail) fail command (return exit code 1) if result bellow threshold 0 -> 100
-f/--format pretty-printer Output format pretty-printer/json/junit
-o/--output print to stdout Save scan result in file
--use-from Load local framework object from specified path. If not used will download latest
--use-default false Load local framework object from default path. If not used will download latest true/false
--exceptions Path to an exceptions obj. If not set will download exceptions from Armo management portal
--submit false If set, Kubescape will send the scan results to Armo management portal where you can see the results in a user-friendly UI, choose your preferred compliance framework, check risk results history and trends, manage exceptions, get remediation recommendations and much more. By default the results are not sent true/false
--keep-local false Kubescape will not send scan results to Armo management portal. Use this flag if you ran with the --submit flag in the past and you do not want to submit your current scan results true/false
--account Armo portal account ID. Default will load account ID from configMap or config file

Usage & Examples

Examples

  • Scan a running Kubernetes cluster with nsa framework and submit results to ARMO portal
kubescape scan framework nsa --submit
kubescape scan framework mitre --submit
  • Scan a running Kubernetes cluster with a specific control using the control name or control ID. List of controls
kubescape scan control "Privileged container"
kubescape scan framework nsa *.yaml
  • Scan kubernetes manifest files from a public github repository
kubescape scan framework nsa https://github.com/armosec/kubescape
  • Output in json format
kubescape scan framework nsa --exclude-namespaces kube-system,kube-public --format json --output results.json
  • Output in junit xml format
kubescape scan framework nsa --exclude-namespaces kube-system,kube-public --format junit --output results.xml
  • Scan with exceptions, objects with exceptions will be presented as exclude and not fail
kubescape scan framework nsa --exceptions examples/exceptions.json

Helm Support

helm template [NAME] [CHART] [flags] --dry-run | kubescape scan framework nsa -

for example:

helm template bitnami/mysql --generate-name --dry-run | kubescape scan framework nsa -

Offline Support

It is possible to run Kubescape offline!

First download the framework and then scan with --use-from flag

  1. Download and save in file, if file name not specified, will store save to ~/.kubescape/<framework name>.json
kubescape download framework nsa --output nsa.json
  1. Scan using the downloaded framework
kubescape scan framework nsa --use-from nsa.json

Kubescape is an open source project, we welcome your feedback and ideas for improvement. We’re also aiming to collaborate with the Kubernetes community to help make the tests themselves more robust and complete as Kubernetes develops.

How to build

Build using python (3.7^) script

Kubescpae can be built using:

python build.py

Note: In order to built using the above script, one must set the environment variables in this script:

  • RELEASE
  • ArmoBEServer
  • ArmoERServer
  • ArmoWebsite

Build using go

Note: development (and the release process) is done with Go 1.17

  1. Clone Project
git clone https://github.com/armosec/kubescape.git kubescape && cd "$_"
  1. Build
go build -o kubescape .
  1. Run
./kubescape scan framework nsa
  1. Enjoy 🤪

Docker Support

Official Docker image

quay.io/armosec/kubescape

Build your own Docker image

  1. Clone Project
git clone https://github.com/armosec/kubescape.git kubescape && cd "$_"
  1. Build
docker build -t kubescape -f build/Dockerfile .

Under the hood

Tests

Kubescape is running the following tests according to what is defined by Kubernetes Hardening Guidance by NSA and CISA

  • Non-root containers
  • Immutable container filesystem
  • Privileged containers
  • hostPID, hostIPC privileges
  • hostNetwork access
  • allowedHostPaths field
  • Protecting pod service account tokens
  • Resource policies
  • Control plane hardening
  • Exposed dashboard
  • Allow privilege escalation
  • Applications credentials in configuration files
  • Cluster-admin binding
  • Exec into container
  • Dangerous capabilities
  • Insecure capabilities
  • Linux hardening
  • Ingress and Egress blocked
  • Container hostPort
  • Network policies
  • Symlink Exchange Can Allow Host Filesystem Access (CVE-2021-25741)

Technology

Kubescape based on OPA engine: https://github.com/open-policy-agent/opa and ARMO's posture controls.

The tools retrieves Kubernetes objects from the API server and runs a set of regos snippets developed by ARMO.

The results by default printed in a pretty "console friendly" manner, but they can be retrieved in JSON format for further processing.

Kubescape is an open source project, we welcome your feedback and ideas for improvement. We’re also aiming to collaborate with the Kubernetes community to help make the tests themselves more robust and complete as Kubernetes develops.

kubescape's People

Contributors

dwertent avatar daniel-grunbergerca avatar slashben avatar bezbran avatar rotemamsa avatar avnertzurarmo avatar yiscahlevysilas1 avatar xdavidel avatar moshe-rappaport-ca avatar atzur1091 avatar juneezee avatar amiralis avatar brsolomon-deloitte avatar clfs avatar ferhaty avatar mayocream avatar pettersolberg88 avatar chmod-777-shauli avatar taylor avatar zc2638 avatar

Watchers

James Cloos avatar  avatar

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.