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

Use TreeMap in SimpleFacade to solve DoS vuln #390

Merged
merged 2 commits into from Jan 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions parser/shared/src/main/scala/jawn/Facade.scala
@@ -1,6 +1,9 @@
package org.typelevel.jawn

import scala.collection.mutable
import scala.collection.immutable.TreeMap
import scala.collection.JavaConverters._
import java.util.HashMap

/**
* [[Facade]] is a type class that describes how Jawn should construct
Expand Down Expand Up @@ -79,7 +82,7 @@ object Facade {
final def objectContext(): FContext[J] =
new FContext.NoIndexFContext[J] {
private[this] var key: String = null
private[this] var vs = Map.empty[String, J]
private[this] var vs = TreeMap.empty[String, J]
def add(s: CharSequence): Unit =
if (key == null)
key = s.toString
Expand Down Expand Up @@ -121,7 +124,7 @@ object Facade {
final def objectContext(): FContext[J] =
new FContext.NoIndexFContext[J] {
private[this] var key: String = null
private[this] val vs = mutable.Map.empty[String, J]
private[this] val vs = (new HashMap[String, J]).asScala
def add(s: CharSequence): Unit =
if (key == null)
key = s.toString
Expand Down