Asynchronous scanning strategies
When scanning a large monorepo, a common approach taken by security teams is to run an asynchronous cron job outside a CI/CD-based environment. This is often the point of least friction but is prohibitive. With this approach, inline blocking of critical issues is not generally possible. We would be remiss not to mention this as a scanning strategy for monorepos but this approach is NOT recommended beyond a step to get initial visibility into a large monorepo.Performance Enhancements for inline scanning strategies
The following performance enhancements may be used with Endor Labs to enable the scanning of large monorepos:Scoping scans based on changed files
For many CI/CD systems path filters are readily available. For example, with GitHub Actions, dorny path filters is a readily accessible way to establish a set of filters by a path. This is generally the most effective path to handle monorepo deployments but does require the highest level of investment in terms of human time. The human time investment is made up for by the time saved by reducing the need to scan everything on each change. Based on the paths that change you can scope scans based on the files that have actually changed. For example, you can scan only the packages in a monorepo that are housed under theui/ directory when this path has changed by running a scan such as endorctl scan --include-path=ui/** when this path has been modified.
Using a path filtering approach each team working in a monorepo would need to be responsible for the packages that they maintain, but generally, each team may be associated with one to several pre-defined directory paths.
Parallelizing scans for many packages
When scanning a large monorepo organizations can choose to regularly scan the whole monorepo based on the packages or directories they’d like to scan. Different jobs may be created that scan each directory simultaneously.Parallelizing with scoped scans
Using scoped scans for monorepos with multiple parallel include patterns is a common performance optimization for monorepos. The following example shows parallel GitHub action scan that you can use as a reference.ui/ and backend/ are both scanned simultaneously and the results are aggregated by Endor Labs. This approach can improve the overall scan performance across a monorepo where each directory can be scanned independently.
To include or exclude a package based on its directory.