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

document correct usage for library authors #20

Merged
merged 2 commits into from Nov 22, 2022
Merged

document correct usage for library authors #20

merged 2 commits into from Nov 22, 2022

Conversation

w4rum
Copy link
Contributor

@w4rum w4rum commented Nov 18, 2022

This addresses #11:

When using another smart-contract as dependency it also generates it's security.txt.
The compiler is helpful here and prevents two conflicting security.txt being present.

Dependencies have to omit emitting the security.txt. Solana contracts already use the no-entrypoint feature to avoid including entrypoints of dependent smart-contracts, this can easily be adapted here.

We have brainstormed a bit, but there doesn't seem to be a fool-proof solution for solving this automatically. So there isn't much we can do about that from the perspective from this crate. The decision to include or not include the macro always has to happen from the caller, and we cannot introspect if the parent is compiled with no-entrypoint.

This aspect is currently lacking from the documentation, working on a pull-request to fix this, and make it very clear that if you expect to be included as dependency and have an exposed no_entrypoint feature, you have to put the security.txt under that as well:

#[cfg(not(feature = "no-entrypoint"))]
security_txt! {
...
}

Unfortunately, this issue means contracts that currently do not do this cannot be used as a dependency until they are updated.

@w4rum w4rum requested a review from tlambertz November 18, 2022 16:06
@tlambertz
Copy link
Contributor

Let's add the conditional to the example in security-txt/src/lib.rs as well.

@w4rum
Copy link
Contributor Author

w4rum commented Nov 22, 2022

Oops, done.

@tlambertz tlambertz merged commit fb8bdcd into neodyme-labs:master Nov 22, 2022
@w4rum w4rum deleted the no-entrypoint-docs branch November 22, 2022 14:15
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.

None yet

2 participants