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

Intellij IDEA generates unsafe code for new project #54

Open
apatrida opened this issue Jun 29, 2021 · 0 comments
Open

Intellij IDEA generates unsafe code for new project #54

apatrida opened this issue Jun 29, 2021 · 0 comments

Comments

@apatrida
Copy link

This is likely the Intellij Kotlin project wizard, more than KTOR plugin, but I can't tell from outside which plugin adds the Kotlin "Full Stack Web" project creator. Anyways, it generates this code for serving the static content:

fun main() {
    embeddedServer(Netty, port = 8080, host = "127.0.0.1") {
        routing {
            get("/") {
                call.respondHtml(HttpStatusCode.OK, HTML::index)
            }
            static("/static") {
                resources()
            }
        }
    }.start(wait = true)
}

The resources() seems dangerous, without a limit on the file extensions served, and without a package prefix, you could basically download class files and anything else in the class path, which could include configuration and other unintended files.

This is a bad practice to teach, and people won't question what this wizard creates.

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