Skip to content

Commit

Permalink
added DAST, SAST , LINT and sonarcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
Anvisimi committed Oct 17, 2024
1 parent 3697dd3 commit 593a2b5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
- name: Build, Test, and Analyze with Maven
run: |
mvn clean verify sonar:sonar \
-Dsonar.projectKey=ShopSmartSG_central-repo-service \
-Dsonar.projectKey=ShopSmartSG_shopsmartsg-backend \
-Dsonar.organization=shopsmartsg \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=${{ secrets.SONAR_TOKEN }} \
Expand All @@ -106,8 +106,8 @@ jobs:
- name: Build Docker image
run: |
docker build -t shopsmartsg/central-repo-service .
docker tag shopsmartsg/central-repo-service:latest ${{ secrets.ECR_REPO_URI }}:latest
docker build -t shopsmartsg/central-hub .
docker tag shopsmartsg/central-hub:latest ${{ secrets.ECR_REPO_URI }}:latest
- name: Push Docker image to ECR
run: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/zap-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ jobs:
- name: Create Docker Network
run: docker network create zap-network

# Step 2: Build the Docker image for the central-repo-service
# Step 2: Build the Docker image for the central-hub
- name: Build Docker Image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: false
tags: central-repo-service:latest
tags: central-hub:latest

# Step 3: Run the Docker container for the application in the zap-network
- name: Run Docker Container
run: docker run -d --name central-repo-service --network zap-network -p 8084:8084 central-repo-service:latest
run: docker run -d --name central-hub --network zap-network -p 8082:8082 central-hub:latest

# Step 4: Wait for the application to start and be available
- name: Wait for Application to Start
run: |
echo "Waiting for the application to start..."
for i in {1..10}; do
if curl -s http://localhost:8084 >/dev/null; then
if curl -s http://localhost:8082 >/dev/null; then
echo "Application is up!"
break
fi
Expand All @@ -57,9 +57,9 @@ jobs:
- name: ZAP Full Scan
uses: zaproxy/action-full-scan@v0.11.0
with:
target: 'http://central-repo-service:8084' # Target by container name in the zap-network
target: 'http://central-hub:8082' # Target by container name in the zap-network
token: ${{ secrets.GITHUB_TOKEN }}
cmd_options: '-t http://central-repo-service:8084 -r zap_report.html'
cmd_options: '-t http://central-hub:8082 -r zap_report.html'

# Step 6: Upload the ZAP report as an artifact
- name: Upload ZAP Report
Expand Down
14 changes: 7 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ RUN mvn clean package
FROM openjdk:21-jdk-slim

# Create the log directory and set proper permissions
RUN mkdir -p /var/log/central-repo-service && \
chmod -R 777 /var/log/central-repo-service # Ensure the app can write to the log directory
RUN mkdir -p /var/log/central-hub && \
chmod -R 777 /var/log/central-hub # Ensure the app can write to the log directory

# Copy the project’s jar file into the container at /app
COPY --from=build /app/target/central-repo-service.jar central-repo-app.jar
COPY --from=build /app/target/central-hub.jar central-repo-app.jar

# Make port 8084 available to the world outside this container
EXPOSE 8084
# Make port 8082 available to the world outside this container
EXPOSE 8082

# Run the jar file
ENTRYPOINT ["java", "-jar", "central-repo-app.jar"]

# to build image after building jar post any changes
# docker build -t central-repo-service:latest .
# docker build -t central-hub:latest .
# docker-compose up --build
# docker push simranarora264/central-repo-service:latest
# docker push simranarora264/central-hub:latest
# docker file and docker-compose port should be same
# docker-compose down : shutdown the container
# till we shutdown the postgres image , db remains intact
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</dependency>
</dependencies>
<build>
<finalName>central-repo-service</finalName>
<finalName>central-hub</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down

0 comments on commit 593a2b5

Please sign in to comment.