Skip to content

KAFKA-20822: Harden Trogdor polymorphic JSON deserialization - #22936

Open
lh0156 wants to merge 1 commit into
apache:trunkfrom
lh0156:agent/KAFKA-20822-harden-trogdor-json
Open

KAFKA-20822: Harden Trogdor polymorphic JSON deserialization#22936
lh0156 wants to merge 1 commit into
apache:trunkfrom
lh0156:agent/KAFKA-20822-harden-trogdor-json

Conversation

@lh0156

@lh0156 lh0156 commented Jul 26, 2026

Copy link
Copy Markdown

Fixes KAFKA-20822.

Summary

  • Configure Trogdor's shared Jackson mapper with a BasicPolymorphicTypeValidator.
  • Allow only built-in TaskSpec implementations from the task, fault, and workload packages.
  • Add regression coverage proving unsupported TaskSpec subtypes are rejected while built-in types from each supported package remain readable.

Why

TaskSpec uses Jackson JsonTypeInfo.Id.CLASS, which previously allowed any class on the classpath that extended TaskSpec to be selected by the incoming class type id. The allowlist preserves the existing wire format and built-in task types while preventing external subtypes from being instantiated.

Verification

  • TDD RED: the unsupported-subtype regression test instantiated the external test subtype before the validator was added.
  • TDD GREEN: ./gradlew :trogdor:test --tests org.apache.kafka.trogdor.task.TaskSpecTest --no-build-cache
  • Full module tests: ./gradlew :trogdor:test --no-build-cache
  • Static checks: ./gradlew :trogdor:spotlessCheck :trogdor:checkstyleMain :trogdor:checkstyleTest :trogdor:spotbugsMain --no-build-cache
  • git diff --check

No public JSON shape or built-in Trogdor task behavior is changed.

@github-actions github-actions Bot added triage PRs from the community tools labels Jul 26, 2026
Generated-by: OpenAI Codex (GPT-5)
@lh0156
lh0156 force-pushed the agent/KAFKA-20822-harden-trogdor-json branch from 1912c18 to 2ea02cf Compare August 2, 2026 13:16
@lh0156

lh0156 commented Aug 2, 2026

Copy link
Copy Markdown
Author

Rebased this PR onto the latest trunk and added the Kafka-required AI contribution trailer to the commit (Generated-by: OpenAI Codex (GPT-5)).

Independent verification on the rebased commit:

  • ./gradlew :trogdor:test :trogdor:spotlessCheck :trogdor:checkstyleMain :trogdor:checkstyleTest :trogdor:spotbugsMain --no-build-cache --console=plain
  • All Trogdor tests passed, including the built-in TaskSpec allowlist and external-subtype rejection coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant