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

Top 10 Integration Platform as a Service (iPaaS) Tools in 2026: Features, Pros, Cons & Comparison

Introduction In todayโ€™s fast-paced digital world, businesses are leveraging multiple software applications, cloud services, and data sources to streamline operations. However, the challenge lies in integrating these…

Read More

IReviewed Blog’s Post List

truereviewnow.com is a portal for product review and rating. truereviewnow.com is having very in-depth analysis of review and testimony of Mobiles, Laptop, Electronics Gadgets, Airports, Boradbands, Movies…

Read More

Top 10 Social Media Management Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, social media continues to be a cornerstone of digital marketing strategies, shaping how businesses connect with their audiences. With millions of users interacting on…

Read More

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

Introduction In 2026, drones are not only revolutionizing industries like agriculture, logistics, filmmaking, and construction, but also the way we collect and process data. Drone software is…

Read More

Top 10 AI Survey Automation Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI Survey Automation Tools are transforming the way businesses, researchers, and organizations gather and analyze feedback. Traditional survey platforms often relied on static questions…

Read More

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

Introduction In 2026, AI animation tools are revolutionizing how creators, businesses, and educators bring stories to life, making animation accessible to all skill levels. These tools leverage…

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