Best Practices: Scoping scans
Exclude and include filters help your team to focus their attention on the open source packages that matter most and to improve scan performance. Use inclusion patterns when you have many packages that you want to scan separately and exclusion patterns when you want to filter out packages that are not important to you.
You can include or exclude packages using the following standard patterns:
- Include or exclude specific packages.
- Include or exclude specific directories.
- Include or exclude with a Glob style expressions.
- Use include and exclude patterns together to exclude specific directories such as a test directory from a scan.
- Use multiple include and exclude patterns together to exclude or include specific directories or file paths.
Scoping scans with endorctl
To include or exclude a package based on its file name when you scan with endorctl.
endorctl scan --include-path="path/to/your/manifest/file/package.json"
endorctl scan --exclude-path="path/to/your/manifest/file/package.json"
To include or exclude a package based on its directory
endorctl scan --include-path="directory/path/**"
endorctl scan --include-path="src/java/**"
endorctl scan --exclude-path="path/to/your/directory/**"
endorctl scan --exclude-path="src/ruby/**"
Examples of scoping scan
The following examples show how you can use scoping scans.
Use --exclude-path="src/java/**"
to exclude all files under src/java, including all its subdirectories.
endorctl scan --exclude-path="src/java/**"
Use --exclude-path=src/java/*
to only exclude the files under src/java, but not its subdirectories.
endorctl scan --exclude-path=src/java/*
Use --include-path
and --exclude-path
together to exclude specific directories such as test directories.
endorctl scan --include-path="src/java/**" --exclude-path="src/java/test/**"
Use multiple inclusion patterns together.
endorctl scan --quick-scan --include-path="src/java/**" --include-path="src/dotnet/**"
- Use multiple exclusion patterns together.
endorctl scan --include-path="src/java/**" --exclude-path="src/java/gradle/**" --exclude-path="src/java/maven/**"
Best practices of scoping scans
Here are a few best practices of using scoping scans:
- Ensure that you enclose your exclude pattern in double quotes to avoid shell expansion issues. For example, do not use
--exclude-path=src/test/**
, instead, use--exclude-path="src/test/**"
. - Inclusion patterns are not designed for documentation or example directories. You cannot explicitly include documentation or example directories:
docs/
documentation/
groovydoc/
javadoc
man/
examples/
demos/
inst/doc/
samples/
- The specified paths must be relative to the root of the directory.
- If you are using JavaScript workspaces, take special consideration when including and excluding the root package:
- When using include or exclude patterns, it’s crucial to make sure you never exclude and always include the parent workspace package. Otherwise, all child packages won’t build properly.
- You can always exclude child packages in the workspace if the root is included.
- There is only one lock file for the workspace that exists in the workspace root directory. Make sure to include the lock file to perform a successful scan.
Feedback
Was this page helpful?
Thanks for the feedback. Write to us at support@endor.ai to tell us more.
Thanks for the feedback. Write to us at support@endor.ai to tell us more.