diff --git a/.dockerignore b/.dockerignore
index a4886ac..e88192d 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,4 +1,17 @@
.*
+AWS/
doc
+Dockerfile
+*.md
+!README.md
+*.svg
+*.json
+*.png
+docker-compose.yml
providers/
LICENSE
+examples/
+example/
+PowerShell/
+BASH/
+Kubernetes/
\ No newline at end of file
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
new file mode 100644
index 0000000..1a72685
--- /dev/null
+++ b/.github/workflows/codeql-analysis.yml
@@ -0,0 +1,72 @@
+# For most projects, this workflow file will not need changing; you simply need
+# to commit it to your repository.
+#
+# You may wish to alter this file to override the set of languages analyzed,
+# or to provide custom queries or build logic.
+#
+# ******** NOTE ********
+# We have attempted to detect the languages in your repository. Please check
+# the `language` matrix defined below to confirm you have the correct set of
+# supported CodeQL languages.
+#
+name: "CodeQL"
+
+on:
+ push:
+ branches: [ "main" ]
+ pull_request:
+ # The branches below must be a subset of the branches above
+ branches: [ "main" ]
+ schedule:
+ - cron: '41 11 * * 0'
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: [ 'javascript', 'python' ]
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ with:
+ languages: ${{ matrix.language }}
+ # If you wish to specify custom queries, you can do so here or in a config file.
+ # By default, queries listed here will override any specified in a config file.
+ # Prefix the list here with "+" to use these queries and those in the config file.
+
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
+ # queries: security-extended,security-and-quality
+
+
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
+ # If this step fails, then you should remove it and run the build manually (see below)
+ - name: Autobuild
+ uses: github/codeql-action/autobuild@v2
+
+ # âšī¸ Command-line programs to run using the OS shell.
+ # đ See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
+
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
+
+ # - run: |
+ # echo "Run, Build Application using script"
+ # ./location_of_script_within_repo/buildscript.sh
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml
new file mode 100644
index 0000000..e5886c6
--- /dev/null
+++ b/.github/workflows/codeql.yml
@@ -0,0 +1,72 @@
+# For most projects, this workflow file will not need changing; you simply need
+# to commit it to your repository.
+#
+# You may wish to alter this file to override the set of languages analyzed,
+# or to provide custom queries or build logic.
+#
+# ******** NOTE ********
+# We have attempted to detect the languages in your repository. Please check
+# the `language` matrix defined below to confirm you have the correct set of
+# supported CodeQL languages.
+#
+name: "CodeQL"
+
+on:
+ push:
+ branches: [ "main" ]
+ pull_request:
+ # The branches below must be a subset of the branches above
+ branches: [ "main" ]
+ schedule:
+ - cron: '38 19 * * 0'
+
+jobs:
+ analyze:
+ name: Analyze
+ runs-on: ubuntu-latest
+ permissions:
+ actions: read
+ contents: read
+ security-events: write
+
+ strategy:
+ fail-fast: false
+ matrix:
+ language: [ 'javascript', 'python' ]
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v3
+
+ # Initializes the CodeQL tools for scanning.
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@v2
+ with:
+ languages: ${{ matrix.language }}
+ # If you wish to specify custom queries, you can do so here or in a config file.
+ # By default, queries listed here will override any specified in a config file.
+ # Prefix the list here with "+" to use these queries and those in the config file.
+
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
+ # queries: security-extended,security-and-quality
+
+
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
+ # If this step fails, then you should remove it and run the build manually (see below)
+ - name: Autobuild
+ uses: github/codeql-action/autobuild@v2
+
+ # âšī¸ Command-line programs to run using the OS shell.
+ # đ See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
+
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
+
+ # - run: |
+ # echo "Run, Build Application using script"
+ # ./location_of_script_within_repo/buildscript.sh
+
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/codesee-arch-diagram.yml b/.github/workflows/codesee-arch-diagram.yml
new file mode 100644
index 0000000..806d41d
--- /dev/null
+++ b/.github/workflows/codesee-arch-diagram.yml
@@ -0,0 +1,23 @@
+# This workflow was added by CodeSee. Learn more at https://codesee.io/
+# This is v2.0 of this workflow file
+on:
+ push:
+ branches:
+ - main
+ pull_request_target:
+ types: [opened, synchronize, reopened]
+
+name: CodeSee
+
+permissions: read-all
+
+jobs:
+ codesee:
+ runs-on: ubuntu-latest
+ continue-on-error: true
+ name: Analyze the repo with CodeSee
+ steps:
+ - uses: Codesee-io/codesee-action@v2
+ with:
+ codesee-token: ${{ secrets.CODESEE_ARCH_DIAG_API_TOKEN }}
+ codesee-url: https://app.codesee.io
diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml
new file mode 100644
index 0000000..fe461b4
--- /dev/null
+++ b/.github/workflows/dependency-review.yml
@@ -0,0 +1,20 @@
+# Dependency Review Action
+#
+# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging.
+#
+# Source repository: https://github.com/actions/dependency-review-action
+# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
+name: 'Dependency Review'
+on: [pull_request]
+
+permissions:
+ contents: read
+
+jobs:
+ dependency-review:
+ runs-on: ubuntu-latest
+ steps:
+ - name: 'Checkout Repository'
+ uses: actions/checkout@v3
+ - name: 'Dependency Review'
+ uses: actions/dependency-review-action@v2
diff --git a/.gitignore b/.gitignore
index f1b0d54..13e406e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -94,6 +94,17 @@ venv.bak/
.spyderproject
.spyproject
+#IntelliJ IDEA project settings
+.ideas
+.idea
+
+#VS Code project settings
+.vscode
+.vscode/
+
+# Embold
+.embold/
+
# Rope project settings
.ropeproject
@@ -102,3 +113,10 @@ venv.bak/
# mypy
.mypy_cache/
+
+# Terraform configuration
+.terraform/
+*.tfstate
+
+# Mac
+.DS_Store
\ No newline at end of file
diff --git a/AWS/blast-radius-aws.tf b/AWS/blast-radius-aws.tf
new file mode 100644
index 0000000..632b217
--- /dev/null
+++ b/AWS/blast-radius-aws.tf
@@ -0,0 +1,189 @@
+terraform {
+}
+
+provider "aws" {
+ # uncomment if global configuration is not set up yet
+# access_key = var.AWS_ACCESS_KEY_ID
+# secret_key = var.AWS_SECRET_ACCESS_KEY
+ region = var.AWS_REGION
+}
+
+#variable "AWS_ACCESS_KEY_ID" {
+# default = ""
+#}
+#
+#variable "AWS_SECRET_ACCESS_KEY" {
+# default = ""
+#}
+#
+variable "AWS_REGION" {
+ default = ""
+}
+
+variable "AMI_ID" {
+ default = "09d56f8956ab235b3" #UBUNTU
+}
+
+variable "KEY_NAME" {
+ default = ""
+}
+
+variable "KEY_PATH" {
+ default = ""
+}
+
+variable "ACCESS_PORT" {
+ default = 8888
+}
+
+resource "aws_vpc" "terraform-vpc" {
+ cidr_block = "10.10.0.0/16"
+
+ tags = {
+ Name = "blastradius"
+ }
+}
+
+resource "aws_subnet" "first-subnet" {
+ cidr_block = "10.10.1.0/24"
+ vpc_id = aws_vpc.terraform-vpc.id
+ availability_zone = "${var.AWS_REGION}a"
+}
+
+resource "aws_route_table" "route-table" {
+ vpc_id = aws_vpc.terraform-vpc.id
+ tags = {
+ Name = "route-table"
+ }
+}
+
+resource "aws_internet_gateway" "igw" {
+ vpc_id = aws_vpc.terraform-vpc.id
+
+ tags = {
+ Name = "internet-gateway"
+ }
+}
+
+resource "aws_route" "blast-radius-route" {
+ route_table_id = aws_route_table.route-table.id
+ destination_cidr_block = "0.0.0.0/0"
+ gateway_id = aws_internet_gateway.igw.id
+ depends_on = [
+ aws_route_table.route-table,
+ aws_internet_gateway.igw
+ ]
+}
+
+resource "aws_main_route_table_association" "main-rt" {
+ vpc_id = aws_vpc.terraform-vpc.id
+ route_table_id = aws_route_table.route-table.id
+}
+
+locals {
+ rulesmap = {
+ "HTTP" = {
+ port = 80,
+ cidr_blocks = ["0.0.0.0/0"],
+ ipv6_cidr_blocks = ["::/0"]
+ },
+ "HTTPS" = {
+ port = 443,
+ cidr_blocks = ["0.0.0.0/0"],
+ ipv6_cidr_blocks = ["::/0"]
+ }
+ "SSH" = {
+ port = 22,
+ cidr_blocks = ["0.0.0.0/0"],
+ ipv6_cidr_blocks = ["::/0"]
+ },
+ "BLASTR" = {
+ port = var.ACCESS_PORT,
+ cidr_blocks = ["0.0.0.0/0"],
+ ipv6_cidr_blocks = ["::/0"]
+ }
+ }
+}
+
+resource "aws_security_group" "sg" {
+ vpc_id = aws_subnet.first-subnet.vpc_id
+
+ dynamic "ingress" {
+ for_each = local.rulesmap
+ content {
+ description = ingress.key # HTTP or SSH
+ from_port = ingress.value.port
+ to_port = ingress.value.port
+ protocol = "tcp"
+ cidr_blocks = ingress.value.cidr_blocks
+ }
+ }
+
+ egress {
+ from_port = 0
+ to_port = 0
+ protocol = "-1"
+ cidr_blocks = ["0.0.0.0/0"]
+ ipv6_cidr_blocks = ["::/0"]
+ }
+
+ egress {
+ from_port = 80
+ to_port = 80
+ protocol = "tcp"
+ cidr_blocks = ["0.0.0.0/0"]
+ }
+
+ egress {
+ from_port = 443
+ to_port = 443
+ protocol = "tcp"
+ ipv6_cidr_blocks = ["::/0"]
+ }
+
+ tags = {
+ Name = "default"
+ }
+}
+
+resource "aws_instance" "blast-radius-ec2-instance" {
+ associate_public_ip_address = true
+ # ami = "ami-02584c1c9d05efa69" // Ubuntu 20.04LTS - not using data.aws_ami.amazon_linux.id
+ ami = "ami-${var.AMI_ID}"
+ instance_type = "t2.micro"
+ key_name = "${var.KEY_NAME}"
+ vpc_security_group_ids = [aws_security_group.sg.id]
+ subnet_id = aws_subnet.first-subnet.id
+
+ connection {
+ agent = false
+ host = self.public_ip
+ private_key = file(var.KEY_PATH)
+ type = "ssh"
+ user = "ubuntu"
+ }
+
+ provisioner "remote-exec" {
+ inline = [
+ "sudo apt-get update -y",
+ "sudo apt-get install docker.io docker -y",
+ "sudo chmod 666 /var/run/docker.sock",
+ "sudo service docker start",
+ "docker run --rm -it -d -p ${var.ACCESS_PORT}:5000 -v $(pwd):/data:ro --security-opt apparmor:unconfined --cap-add=SYS_ADMIN ianyliu/blast-radius-fork"
+ ]
+ }
+
+ tags = {
+ Terraform = "true"
+ Environment = "dev"
+ Name = "blast-radius"
+ }
+}
+
+output "ec1-public-ip" {
+ value = aws_instance.blast-radius-ec2-instance.public_ip
+}
+
+output "port" {
+ value = var.ACCESS_PORT
+}
diff --git a/BASH/docker_build.sh b/BASH/docker_build.sh
new file mode 100755
index 0000000..9716271
--- /dev/null
+++ b/BASH/docker_build.sh
@@ -0,0 +1,29 @@
+#! /bin/bash
+IMAGE_NAME="blast-radius-fork-local"
+MULTI_CPU=false
+SCRIPT_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") # get the directory of this script
+DOCKERFILE_DIR=$(dirname -- "$(readlink -f -- "$SCRIPT_DIR")") # get the parent directory of this script (the directory of the Dockerfile)
+
+if [ "$1" != "" ]; then
+ IMAGE_NAME=$1
+fi
+
+if [ "$2" == true ]; then
+ MULTI_CPU=true
+fi
+
+if [ ! -e "$DOCKERFILE_DIR/Dockerfile" ]; then
+ echo "File $DOCKERFILE_DIR/Dockerfile does not exist, so image $IMAGE_NAME could not be built. Exiting"
+ exit 1
+fi
+
+if [ "$MULTI_CPU" == false ]; then
+ echo "Building image $IMAGE_NAME without multi-cpu support. Your image will be saved locally."
+ docker build -t "$IMAGE_NAME" "$DOCKERFILE_DIR"
+else
+ echo "Building image $IMAGE_NAME with multi-cpu support. Your image will be pushed remotely to Docker Hub and saved locally afterwards. "
+ docker buildx build \
+ --platform linux/arm64,linux/amd64,linux/amd64/v2,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 \
+ -t "$IMAGE_NAME" --push "$DOCKERFILE_DIR"
+ docker pull "$IMAGE_NAME"
+fi
\ No newline at end of file
diff --git a/BASH/docker_run.sh b/BASH/docker_run.sh
new file mode 100644
index 0000000..e28bc4c
--- /dev/null
+++ b/BASH/docker_run.sh
@@ -0,0 +1,59 @@
+#! /bin/bash
+
+SCRIPT_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") # get the directory of this script
+BUILDFILE=$SCRIPT_DIR/docker_build.sh # get the path to the docker build script
+
+IMAGE_NAME="blast-radius-fork-local"
+ACCESS_PORT=5000
+
+# first check if number of arguments to script is greater than 3 or not, if it is exit
+if [ $# -gt 3 ]; then
+ echo "$0 does not accept more than 2 arguments (image name & port). You have provided $# arguments."
+ exit 1
+fi
+
+# if number of arguments is equal to 0
+if [ $# -eq 0 ]; then
+ echo "Using default image name: ${IMAGE_NAME} and default port: ${ACCESS_PORT} because no arguments were passed"
+else
+ if [ "$1" != "" ]; then
+ IMAGE_NAME=$1
+ fi
+ if [ "$2" != "" ]; then
+ ACCESS_PORT=$2
+ fi
+fi
+
+# check if image exists, if not try to build it
+if [[ "$(docker image inspect "$IMAGE_NAME" --format='exists')" != 'exists' ]]; then
+ echo "$IMAGE_NAME does not exist. Trying to build the image using $BUILDFILE ..."
+
+ if [ ! -e "$BUILDFILE" ]; then
+ echo "File $BUILDFILE does not exist. Exiting"
+ exit 1
+ fi
+
+ if [ ! -s "$BUILDFILE" ]; then
+ echo "File $BUILDFILE is empty. Exiting"
+ exit 1
+ fi
+
+ if [ ! -x "$BUILDFILE" ]; then
+ echo "File $BUILDFILE is not executable. Exiting"
+ echo "Hint: Try running 'chmod +x $BUILDFILE'"
+ exit 1
+ fi
+
+ echo "Using $BUILDFILE to build image $IMAGE_NAME"
+ $BUILDFILE "$IMAGE_NAME"
+
+fi
+
+if [[ "$(docker image inspect "$IMAGE_NAME" --format='exists')" == 'exists' ]]; then
+ echo "Attempting to run Docker Image: $IMAGE_NAME on $ACCESS_PORT"
+ docker run --rm -it -d -p "$ACCESS_PORT":5000 \
+ -v "$(PWD)":/data:ro \
+ --security-opt apparmor:unconfined \
+ --cap-add=SYS_ADMIN \
+ "$IMAGE_NAME"
+fi
\ No newline at end of file
diff --git a/Docker.md b/Docker.md
new file mode 100644
index 0000000..aab7031
--- /dev/null
+++ b/Docker.md
@@ -0,0 +1,314 @@
+
Docker
+
+[privileges]: https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities
+[overlayfs]: https://wiki.archlinux.org/index.php/Overlay_filesystem
+
+## Table of Contents
+- [Table of Contents](#table-of-contents)
+- [Prerequisites](#prerequisites)
+- [Run Docker Containers with Docker Hub Images](#run-docker-containers-with-docker-hub-images)
+- [Docker configurations](#docker-configurations)
+- [Port configurations](#port-configurations)
+- [Docker \& Subdirectories](#docker--subdirectories)
+- [Image Building](#image-building)
+ - [Prerequisites for Buildx](#prerequisites-for-buildx)
+- [Shell Scripts](#shell-scripts)
+- [Aliases](#aliases)
+ - [Temporary Aliases](#temporary-aliases)
+ - [Permanent Aliases](#permanent-aliases)
+
+
+## Prerequisites
+* Install Docker
+ * [Linux](https://docs.docker.com/desktop/install/linux-install/)
+ * [Mac](https://docs.docker.com/desktop/install/mac-install/)
+ * [Windows](https://docs.docker.com/desktop/install/windows-install/)
+
+It is recommended to nstall [Docker Desktop](https://www.docker.com/products/docker-desktop/) as well, a more intuitive GUI for Docker.
+
+Verify Docker is installed in your Terminal: ```docker info```
+
+## Run Docker Containers with Docker Hub Images
+
+Launch *Blast Radius* for a local directory by manually running:
+
+> sh, zsh, bash
+```sh
+docker run --rm -it -p 5000:5000 \
+ -v $(pwd):/data:ro \
+ --security-opt apparmor:unconfined \
+ --cap-add=SYS_ADMIN \
+ ianyliu/blast-radius-fork
+```
+
+Note: If you have spaces in your directory then you may have to change `-v ${pwd}:/data:ro` to `-v "${pwd}:/data:ro"` instead.
+
+> Windows PowerShell
+```powershell
+docker run --rm -it -p 5000:5000 `
+ -v ${pwd}:/data:ro `
+ --security-opt apparmor:unconfined `
+ --cap-add=SYS_ADMIN `
+ ianyliu/blast-radius-fork
+```
+
+If you do not have the Docker image, it will be automatically pulled for you. You can also build the image yourself
+see ([Image Building](#image-building)).
+
+A slightly more customized variant of this is also available as an example
+[docker-compose.yml](./Docker/docker-compose.yml) use case for Workspaces.
+
+## Docker configurations
+
+
+
+*Terraform* module links are saved as _absolute_ paths in relative to the
+project root (note `.terraform/modules/`). Given these paths will vary
+betwen Docker and the host, we mount the volume as read-only, assuring we don't
+ever interfere with your real environment.
+
+However, in order for *Blast Radius* to actually work with *Terraform*, it needs
+to be initialized. To accomplish this, the container creates an [overlayfs][]
+that exists within the container, overlaying your own, so that it can operate
+independently. To do this, certain runtime privileges are required --
+specifically `--cap-add=SYS_ADMIN`.
+
+> Note: This is considered a security risk by some, so be sure you understand how this works.
+
+For more information on how this works and what it means for your host, check
+out the [runtime privileges][privileges] documentation.
+
+
+## Port configurations
+
+
+To run the Docker image on a different port, you can modify the Docker command so that PORTNUMBER
+maps to the desired port number.
+
+```sh
+docker run --rm -it -p PORTNUMBER:5000 \
+ -v $(pwd):/data:ro \
+ --security-opt apparmor:unconfined \
+ --cap-add=SYS_ADMIN \
+ ianyliu/blast-radius-fork
+```
+
+
+
+## Docker & Subdirectories
+
+
+
+
+If you organized your *Terraform* project using stacks and modules,
+*Blast Radius* must be called from the project root and reference them as
+subdirectories -- don't forget to prefix `--serve`!
+
+For example, let's create a Terraform `project` with the following:
+
+```txt
+$ tree -d
+`-- project/
+ |-- modules/
+ | |-- foo
+ | |-- bar
+ | `-- dead
+ `-- stacks/
+ `-- beef/
+ `-- .terraform
+```
+
+It consists of 3 modules `foo`, `bar` and `dead`, followed by one `beef` stack.
+To apply *Blast Radius* to the `beef` stack, you would want to run the container
+with the following:
+
+```sh
+$ cd project
+$ docker run --rm -it -p 5000:5000 \
+ -v $(pwd):/data:ro \
+ --security-opt apparmor:unconfined \
+ --cap-add=SYS_ADMIN \
+ ianyliu/blast-radius-fork --serve stacks/beef
+```
+
+
+## Image Building
+
+If you'd like to build your own Docker image after making changes to Blast Radius, you can build it in 2 ways:
+1. Normal Build
+
+To execute a normal build, navigate (using commands like `cd`) to the root of your modified Blast Radius project in your terminal.
+Make sure you have the Dockerfile in the root of your project.
+Now run:
+
+```
+docker build -t imagename .
+```
+
+Replace imagename with the name you'd like to give your image.
+
+Once the build is complete you can run it in the Terraform directory you'd like visualize.
+
+> sh, zsh, bash
+```sh
+docker run --rm -it -p 5000:5000 \
+ -v $(pwd):/data:ro \
+ --security-opt apparmor:unconfined \
+ --cap-add=SYS_ADMIN \
+ imagename
+```
+
+> Windows PowerShell
+```powershell
+docker run --rm -it -p 5000:5000 `
+ -v ${pwd}:/data:ro `
+ --security-opt apparmor:unconfined `
+ --cap-add=SYS_ADMIN `
+ imagename
+```
+
+Go to http://127.0.0.1:5000/ to view the visualization.
+
+2. Multi-CPU Build
+
+To build Docker images with multi-architecture support, we will use something known as docker
+[buildx](https://docs.docker.com/build/buildx/).
+
+### Prerequisites for Buildx
+
+There are 2 ways to set up buildx, the first being insanely easy, while the second being quite complicated.
+
+1. **Install Docker Desktop>=2.1.0**
+Install Docker Desktop [here](https://www.docker.com/products/docker-desktop/).
+ Then go to `Settings > Docker Engine`. Edit the JSON configuration and change it so that "buildkit" is set to "true".
+ ![](Docker/Docker-Desktop.png)
+2. **Manual Installation**
+You will need the following software requirements:
+- Docker >= 19.03
+- Experimental mode enabled for Docker CLI
+ - Set an environment variable: `export DOCKER_CLI_EXPERIMENTAL=enabled`
+ - Edit config file at `$HOME/.docker/config.json`: `{"experimental": "enabled"}`
+- Linux kernel >= 4.8 or fix-binary (F) flag support on the kernel side of binfmt_misc
+- binfmt_misc file system mounted
+- Host or Docker image based installation of:
+ - Host installation
+ - QEMU installation
+ - binfmt-support package >= 2.1.7
+ - Docker image-based installation
+ - A Docker image containing both QEMU binaries and set up scripts that register QEMU in binfmt_misc
+
+For more details on manual installation see
+[this Medium article](https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408).
+
+Check that buildx is installed: `docker buildx`
+
+Now we need to create a buildx builder
+
+`docker buildx create --name mybuilder`
+
+and use the builder
+
+`docker buildx use mybuilder`
+
+View your new builder: `docker buildx ls`
+
+As of 2022, buildx can export the image locally or to a Docker registry.
+
+However, local image loading is only supported for single-architecture images.
+To use multi-architecture images, we will need to push to a Docker registry.
+
+To use a Docker registry, we need to first login using
+`docker login`.
+If you don't have a Docker account yet, you can create one
+[here](https://hub.docker.com/).
+
+Navigate to the directory where the `Dockerfile` is located (download the repo via Git/GitHub if you haven't already).
+Now we can build the image.
+
+```sh
+docker buildx build \
+--platform \
+linux/arm64,linux/amd64,linux/amd64/v2,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 \
+-t imagename \
+--push .
+```
+
+Run the image (replace USERNAME and imagename accordingly)
+```sh
+docker run --rm -it -p 5000:5000 \
+ -v $(pwd):/data:ro \
+ --security-opt apparmor:unconfined \
+ --cap-add=SYS_ADMIN \
+ USERNAME/imagename
+```
+
+> Note: Architectures `linux/riscv64,linux/mips64le,linux/mips64` are supported by buildx,
+but the image of Python Alpine does not usually support these architectures.
+> Note: If in the future local loading of Docker images is supported, replace `--push` with `--load`
+
+
+## Shell Scripts
+In the [PowerShell folder](PowerShell) and [BASH folder](BASH) there are Docker build and run shell scripts.
+Using shell scripts makes running and building the Docker containers easier and less error prone.
+
+Here's an example of running the docker Shell script for running a container.
+
+```sh
+cd blast-radius-fork
+/bin/bash ./docker_run.sh
+```
+
+Compare that to
+
+```sh
+docker run --rm -it -p 5000:5000 \
+ -v $(pwd):/data:ro \
+ --security-opt apparmor:unconfined \
+ --cap-add=SYS_ADMIN \
+ blast-radius-fork
+```
+
+## Aliases
+
+An alias in Linux is a shortcut to a command. They are usually used to replace long commands.
+To see what aliases you have, run `alias`.
+
+There are 2 types of aliases. Temporary ones and permanent ones.
+
+#### Temporary Aliases
+
+To creat temporary aliases, simply follow the formula of ```alias SHORTCUT='COMMAND'```. Here's an example of a clear
+command referenced by `c`: `alias c='clear'`
+
+Let's say we want to use `br-docker` to replace the long Docker run command.
+
+```sh
+alias br-docker='docker run --rm -it -p 5000:5000 \
+-v $(pwd):/data:ro \
+ --security-opt apparmor:unconfined \
+ --cap-add=SYS_ADMIN \
+ ianyliu/blast-radius-fork'
+```
+Now we can just run `br-docker` whenever we want to run a Docker container to start Blast Radius!
+
+Here's another example using [Shell scripts](#shell-scripts).
+```sh
+alias br-build='/bin/bash /Users/USERNAME/blast-radius-fork/BASH/docker_build.sh'
+```
+Now we can build our Docker image by just using `br-build`!
+
+#### Permanent Aliases
+
+To create permanent aliases, one needs to add it to their shell configuration file.
+
+* PowerShell configuration files are usually located in `$PSHOME`
+* BASH: `~/.bashrc`
+* ZSH: `~/.zshrc`
+* FISH: `~/.config/fish/config.fish`
+
+Now open the shell config file in a text editor.
+Example: `sudo vi ~/.bashrc`
+
+Go to the aliases section, and add your aliases.
+Here's a helpful
+[article](https://phoenixnap.com/kb/linux-alias-command#:~:text=In%20Linux%2C%20an%20alias%20is,and%20avoiding%20potential%20spelling%20errors.).
\ No newline at end of file
diff --git a/Docker/Docker-Desktop.png b/Docker/Docker-Desktop.png
new file mode 100644
index 0000000..cb317c0
Binary files /dev/null and b/Docker/Docker-Desktop.png differ
diff --git a/examples/docker-compose.yml b/Docker/docker-compose.yml
similarity index 85%
rename from examples/docker-compose.yml
rename to Docker/docker-compose.yml
index 5dc2f4f..f825dd9 100644
--- a/examples/docker-compose.yml
+++ b/Docker/docker-compose.yml
@@ -1,8 +1,8 @@
-version: '3.7'
+version: '3.8'
services:
blastradius:
- image: 28mm/blast-radius
+ image: ianyliu/blast-radius-fork
cap_add:
- SYS_ADMIN
security_opt:
diff --git a/Dockerfile b/Dockerfile
index 2d35634..87b9845 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,11 +1,12 @@
-ARG TF_VERSION=0.12.12
-ARG PYTHON_VERSION=3.7
+ARG TF_VERSION=1.3.3
+ARG PYTHON_VERSION=3.10
FROM hashicorp/terraform:$TF_VERSION AS terraform
FROM python:$PYTHON_VERSION-alpine
-RUN pip install -U pip ply \
- && apk add --update --no-cache graphviz ttf-freefont
+RUN pip install -U --no-cache-dir pip ply \
+ && apk add --update --no-cache graphviz ttf-freefont git \
+ && apk upgrade
COPY --from=terraform /bin/terraform /bin/terraform
COPY ./docker-entrypoint.sh /bin/docker-entrypoint.sh
@@ -15,7 +16,9 @@ WORKDIR /src
COPY . .
RUN pip install -e .
+# comment out 2 lines below to optimize build speed
WORKDIR /data
+RUN echo $(timeout 15 blast-radius --serve --port 5001; test $? -eq 124) > /output.txt
ENTRYPOINT ["/bin/docker-entrypoint.sh"]
-CMD ["blast-radius", "--serve"]
+CMD ["blast-radius", "--serve"]
\ No newline at end of file
diff --git a/Kubernetes/k8-blast-radius-deployment.yaml b/Kubernetes/k8-blast-radius-deployment.yaml
new file mode 100644
index 0000000..d9f8fda
--- /dev/null
+++ b/Kubernetes/k8-blast-radius-deployment.yaml
@@ -0,0 +1,23 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: k8-blast-radius-deployment
+spec:
+ selector:
+ matchLabels:
+ app: flask-blast-radius
+ template:
+ metadata:
+ labels:
+ app: flask-blast-radius
+ spec:
+ containers:
+ - name: flask-k8s
+ image: docker.io/ianyliu/blast-radius-fork
+ imagePullPolicy: IfNotPresent
+ ports:
+ - containerPort: 5000
+ args: ["blast-radius", "--serve"]
+ securityContext:
+ capabilities:
+ add: [ "SYS_ADMIN" ]
\ No newline at end of file
diff --git a/Kubernetes/k8-blast-radius-service.yaml b/Kubernetes/k8-blast-radius-service.yaml
new file mode 100644
index 0000000..c1347a0
--- /dev/null
+++ b/Kubernetes/k8-blast-radius-service.yaml
@@ -0,0 +1,12 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: k8-blast-radius-service
+spec:
+ selector:
+ app: flask-blast-radius
+ ports:
+ - protocol: "TCP"
+ port: 5000
+ targetPort: 5000
+ type: LoadBalancer
\ No newline at end of file
diff --git a/Makefile b/Makefile
index b3a191a..65bf3e3 100644
--- a/Makefile
+++ b/Makefile
@@ -23,13 +23,13 @@ dist:
# build docker image
.PHONY: docker
docker:
- -docker build -t 28mm/blast-radius .
+ -docker build -t ianyliu/blast-radius-fork .
# push pypi and docker images to public repos
.PHONY: publish
publish:
-twine upload dist/*
- -docker push 28mm/blast-radius:latest
+ -docker push ianyliu/blast-radius-fork:latest
# rebuild categories.js from upstream docs
.PHONY: categories
diff --git a/PowerShell/docker_build.ps1 b/PowerShell/docker_build.ps1
new file mode 100644
index 0000000..e998329
--- /dev/null
+++ b/PowerShell/docker_build.ps1
@@ -0,0 +1,8 @@
+& docker build -f ..\Dockerfile `
+-t blast-radius-fork ../
+
+#Multi-cpu build
+#& docker buildx build -f ..\Dockerfile `
+#--platform `
+#linux/arm64,linux/amd64,linux/amd64/v2,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6 `
+#-t blast-radius-fork --push ../
\ No newline at end of file
diff --git a/PowerShell/docker_run.ps1 b/PowerShell/docker_run.ps1
new file mode 100644
index 0000000..611e72a
--- /dev/null
+++ b/PowerShell/docker_run.ps1
@@ -0,0 +1 @@
+& docker run --rm -it -p 5000:5000 -v "$PSScriptRoot/template:/data:ro" --security-opt apparmor:unconfined --cap-add=SYS_ADMIN blast-radius-fork
\ No newline at end of file
diff --git a/README.md b/README.md
index d475fd7..b3a0772 100644
--- a/README.md
+++ b/README.md
@@ -1,114 +1,200 @@
-# Blast Radius
-
-[![CircleCI](https://circleci.com/gh/28mm/blast-radius/tree/master.svg?style=svg)](https://circleci.com/gh/28mm/blast-radius/tree/master)
-[![PyPI version](https://badge.fury.io/py/BlastRadius.svg)](https://badge.fury.io/py/BlastRadius)
+
Blast Radius Fork
[terraform]: https://www.terraform.io/
[examples]: https://28mm.github.io/blast-radius-docs/
-
-_Blast Radius_ is a tool for reasoning about [Terraform][] dependency graphs
-with interactive visualizations.
+[docs]: https://28mm.github.io/blast-radius-docs/
+
+_Blast Radius Fork_ is an interactive visualizer for [Terraform](https://www.terraform.io/) based off of
+[_Blast Radius_](https://28mm.github.io/blast-radius/),
+which hasn't been actively maintained since 2020.
+
+It is not guaranteed to be bug free. Please feel free to contribute!
+
+----------------------------------
+
+## Table of Contents
+- [Table of Contents](#table-of-contents)
+- [Usage](#usage)
+- [Prerequisites for Local Use](#prerequisites-for-local-use)
+- [Local Quickstart](#local-quickstart)
+- [Docker Quickstart](#docker-quickstart)
+- [Kubernetes Quickstart](#kubernetes-quickstart)
+ - [Kubernetes Prerequisites](#kubernetes-prerequisites)
+ - [Start the App on Kubernetes](#start-the-app-on-kubernetes)
+ - [Kubernetes Debugging/Helpful Commands](#kubernetes-debugginghelpful-commands)
+- [Parameters](#parameters)
+- [Embedded Figures](#embedded-figures)
+- [How It Works](#how-it-works)
+- [Motivation](#motivation)
+- [What's Different](#whats-different)
+- [Future Implementations \& Possible Functionalities](#future-implementations--possible-functionalities)
+- [Further Reading](#further-reading)
+- [Other Tools to Check Out](#other-tools-to-check-out)
+
+----------------------------------
+
+## Usage
Use _Blast Radius_ to:
* __Learn__ about *Terraform* or one of its providers through real [examples][]
-* __Document__ your infrastructure
+* __Visualize__ your infrastructure
* __Reason__ about relationships between resources and evaluate changes to them
* __Interact__ with the diagram below (and many others) [in the docs][examples]
+* __Compare__ different infrastructure
![screenshot](doc/blastradius-interactive.png)
-## Prerequisites
+## Prerequisites for Local Use
+* [Python](https://www.python.org/) 3.7+
* [Graphviz](https://www.graphviz.org/)
-* [Python](https://www.python.org/) 3.7 or newer
+* [Terraform](https://www.terraform.io/) (if you do not have generated Terraform DOT graphs yet)
> __Note:__ For macOS you can `brew install graphviz`
+
+> __Note:__ For Docker usage prerequisites, see [Docker.md](Docker.md)
-## Quickstart
+## Local Quickstart
-The fastest way to get up and running with *Blast Radius* is to install it with
+The fastest way to run with *Blast Radius* is to install it with
`pip` to your pre-existing environment:
```sh
-pip install blastradius
+python -m pip install git+https://github.com/Ianyliu/blast-radius-fork
+```
+or
+```sh
+python3 -m pip install git+https://github.com/Ianyliu/blast-radius-fork
```
-Once installed just point *Blast Radius* at any initialized *Terraform*
-directory:
+You can then run Blast Radius from the command line:
```sh
+blast-radius --serve
+```
+
+If you want to create graphs for an initialized *Terraform* directory, you can just start *Blast Radius* within the
+initialized *Terraform*
+directory:
+
+```
blast-radius --serve /path/to/terraform/directory
```
And you will shortly be rewarded with a browser link http://127.0.0.1:5000/.
-## Docker
+[//]: # (You can specify the host and/or port number with the `--host` and --port` flags:)
+
+[//]: # ()
+[//]: # (```)
+
+[//]: # (blast-radius --serve /path/to/terraform/directory --host 127.0.0.1 --port=8080)
+
+[//]: # (```)
+
+
+Note: If you do not have an initialized Terraform directory but have the DOT script (the output of the `terraform graph` command, note that this is not the same as a JSON file or state graph). You can either copy and paste the DOT script into the text input field or uploaded the DOT script file.
+
+Other ways to run it include [Docker](#docker-quickstart) and [Kubernetes](#kubernetes-quickstart)
+
+## Docker Quickstart
[privileges]: https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities
[overlayfs]: https://wiki.archlinux.org/index.php/Overlay_filesystem
-To launch *Blast Radius* for a local directory by manually running:
+Launch a container for a local directory with *Blast Radius* running:
+sh, zsh, bash, etc. (Linux recommended):
```sh
docker run --rm -it -p 5000:5000 \
-v $(pwd):/data:ro \
--security-opt apparmor:unconfined \
--cap-add=SYS_ADMIN \
- 28mm/blast-radius
+ ianyliu/blast-radius-fork
```
-A slightly more customized variant of this is also available as an example
-[docker-compose.yml](./examples/docker-compose.yml) usecase for Workspaces.
-
-### Docker configurations
-
-*Terraform* module links are saved as _absolute_ paths in relative to the
-project root (note `.terraform/modules/`). Given these paths will vary
-betwen Docker and the host, we mount the volume as read-only, assuring we don't
-ever interfere with your real environment.
-
-However, in order for *Blast Radius* to actually work with *Terraform*, it needs
-to be initialized. To accomplish this, the container creates an [overlayfs][]
-that exists within the container, overlaying your own, so that it can operate
-independently. To do this, certain runtime privileges are required --
-specifically `--cap-add=SYS_ADMIN`.
-
-For more information on how this works and what it means for your host, check
-out the [runtime privileges][privileges] documentation.
-
-#### Docker & Subdirectories
-
-If you organized your *Terraform* project using stacks and modules,
-*Blast Radius* must be called from the project root and reference them as
-subdirectories -- don't forget to prefix `--serve`!
-
-For example, let's create a Terraform `project` with the following:
-
-```txt
-$ tree -d
-`-- project/
- |-- modules/
- | |-- foo
- | |-- bar
- | `-- dead
- `-- stacks/
- `-- beef/
- `-- .terraform
+Windows PowerShell:
+```powershell
+docker run --rm -it -p 5000:5000 `
+ -v ${pwd}:/data:ro `
+ --security-opt apparmor:unconfined `
+ --cap-add=SYS_ADMIN `
+ ianyliu/blast-radius-fork
```
-It consists of 3 modules `foo`, `bar` and `dead`, followed by one `beef` stack.
-To apply *Blast Radius* to the `beef` stack, you would want to run the container
-with the following:
+Note: If you have spaces in your directory then you may have to change `-v ${pwd}:/data:ro` to `-v "${pwd}:/data:ro"` instead.
-```sh
-$ cd project
-$ docker run --rm -it -p 5000:5000 \
- -v $(pwd):/data:ro \
- --security-opt apparmor:unconfined \
- --cap-add=SYS_ADMIN \
- 28mm/blast-radius --serve stacks/beef
+A slightly more customized variant of this is also available as an example
+[docker-compose.yml](./Docker/docker-compose.yml) usecase for Workspaces.
+
+For more details on Docker usage, see [Docker.md](Docker.md)
+
+## Kubernetes Quickstart
+
+Launch *Kubernetes* locally using Minikube, Kubernetes, and Kubectl:
+
+### Kubernetes Prerequisites
+
+
+
+* Docker (or another container or virtual machine manager)
+* Kubectl: https://kubernetes.io/docs/tasks/tools/
+* Minikube: https://minikube.sigs.k8s.io/docs/start/
+
+
+### Start the App on Kubernetes
+
+
+
+1. Start Minikube
+```minikube start```
+2. Change directories to the file containing the 2 YAML files (*k8-blast-radius-deployment.yaml* and
+3. *k8-blast-radius-service.yaml* apply the YAML configuration files to the default namespace (or any other namespace)
+```
+kubectl apply -f k8-blast-radius-deployment.yaml
+kubectl apply -f k8-blast-radius-service.yaml
```
+Access the app
+```
+minikube service k8-blast-radius-service
+```
+
+
+### Kubernetes Debugging/Helpful Commands
+
+
+
+* To check the state of your pods (containers), execute the following:
+```kubectl get pods```
+* To see more details about a pod. (Replace `````` and `````` with the corresponding values)
+```kubectl describe -n= pod/```
+* To see logs for a pod (replace corresponding values)
+```kubectl logs -f -n=```
+* The most helpful tool is probably Minikube's dashboard, where you can more things
+```minikube dashboard```
+
+
+## Parameters
+* Directory: Defaults to `$PWD` or current directory. The directory in which to look for Terraform files.
+This is required if the user wants to use a Terraform project as input
+(instead of uploading a file or pasting DOT script).
+* `--host`: Defaults to 0.0.0.0. The IP address to bind to, to access the app (http://HOST:5000)
+* `--port`: Defaults to 5000. The port to access the app (http://localhost:PORT)
+Any valid localhost port is allowed.
+* `--serve`: Starts a webserver locally with Terraform's interactive graph
+* `--json`: Prints a JSON representation of a Terraform graph. The JSON has 2 items, `edges` and `nodes`.
+* `--dot`: Returns a string consisting of Graphviz DOT script of graph. (no colors)
+* `--svg`: Prints SVG representation of graph (with colors).
+* `--graph`:
+* `--module-depth`: Takes an integer as input and only eliminates display of deeply nested modules.
+This will not show every node on the graph unless the user specifies a depth larger than the graph.
+* `--focus`: Show only specified resource and its dependencies. Not available in web app. Only works with `--json` and `--svg`.
+ * Example: ```terraform graph | blast-radius --focus \
+ "[root] module.us-west-2.module.secondary_subnet.data.aws_vpc.target" --svg```
+* `--center`: Prunes the graph to a subgraph (same thing as red button in web app). Only works with `--json` and `--svg`.
+ * Example: ```terraform graph | blast-radius --center \
+ "[root] module.us-west-2.module.secondary_subnet.data.aws_vpc.target" --svg```
## Embedded Figures
@@ -119,18 +205,85 @@ You will need the following:
2. `javascript` and `css` found in `.../blastradius/server/static`
3. A uniquely identified DOM element, where the `