Monorepos make shared code and coordinated releases easier, but they also complicate security scanning. This checklist explains how to define scan scope, assign ownership, choose scan frequency, and reduce duplicate or misrouted findings across services, libraries, infrastructure, and shared dependencies.
Overview
A monorepo should be treated as one source repository with several security-relevant units. A service, package, deployment chart, infrastructure module, or mobile client may have its own build process, data sensitivity, runtime exposure, and owning team. Scanning the entire repository as one undifferentiated project often creates noisy results. Scanning every directory independently can produce duplicate findings and inconsistent policy decisions.
The practical goal is to create logical scan projects inside the repository. Each project should have a defined path, build context, owner, deployment relationship, and reporting destination. The repository remains the source of truth, while security findings are grouped according to the component that can fix them.
Use the three common application security methods for different questions. SAST examines source or compiled code for insecure patterns. SCA identifies vulnerable or noncompliant open-source dependencies. DAST tests a running application from the outside and is usually mapped to deployable services rather than source directories. Container and infrastructure scans should likewise follow image, deployment, or infrastructure ownership rather than the repository root alone. For background on how these methods fit together, see SAST vs DAST vs SCA by development stage.
A simple repository-scope matrix
| Repository unit | Primary scans | Typical owner | Useful frequency |
|---|---|---|---|
| Deployable service | SAST, SCA, container, DAST | Service team | Pull request, build, and scheduled |
| Shared library | SAST, SCA, license or policy checks | Library maintainer or consuming team | Pull request and dependency update |
| Infrastructure module | Infrastructure-as-code and secret scanning | Platform or infrastructure team | Pull request and scheduled |
| Deployment configuration | Configuration, image, and manifest checks | Platform or service team | Pull request and release |
| Documentation and tests | Secret scanning; targeted code checks where applicable | Directory owner | Pull request or repository scan |
The matrix is a starting point, not a universal policy. Adjust it when a directory contains several applications, when a shared library is highly sensitive, or when a tool cannot resolve the repository's build structure reliably.
Checklist by scenario
When adding a new service
- Define the service root, source paths, test paths, generated files, and build files.
- Record the production artifact: package, container image, function, or deployable bundle.
- Assign a technical owner and a backup owner using the same directory or project naming convention used by code review.
- Connect the service to its dependency lockfile, container definition, deployment manifests, and runtime endpoint.
- Run SAST and SCA in the pull request workflow, then run the same logical scan in the release or main-branch workflow.
- Set a scheduled scan for changes that may not be introduced by a pull request, such as newly disclosed dependency vulnerabilities.
A scanner should know which files belong to the service and which files are shared. If the service imports a library from another workspace package, record that relationship instead of copying the library into the service's scan scope.
When scanning shared libraries
- Scan the library's own source and manifest once as its primary project.
- Scan consuming services in their build context so transitive dependency exposure is visible where the artifact is used.
- Designate one owner for fixing issues in the library and define how consuming teams are notified.
- Separate vulnerabilities in the library from vulnerabilities caused by an unsafe use pattern in a consuming service.
- Exclude generated bundles only when their source and build output are covered elsewhere and the exclusion is documented.
This approach prevents one shared dependency from generating a separate, apparently unrelated finding for every service. It also preserves context: a vulnerable package may have different exposure depending on which product includes it and how it is deployed.
When using a single CI/CD workflow
- Pass the changed paths, affected projects, or dependency graph into the scanner when supported.
- Run fast checks for changed projects on pull requests.
- Run a broader repository or organization scan on the main branch or on a schedule.
- Keep finding identifiers stable when possible so repeated results are updated rather than recreated.
- Publish results to the project or team that can remediate them, not only to a central security queue.
For decisions about whether a result should block a merge, use a documented gate based on severity, exploitability, exposure, confidence, and available remediation—not simply the number of findings. The CI/CD build-gate guide provides a separate framework for that decision.
When the repository includes APIs or public applications
- Map each deployed API or web application to its source project and runtime environment.
- Use DAST or API security scanning against the deployed service, with authentication handled through a safe test account where needed.
- Keep staging and production targets distinct in the scanner configuration.
- Assign runtime findings to the service owner, even when the source code is maintained in a shared platform directory.
- Record route or endpoint ownership so findings do not default to the repository administrator.
Source scanning and runtime scanning answer different questions. A monorepo scope plan should connect their results without treating them as duplicate evidence. See the API security scanning guide for practical coverage considerations.
What to double-check
Path boundaries and exclusions
Review every include and exclude pattern. Confirm that exclusions cover only generated output, vendored code, fixtures, or other intentionally unscanned content. A broad pattern such as an entire packages or src directory can silently remove important coverage. Keep an inventory of excluded paths with an owner and a reason.
Build and dependency context
SAST and SCA results become less reliable when the scanner uses the wrong working directory, package manager, lockfile, compiler settings, or workspace configuration. Test a representative project from a clean checkout. Confirm that the scanner resolves internal workspace packages and does not treat every local package as an external, duplicated dependency.
Ownership metadata
Use a path-to-owner template that is easy to review:
project: payments-api
paths: services/payments/**
artifacts: payments-api, payments-worker
code_owner: payments-team
security_contact: appsec-oncall
scan_types: sast, sca, container, dast
review_cadence: pull-request, main-branch, weekly
shared_dependencies: packages/auth, packages/logging
Store this metadata near the repository configuration or in the system that manages security projects. Keep team names, escalation contacts, and artifact names consistent across code review, CI/CD, vulnerability management, and compliance evidence. The compliance-ready vulnerability management workflow covers why ownership and evidence should be connected.
Duplicate and inherited findings
Before suppressing a repeated finding, determine whether it is the same underlying issue or several separate instances. A vulnerable shared package may legitimately appear in multiple deployable artifacts. Grouping can reduce noise, but do not hide a service's distinct exposure, reachable code path, or remediation deadline. Capture the parent dependency, affected artifacts, and the action required from each owner.
Finding triage
Check whether the result contains enough context to act: file and line, package or artifact, affected project, reachable environment, confidence, first-seen date, and remediation guidance. Risk-based prioritization can help teams handle shared dependencies without assigning every alert the same urgency. See the vulnerability prioritization framework for a broader triage model.
Common mistakes
- Scanning only the repository root: The tool may miss project-specific build context or report an unhelpful combined result.
- Creating one security project per directory: This can multiply findings when a shared library is imported by many services.
- Assigning everything to the platform team: Central ownership may be convenient, but it delays fixes when the service team controls the code or deployment.
- Using the same frequency for every component: A public API, internal library, and inactive documentation folder do not require identical scheduling.
- Ignoring generated files without verification: Generated output can contain secrets or security-relevant behavior. Exclude it only when the generating source and artifact are covered appropriately.
- Suppressing findings globally: A false positive in one project may be valid in another. Prefer narrow, documented suppressions with an expiration or review date.
- Changing scanner configuration without testing history: Scope changes can reopen old findings, close results, or alter identifiers. Review the effect before applying a new configuration broadly.
When to revisit
Review the monorepo scanning plan before seasonal planning cycles and whenever workflows or tools change. A useful review trigger is any event that changes the relationship between code, artifacts, owners, or runtime environments.
- A service or package moves to a different directory.
- A team takes ownership of an existing component or a team is reorganized.
- A shared library gains new consumers or becomes externally exposed.
- The build system, package manager, workspace layout, or lockfile format changes.
- A new container, cloud resource, API, or deployment target is introduced.
- Scanner configuration, rules, integrations, or finding identifiers change.
- Repeated findings suggest that scope, deduplication, or ownership is not working.
- An audit, incident review, or release retrospective identifies missing evidence or unclear remediation responsibility.
To make the review actionable, export the current project list and compare it with the repository's deployable artifacts and ownership files. Sample each scan type: one service, one shared library, one infrastructure module, and one generated-output path. Confirm that findings reach the right team, that scheduled scans still run, and that exclusions remain justified. Then update the scope matrix, ownership template, and CI/CD configuration together.
A monorepo security program does not need every directory to follow the same scan rule. It needs clear boundaries, repeatable ownership, appropriate frequency, and enough context for developers to fix what they receive. Revisit those decisions whenever the repository's structure or delivery model changes.