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

Clarify allowed files and extensions when adding a package #2421

Open
deelawn opened this issue Jun 24, 2024 · 0 comments
Open

Clarify allowed files and extensions when adding a package #2421

deelawn opened this issue Jun 24, 2024 · 0 comments
Labels
📖 documentation Improvements or additions to documentation hacktoberfest This might be a good issue for a hacktoberfest participant to handle. help wanted Want to contribute? We recommend these issues.

Comments

@deelawn
Copy link
Contributor

deelawn commented Jun 24, 2024

Description

Filtering exists for files uploaded when a new package is added. These filters are a combination of conditionals and regular expressions that exist in multiple places. The definition of filenames and extensions that are allowed should be better defined, unified, and put into a single location.

Here are the three locations I've found thus far:

gno/gnovm/pkg/gnolang/nodes.go

Lines 1110 to 1117 in 31a5f2e

allowedFiles := []string{ // make case insensitive?
"gno.mod",
"LICENSE",
"README.md",
}
allowedFileExtensions := []string{
".gno",
}

var (
rePkgName = regexp.MustCompile(`^[a-z][a-z0-9_]*$`)
rePkgOrRlmPath = regexp.MustCompile(`^gno\.land\/(?:p|r)(?:\/_?[a-z]+[a-z0-9_]*)+$`)
reFileName = regexp.MustCompile(`^([a-zA-Z0-9_]*\.[a-z0-9_\.]*|LICENSE|README)$`)
)

app.Router.Handle("/r/{rlmname:[a-z][a-z0-9_]*(?:/[a-z][a-z0-9_]*)+}/{filename:(?:.*\\.(?:gno|md|txt|mod)$)?}", handlerRealmFile(logger, app, &cfg))
app.Router.Handle("/r/{rlmname:[a-z][a-z0-9_]*(?:/[a-z][a-z0-9_]*)+}", handlerRealmMain(logger, app, &cfg))
app.Router.Handle("/r/{rlmname:[a-z][a-z0-9_]*(?:/[a-z][a-z0-9_]*)+}:{querystr:.*}", handlerRealmRender(logger, app, &cfg))
app.Router.Handle("/p/{filepath:.*}", handlerPackageFile(logger, app, &cfg))

Then there is also the addition of the license constant added as a temporary fix for exposing a LICENSE file via gnoweb:

gno/tm2/pkg/std/memfile.go

Lines 107 to 109 in 289785b

case last == licenseName:
return strings.Join(parts[:len(parts)-1], "/"), licenseName
}

@Kouteki Kouteki moved this from Triage to Todo in 🧙‍♂️gno.land core team Jul 5, 2024
@Kouteki Kouteki added the 📖 documentation Improvements or additions to documentation label Jul 5, 2024
@zivkovicmilos zivkovicmilos added the help wanted Want to contribute? We recommend these issues. label Sep 12, 2024
@wyhaines wyhaines added the hacktoberfest This might be a good issue for a hacktoberfest participant to handle. label Oct 1, 2024
@Kouteki Kouteki added this to the ⏭️Next after mainnet milestone Oct 16, 2024
@Kouteki Kouteki moved this from Todo to Backlog in 🧙‍♂️gno.land core team Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📖 documentation Improvements or additions to documentation hacktoberfest This might be a good issue for a hacktoberfest participant to handle. help wanted Want to contribute? We recommend these issues.
Projects
Status: Backlog
Development

No branches or pull requests

4 participants