server: control honouring internal IDs by old APIs#11976
Conversation
Fixes apache#9684 Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11976 +/- ##
============================================
+ Coverage 17.56% 19.47% +1.90%
- Complexity 15540 19360 +3820
============================================
Files 5909 6301 +392
Lines 529045 568776 +39731
Branches 64615 69669 +5054
============================================
+ Hits 92933 110751 +17818
- Misses 425657 445948 +20291
- Partials 10455 12077 +1622
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
DaanHoogland
left a comment
There was a problem hiding this comment.
clgtm (as said on the issue, we can expand on it but good as is)
|
@blueorangutan package |
|
@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16647 |
|
@nvazquez can you check/review? |
|
@blueorangutan test |
|
@shwstppr a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-15345)
|
There was a problem hiding this comment.
Pull request overview
Adds a global configuration switch to control whether legacy (pre-3.x) APIs may still accept internal database IDs for UUID-typed parameters, enabling stricter UUID-only enforcement to address issue #9684.
Changes:
- Introduces a new global config key
api.disallow.internal.idsinApiServer. - Applies the config in
ParamProcessWorker.translateUuidToInternalIdto prevent fallback parsing of numeric/internal IDs when disallowed.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
server/src/main/java/com/cloud/api/dispatch/ParamProcessWorker.java |
Gates “pre-3.x internal ID fallback” logic on a new global config flag. |
server/src/main/java/com/cloud/api/ApiServer.java |
Adds and registers the api.disallow.internal.ids configuration key. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public static final ConfigKey<Boolean> ApiDisallowInternalIds = new ConfigKey<>( | ||
| ConfigKey.CATEGORY_ADVANCED, | ||
| Boolean.class, | ||
| "api.disallow.internal.ids", | ||
| "true", | ||
| "When enabled, APIs will not honour requests containing internal database IDs. " | ||
| + "Only UUIDs will be accepted as entity identifiers. " | ||
| + "By default, internal IDs are still accepted for backward compatibility with pre-3.x APIs.", | ||
| true, | ||
| ConfigKey.Scope.Global | ||
| ); |
| // If annotation's empty, the cmd existed before 3.x try conversion to long | ||
| final boolean isPre3x = annotation.since().isEmpty(); | ||
| final boolean isPre3x = annotation.since().isEmpty() && !ApiServer.ApiDisallowInternalIds.value(); |
| Long internalId = null; | ||
| // If annotation's empty, the cmd existed before 3.x try conversion to long | ||
| final boolean isPre3x = annotation.since().isEmpty(); | ||
| final boolean isPre3x = annotation.since().isEmpty() && !ApiServer.ApiDisallowInternalIds.value(); |
| Long internalId = null; | ||
| // If annotation's empty, the cmd existed before 3.x try conversion to long | ||
| final boolean isPre3x = annotation.since().isEmpty(); | ||
| final boolean isPre3x = annotation.since().isEmpty() && !ApiServer.ApiDisallowInternalIds.value(); |
| Long internalId = null; | ||
| // If annotation's empty, the cmd existed before 3.x try conversion to long | ||
| final boolean isPre3x = annotation.since().isEmpty(); | ||
| final boolean isPre3x = annotation.since().isEmpty() && !ApiServer.ApiDisallowInternalIds.value(); |
| "When enabled, APIs will not honour requests containing internal database IDs. " | ||
| + "Only UUIDs will be accepted as entity identifiers. " | ||
| + "By default, internal IDs are not accepted even for pre-3.x APIs.", |
Description
Fixes #9684
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?