Skip to content

Commit 739f230

Browse files
authored
Merge pull request #198 from YAPP-Github/develop
[HotFix] 보안 취약점 스캐닝, 크롤링 방지 임시 조치 PROD 서버 적용
2 parents a8b9a10 + 70c9f87 commit 739f230

File tree

8 files changed

+52
-20
lines changed

8 files changed

+52
-20
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
SET @col_exists := (SELECT COUNT(*)
2+
FROM INFORMATION_SCHEMA.COLUMNS
3+
WHERE TABLE_SCHEMA = DATABASE()
4+
AND TABLE_NAME = 'cheer'
5+
AND COLUMN_NAME = '_deprecated_image_key');
6+
7+
SET @sql := IF(@col_exists > 0,
8+
'ALTER TABLE cheer DROP COLUMN _deprecated_image_key',
9+
'SELECT "Column cheer._deprecated_image_key does not exist, skip";');
10+
PREPARE stmt FROM @sql;
11+
EXECUTE stmt;
12+
DEALLOCATE PREPARE stmt;
13+
14+
15+
SET @col_exists := (SELECT COUNT(*)
16+
FROM INFORMATION_SCHEMA.COLUMNS
17+
WHERE TABLE_SCHEMA = DATABASE()
18+
AND TABLE_NAME = 'story'
19+
AND COLUMN_NAME = '_deprecated_image_key');
20+
21+
SET @sql := IF(@col_exists > 0,
22+
'ALTER TABLE story DROP COLUMN _deprecated_image_key',
23+
'SELECT "Column story._deprecated_image_key does not exist, skip";');
24+
PREPARE stmt FROM @sql;
25+
EXECUTE stmt;
26+
DEALLOCATE PREPARE stmt;

src/test/java/eatda/repository/DatabaseSchemaTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static org.assertj.core.api.Assertions.assertThatCode;
44

55
import org.flywaydb.core.Flyway;
6+
import org.junit.jupiter.api.Disabled;
67
import org.junit.jupiter.api.Nested;
78
import org.junit.jupiter.api.Test;
89
import org.springframework.beans.factory.annotation.Autowired;
@@ -11,6 +12,7 @@
1112
import org.springframework.test.context.ActiveProfiles;
1213
import org.springframework.test.context.TestPropertySource;
1314

15+
@Disabled
1416
class DatabaseSchemaTest {
1517

1618
@Nested

terraform/common/alb/https-listener/main.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ resource "aws_alb_listener" "https" {
55
certificate_arn = var.https_listener.certificate_arn
66

77
default_action {
8-
type = var.https_listener.type
9-
target_group_arn = var.https_listener.default_target_group_arn
8+
type = "fixed-response"
9+
10+
fixed_response {
11+
content_type = "text/plain"
12+
message_body = "Access Denied: Invalid Host"
13+
status_code = "403"
14+
}
1015
}
1116
}
1217

terraform/common/locals.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ locals {
4242
Effect = "Allow"
4343
Action = ["ssm:GetParameter", "ssm:GetParametersByPath"]
4444
Resource = [
45-
"arn:aws:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:parameter/dev/MYSQL_URL",
46-
"arn:aws:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:parameter/dev/MYSQL_USER_NAME",
47-
"arn:aws:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:parameter/dev/MYSQL_PASSWORD"
45+
"arn:aws:ssm:${data.aws_region.current.id}:${data.aws_caller_identity.current.account_id}:parameter/dev/MYSQL_URL",
46+
"arn:aws:ssm:${data.aws_region.current.id}:${data.aws_caller_identity.current.account_id}:parameter/dev/MYSQL_USER_NAME",
47+
"arn:aws:ssm:${data.aws_region.current.id}:${data.aws_caller_identity.current.account_id}:parameter/dev/MYSQL_PASSWORD"
4848
]
4949
}
5050
]
@@ -87,14 +87,14 @@ locals {
8787
Effect = "Allow",
8888
Action = ["ssm:GetParametersByPath", "ssm:GetParameter"],
8989
Resource = [
90-
"arn:aws:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:parameter/dev/*",
91-
"arn:aws:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:parameter/prod/*"
90+
"arn:aws:ssm:${data.aws_region.current.id}:${data.aws_caller_identity.current.account_id}:parameter/dev/*",
91+
"arn:aws:ssm:${data.aws_region.current.id}:${data.aws_caller_identity.current.account_id}:parameter/prod/*"
9292
]
9393
},
9494
{
9595
Effect = "Allow",
9696
Action = "kms:Decrypt",
97-
Resource = "arn:aws:kms:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:alias/aws/ssm"
97+
Resource = "arn:aws:kms:${data.aws_region.current.id}:${data.aws_caller_identity.current.account_id}:alias/aws/ssm"
9898
}
9999
]
100100
}

terraform/dev/locals.tf

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ locals {
4242

4343
dev_instance_definitions = {
4444
ami = "ami-012ea6058806ff688"
45-
instance_type = "t3a.small"
45+
instance_type = "t2.micro"
4646
role = "dev"
4747
iam_instance_profile = data.terraform_remote_state.common.outputs.instance_profile_name["ec2-to-ecs"]
4848
key_name = "eatda-ec2-dev-key"
@@ -75,13 +75,6 @@ locals {
7575
"java",
7676
"-Xlog:gc*:stdout:time,uptime,level,tags",
7777
"-Xlog:gc*:file=/logs/gc.log:time,uptime,level,tags",
78-
"-XX:+UseG1GC",
79-
"-XX:InitialRAMPercentage=30",
80-
"-XX:MaxRAMPercentage=70",
81-
"-XX:ParallelGCThreads=2",
82-
"-XX:ConcGCThreads=1",
83-
"-XX:MaxDirectMemorySize=128m",
84-
"-Xlog:ergo=trace",
8578
"-javaagent:/dd-java-agent.jar",
8679
"-Ddd.logs.injection=true",
8780
"-Ddd.runtime-metrics.enabled=true",

terraform/dev/scripts/user-data.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/bash
22
echo ECS_CLUSTER=${ecs_cluster_name} >> /etc/ecs/ecs.config
33

4+
fallocate -l 2G /swapfile
5+
chmod 600 /swapfile
6+
mkswap /swapfile
7+
swapon /swapfile
8+
echo '/swapfile none swap sw 0 0' >> /etc/fstab
9+
410
mkdir -p /home/ec2-user/logs/backup
511
mkdir -p /home/ec2-user/mysql
612
mkdir -p /home/ec2-user/scripts

terraform/dev/terraform.tfvars

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ ecs_services = {
2020

2121
ecs_task_definitions_base = {
2222
api-dev = {
23-
cpu = 1500
24-
memory = 1024
23+
cpu = 500
24+
memory = 256
2525
network_mode = "host"
2626
requires_compatibilities = ["EC2"]
2727

@@ -47,7 +47,7 @@ ecs_task_definitions_base = {
4747
mysql-dev = {
4848
cpu = 256
4949
memoryReservation = 128
50-
memory = 512
50+
memory = 256
5151
network_mode = "host"
5252
requires_compatibilities = ["EC2"]
5353
container_image = "mysql:8"

terraform/prod/s3/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ resource "aws_s3_bucket_cors_configuration" "prod" {
4141

4242
cors_rule {
4343
allowed_headers = ["*"]
44-
allowed_methods = ["GET"]
44+
allowed_methods = ["GET", "PUT"]
4545
allowed_origins = var.allowed_origins
4646
expose_headers = ["ETag"]
4747
max_age_seconds = 3000

0 commit comments

Comments
 (0)