Skip to content

feat(elixir): emit dependency relationships from mix.lock#4985

Open
cgreeno wants to merge 2 commits into
anchore:mainfrom
cgreeno:feat/elixir-mix-lock-relationships
Open

feat(elixir): emit dependency relationships from mix.lock#4985
cgreeno wants to merge 2 commits into
anchore:mainfrom
cgreeno:feat/elixir-mix-lock-relationships

Conversation

@cgreeno

@cgreeno cgreeno commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

TLDR

We are missing the ability to distinguish transitive/direct dependencies when running SBOM on our Elixir codebase. Followed the structure I found in other parts of the code base, going to add this for Elixir and Ruby. Link the ruby PR as well when I am done it.

Description

The Elixir cataloger catalogued packages from mix.lock but discarded each entry's dependency list, so it emitted no relationships. Every mix.lock entry already encodes its own dependencies (the 6th element of the entry tuple, e.g. {:cowlib, ...}, {:ranch, ...}), so the dependency graph is derivable from data already in the file... no new inputs required.

This change emits dependency-of relationships between locked packages, using the same shared dependency.Processor / Specifier mechanism that the alpine, arch, debian, redhat, and python catalogers already use to express their dependency graphs. It is purely additive: a new optional metadata field plus relationships; package cataloging itself is unchanged.

Changeset:

File Change
syft/pkg/elixir.go add Dependencies []string to ElixirMixLockEntry
syft/pkg/cataloger/elixir/parse_mix_lock.go extract dependency names from each entry's dependency list (the entry's own source tuple is skipped)
syft/pkg/cataloger/elixir/dependency.go (new) mixLockDependencySpecifier declaring Provides=[name], Requires=[deps]
syft/pkg/cataloger/elixir/cataloger.go register dependency.Processor(mixLockDependencySpecifier)
internal/constants.go JSON schema 16.1.4 → 16.1.5
schema/json/schema-16.1.5.json (new) + schema-latest.json regenerated
dependency_test.go (new), parse_mix_lock_test.go, cataloger_test.go + fixture unit tests for extraction and the specifier, plus a cataloger-level test asserting the resolved relationships

Schema: bumped 16.1.4 → 16.1.5 additive only (a new optional dependencies field on ElixirMixLockEntry), compatible with all historical data per the SchemaVer ADDITION rule.

Type of change: New feature (non-breaking) adds relationship data without altering existing package output.

The Elixir cataloger only catalogued packages from mix.lock; it discarded
each entry's dependency list and emitted no relationships. This adds
dependency-of relationships between locked packages, matching how other
ecosystem catalogers (alpine, arch, debian, redhat, python) express the
dependency graph via the shared dependency.Processor/Specifier mechanism.

- ElixirMixLockEntry gains a Dependencies field (the names from the entry's
  dependency list — the 6th element of each mix.lock tuple).
- parseMixLock extracts those names; the entry's own source tuple is skipped.
- A mixLockDependencySpecifier declares Provides=[name], Requires=[deps] and
  is registered via dependency.Processor on the cataloger.
- JSON schema bumped 16.1.4 -> 16.1.5 (additive: new optional field).

Tests: unit tests for the extractor and specifier, and a cataloger-level
test asserting the resolved dependency-of relationships.

Signed-off-by: Chris Greeno <cgreeno@gmail.com>
@oss-housekeeper

oss-housekeeper Bot commented Jun 16, 2026

Copy link
Copy Markdown

Schema Change Detection

New Schemas

  • schema/json/schema-16.1.6.json

@cgreeno

cgreeno commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

⬆️ PR applying the same approach to Ruby Gemfile.lock: #4986

@cgreeno

cgreeno commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@wagoodman - you appear to be the main owner? Sorry if I got the wrong end of the stick. --> Same approach on this PR #4986

Signed-off-by: Chris Greeno <cgreeno@gmail.com>

# Conflicts:
#	internal/constants.go
#	schema/json/schema-16.1.5.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant