Skip to content

Bug: Users can override the crate keyword as a DRP name #310

@LesterEvSe

Description

@LesterEvSe

Project version

master (unreleased)

Project

driver

What happened?

Currently, because users can interact directly with the DependencyMap API in SimplicityHL, they can manually set the crate keyword to any path they want. This happens because the insert method allows adding the crate alias without throwing any validation errors.

Fix Suggestion

There are two potential ways to solve this problem:

  1. Add validation checks inside the insert method to explicitly forbid using the crate keyword.
  2. Make the insert method inside the DependencyMap struct private to external crates. Instead, implement the From<Vec<Remapping>> trait to handle conversions and perform all necessary validations at that stage.

Minimal reproduction steps

Using SDK, if you insert a mapping like the one below, it will be accepted by the compiler without any errors:

DependencyMap {
    inner: [
        Remapping {
            context_prefix: CanonPath(
                "/home/user/SimplicityHL/program",
            ),
            drp_name: "crate",
            target: CanonPath(
                "/home/user/another-dir/",
            ),
        },
    ],
}

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions