Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 26de816

Browse files
committed
2 parents c40ce1c + bdb31f9 commit 26de816

7 files changed

Lines changed: 66 additions & 37 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ Once inside Cloud9, we can begin the process of setting up our labs.
2626
Copy and paste the following code into the terminal of your Cloud9IDE (the terminal is at the bottom right of your screen), hit `enter` to execute the script.
2727

2828
cd ~/environment && \
29-
rm -rf macie-ANZ-devlabs && \
29+
rm -rf amazon-macie-detect-sensitive-data-lab && \
3030
git clone https://github.com/aws-samples/amazon-macie-detect-sensitive-data-lab.git --quiet && \
31-
cd macie-ANZ-devlabs && \
31+
cd amazon-macie-detect-sensitive-data-lab && \
3232
pip3 install boto3 --quiet && \
3333
python3 setup_lab.py && \
3434
cd ~/environment

setup_lab.py

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,73 +2,77 @@
22
import botocore
33
import os
44

5-
def color(text: str,color: str='cyan') -> str:
5+
6+
def color(text: str, color: str = "cyan") -> str:
67
"""
78
colors the output to terminal -- nicer aesthetic!
89
"""
9-
10-
if color =='cyan':
11-
r,g,b = 0,255,255
12-
elif color =='orange':
13-
r,g,b = 255,179,71
14-
elif color == 'green':
15-
r,g,b = 57,255,20
16-
10+
11+
if color == "cyan":
12+
r, g, b = 0, 255, 255
13+
elif color == "orange":
14+
r, g, b = 255, 179, 71
15+
elif color == "green":
16+
r, g, b = 57, 255, 20
17+
1718
return f"\033[38;2;{r};{g};{b}m{text}\033[38;2;255;255;255m"
1819

1920

20-
bucket_name_parameter = 'MacieDevlabBucketName'
21-
sensitive_data_folder = 'test-data'
21+
bucket_name_parameter = "MacieDevlabBucketName"
22+
sensitive_data_folder = "test-data"
2223

23-
ssm_client = boto3.client('ssm')
24-
s3_client = boto3.client('s3')
25-
macie_client = boto3.client('macie2')
24+
ssm_client = boto3.client("ssm")
25+
s3_client = boto3.client("s3")
26+
macie_client = boto3.client("macie2")
2627

2728

28-
bucket_name = ssm_client.get_parameter(
29-
Name=bucket_name_parameter
30-
)['Parameter']['Value']
31-
bucket_location = s3_client.get_bucket_location(Bucket=bucket_name)['LocationConstraint']
29+
bucket_name = ssm_client.get_parameter(Name=bucket_name_parameter)["Parameter"]["Value"]
30+
bucket_location = s3_client.get_bucket_location(Bucket=bucket_name)[
31+
"LocationConstraint"
32+
]
3233
if bucket_location is None:
33-
bucket_location = 'us-east-1'
34-
print(f"Bucket with test data is {color(bucket_name)} in the {color(bucket_location,color='orange')} region")
34+
bucket_location = "us-east-1"
35+
print(
36+
f"Bucket with test data is {color(bucket_name)} in the {color(bucket_location,color='orange')} region"
37+
)
3538
macie_console_link = f"https://{bucket_location}.console.aws.amazon.com/macie/home?region={bucket_location}"
3639

3740

3841
list_files = os.listdir(sensitive_data_folder)
3942
for file_name in list_files:
40-
response = s3_client.upload_file(f"./{sensitive_data_folder}/{file_name}", bucket_name, file_name)
43+
response = s3_client.upload_file(
44+
f"./{sensitive_data_folder}/{file_name}", bucket_name, file_name
45+
)
4146
print(f"Uploaded test data to {color(bucket_name)} bucket")
4247

4348

4449
try:
4550
macie_client.disable_macie()
4651
print("Disabled installation of Macie from previous Lab Participant")
47-
except macie_client.exceptions.from_code('AccessDeniedException') as e:
48-
print(e.response['Error']['Message'])
52+
except macie_client.exceptions.from_code("AccessDeniedException") as e:
53+
print(e.response["Error"]["Message"])
4954
macie_client.enable_macie()
5055
response = macie_client.get_macie_session()
5156
macie_client.create_custom_data_identifier(
52-
description='Passport number of Gotham Citizens',
57+
description="Passport number of Gotham Citizens",
5358
keywords=[
54-
'passport',
59+
"passport",
5560
],
5661
maximumMatchDistance=50,
57-
name='Gotham Passport',
58-
regex='[ABCDEF]\\d{7}[A-Z]',
62+
name="Gotham Passport",
63+
regex="[ABCDEF]\\d{7}[A-Z]",
5964
severityLevels=[
60-
{
61-
'occurrencesThreshold': 1,
62-
'severity': 'HIGH'
63-
},
64-
]
65+
{"occurrencesThreshold": 1, "severity": "HIGH"},
66+
],
6567
)
6668

6769

68-
if response['status'] == 'ENABLED':
70+
if response["status"] == "ENABLED":
6971
print("Macie enabled!\n\n")
7072
print(f"🚀 {color('You are ready to go',color='green')} 🚀")
71-
print(f"Click this link, and then click open to continue to Macie: {color(macie_console_link, color='cyan')}")
73+
print(
74+
f"Click this link, and then click open to continue to Macie: {color(macie_console_link, color='cyan')}"
75+
)
7276
print("\n\n")
7377
else:
74-
print("Error enabling Macie, please check with the lab organizer")
78+
print("Error enabling Macie, please check with the lab organizer")

test-data/cc_numbers.csv

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name, cc expiration,cvv2,
2+
Bruce Wayne, 02/24,110,
3+
Martha Wayne, 02/23,100,
4+
Alexander Luthor, 01/24,444,
5+
Martha Kent, 08/25,980,

test-data/constatine_passport.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Hi,
2+
3+
I'm John Constantine, my passport number is 107182890
4+
5+
With love,
6+
The Laughing Magician

test-data/gotham_passport.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
We'll give you not the hero you deserve, but the one you need -- but whoever he is, let's make sure his passport number is F1234567A.
2+
3+
Long live Gotham!

test-data/letter.pdf

19.4 KB
Binary file not shown.

test-data/plastic_order.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Hi,
2+
3+
I recently purchased some high quality resin from you, but it no longer works with the specific plastic I have.
4+
5+
Would you be able to issue a refund.
6+
7+
My Credit card number is 5555 5555 5555 4444.
8+
9+
Thank you.
10+
11+
Patrick O' Brien

0 commit comments

Comments
 (0)