Skip to content

Commit dab67b8

Browse files
committed
updating
1 parent 4fe5eb4 commit dab67b8

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

terraform/pipelines/buildspecs/awsome-fastapi/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ phases:
4646
- name: $IMAGE_REPO_NAME
4747
image: $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:latest
4848
ports:
49-
- containerPort: 8080
49+
- containerPort: 80
5050
livenessProbe:
5151
httpGet:
5252
path: /

terraform/pipelines/modules/codepipeline/buildspecs/ossdepscan.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,24 @@ phases:
55
runtime-versions:
66
python: 3.9
77
commands:
8-
- echo "Installing dependency scanning tools..."
8+
- echo "Installing container scanning tools..."
99
- pip install --upgrade pip
1010
- curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh
1111
pre_build:
1212
commands:
13-
- echo "Running pre-scan checks..."
14-
- pip install -r requirements.txt
13+
- echo "Building Docker Container"
14+
- docker build -t $IMAGE_REPO_NAME:latest .
1515
build:
1616
commands:
17-
- echo "Scanning dependencies for vulnerabilities with Trivy..."
18-
- trivy fs --scanners vuln --severity HIGH,CRITICAL .
17+
- echo "Scanning container for vulnerabilities with Trivy..."
18+
# Fail the build on HIGH and CRITICAL vulnerabilities
19+
- ./bin/trivy image --severity HIGH,CRITICAL --exit-code 1 $IMAGE_REPO_NAME:latest
1920
post_build:
2021
commands:
21-
- echo "Dependency scanning completed."
22+
- echo "Container Scanning completed."
2223

2324
artifacts:
2425
files:
2526
- "**/*"
2627
discard-paths: yes
27-
28-
reports:
29-
trivy_vulnerabilities:
30-
files:
31-
- "trivy-results.json"
32-
file-format: JSON
28+

terraform/pipelines/modules/codepipeline/buildspecs/sastscanning.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,25 @@ version: 0.2
33
phases:
44
install:
55
runtime-versions:
6-
nodejs: 16
6+
nodejs: 20
7+
python: 3.12
78
commands:
89
- echo "Installing Snyk CLI..."
910
- npm install -g snyk
1011
- snyk auth ${SNYK_TOKEN} # Authenticate using the Snyk token
1112
pre_build:
1213
commands:
13-
- echo "Preparing for Snyk scanning..."
14-
- snyk test --json > snyk_test_results.json || true # Run dependency scanning
14+
- echo "Preparing for Snyk dependency scanning..."
15+
# Fail the build if high or critical vulnerabilities are found
16+
- snyk test --file=prerequirements.txt --severity-threshold=high
1517
build:
1618
commands:
17-
- echo "Running Snyk security checks..."
18-
- snyk code --json > snyk_code_results.json || true # Run code scanning
19+
- echo "Running Snyk code security checks..."
20+
# Fail the build if high or critical code vulnerabilities are found
21+
- snyk code test --severity-threshold=high
1922
post_build:
2023
commands:
2124
- echo "Snyk scanning completed."
22-
- echo "Uploading reports..."
25+
2326
artifacts:
24-
files:
25-
- snyk_test_results.json
26-
- snyk_code_results.json
2727
discard-paths: no
28-
29-
reports:
30-
snyk_vulnerabilities:
31-
files:
32-
- snyk_test_results.json
33-
file-format: JSON
34-
snyk_code_issues:
35-
files:
36-
- snyk_code_results.json
37-
file-format: JSON

terraform/pipelines/modules/codepipeline/main.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ resource "aws_iam_policy" "codebuild_policy" {
148148
"${var.s3_bucket_arn}/*"
149149
]
150150
},
151+
{
152+
Effect = "Allow"
153+
Action = [
154+
"codebuild:CreateReportGroup",
155+
"codebuild:CreateReport",
156+
"codebuild:UpdateReport"
157+
]
158+
Resource = "*"
159+
},
151160
{
152161
Effect = "Allow"
153162
Action = [
@@ -377,6 +386,11 @@ resource "aws_codebuild_project" "oss_scanning_project" {
377386
image = var.build_image
378387
type = var.environment_type
379388
privileged_mode = var.privileged_mode
389+
390+
environment_variable {
391+
name = "IMAGE_REPO_NAME"
392+
value = aws_ecr_repository.this.name
393+
}
380394
}
381395

382396
source {

0 commit comments

Comments
 (0)