Admit application release modules to Forge

23b4f8a5962e · AtlantisPleb · · parent 943a7b8e7733

Admit application release modules to Forge

Deploy story

What this commit did to the running system — joined from the forge receipt chain, the part a commit page elsewhere cannot show.

Not deployed through the forge lane

No push, promotion, build, or deploy receipt references this commit (receipts are scanned over a bounded recent window). Changes shipped by full node replacement carry their proof in the release gate receipt instead.

Changed files

  • modified lib/openagents/forge/build_artifact.ex
  • modified test/openagents/forge/build_artifact_test.exs

Diff

2 files changed, +35 -2

lib/openagents/forge/build_artifact.ex modified +5 -2

@@ -16,13 +16,16 @@ defmodule OpenAgents.Forge.BuildArtifact do

16 16
  @max_artifact_bytes 32 * 1_048_576
17 17
  @max_manifest_bytes 1_048_576
18 18
  @max_beam_bytes 4 * 1_048_576
19
  @max_modules 512
19
  @max_modules 2_048
20 20
  @manifest_keys ~w(schema build_id repo source_sha baseline toolchain classification structural_reasons changes modules)
21 21
  @toolchain_keys ~w(elixir otp erts application_version application_spec_sha256 mix_lock_sha256)
22 22
  @change_keys ~w(added changed deleted)
23 23
  @module_keys ~w(name sha256 size)
24 24
  @classification ~w(direct_candidate needs_rolling_replace)
25
  @module_pattern ~r/^Elixir\.OpenAgents(?:\.[A-Za-z][A-Za-z0-9_]*)+$/
25
  # Keep atom creation bounded to module namespaces owned by this OTP
26
  # application. The release contains the two application roots, generated
27
  # Inspect implementations, and Mix tasks in addition to OpenAgents.*.
28
  @module_pattern ~r/^Elixir\.(?:(?:OpenAgents|OpenAgentsWeb)(?:\.[A-Za-z][A-Za-z0-9_]*)*|Inspect\.(?:OpenAgents|OpenAgentsWeb)(?:\.[A-Za-z][A-Za-z0-9_]*)+|Mix\.Tasks\.(?:OpenAgents|Openagents)(?:\.[A-Za-z][A-Za-z0-9_]*)+)$/
26 29
27 30
  @type beam :: %{module: String.t(), binary: binary()}
28 31
  @type verified :: %{
test/openagents/forge/build_artifact_test.exs modified +30

@@ -192,6 +192,30 @@ defmodule OpenAgents.Forge.BuildArtifactTest do

192 192
    assert {:error, :invalid_artifact_entry} = BuildArtifact.verify(tar_bytes(traversal))
193 193
  end
194 194
195
  test "application-owned release module namespaces are admitted" do
196
    build_id = Ecto.UUID.generate()
197
198
    beams = [
199
      loaded_beam(OpenAgents),
200
      loaded_beam(OpenAgentsWeb),
201
      loaded_beam(Inspect.OpenAgents.Accounts.User),
202
      loaded_beam(Mix.Tasks.Openagents.Config.Readiness)
203
    ]
204
205
    assert {:ok, artifact} =
206
             BuildArtifact.pack(@repo, @sha, build_id, beams,
207
               toolchain: BuildArtifact.current_toolchain()
208
             )
209
210
    assert artifact.manifest["changes"]["added"] ==
211
             Enum.sort([
212
               "Elixir.Inspect.OpenAgents.Accounts.User",
213
               "Elixir.Mix.Tasks.Openagents.Config.Readiness",
214
               "Elixir.OpenAgents",
215
               "Elixir.OpenAgentsWeb"
216
             ])
217
  end
218
195 219
  defp compile_beam(suffix, value) do
196 220
    module = "OpenAgents.Scratch.#{suffix}"
197 221

@@ -203,6 +227,12 @@ defmodule OpenAgents.Forge.BuildArtifactTest do

203 227
    %{module: "Elixir." <> module, binary: binary}
204 228
  end
205 229
230
  defp loaded_beam(module) do
231
    assert {:module, ^module} = Code.ensure_loaded(module)
232
    {^module, binary, _path} = :code.get_object_code(module)
233
    %{module: Atom.to_string(module), binary: binary}
234
  end
235
206 236
  defp tar_bytes(entries) do
207 237
    path = Path.join(System.tmp_dir!(), "artifact-test-#{System.unique_integer([:positive])}.tar")
208 238
    :ok = :erl_tar.create(String.to_charlist(path), entries)

This page updates live while a promote is in flight · changelog