Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endpoint to parse contract imports and pragmas #103

Open
davidyuk opened this issue Aug 29, 2022 · 1 comment
Open

Endpoint to parse contract imports and pragmas #103

davidyuk opened this issue Aug 29, 2022 · 1 comment

Comments

@davidyuk
Copy link
Member

I need to compile a contract created by user, it may contain some imports of files that I should pass to compiler in file_system option. I have access to file system, but I don't know what files imported. For privacy reasons I may not want to pass all local files in file_system option, also I don't want to implement an import parser as an error-prone approach. So I need an endpoint that accepts a single sophia file and return an array of its imports.

Additionally, would be nice to have a way to distinguish imports defined by language (a standard library?) and that ones that should be accessible in a local filesystem.

Pragmas parsing would help to identify a compatible compiler in case multiple available.

For example, for code:

@compiler >= 5

include "Option.aes"
include "String.aes"

contract FungibleTokenFull =
...

It should return something like this:

{
  "includes": ["Option.aes", "String.aes"],
  "pragmas": {
    "compiler": [["gte", 5]]
  }
}
@davidyuk
Copy link
Member Author

Then a malicious compiler can return something like "includes": ["~/.ssh/id_rsa"] and potentially get this file in file_system options. I don't know what's wrong with this architecture.

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

No branches or pull requests

1 participant