<commit_before>## launchTmtcTeam.sh ${teamname} ${tenantid} ${tenantpw}
## --debug --disable-rollback \
#!/bin/bash


t0User=${1}
t0Pass=${2}
dsmFqdn=${3}
dsmConsolePort=${4}
teamname=${5}
teamPassword=${6}
keyPair=${7}
eventName=${8}
baseDomain=${9}
baseDomainHostedZoneId=${10}
iamusername=${teamname}-${eventName}-dsmservice
logfile=${teamname}.log


echo "t0user: ${t0User}" >> ${logfile}
echo "t0Pass: ${t0Pass}" >> ${logfile}
echo "dsmFqdn: ${dsmFqdn}" >> ${logfile}
echo "dsmConsolePort: ${dsmConsolePort}" >> ${logfile}
echo "teamname: ${teamname}" >> ${logfile}
echo "teamPassword: ${teamPassword}" >> ${logfile}


echo -e "\nCreate Tenant\n"
echo "Create ${teamname} DS Tenant" >> ${logfile} 2>&1
tenantCreds=($(../dsm/ds10-rest-tenantCreate.sh ${t0User} ${t0Pass} ${dsmFqdn} ${dsmConsolePort} ${teamname} ${teamPassword}))

echo -e "\nCreate IAM stuff\n"
echo "Create IAM stuff for ${teamname}" >> ${logfile} 2>&1
aws iam create-user --user-name ${iamusername}
aws iam put-user-policy --user-name ${iamusername} --policy-name DSMUserRole --policy-document '{"Statement" : [{"Effect" : "Allow","Action" : ["ec2:DescribeInstances","ec2:DescribeImages","ec2:DescribeTags","ec2:DescribeRegions","ec2:DescribeVpcs","ec2:DescribeSubnets"],"Resource" : "*"}]}'
AWSKEYS=($(aws iam create-access-key --user-name ${iamusername} --query 'AccessKey.[AccessKeyId,SecretAccessKey]' --output text))

echo "sleep to let tenant come up"
echo "Sleep 30 to give tenant ${teamname} a head start" >> ${logfile} 2>&1
sleep 30


echo -e "\nCreate Stack\n"
echo "Create ${teamname} cfn stack" >> ${logfile} 2>&1
aws cloudformation create-stack --disable-rollback \
--output text \
--stack-name ${teamname}-${eventName}-TMTC \
--capabilities CAPABILITY_IAM \
--template-url "https://s3.amazonaws.com/trendctf/cfn/threatChallengeTeam.template" \
--parameters \
ParameterKey=TeamName,ParameterValue=${teamname} \
ParameterKey=Build,ParameterValue=MT \
ParameterKey=DSTenantId,ParameterValue=${tenantCreds[1]} \
ParameterKey=DSTenantPassword,ParameterValue=${tenantCreds[0]} \
ParameterKey=DeepSecurityAdminPass,ParameterValue=${teamPassword} \
ParameterKey=TeamPassword,ParameterValue=${teamPassword} \
ParameterKey=MtDsmFqdn,ParameterValue=${dsmFqdn} \
ParameterKey=AWSIKeyPairName,ParameterValue=${keyPair} \
ParameterKey=EventName,ParameterValue=${eventName} \
ParameterKey=IncludeOsceChallenge,ParameterValue=true \
ParameterKey=baseDomain,ParameterValue=${baseDomain} \
ParameterKey=baseDomainHostedZoneId,ParameterValue=${baseDomainHostedZoneId}
--tags \
Key=TeamName,Value=${teamname} \
Key=CtfRole,Value=SkoTeamStack


echo "Customize tenant" >> ${logfile} 2>&1
../dsm/ds10-customize-teamTenant.sh MasterAdmin ${teamPassword} ${dsmFqdn} ${dsmConsolePort} ${teamname} >> ${logfile} 2>&1



echo "create connector with keys"<commit_msg>Handle special characters in passwords<commit_after>## launchTmtcTeam.sh ${teamname} ${tenantid} ${tenantpw}
## --debug --disable-rollback \
#!/bin/bash


t0User=${1}
t0Pass=${2}
dsmFqdn=${3}
dsmConsolePort=${4}
teamname=${5}
teamPassword=${6}
keyPair=${7}
eventName=${8}
baseDomain=${9}
baseDomainHostedZoneId=${10}
iamusername=${teamname}-${eventName}-dsmservice
logfile=${teamname}.log


echo "t0user: ${t0User}" >> ${logfile}
echo "t0Pass: ${t0Pass}" >> ${logfile}
echo "dsmFqdn: ${dsmFqdn}" >> ${logfile}
echo "dsmConsolePort: ${dsmConsolePort}" >> ${logfile}
echo "teamname: ${teamname}" >> ${logfile}
echo "teamPassword: ${teamPassword}" >> ${logfile}


echo -e "\nCreate Tenant\n"
echo "Create ${teamname} DS Tenant" >> ${logfile} 2>&1
tenantCreds=($(../dsm/ds10-rest-tenantCreate.sh ${t0User} ${t0Pass} ${dsmFqdn} ${dsmConsolePort} ${teamname} ${teamPassword}))

echo -e "\nCreate IAM stuff\n"
echo "Create IAM stuff for ${teamname}" >> ${logfile} 2>&1
aws iam create-user --user-name ${iamusername}
aws iam put-user-policy --user-name ${iamusername} --policy-name DSMUserRole --policy-document '{"Statement" : [{"Effect" : "Allow","Action" : ["ec2:DescribeInstances","ec2:DescribeImages","ec2:DescribeTags","ec2:DescribeRegions","ec2:DescribeVpcs","ec2:DescribeSubnets"],"Resource" : "*"}]}'
AWSKEYS=($(aws iam create-access-key --user-name ${iamusername} --query 'AccessKey.[AccessKeyId,SecretAccessKey]' --output text))

echo "sleep to let tenant come up"
echo "Sleep 30 to give tenant ${teamname} a head start" >> ${logfile} 2>&1
sleep 30


echo -e "\nCreate Stack\n"
echo "Create ${teamname} cfn stack" >> ${logfile} 2>&1
aws cloudformation create-stack --disable-rollback \
--output text \
--stack-name ${teamname}-${eventName}-TMTC \
--capabilities CAPABILITY_IAM \
--template-url "https://s3.amazonaws.com/trendctf/cfn/threatChallengeTeam.template" \
--parameters \
ParameterKey=TeamName,ParameterValue=${teamname} \
ParameterKey=Build,ParameterValue=MT \
ParameterKey=DSTenantId,ParameterValue=${tenantCreds[1]} \
ParameterKey=DSTenantPassword,ParameterValue=${tenantCreds[0]} \
ParameterKey=DeepSecurityAdminPass,ParameterValue="${teamPassword}" \
ParameterKey=TeamPassword,ParameterValue="${teamPassword}" \
ParameterKey=MtDsmFqdn,ParameterValue=${dsmFqdn} \
ParameterKey=AWSIKeyPairName,ParameterValue=${keyPair} \
ParameterKey=EventName,ParameterValue=${eventName} \
ParameterKey=IncludeOsceChallenge,ParameterValue=true \
ParameterKey=baseDomain,ParameterValue=${baseDomain} \
ParameterKey=baseDomainHostedZoneId,ParameterValue=${baseDomainHostedZoneId} \
--tags \
Key=TeamName,Value=${teamname} \
Key=CtfRole,Value=SkoTeamStack


echo "Customize tenant" >> ${logfile} 2>&1
../dsm/ds10-customize-teamTenant.sh MasterAdmin ${teamPassword} ${dsmFqdn} ${dsmConsolePort} ${teamname} >> ${logfile} 2>&1



echo "create connector with keys"
{'fraction_non_alphanumeric': 0.18106633820165405, 'fraction_numerical': 0.01689248636283653, 'mean_word_length': 7.322108345534407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 63, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3741187', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1947, 'n_words': 361}