GithubHelp home page GithubHelp logo

isabella232 / learn-inspec Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hashicorp/learn-inspec

0.0 0.0 0.0 1.03 MB

Inspec tests for the learn platform.

Dockerfile 3.21% Ruby 83.23% Makefile 5.78% Shell 7.78%

learn-inspec's Introduction

Overview

This repo contains inspec integration with the learn platform. It uses docker to run inspec. Tests/Controls are automatically generated by extracting fenced code blocks from the markdown (mdx). Each test then runs against an target docker container via a mounted docker socket. You can customize the environment of this "target" with real world environmental variables such as AWS Keys to do live tests with example code. You can modify this target with stand-in configurations by rebuilding the target docker container.

Currently these tests run syntax checks against terraform hcl, json and shell. See the RFC for an explanation of active vs passive testing.

Usage

Executing this code requires two containers. The inspec container is not actually required but is provided to minimize workstation requirements via run.sh. The inspec-target is automatically spun up. You can also run it interactivly to debug using ./target/interactive.sh

Requirements

Docker is required, you can download it here.

Executing an inspec profile

In a terminal window , run the ./run.sh script shown below. The code extracts markdown content from your local checkout/branch of the learn repo. You must provide the path to the root of your local learn repo with -d. You can then pass which product you wish to run tests against with. These product names correspond to inspec profiles

make
./run.sh -p terraform -d ~/src/learn
./run.sh -p vault -d ~/src/learn
./run.sh -p nomad -d ~/src/learn
./run.sh -p consul -d ~/src/learn

You can run all profiles with -p all You can pipe the output with color with | less -r

Product profiles

Profile Notes
terraform Extracts all hcl, shell, json and yaml codeblocks and validates them
vault Extracts all shell, json and yaml codeblocks validates them
nomad Extracts all shell, json and yaml codeblocks validates them
consul Extracts all shell, json and yaml codeblocks validates them

terraform validates syntax by passing each block as stdin via terraform fmt -.

Utility profiles

Profile Notes
all For use with the ./run.sh script. Runs all product profiles
shared Used to store shared custom resources for inspec libraries
github Used with Github Action, expects GITHUB environment vars for commit lookup

Support Files

run.sh

This script is used by authors and developers to run the tests locally.

input.yml

This file contains inputs to (globally) to the inspec profiles. It currently is used by shell_syntax custom resource to do dynamic replacments for placeholders in the code. This replacements hash allows us to run syntax checks on commands that otherwise would be invalid syntax with the placeholder.

learn-inspec's People

Contributors

acidprime avatar danielehc avatar kaitlincart avatar mdeggies 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.