Fix hard-coded condition_template_id allow-list rejecting valid platform templates - #437
Open
soumyas-dev wants to merge 3 commits into
Open
Fix hard-coded condition_template_id allow-list rejecting valid platform templates#437soumyas-dev wants to merge 3 commits into
condition_template_id allow-list rejecting valid platform templates#437soumyas-dev wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix hard-coded
condition_template_idallow-list rejecting valid platform templatesFixes #432
Problem
resource/xray_custom_curation_conditionrestrictedcondition_template_idto ahard-coded
stringvalidator.OneOf(...)of 9 template IDs. The set of templatesXray actually supports is dynamic — it is returned by the
GET xray/api/v1/curation/condition_templatesAPI and varies by JFrog Platformversion and enabled features (e.g. malicious-package detection).
As a result, valid platform templates such as
isMalicious,NoLicense, andaged-package variants were rejected by the provider at
terraform validate/plantime, before the request ever reached the API:
The schema description itself already stated the value is "One of the IDs of the
supported condition templates returned by the list condition templates API" — but
the validator contradicted that by baking in a static list.
Fix
OneOfoncondition_template_id(keptLengthAtLeast(1)). The Xray API is the source of truth and returns a clearUnknown ConditionTemplateId '<id>'error for genuinely invalid IDs.param_valuesvalidator still fully validates templates the provider knowsabout (param names, counts, required params, value types), but for any template
not in its internal map it now validates only JSON syntax and defers the rest to
the API — so new/platform-specific templates aren't blocked by provider-side
param rules.
client-side.
Reproduction & verification
Reproduced with a locally-built provider (dev override):
condition_template_id = "isMalicious"Invalid Attribute Value MatchatvalidateCVEName) + valid paramsCVEName) + invalidparam_idOn the test platform (Xray 3.143.30) the
condition_templatesAPI returns onlythe original 9 templates and rejects
isMaliciouswithUnknown ConditionTemplateId 'isMalicious'— confirming the template set isplatform-dependent and that the API correctly gatekeeps invalid IDs once the
client-side block is removed.
Tests
Added
TestAccCustomCurationCondition_PlatformSpecificTemplate_NotRejectedClientSide.It uses a
PlanOnlystep withcondition_template_id = "isMalicious", so itexercises the config-level validators (where the
OneOflived) without requiringthe backend to support the template. It fails before the fix
(
Invalid Attribute Value Match) and passes after. Existing acceptance tests forthe known templates continue to validate parameters exactly as before.
Changelog
Added a
3.1.12BUG FIXES entry.