Skip to content

src/generated is a bare string literal replicated across two repos' code, config and CI #77

Description

@thedavidmeister

Audit scope: whole-repo, commit 7aa85a4

Dimension 6 (hazard surface) · severity medium

Where

Problem

One concept — where generated code lives — is spelled out independently in
seven-plus places across rain.sol.codegen and rainix, and changing the
canonical one disables checks silently rather than loudly.

GENERATED_DIR is the constant, but foundry.toml:32's fs_permissions grant,
the README, the test literals, and three separate rainix mechanisms all
restate the path by hand: rainix-copy-artifacts.yaml's [ -d src/generated ]
guard, rainix-sol-static.yaml's frozen-snapshots-append-only action, and
rainix-autopublish.yaml's soldeer content gate, which excludes src/generated/
when hashing normalized package content. None derives the path from the
constant, and no test asserts they agree.

Scenario: GENERATED_DIR is changed (to src/gen, or to include a
subdirectory). The fs_permissions grant no longer matches, so the write is
refused — loud, and the change gets "fixed" by editing foundry.toml. Three
consequences then land silently: rainix-copy-artifacts's [ -d src/generated ]
guard is now false, so a repo committing generated sources without
script/Build.sol is no longer hard-failed; frozen-snapshots-append-only stops
policing the frozen deploy-pin snapshots; and the autopublish content gate stops
excluding generated files, so every regeneration counts as a content change and
the package republishes on runs that changed nothing.

Proposed fix

Make the path a single canonical fact the checks read, not restate. In this
repo, one test that ties the constant to the grant it needs — the repo already
grants { access = "read", path = "foundry.toml" }, currently read by nothing,
which is exactly what makes this assertable:

/// The write only works while foundry.toml grants read-write on the directory
/// the constant names. Two spellings of one fact, asserted to agree.
function testGeneratedDirIsGranted() external view {
    assertTrue(
        vm.contains(vm.readFile("foundry.toml"), string.concat("path = \"", GENERATED_DIR, "\"")),
        "GENERATED_DIR is not the path fs_permissions grants"
    );
}

In rainix, the three workflow-side literals should read one value (a repo-level
input or a single RAINIX_GENERATED_DIR env in the reusables) rather than each
hardcoding src/generated. Shared CI is rainix's to own, so that half is filed
separately at rainlanguage/rainix#313

Activity

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

Metadata

Metadata

Labels

auditAudit findingmediumAudit findingpass6Audit finding

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions