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

Added trivy.yaml #1289

Merged
merged 6 commits into from
Apr 6, 2025
Merged

Added trivy.yaml #1289

merged 6 commits into from
Apr 6, 2025

Conversation

Naveen-Pal
Copy link
Collaborator

Resolves #1288

@Naveen-Pal Naveen-Pal requested a review from arkid15r as a code owner April 5, 2025 20:55
Copy link
Contributor

coderabbitai bot commented Apr 5, 2025

Summary by CodeRabbit

  • New Features
    • Improved security scanning with a dedicated configuration, enhancing vulnerability detection and control.
  • Chores
    • Refined automation processes by transitioning from inline settings to an external configuration approach.
    • Introduced a curated ignore list to streamline vulnerability assessments and optimize scan performance.

Walkthrough

The pull request updates the CI/CD workflow by replacing inline severity parameters with a reference to an external configuration file (trivy.yaml) for multiple vulnerability scanning jobs. It introduces a new .trivyignore file listing CVE IDs for exclusion during scans and a new trivy.yaml file that defines various scanning parameters such as vulnerability checks, ignored paths, and a timeout setting.

Changes

File Change Summary
.github/.../run-ci-cd.yaml Updated CI/CD scanning jobs (scan-code, scan-ci-dependencies, scan-staging-images, scan-production-images): replaced inline severity (HIGH,CRITICAL) with config: trivy.yaml.
.trivyignore New file containing a list of CVE identifiers to be ignored during scans.
trivy.yaml New configuration file for Trivy defining vulnerability scanning settings, including the ignorefile reference, scan parameters (e.g., security-checks, severity), excluded paths, and timeout.

Assessment against linked issues

Objective Addressed Explanation
Introduce a trivy.yaml configuration file to manage vulnerability scanning for Docker images [#1288]
Address specific vulnerabilities (libldap-2.5-0, perl-base, zlib1g) [#1288] The configuration does not include explicit handling for CVE-2023-2953, CVE-2023-31484, or CVE-2023-45853.
Implement general recommendations for vulnerability management (e.g., regular scanning, ignore configurations) [#1288] While scanning and ignore list configuration are present, recommendations like using minimal base images or multi-stage builds are not addressed.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 53afc99 and e515ffb.

📒 Files selected for processing (3)
  • .github/workflows/run-ci-cd.yaml (4 hunks)
  • .trivyignore (1 hunks)
  • trivy.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • trivy.yaml
  • .trivyignore
  • .github/workflows/run-ci-cd.yaml
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run backend tests
  • GitHub Check: Run frontend e2e tests

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the ci label Apr 5, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
.github/workflows/trivy.yaml (1)

11-13: Environment Variable Consideration
The DOCKERHUB_USERNAME is hardcoded. If this value might change or if there’s any potential for sensitive information in the future, consider moving it to GitHub repository variables or secrets.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 87507ed and 323e14b.

📒 Files selected for processing (2)
  • .github/workflows/run-ci-cd.yaml (0 hunks)
  • .github/workflows/trivy.yaml (1 hunks)
💤 Files with no reviewable changes (1)
  • .github/workflows/run-ci-cd.yaml
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/trivy.yaml

57-57: expected scalar node for string value but found sequence node with "!!seq" tag

(syntax-check)


72-72: expected scalar node for string value but found sequence node with "!!seq" tag

(syntax-check)


89-89: expected scalar node for string value but found sequence node with "!!seq" tag

(syntax-check)


104-104: expected scalar node for string value but found sequence node with "!!seq" tag

(syntax-check)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run backend tests
  • GitHub Check: Run frontend unit tests
🔇 Additional comments (5)
.github/workflows/trivy.yaml (5)

1-2: New Workflow Name is Descriptive
The workflow is named "Security Scans", clearly indicating its purpose of automating security scans.


3-10: Trigger Configuration is Correct
The workflow is set to trigger on the completion of the "Run CI/CD" workflow on the main branch, which aligns with the intended chain of execution.


14-28: Repository Scan Job is Properly Configured
The scan-repository job correctly checks out the code and runs the Trivy scan with appropriate parameters. The use of an explicit commit reference for actions (both checkout and Trivy) is acceptable, though consider using version tags if ongoing updates are needed.


29-42: Filesystem Scan Job is Configured Correctly
The scan-filesystem job mirrors the repository scan setup with the necessary adjustment for filesystem scanning. No issues are noted here.


1-106: Overall Workflow File Review
The new workflow for Trivy scans is well-structured with clearly separated jobs for repository, filesystem, and image scans. Once the minor YAML scalar issues with the ignore-cves parameters are addressed, the file will integrate seamlessly into the CI/CD pipeline and enhance the security scanning process.

🧰 Tools
🪛 actionlint (1.7.4)

57-57: expected scalar node for string value but found sequence node with "!!seq" tag

(syntax-check)


72-72: expected scalar node for string value but found sequence node with "!!seq" tag

(syntax-check)


89-89: expected scalar node for string value but found sequence node with "!!seq" tag

(syntax-check)


104-104: expected scalar node for string value but found sequence node with "!!seq" tag

(syntax-check)

Comment on lines 71 to 73
ignore-cves:
- CVE-2025-31115
exit-code: 1
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

YAML Scalar Issue for 'ignore-cves' in Backend Staging Image Scan
Similarly, in the backend image scan step (lines 71–73), the ignore-cves field is defined as a sequence with a single item. Converting it to a scalar string will resolve the static analysis warning.

Proposed change:

-          ignore-cves:
-            - CVE-2025-31115
+          ignore-cves: "CVE-2025-31115"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ignore-cves:
- CVE-2025-31115
exit-code: 1
ignore-cves: "CVE-2025-31115"
exit-code: 1
🧰 Tools
🪛 actionlint (1.7.4)

72-72: expected scalar node for string value but found sequence node with "!!seq" tag

(syntax-check)

Comment on lines 103 to 105
ignore-cves:
- CVE-2025-31115
exit-code: 1
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

YAML Scalar Issue for 'ignore-cves' in Production Backend Image Scan
For the production backend image scan (lines 103–105), the ignore-cves parameter should also be a scalar string rather than a list.

Proposed change:

-          ignore-cves:
-            - CVE-2025-31115
+          ignore-cves: "CVE-2025-31115"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ignore-cves:
- CVE-2025-31115
exit-code: 1
ignore-cves: "CVE-2025-31115"
exit-code: 1
🧰 Tools
🪛 actionlint (1.7.4)

104-104: expected scalar node for string value but found sequence node with "!!seq" tag

(syntax-check)

Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

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

This doesn't seem to introduce trivy.yaml config file as described in the issue. Instead you extracted the workflow to a separate file.

What we want is to configure trivy using trivy.yaml. It also looks like we may need .trivyignore too.

@@ -0,0 +1,105 @@
name: Security Scans
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why moving this out of the CI/CD scope? I think this way we won't be able to use them in needs sections.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 323e14b and 6231c82.

📒 Files selected for processing (3)
  • .github/workflows/run-ci-cd.yaml (4 hunks)
  • .trivyignore (1 hunks)
  • trivy.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .trivyignore
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/run-ci-cd.yaml
🧰 Additional context used
🪛 YAMLlint (1.35.1)
trivy.yaml

[error] 12-12: no new line character at the end of file

(new-line-at-end-of-file)

🪛 GitHub Actions: Run CI/CD
trivy.yaml

[error] 12-12: no new line character at the end of file (new-line-at-end-of-file)

🔇 Additional comments (3)
trivy.yaml (3)

1-6: Vulnerability Block Configuration Validated
The vulnerability configuration block is well-defined and includes the necessary keys (ignorefile, ignore-unfixed, security-checks, and severity). This centralized configuration will simplify managing scanning parameters in the CI/CD pipeline.


7-11: Filesystem Exclusion Configuration is Clear
The filesystem block correctly specifies directories (frontend/node_modules/ and backend/.venv/) to be skipped during scanning. This exclusion is important for reducing scan noise and improving scan performance.


12-12: Timeout Setting Specified
The timeout is set to 10m, which appears appropriate for extensive scanning jobs. Confirm that this duration aligns well with your expected scan performance and does not lead to premature termination during heavy workloads.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 12-12: no new line character at the end of file

(new-line-at-end-of-file)

🪛 GitHub Actions: Run CI/CD

[error] 12-12: no new line character at the end of file (new-line-at-end-of-file)

trivy.yaml Outdated
- frontend/node_modules/
- backend/.venv/

timeout: 10m
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix YAML Newline at End of File
YAML lint and the CI/CD pipeline have flagged a missing newline at the end of the file. Please add a newline after line 12 to comply with standard YAML formatting guidelines.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 12-12: no new line character at the end of file

(new-line-at-end-of-file)

🪛 GitHub Actions: Run CI/CD

[error] 12-12: no new line character at the end of file (new-line-at-end-of-file)

Copy link

sonarqubecloud bot commented Apr 6, 2025

@arkid15r arkid15r enabled auto-merge April 6, 2025 16:30
Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

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

Let's try this in staging 👍

@arkid15r arkid15r added this pull request to the merge queue Apr 6, 2025
Merged via the queue into OWASP:main with commit cf3b43f Apr 6, 2025
22 checks passed
@Naveen-Pal
Copy link
Collaborator Author

Naveen-Pal commented Apr 6, 2025

@arkid15r
we need to replace config: trivy.yaml with trivy-config: trivy.yaml
updated on trivy.yaml branch
https://github.com/Naveen-Pal/Nest/blob/add-trivy-yaml/.github/workflows/run-ci-cd.yaml

Trivy Doc: https://github.com/aquasecurity/trivy-action#usage

@coderabbitai coderabbitai bot mentioned this pull request Apr 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introducy trivy.yaml
2 participants