Skip to content

Conversation

@tanmaya-panda1
Copy link
Collaborator

@tanmaya-panda1 tanmaya-panda1 commented Jan 12, 2026

This pull request introduces a new mechanism for validating that Kusto endpoints are trusted, using a configurable set of rules loaded from a shared JSON file. The validation logic is enforced at client initialization, and is extensible for custom or additional trusted hosts. The changes include new utility classes for endpoint rule matching, data loading from JSON, and a custom exception for invalid endpoints. The build process is also updated to ensure the JSON file is available at runtime.

Endpoint trust validation and configuration:

  • Added KustoTrustedEndpoints utility to validate Kusto endpoints against a set of trusted hostnames and suffixes, loaded from WellKnownKustoEndpoints.json. The logic allows for overrides and additional trusted hosts, and throws a custom exception if validation fails.
  • Introduced FastSuffixMatcher for efficient hostname/suffix rule matching, and supporting data classes for rule and match result representation.
  • Added WellKnownKustoEndpointsData for loading and parsing the trusted endpoints JSON file from the classpath, with robust error handling.
  • Created KustoClientInvalidConnectionStringException for signaling invalid or untrusted endpoints.

Integration and enforcement in client initialization:

  • Updated KustoBaseApiClient to validate the dmUrl endpoint on initialization unless security checks are explicitly skipped, using the new trusted endpoints logic. [1] [2]

Build process update:

  • Modified ingest-v2/pom.xml to copy WellKnownKustoEndpoints.json from the data module into the build output, ensuring the trusted endpoints configuration is always available at runtime.### Added

Changed

Fixed

@github-actions
Copy link

github-actions bot commented Jan 12, 2026

Test Results

530 tests  ±0   521 ✅ ±0   3m 29s ⏱️ +5s
 31 suites ±0     9 💤 ±0 
 31 files   ±0     0 ❌ ±0 

Results for commit 70b72d3. ± Comparison against base commit b9ccf14.

♻️ This comment has been updated with latest results.

// Validate endpoint is trusted unless security checks are skipped
// Note: dmUrl might be empty/null in some test scenarios (e.g., mocked clients)
// Use @Suppress to handle potential platform nullability from Java interop
@Suppress("SENSELESS_COMPARISON")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this annotation required ?

*/
@JvmStatic
@JvmOverloads
fun validateTrustedEndpoint(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is JvmOverloads needed here. Both comments applicable on line 211. Lets check if we are missing some context before using the annotation

* @param loginEndpoint The login endpoint to check against (optional, defaults to public cloud)
* @throws KustoClientInvalidConnectionStringException if endpoint is not trusted
*/
@JvmStatic
Copy link
Contributor

Choose a reason for hiding this comment

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

JvmStatic is used with companions to make the singleton method visible with the class. This is an object, is this annotation really needed

* @param loginEndpoint The login endpoint to check against
* @throws KustoClientInvalidConnectionStringException if endpoint is not trusted
*/
@JvmStatic
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above here

/**
* Data class representing the structure of WellKnownKustoEndpoints.json
*/
@Serializable
Copy link
Contributor

Choose a reason for hiding this comment

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

In the generated classes we import Kotlin serializable to an alias KSerializable and use it in the annotation to avoid confusion with Java Serializable. please evaluate if that may be a good idea


constructor(message: String, cause: Throwable) : super(message, cause)

constructor(cause: Throwable) : super(cause)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since both these calls just do super, are these constructors needed. Can we live with only the constructor below

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Reference as a property

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