Watch
2
0
Fork
You've already forked dixmont
0
Dixmont Jackson extensions
  • Java 99.8%
  • CSS 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-07-31 18:42:51 +01:00
.forgejo Update workflows. 2026-07-31 18:42:51 +01:00
com.io7m.dixmont.colors Begin next development iteration. 2025-12-10 15:43:19 +00:00
com.io7m.dixmont.core Correct semantic versioning. 2026-02-22 15:32:13 +00:00
com.io7m.dixmont.tests Begin next development iteration. 2025-12-10 15:43:19 +00:00
src/site/resources Update site metadata. 2025-08-09 15:06:40 +00:00
.gitignore Update .gitignore. 2024-05-07 16:01:41 +00:00
.gitmodules Move to new organization. 2024-04-28 20:55:52 +00:00
checkstyle-filter.xml Add a colors module 2022-10-02 09:42:10 +00:00
checkstyle-suppressions-1.0.dtd Add a colors module 2022-10-02 09:42:10 +00:00
doc7m-books.json Add doc7m-books.json 2026-07-31 18:36:42 +01:00
pom.xml Migrate project. 2026-06-27 11:07:08 +01:00
README-CHANGES.xml Add the ability to allow entire packages of types. 2026-02-22 15:32:13 +00:00
README-LICENSE.txt Update LICENSE 2023-08-13 21:16:12 +00:00
README.in Note relocation 2026-06-26 17:31:07 +01:00
README.md Migrate project. 2026-06-27 11:07:08 +01:00

dixmont

Maven Central Maven Central (snapshot) Java Version

com.io7m.dixmont

Repository Relocation

Development of this project has moved to an open-source but not open-contribution model.

Source code and commits will remain publicly available perpetually, but issues and/or pull requests will be rejected and/or ignored. Additionally, this project will now only be available via a read-only mirror at:

https://codeberg.org/io7m-com/dixmont

dixmont

Some useful extension classes for jackson.

Features

  • Restricted JSON deserializer for preventing reflection-based serialization attacks.
  • Written in pure Java 17.
  • OSGi ready.
  • JPMS ready.
  • ISC license.
  • High-coverage automated test suite.

Motivation

Systems that use reflection to deserialize data are typically subject to deserialization attacks. The jackson JSON library is no exception to this.

The dixmont package provides a blunt and brute-force means to reduce the impact of attacks: All of the permitted classes that can be deserialized are listed, and everything else is rejected.

Building

$ mvn clean verify

Usage

Create a restricted serializer that is permitted to deserialize only the given classes and no others, and then register it with a mapper:

var builder =
  DmJsonRestrictedDeserializers.builder();

// Allow deserializing values of various "value" classes...
builder.allowClass(Path.class)
  .allowClass(String.class)
  .allowClass(URI.class)
  .allowClass(int.class)
  .allowClass(double.class);

// Allow java.util.Optional<java.lang.Integer>
builder.allowOptionalOfClass(Integer.class);

// Or, equivalently:
builder.allowClassName("java.util.Optional<java.lang.Integer>")

// Allow java.util.List<java.lang.String>
builder.allowListsOfClass(String.class);

// Or, equivalently:
builder.allowClassName("java.util.List<java.lang.String>");

// Allow java.util.Set<java.lang.String>
builder.allowSetsOfClass(String.class);

// Or, equivalently:
builder.allowClassName("java.util.Set<java.lang.String>");

// Allow java.util.Map<java.lang.Integer, java.lang.String>
builder.allowMapsOfClass(Integer.class, String.class);

// Or, equivalently:
builder.allowClassName("java.util.Map<java.lang.Integer, java.lang.String>");

final var serializers = builder.build();
final var simpleModule = new SimpleModule();
simpleModule.setDeserializers(serializers);

final var mapper =
  JsonMapper.builder()
    .addModule(simpleModule)
    .build();

Parser code using the given ObjectMapper will be prevented from deserializing values of anything other than the given classes. Hostile JSON text that attempts to get the deserializer to instantiate other classes will fail.