Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to class for clarity #14

Merged
merged 12 commits into from
Dec 9, 2024
8 changes: 8 additions & 0 deletions .chef/.chef/accepted_licenses/inspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: inspec
name: Chef InSpec
date_accepted: '2024-12-08T19:28:12+00:00'
accepting_product: inspec
accepting_product_version: 6.8.11
user: codespace
file_format: 1
7 changes: 7 additions & 0 deletions .chef/.chef/licenses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
:file_format_version: 4.0.0
:licenses:
- :license_key: free-7254f65d-389d-4ea8-bd08-c08e921b08a7-6456
:license_type: :free
:update_time: '2024-12-08T19:29:29+00:00'
:license_server_url: https://services.chef.io/licensing
8 changes: 8 additions & 0 deletions .chef/accepted_licenses/inspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
id: inspec
name: Chef InSpec
date_accepted: '2024-12-08T19:28:12+00:00'
accepting_product: inspec
accepting_product_version: 6.8.11
user: codespace
file_format: 1
10 changes: 10 additions & 0 deletions .chef/licenses.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
:file_format_version: 4.0.0
:licenses:
- :license_key: free-7254f65d-389d-4ea8-bd08-c08e921b08a7-6456
:license_type: :free
:update_time: '2024-12-08T19:29:29+00:00'
- :license_key: tmns-07cf57df-2128-42c3-9ad7-655a22820031-4280
:license_type: :trial
:update_time: '2024-12-08T19:41:25+00:00'
:license_server_url: https://services.chef.io/licensing
116 changes: 3 additions & 113 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The repository is setup to be very low overhead, we use a simple `build-lab.sh`

- CodeSpaces Linux Base Community Image
- <https://github.com/microsoft/vscode-dev-containers/tree/main/containers/codespaces-linux>
- InSpec Omnitruk install of the latest InSpec
- InSpec Omnitruck install of the latest InSpec
- `curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -c stable -P inspec`
- MITRE SAF CLI
- <https://saf-cli.mitre.org>
Expand All @@ -26,117 +26,7 @@ The repository is setup to be very low overhead, we use a simple `build-lab.sh`

## Using the Lab

To use the lab:

1. Make sure you've signed in to your GitHub Account

2. On the [SAF Training repo](https://github.com/mitre/saf-training-lab-environment/tree/main), click the green 'Use this template' dropdown button and select 'Create a new repository'

![green button with the words 'use this template' in white text](https://user-images.githubusercontent.com/79539195/213498628-934c3343-4b9a-4488-9295-d21840e766f6.png)

![green dropdown with 2 options, the first one says 'create a new repository' and is highlighted with a red box. the second option says 'open in a codespace'](https://user-images.githubusercontent.com/79539195/213499867-0a2bbff2-9593-443d-a8c5-dd9170ddca9e.png)

3. Check to make sure your username is the owner of the new repository and enter a name for your repository.
We recommend using the name `saf-training-lab-environment` for ease. Additionally, feel free to make your repository public, if it isn't already.

![form to create a new repository based off of the SAF training lab environment template](https://github.com/user-attachments/assets/87d8aa26-e00c-4933-a18d-fe3259c12757)


4. Click the 'Create repository from template' button at the bottom

> **Note**
>
> If the button is greyed out, check to make sure you've selected your username as the owner, and named the repository.

![green button that says 'create repository from template'](https://user-images.githubusercontent.com/79539195/213503629-13ecb85b-c173-4f8b-ba1b-be6cd194a9f7.png)

5. Wait for your repository to open up, then click the 'Code' drop down button

![green button that says 'code'](https://user-images.githubusercontent.com/79539195/213504430-e0417daf-e1e9-40b2-9c82-541a7f766ced.png)

6. After clicking the 'Code' button, a drop down menu should display, with a 'Local' and a 'Codespace' option. Select the 'Codespace' tab, then click the button that says 'Create codespace on main'

> **Note**
>
> Please make sure to read the [Codespace section](https://github.com/mitre/saf-training-lab-environment/blob/updates/README.md#note) of this README, as GitHub has updated their policy about Codespaces.

![codespaces menu](https://user-images.githubusercontent.com/79539195/213504777-b74cf75a-6dec-4a39-8c52-a5ff4a8b07c3.png)

7. A new tab in your browser should open up with your Codespace. It should open up the README.md file, with a terminal at the bottom featuring your own username.

![view of codespace when it first opens up](https://github.com/user-attachments/assets/72513063-a937-4514-a5fb-8df129275bcb)

8. In the terminal, run the `build-lab.sh` script:

```sh
source ./build-lab.sh
```

Once the script finishes your terminal should display something like the following, right before your username and the path to your codespace:

![image of terminal after running the lab-setup command](https://github.com/user-attachments/assets/19a7cfed-317d-47fc-bf2e-67530e495c48)

Your environment should have the MITRE SAF CLI installed as `saf`, InSpec installed as `inspec`, and two running docker containers tagged as 'nginx' and 'redhat8'.

9. Once complete, you can verify the setup in your environment with the `test-lab.sh` script:

```sh
./test-lab.sh
```

Which should return something like the following:

```sh
_______________________________________________________________________________________________________________

Verify the script returns the following information:
* A "MITRE SAF" version number.
* An "InSpec" version number.
* Two running containers:
- nginx
- redhat

_______________________________________________________________________________________________________________

Collecting verification information...

* MITRE SAF Version: @mitre/saf/1.2.34 linux-x64 node-v20.8.1
* InSpec Version: 5.22.29
* Docker is running the following container(s):
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c114494b9812 redhat/ubi8 "/bin/bash" 38 minutes ago Up 38 minutes redhat8
944568b8768c nginx:latest "/docker-entrypoint.…" 38 minutes ago Up 38 minutes 80/tcp nginx

_______________________________________________________________________________________________________________

All verification tests completed successfully.

```

## Codespaces

> **Note**
>
> Previously, the SAF Training courses utilized GitHub Codespaces as a way for users to learn and work on executing InSpec profiles.
> GitHub has updated their policy so that Codespaces can be used for a certain amount of time before the user gets billed.
> If you have a free GitHub account, you're given 120 core hours per month.
> This means that if you use a 2-core machine, and your codespace runs for 8 hours, you've used up 16 (2 mulitplied by 8 = 16) core hours out of the 120.
> You can read more about it here:
> <https://docs.github.com/en/codespaces/overview#using-github-codespaces>

All of your active Codespaces can be found here:
<https://github.com/codespaces>

From the above link, you can access all of your codespaces, and stop the codespace as well.
![image of codespace options](https://user-images.githubusercontent.com/79539195/213740523-639e2dd0-763b-47b8-b038-97195f32c04d.png)

***Docker Container Restart May be Needed***

Occasionally, you may have to restart your Docker containers:

1. Run: `docker ps`
2. If your containers are not running, then just run: `build-lab.sh`
3. Run: `docker ps` or `test-lab.sh` to verify that your containers are running in your environment.
Refer to the instructions [here](https://mitre.github.io/saf-training/resources/02.html#instructions).

## Adding Services and Software

Expand All @@ -150,7 +40,7 @@ Go for it and if for some reason you break your environment, just start a new on

### NOTICE

© 2018-2023 The MITRE Corporation.
© 2018-2024 The MITRE Corporation.

Approved for Public Release; Distribution Unlimited. Case Number 18-3678.

Expand Down
15 changes: 4 additions & 11 deletions build-lab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ echo -e "\n${HIGH}You can now issue the command ${VERB}lab${RSET} ${HIGH}to quic
# By default, do not install Ruby documentation as it is not needed.
# Note: The '.gemrc' file must go in the user's home directory.
echo "gem: --no-document" > "${HOME}/.gemrc"

# Accept the Chef license so the students are not prompted when first
# starting Inspec.
export CHEF_LICENSE="accept-silent"


echo -e "${LINE_ASCII_CONSOLE}\n"

echo -e "${VERB}Installing Code extensions.${RSET}\n"

code --install-extension shopify.ruby-lsp
Expand All @@ -52,8 +45,8 @@ echo -e "${LINE_ASCII_CONSOLE}\n"

if ! command -v inspec &> /dev/null
then
echo -e "${VERB}Installing InSpec into the Environment.${RSET}"
curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -c stable -P inspec -v 5
echo -e "${VERB}Installing InSpec (CINC Auditor Distribution) into the Environment.${RSET}"
curl -L https://omnitruck.cinc.sh/install.sh | sudo bash -s -- -P cinc-auditor -v 6
else
echo -e "${HIGH}InSpec is already installed.${RSET}"
fi
Expand All @@ -73,8 +66,8 @@ fi
echo -e "${LINE_ASCII_CONSOLE}\n"

# Heimdall Lite & SAF CLI use Node v18
nvm install 18 &> /dev/null
nvm use 18 &> /dev/null
nvm install 20 &> /dev/null
nvm use 20 &> /dev/null

if ! command -v saf &> /dev/null
then
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
version: '3'
services:
operatingsystem:
image: redhat/ubi8
container_name: redhat8
image: redhat/ubi9
container_name: redhat9
tty: true
stdin_open: true
restart: always
Expand Down
11 changes: 10 additions & 1 deletion my_nginx_answer_key/inspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,20 @@ maintainer: The Authors
copyright: The Authors
copyright_email: [email protected]
license: Apache-2.0
summary: An InSpec Compliance Profile
summary: The Answer Key for class!
version: 0.1.0
supports:
platform: os

###
# This repo is present in the environment to serve as
# an example profile that students can refer back to
# during the MITRE SAF training series.
#
# Feel free to execute this against your NGINX
# container and see what happens!
###

inputs:
- name: nginx_version
type: String
Expand Down
6,893 changes: 6,893 additions & 0 deletions resources/U_RHEL_9_STIG_V2R2_Manual-xccdf.xml

Large diffs are not rendered by default.

Binary file removed resources/git_test.zip
Binary file not shown.
Binary file added resources/git_test_target.tar.gz
Binary file not shown.
Binary file removed resources/rhel8-baseline-stubs.tar.gz
Binary file not shown.