Skip to content

Commit

Permalink
GHSA-9w8w-34vr-65j2 Serve repository content in sandbox to improve se…
Browse files Browse the repository at this point in the history
…curity on human-readable resources
  • Loading branch information
dzikoysk committed May 3, 2024
1 parent 731001f commit 279a472
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ import io.javalin.http.Context
import io.javalin.http.HandlerType.HEAD
import io.javalin.http.HandlerType.OPTIONS
import io.javalin.http.Header.CACHE_CONTROL
import io.javalin.http.Header.CONTENT_SECURITY_POLICY
import io.javalin.http.HttpStatus
import org.eclipse.jetty.server.HttpOutput
import panda.std.Result
import java.io.Closeable
import java.io.InputStream
import java.io.OutputStream
import java.net.URLEncoder
import java.nio.charset.Charset
import kotlin.time.Duration.Companion.hours
import org.eclipse.jetty.server.HttpOutput
import panda.std.Result

internal class ContentTypeSerializer : StdSerializer<ContentType> {

Expand Down Expand Up @@ -93,6 +94,8 @@ internal fun Context.resultAttachment(
cache: Boolean,
data: InputStream
) {
header(CONTENT_SECURITY_POLICY, "sandbox")

if (!contentType.isHumanReadable) {
contentDisposition("""attachment; filename="$name"; filename*=utf-8''${URLEncoder.encode(name, "utf-8")}""")
}
Expand Down

1 comment on commit 279a472

@dzikoysk
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GHSL-2024-072

Please sign in to comment.