Skip to content

Entry points and uses the call graph misses, now affecting dependency reachability #48

Backlog

Description

@matiasdaloia

Problem

Project reachability reads some live functions as unreachable because nothing in the call graph calls them and no entry-point rule roots them. Until now this only affected findings in the scanned project's own code. crypto-finder is about to use the same verdict to decide which calls into a dependency count, so a dependency reached only through one of these functions will read unreachable.

Found while reviewing the functions left out on eight open source projects (Go, Rust, Python, Java, JavaScript/TypeScript). No verdict changed on the 1,686 dependency findings measured, so this is exposure, not an observed regression.

Missed kinds

  • Go: cgo //export functions. They are called from C, Objective-C or through FFI, never from Go. A shared library built with -buildmode=c-shared has no other entry point.
  • Function used as a value that also has a dead direct caller. A function assigned to a variable or field (x.Run = pkg.RunConfirm) is protected only when it has no direct caller at all. One dead direct caller removes the protection.
  • Rust: call through an .await chain that does not resolve. The only resolved callers left are inline tests, so the function reads as test-only.
  • JavaScript: framework hooks by export convention. For example Gatsby's exports.sourceNodes in gatsby-node.js.
  • JSX: a component used only as an element. <WalletsButton /> is not seen as a use of WalletsButton.
  • JavaScript: a module loaded by path through a bundler, for code that runs in another runtime (a script injected into a browser page).
  • Python: PEP 562 module __getattr__, and functions called only from code held in strings.

Suggested order

cgo //export and value references to called functions first: both are common in ordinary Go code and both are structural rules with no framework knowledge.

Related, product decision rather than a gap

A package that ships both a library API and a main reads its library-only functions as dead, which is right for the program and wrong for someone embedding the library.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions