Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1867 - Fix SonarCloud high security issues #1951

Merged
merged 48 commits into from
May 25, 2023

Conversation

sh16011993
Copy link
Collaborator

@sh16011993 sh16011993 commented May 18, 2023

This PR has the following issues fixed for api, queue-consumers and workers:

Issue: Running containers as a privileged user weakens their runtime security.
Fix: The images for api, workers and queue-consumers now run as a non-root user

Issue: Copying recursively might inadvertently add sensitive data to the container.
Fix: Only the required directories and files are now being copied.

The following issue is not fixed as a part of this PR:
Make sure write access is not granted to other users.

- This image might run with root as the default user.
@sh16011993 sh16011993 self-assigned this May 18, 2023
@sh16011993 sh16011993 linked an issue May 18, 2023 that may be closed by this pull request
2 tasks
Copy link
Contributor

@ann-aot ann-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 . Pls address other devs comment's


# Building app
RUN npm run build queue-consumers

# Ensure that the non-root user will be able to write the coverage report.
RUN mkdir -p /app/apps/queue-consumers/coverage/ && chown node /app/apps/queue-consumers/coverage/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prod does not need it.

COPY . .
# Copying sources.
COPY ./apps/queue-consumers ./apps/queue-consumers
COPY ./apps/db-migrations ./apps/db-migrations
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prod does not need it.

COPY . .
# Copying sources.
COPY ./apps/workers ./apps/workers
COPY ./apps/db-migrations ./apps/db-migrations
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prod does not need it.


# Building app
RUN npm run build workers

# Ensure that the non-root user will be able to write the coverage report.
RUN mkdir -p /app/apps/workers/coverage/ && chown node /app/apps/workers/coverage/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prod does not need it.

Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, please take a look at the comments.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@github-actions
Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 17.7% ( 2052 / 11596 )
Methods: 7.86% ( 117 / 1489 )
Lines: 20.5% ( 1804 / 8798 )
Branches: 10.01% ( 131 / 1309 )

@github-actions
Copy link

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 33.02% ( 177 / 536 )
Methods: 22.08% ( 17 / 77 )
Lines: 40.1% ( 158 / 394 )
Branches: 3.08% ( 2 / 65 )

@github-actions
Copy link

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 68.15% ( 383 / 562 )
Methods: 57.75% ( 41 / 71 )
Lines: 70.27% ( 338 / 481 )
Branches: 40% ( 4 / 10 )

@github-actions
Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 40.97% ( 2851 / 6958 )
Methods: 34.11% ( 308 / 903 )
Lines: 46.31% ( 2406 / 5195 )
Branches: 15.93% ( 137 / 860 )

Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the changes, looks good 👍

Copy link
Collaborator

@dheepak-aot dheepak-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on fixing the issues and also reaching out to team members for help.👍

Copy link
Collaborator

@andrepestana-aot andrepestana-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Collaborator

@andrepestana-aot andrepestana-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Collaborator

@guru-aot guru-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice work @sh16011993

@sh16011993 sh16011993 merged commit a6593f5 into main May 25, 2023
@sh16011993 sh16011993 temporarily deployed to DEV May 25, 2023 16:07 — with GitHub Actions Inactive
@sh16011993 sh16011993 deleted the 1867_fix_sonarcloud_high_security_issues branch May 25, 2023 16:07
@sh16011993 sh16011993 temporarily deployed to DEV May 25, 2023 16:07 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV May 25, 2023 16:07 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV May 25, 2023 16:07 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV May 25, 2023 16:07 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV May 25, 2023 16:07 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV May 25, 2023 16:21 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV May 25, 2023 16:23 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV May 25, 2023 16:23 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV May 25, 2023 16:23 — with GitHub Actions Inactive
@sh16011993 sh16011993 temporarily deployed to DEV May 25, 2023 16:23 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Camunda Workers Queue Consumers SIMS-Api SIMS-Api Sonar Involves fixing sonar related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix Sonarcloud high security issues
6 participants