Safeguard
General•

How to Run Offline Reachability Analysis on Dependency Trees Without Sending Code to Your Cloud Provider

Learn how to parse call graphs and check active dependency reachability locally without leaking proprietary source code to external SaaS tools.

Safeguard Team
5 min read

The Problem with Cloud Dependency Scanners

Traditional software composition analysis tools require you to upload your source code, your dependency trees, or your compiled artifacts to a remote SaaS backend. Once your code leaves your perimeter, you lose direct control over its retention, processing, and downstream indexing. For teams working on proprietary algorithms, financial platforms, or sensitive internal tooling, this trade-off is unacceptable.

Yet, teams still need to answer a critical operational question when a new vulnerability drops: Is this dependency actually reachable in our execution path, or is it just sitting dead in a lockfile? If you rely solely on lockfile analysis, every transitive vulnerability looks like an active emergency. You end up wasting engineering cycles patching code that never executes in production.

Running reachability analysis offline solves this problem. By constructing call graphs and analyzing function invocations locally on your build server or developer workstation, you can determine if vulnerable symbols are ever called without a single line of source code leaving your machine.

What Reachability Analysis Actually Does

Dependency scanners traditionally look at package manifests like package.json, go.mod, pom.xml, or generated SBOMs. They match package names and versions against a database of known vulnerabilities. If lodash@4.17.20 is in your tree, you get an alert.

Reachability analysis goes one step further by performing static call graph construction. It parses your source code and your dependencies to answer a specific question: Does an execution path exist from your application entry points to the vulnerable function within the dependency?

If the function is never imported, never referenced, or dead-code eliminated during compilation, the vulnerability is unreachable. You can deprioritize the patch without accepting blind risk.

Step-by-Step Developer Journey: Local Call Graph Parsing

Let us walk through how to perform local reachability analysis on a Go project using static analysis tooling, entirely offline.

Step 1: Generate the Local Module Graph

First, ensure your module dependencies are downloaded to your local module cache. You do not need an active internet connection if your workspace is already populated.

go mod graph > module-graph.txt

This generates a flat list of dependency relationships. To inspect the graph without uploading anything, run a local query tool over the file.

Step 2: Parse Abstract Syntax Trees (AST) Locally

Instead of sending your source files to an external API, use local language parsers to build an Abstract Syntax Tree and extract function references. For Python, you can use the built-in ast module; for JavaScript/TypeScript, use typescript compiler APIs; for Go, use go/packages and go/ssa (Static Single Assignment representation).

Here is a short, runnable Go program that loads your local package graph and inspects function calls without making any external network requests:

package main

import (
	"fmt"
	"go/packages"
	"log"
)

func main() {
	cfg := &packages.Config{
		Mode: packages.NeedName | packages.NeedSyntax | packages.NeedTypes | packages.NeedImports,
	}

	pkgs, err := packages.Load(cfg, "./...")
	if err != nil {
		log.Fatalf("failed to load packages: %v", err)
	}

	for _, pkg := range pkgs {
		fmt.Printf("Analyzing package: %s\n", pkg.PkgPath)
		for _, file := range pkg.Syntax {
			for _, decl := range file.Decls {
				// Inspect local declarations and cross-reference imports
				_ = decl
			}
		}
	}
}

Compile and run this directly on your machine:

go run analyze.go

Step 3: Match Symbols Against Vulnerability Signatures

Once you have built your local call graph, map the identified function signatures against a locally stored database of vulnerable symbols. A proper local database contains the exact package name, version range, and the specific fully qualified function or method name introduced or affected by the CVE.

If your code calls vulnerableFunc from example.com/badpkg, but your call graph shows zero inbound edges from your entry points to that symbol, you have proof of unreachability.

Fix It Without Waiting for Upstream

When an offline reachability scan confirms that a vulnerability is indeed reachable, you often cannot wait for the upstream maintainer to push a release. Here is how engineering teams handle remediation locally:

  1. Function-level patch / monkey patching: If the vulnerable function is small, write a local override or wrapper that sanitizes inputs before passing them to the dependency.
  2. Dead code pruning: If the reachability analysis shows that only a specific helper file triggers the vulnerable path, refactor your imports to drop that module entirely.
  3. Vendor and modify: For languages that support source vendoring (such as Go with vendor/ directories), modify the local copy of the source code directly in your repository, bypassing the need to wait for a published release.

By keeping the entire pipeline local, your intellectual property stays on your hardware while giving you precise, actionable data on actual code exposure.

Internal Links and Further Reading

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

We email you a link to confirm, and only then add you to the list. Unsubscribe in one click. Privacy

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.