Skip to content

Parse rebar.config deps and plugins and OTP application metadata from *.app.src - #174

Merged
andrew merged 2 commits into
git-pkgs:mainfrom
abhinavgautam01:erlang-rebar-config-app-src
Dec 2, 2026
Merged

andrew merged 2 commits into
git-pkgs:mainfrom
abhinavgautam01:erlang-rebar-config-app-src

Conversation

@abhinavgautam01

Copy link
Copy Markdown
Contributor

Part of #77 (the Erlang and Elixir item).

Summary

Adds two hex manifest parsers in internal/rebar, next to the existing rebar.lock parser, on top of a small Erlang term reader.

Erlang term reader

internal/rebar/term.go reads dot-terminated terms the way file:consult/1 does: tuples, lists, quoted and bare atoms, strings (adjacent literals joined), binaries (string segments kept, size and type specifiers skipped), integers, floats, based integers such as 16#ff, character literals, maps, list tails and % comments. Anything else, such as a ?MACRO, is a ParseError with a line number, since file:consult/1 rejects it too.

rebar.config

Entry Result
jsx Name: jsx, no version
{cowboy, "2.10.0"}, {lager, "~> 3.9"} version kept as written
{jiffy, "1.1.1", {pkg, jiffy_fork}} Name: jiffy_fork (the Hex package), location deps/jiffy
{recon, {git, URL, {tag, "2.5.3"}}} git source with Tag; branch and ref go to Branch and Ref
{app, {git_subdir, URL, Spec, "dir"}} git source with the directory in Rel
{app, {hg, URL, Spec}} url source
{legacy, ".*", {git, URL, "HEAD"}} (rebar2) the version regex is dropped, a bare string spec goes to Ref
  • Top-level deps are runtime.
  • deps inside profiles are test for the test profile, runtime for prod and development for any other profile, under profiles/<profile>/deps/<app>.
  • plugins and project_plugins are build wherever they appear.
  • Git dependencies keep their name and PURL with the source recorded, as Cargo.toml git dependencies do.

*.app.src

  • Name and Version come from {application, Name, [...]} and vsn. A vsn of git or {cmd, ...} is not a version and is left empty.
  • licenses fills Licenses, description fills Metadata.Description and each links entry is a Metadata.Links item with its own label.
  • applications and included_applications are versionless runtime dependencies. Entries in optional_applications (which OTP 24 also requires in applications) are reported once with optional scope.
  • Applications that ship with Erlang/OTP or Elixir (kernel, stdlib, crypto, ssl, logger, elixir and so on) are skipped since they are not Hex packages.

Tests

  • internal/rebar/term_test.go covers each term form and the syntax errors.
  • internal/rebar/config_test.go covers every dependency form in the fixture with scopes and locations, malformed entries, nested profiles and invalid input.
  • internal/rebar/appsrc_test.go covers the fixture with metadata, licenses and optional applications, git and {cmd, ...} versions, built-in applications, non-application terms and invalid input.
  • rebar_manifests_test.go goes through Parse, checking PURLs for renamed packages and dependencies.
  • New rows in TestIdentifyFiles, TestParseAllEcosystems, TestParseName and TestParseDeclaredLicenses.
  • Fixtures: testdata/rebar/rebar.config and testdata/rebar/myapp.app.src.
  • README: both files in the ecosystem table, a line in the Metadata section and an "Erlang output" section.

go build ./..., go vet ./..., go test ./... and golangci-lint run ./... all pass.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1c3a790c-1c5b-416c-a52c-ce1f58d9fc4c
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The term reader in internal/rebar/term.go recurses through term, sequence, list, binary and mapTerm with no depth limit, so the nesting depth of the input sets the depth of the Go stack. A rebar.config or *.app.src made of a long enough run of [ would exhaust the stack, which in Go is a fatal error that bypasses recover and exits the calling process. These files come from scanned repositories, so add a depth counter to termReader that returns a parse error past a fixed limit, with a test for it. maxNpmOverrideDepth in internal/npm/overrides.go is the equivalent limit for npm overrides. The {pkg, Name} renames, the rebar2 version regex and the profile scopes all match how rebar3 reads these files, so the depth limit is the only change needed.

@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

Thanks. termReader now tracks depth in term(), which every tuple, list, binary and map goes through. Past maxTermDepth (100) it returns a parse error. I went higher than npm's 32 because exceeding the limit here fails the whole file rather than skipping a subtree, and real rebar configs nest only a few levels. Tests check that 100 levels parse, 101 fail, and a million { or [ as well as deeply nested binaries and maps all fail with the depth error. I added a line about the limit to the README too.

@andrew
andrew merged commit 7bd3914 into git-pkgs:main Dec 2, 2026
3 checks passed
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.

2 participants