Skip to content

refactor(core): fix minor security findings - #170

Merged
evebrnd merged 8 commits into
mainfrom
refactor/security-and-tech-improvements
Oct 23, 2026
Merged

evebrnd merged 8 commits into
mainfrom
refactor/security-and-tech-improvements

Conversation

@evebrnd

@evebrnd evebrnd commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

PR Description

What this PR Provides

Add constraints to JSLT processing:

  • Maximum payload bytes (1 MiB, 1,048,576 UTF-8 bytes). Payloads exceeding either limit are rejected with HTTP 400 Bad Request
  • JSON depth (64). Payloads exceeding either limit are rejected with HTTP 400 Bad Request
  • JSLT expression length (10 000). Longer expressions are rejected with HTTP 422 Unprocessable Entity
  • Evaluation timeout (5 sec). Evaluations exceeding it are cancelled and return HTTP 422 Unprocessable Entity
  • Valid requests within these limits continue through the existing success paths: entity listing returns HTTP 200 OK and a successful JSLT dry run returns HTTP 200 OK

GET /api/v1/entities/{templateIdentifier} accepts page sizes up to and including 500. Requests with a size greater than 500 are rejected with HTTP 400 Bad Request.

By default, webhook configurations cannot have security : NONE. This can be altered with application config idp.security.webhook.allow-none.

Enforce a global max pagination size (500 by default). This can be modified using config app.max-page-size

Review

The reviewer must double-check these points:

  • The reviewer has tested the feature
  • The reviewer has reviewed the implementation of the feature
  • The documentation has been updated
  • The feature implementation respects the Technical Doc / ADR previously produced

How to test

  • The service is running and the caller is authenticated.
  • For GET entity list checks, an entity template with entities available for listing exists.
  • For JSLT checks, a valid entity dynamic mapping is available to use with the dry-run endpoint.

Scenarios

  • Entity page size: Call GET /api/v1/entities/{templateIdentifier}?size=100 and then with size=500. Both requests should return HTTP 200 OK with the requested page size. Repeat with size=501; the request should return HTTP 400 Bad Request.
  • JSLT success and payload/depth limits: Submit a valid request to POST /api/v1/entity_dynamic_mappings/dry-run with a payload no larger than 1 MiB, nesting depth no greater than 64, and a valid expression no longer than 10,000 characters. The transformation should complete with HTTP 200 OK. Payloads above 1 MiB or nesting deeper than 64 should be rejected with HTTP 400 Bad Request.
  • Expression length: Submit an expression of 10,000 characters, which is within the limit, then one longer than 10,000 characters. The over-limit expression should be rejected with HTTP 422 Unprocessable Entity.
  • Evaluation timeout: Submit a transformation that takes longer than 5 seconds to evaluate. The evaluation should be cancelled and the request should return HTTP 422 Unprocessable Entity.

Breaking changes

  • Behavior modification of a component: entity-list requests with size greater than 500 are now rejected with HTTP 400 Bad Request.
  • No data loss or API JSON schema modification.

Context of the Breaking Change

The entity listing endpoint now enforces the same maximum page size of 500 as the search endpoint.

Result of the Breaking Change

Clients must request pages of at most 500 entities. Requests at the 500-item boundary remain valid; larger page sizes must be split across multiple requests.'

@github-code-quality

github-code-quality Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Java

Java / code-coverage/jacoco

main 9a9ca26 refactor/security-an... 7050d12 +/-
91% 91% 0%
View coverage of the 10 most impacted files.
File main 9a9ca26 refactor/security-an... 7050d12 +/-
com/decathlon/i...JsltEngine.java 100% 85% -15%
com/decathlon/i...ionHandler.java 84% 84% 0%
com/decathlon/i...aphService.java 90% 90% 0%
com/decathlon/i...ityService.java 98% 98% 0%
com/decathlon/i...onstraints.java 0% 0% 0%
com/decathlon/i...onCriteria.java 100% 100% 0%
com/decathlon/i...ineAdapter.java 81% 82% +1%
com/decathlon/i...ntResolver.java 0% 100% +100%
com/decathlon/i...tionPolicy.java 0% 100% +100%
com/decathlon/i...Properties.java 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 23, 2026 09:57 UTC

@evebrnd
evebrnd marked this pull request as ready for review October 19, 2026 13:18
@brandPittCode
brandPittCode requested a balanced review from Copilot October 22, 2026 14:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

JSLT timeouts do not stop resource-consuming evaluations, and the container health check can incorrectly report healthy services as unhealthy.

2 open issues
What changed in this PR

This PR hardens IDP-Core’s mapping, pagination, and webhook configuration paths, with supporting tests, documentation, and container maintenance.

Changes:

  • Adds JSLT payload, nesting, expression-length, and evaluation-time limits.
  • Introduces configurable pagination limits and disables unauthenticated webhook configuration by default.
  • Updates API documentation, validation tests, container health checks, and maintenance scripts.
File Description
src/​test/​resources/​application-test.yml Allows unauthenticated webhook fixtures in tests.
src/​test/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​ingestion/​security/​WebhookJwtDecoderProviderTest.java Updates security-property construction.
src/​test/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​ingestion/​security/​JwtBearerSecurityValidatorTest.java Updates security-property construction.
src/​test/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​entity_mapping/​jslt/​JsltMappingEngineAdapterTest.java Tests payload-size and nesting limits.
src/​test/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​entity_mapping/​jslt/​JsltEngineTest.java Tests expression limits and timeout responses.
src/​test/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​api/​controller/​InboundWebhookManagementControllerTest.java Tests invalid pagination requests.
src/​test/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​api/​controller/​EntityTemplateControllerTest.java Tests pagination rejection and boundary acceptance.
src/​test/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​api/​controller/​EntityDynamicMappingControllerTest.java Tests invalid pagination requests.
src/​test/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​api/​controller/​EntityControllerTest.java Expands pagination validation coverage.
src/​test/​java/​com/​decathlon/​idp_core/​domain/​service/​webhook/​security/​WebhookSecurityValidationServiceTest.java Tests the unauthenticated-webhook policy.
src/​test/​java/​com/​decathlon/​idp_core/​domain/​service/​entity/​EntityServiceTest.java Adapts search tests to configurable limits.
src/​test/​java/​com/​decathlon/​idp_core/​architecture/​HexagonalArchitectureTest.java Restricts Spring Beans dependencies in the domain.
src/​main/​resources/​application.yml Adds pagination and webhook-security settings.
src/​main/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​ingestion/​security/​WebhookSecurityProperties.java Binds the allow-none setting.
src/​main/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​ingestion/​security/​WebhookSecurityConfiguration.java Maps configuration into the domain policy.
src/​main/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​entity_mapping/​jslt/​JsltMappingEngineAdapter.java Checks payload size and depth before tree parsing.
src/​main/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​entity_mapping/​jslt/​JsltEngine.java Adds expression validation and timed execution.
src/​main/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​api/​handler/​ApiExceptionHandler.java Provides specific pagination type-error messages.
src/​main/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​api/​dto/​in/​EntitySearchRequestDtoIn.java Defers page-size defaults to the controller.
src/​main/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​api/​controller/​EntityController.java Applies configured pagination limits and defaults.
src/​main/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​api/​configuration/​WebConfiguration.java Registers the validating pagination resolver.
src/​main/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​api/​configuration/​ValidatingPageableArgumentResolver.java Rejects malformed and out-of-range pagination.
src/​main/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​api/​configuration/​SwaggerDescription.java Documents page-size bounds.
src/​main/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​api/​configuration/​SearchProperties.java Binds and validates the maximum page size.
src/​main/​java/​com/​decathlon/​idp_core/​infrastructure/​adapters/​api/​auth/​JitProvisioningFilter.java Switches to JSpecify’s nullability annotation.
src/​main/​java/​com/​decathlon/​idp_core/​domain/​service/​webhook/​security/​WebhookSecurityValidationService.java Rejects disallowed NONE security configurations.
src/​main/​java/​com/​decathlon/​idp_core/​domain/​service/​entity/​EntityService.java Uses shared, configurable pagination validation.
src/​main/​java/​com/​decathlon/​idp_core/​domain/​service/​entity/​EntityAuditService.java Removes an unused service dependency.
src/​main/​java/​com/​decathlon/​idp_core/​domain/​service/​entity_graph/​EntityGraphService.java Validates pagination before fetching graph pages.
src/​main/​java/​com/​decathlon/​idp_core/​domain/​model/​search/​PaginationCriteria.java Centralizes pagination bounds checks.
src/​main/​java/​com/​decathlon/​idp_core/​domain/​model/​inbound_connectors/​webhook/​WebhookSecurityValidationPolicy.java Defines the unauthenticated-webhook policy.
src/​main/​java/​com/​decathlon/​idp_core/​domain/​constant/​ValidationMessages.java Centralizes pagination error messages.
src/​main/​java/​com/​decathlon/​idp_core/​domain/​constant/​SearchConstraints.java Defines default pagination values.
src/​main/​java/​com/​decathlon/​idp_core/​domain/​constant/​JsltConstraints.java Defines JSLT processing limits.
flyway-migration-order-report.md Generated migration-report cleanup.
docs/​src/​static/​swagger.yaml Updates published pagination descriptions.
docs/​src/​getting-started/​configuration.md Documents pagination configuration and clarifies CORS examples.
docs/​src/​features/​webhooks.md Explains the default NONE restriction and existing connectors.
docs/​src/​features/​entity-dynamic-mapping.md Documents JSLT limits and error responses.
docs/​src/​concepts/​entity-filtering.md Documents configurable search page limits.
docs/​src/​concepts/​entities.md Documents listing page-size validation.
Dockerfile Simplifies non-root setup and adds a health check.
.gitignore Ignores generated migration reports.
.github/​scripts/​summarize_owasp.sh Uses Bash conditional syntax.
.github/​scripts/​extract_specs.sh Uses Bash conditional syntax.
.github/​scripts/​check_navigation.sh Uses Bash conditional syntax.
.github/​scripts/​check_flyway_migration_order.sh Uses Bash conditional syntax.

Review effort: Balanced

Comment thread Dockerfile Resolved
brandPittCode
brandPittCode previously approved these changes Oct 22, 2026
@evebrnd
evebrnd force-pushed the refactor/security-and-tech-improvements branch from 51280a8 to 7050d12 Compare October 23, 2026 09:53
@sonarqubecloud

Copy link
Copy Markdown

@evebrnd
evebrnd merged commit 7c584be into main Oct 23, 2026
20 checks passed
@evebrnd
evebrnd deleted the refactor/security-and-tech-improvements branch October 23, 2026 10:01
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

Successfully merging this pull request may close these issues.

3 participants