Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

โ€œInvest in yourself โ€” your confidence is always worth it.โ€

Explore Cosmetic Hospitals

Start your journey today โ€” compare options in one place.

Trivy: List of Methods to Ignore Directories & Files During Scanning

Trivy provides multiple ways to ignore directories, files, and vulnerabilities during scanning. This guide covers all correct and updated methods, including command-line options, configuration files, and post-processing techniques.


1๏ธโƒฃ Ignore Directories & Files Using Command-Line Options (Recommended for Quick Exclusions)

Trivy supports --skip-dirs and --skip-files flags to exclude directories and files while scanning.

Examples:

โœ… Ignore specific directories

trivy image --skip-dirs "/var/lib/gems/2.5.0/gems/fluent-plugin-detect-exceptions-0.0.13" \
            --skip-dirs "/var/lib/gems/2.5.0/gems/http_parser.rb-0.6.0" \
            quay.io/fluentd_elasticsearch/fluentd:v2.9.0
Code language: JavaScript (javascript)

โœ… Ignore directories when scanning a local filesystem

trivy fs --skip-dirs "./testdata/*" .
Code language: JavaScript (javascript)

โœ… Ignore Terraform-related files and directories

trivy config --skip-dirs "**/.terraform" .
Code language: JavaScript (javascript)

โœ… Ignore specific files during image scanning

trivy image --skip-files "/Gemfile.lock" --skip-files "/var/lib/gems/2.5.0/gems/http_parser.rb-0.6.0/Gemfile.lock" quay.io/fluentd_elasticsearch/fluentd:v2.9.0
Code language: JavaScript (javascript)

โœ… Ignore all foo directories in any subdirectory

trivy image --skip-files "**/foo" image:tag
Code language: JavaScript (javascript)

โœ… Use --file-patterns to ignore files based on type

trivy fs --file-patterns "dockerfile:.*.docker" --file-patterns "kubernetes:*.tpl" --file-patterns "pip:requirements-.*\.txt" .
Code language: CSS (css)

๐Ÿ“Œ Use Case: Best when you want to exclude files or directories temporarily without modifying any configuration files.


2๏ธโƒฃ Use trivy.yaml Configuration File for Persistent Directory/File Skipping

For a permanent solution, create a trivy.yaml file in the root of your project.

Example trivy.yaml

scan:
  skip-dirs:
    - "**/examples/**"
    - "**/.terraform/**"
    - "node_modules"
    - "vendor"
  skip-files:
    - "**/*.log"
    - "**/Gemfile.lock"
Code language: JavaScript (javascript)

โœ… Run Trivy with the configuration file:

trivy fs --config trivy.yaml .
Code language: CSS (css)

๐Ÿ“Œ Use Case: Best for consistent exclusions across multiple runs without needing CLI options.


3๏ธโƒฃ Ignore Specific Vulnerabilities Using .trivyignore

You can ignore specific vulnerabilities by their IDs using a .trivyignore file.

Example .trivyignore

AVD-KSV-0014
CVE-2023-1234

โœ… Run Trivy and apply .trivyignore:

trivy fs --ignorefile .trivyignore .
Code language: CSS (css)

๐Ÿ“Œ Use Case: When you want to exclude false positives or known vulnerabilities without ignoring entire files or directories.


4๏ธโƒฃ Use find to Dynamically Exclude Directories Before Running Trivy

If you don’t want to modify your Trivy configurations, you can manually exclude directories before scanning.

โœ… Find and exclude examples and node_modules directories

find . -type d \( -name "examples" -o -name "node_modules" \) -prune -o -print | trivy fs .
Code language: PHP (php)

๐Ÿ“Œ Use Case: When you cannot modify project files but need to exclude directories.


5๏ธโƒฃ Use grep -v to Filter Out Results After Scanning

If Trivy scans everything but you want to remove unwanted results from the output:

โœ… Remove results from examples/ directories

trivy fs . | grep -v "examples/"
Code language: JavaScript (javascript)

๐Ÿ“Œ Use Case: Quick fix when Trivy outputs unwanted directories but scanning time is not a concern.


Final Comparison: Best Method to Use

MethodBest ForPermanent?Performance Impact?
--skip-dirs / --skip-filesQuick exclusionsโŒ Noโœ… Improves
trivy.yaml (skip-dirs, skip-files)Persistent exclusionsโœ… Yesโœ… Improves
.trivyignore (Ignore CVEs)Ignoring vulnerabilitiesโœ… Yesโš ๏ธ No impact
find -pruneExcluding before scanningโŒ Noโœ… Improves
grep -vFiltering after scanningโŒ Noโš ๏ธ No impact

Conclusion

๐Ÿš€ Best method โ†’ Use --skip-dirs and --skip-files in the CLI for quick fixes.
โšก For permanent exclusions โ†’ Use trivy.yaml.
๐Ÿ”Ž To ignore vulnerabilities only โ†’ Use .trivyignore.
โณ If you can’t modify configurations โ†’ Use find or grep.

This is the correct, updated, and complete guide to ignoring directories and files in Trivy. โœ… Let me know if you need further clarification! ๐Ÿš€

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

What to choose: front-end or backend development?

Regarding web development, two main areas play a crucial role in creating a functional and visually appealing website: frontend and backend development. Frontend development focuses on the…

Read More

Top 10 Construction Management Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction Construction Management Software (CMS) has become indispensable in 2026 for efficiently handling various aspects of construction projects, ranging from budgeting, scheduling, resource allocation, project tracking, to…

Read More

Top 10 Personal Finance Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction In the fast-paced world of 2026, managing personal finances efficiently is more crucial than ever. With rising inflation, economic uncertainties, and the complexity of multiple financial…

Read More

Top 10 AI Pricing Optimization Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI pricing optimization tools have become indispensable for businesses navigating the complexities of dynamic markets. These tools leverage artificial intelligence, machine learning, and real-time…

Read More

Top 10 On-premise Backup Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, on-premise backup tools are still essential for businesses that need complete control over their data security and disaster recovery plans. Unlike cloud-based solutions, on-premise…

Read More

Top 10 Server Backup Tools in 2026: Features, Pros, Cons & Comparison

Introduction Server backup tools are essential for businesses in 2026 to ensure the safety, security, and reliability of their data. With the growing threats of cyberattacks, hardware…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x