generated from finos/standards-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
76402e4
commit 6c78958
Showing
15 changed files
with
167 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: "Controls Behave Testing - Storage" | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
run_behave_tests_storage: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: "eu-west-3" | ||
|
||
- uses: 'google-github-actions/auth@v2' | ||
with: | ||
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 # This action sets up Python | ||
|
||
- name: Install dependencies | ||
working-directory: ./src/control-catalog/behave_tests | ||
run: pip install -r requirements.txt # Install your Python dependencies | ||
|
||
- name: Run Behave Tests | ||
working-directory: ./src/control-catalog/behave_tests | ||
run: python app.py storage |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import sys | ||
import subprocess | ||
import logging | ||
|
||
from os import environ | ||
from glob import glob | ||
|
||
if environ.get("AWS_DEFAULT_REGION") is None: | ||
environ["AWS_DEFAULT_REGION"] = "eu-west-3" # Set to France | ||
|
||
|
||
class BehaveTester: | ||
|
||
def __init__(self) -> None: | ||
logging.basicConfig(level=logging.INFO) | ||
self.logging = logging.getLogger(__name__) | ||
|
||
def run_behave(self, service_name): | ||
abs_behave_file_paths = glob("./**/*.feature", recursive=True) | ||
|
||
for abs_behave_file_path in abs_behave_file_paths: | ||
behave_test_dir = "/".join(abs_behave_file_path.split("/")[:-2]) | ||
if service_name in behave_test_dir: | ||
print(f"Running behave for {service_name}") | ||
try: | ||
subprocess.run(["behave", behave_test_dir], check=True) | ||
except subprocess.CalledProcessError as err: | ||
self.logging.error(f"Behave tested failed: {err}") | ||
sys.exit(1) | ||
else: | ||
self.logging.info(f"Behave for service {service_name} not found!") | ||
sys.exit(1) | ||
|
||
self.logging.info(f"Behave tested passed for the {service_name} service!") | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
print("Usage: python3 app.py <service_name>") | ||
sys.exit(1) | ||
|
||
tester = BehaveTester() | ||
tester.run_behave(sys.argv[1]) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...ests/ccc.os.c2/features/ccc_os_c2.feature → ...ject/ccc.os.c2/features/ccc_os_c2.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
Feature: (CCC.OS.C2) - Prevent object storage data encrypted for impact | ||
|
||
Scenario: Test Control CCC.OS.C2 AWS | ||
Scenario: Test Control CCC.OS.C2 | ||
GIVEN you own the object storage bucket in AWS | ||
WHEN a data plane request with an untrusted KMS key is made to the object storage bucket | ||
AND you own the object storage bucket in GCP | ||
WHEN a data plane request with an untrusted KMS key is made to the AWS object storage bucket | ||
AND a data plane request with an untrusted KMS key is made to the GCP object storage bucket | ||
THEN the request should be denied |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 49 additions & 2 deletions
51
src/control-catalog/terraform_modules/storage/object/ccc.os.c2/gcp/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,56 @@ | ||
resource "google_storage_bucket" "malicious_storage_bucket" { | ||
name = "${var.bucket_name}-ccc-os-c2" | ||
location = "US" | ||
location = "us-central1" | ||
force_destroy = true | ||
|
||
versioning { | ||
enabled = true | ||
} | ||
} | ||
encryption { | ||
default_kms_key_name = google_kms_crypto_key.trusted_cmek.id | ||
} | ||
|
||
uniform_bucket_level_access = true | ||
} | ||
|
||
data "google_iam_policy" "policy" { | ||
binding { | ||
role = "roles/storage.objectCreator" | ||
members = ["user:*"] | ||
condition { | ||
title = "Deny unencrypted uploads" | ||
description = "Only allow objects to be uploaded with a specific KMS key" | ||
expression = "resource.name.startsWith(\"projects/common-cloud-controls-testing/buckets/${google_storage_bucket.malicious_storage_bucket.name}/objects\") && !request.resource.labels.kms_key_name.startsWith(\"projects/common-cloud-controls-testing/locations/us-central1/keyRings/${google_kms_key_ring.keyring.id}/cryptoKeys/${google_kms_crypto_key.trusted_cmek.name}\")" | ||
} | ||
} | ||
} | ||
|
||
resource "google_storage_bucket_iam_policy" "name" { | ||
bucket = google_storage_bucket.malicious_storage_bucket.name | ||
policy_data = data.google_iam_policy.policy.policy_data | ||
} | ||
|
||
resource "google_kms_key_ring" "keyring" { | ||
name = "${var.bucket_name}-ccc-os-c2-keyring" | ||
location = "us-central1" | ||
} | ||
|
||
resource "google_kms_crypto_key" "trusted_cmek" { | ||
name = "${var.bucket_name}-trusted-ccc-os-c2" | ||
key_ring = google_kms_key_ring.keyring.id | ||
rotation_period = "7776000s" | ||
|
||
lifecycle { | ||
prevent_destroy = false | ||
} | ||
} | ||
|
||
resource "google_kms_crypto_key" "untrusted_cmek" { | ||
name = "${var.bucket_name}-untrusted-ccc-os-c2" | ||
key_ring = google_kms_key_ring.keyring.id | ||
rotation_period = "7776000s" | ||
|
||
lifecycle { | ||
prevent_destroy = false | ||
} | ||
} |