Files
floci/src/test/java
Allen Sanborn 80f25417b3 fix(ssm): return KeyId, AllowedPattern, Tier and Policies from DescribeParameters (#5263)
* fix(ssm): return KeyId, AllowedPattern, Tier and Policies from DescribeParameters

PutParameter accepted KeyId, AllowedPattern, Tier and Policies and dropped
them, so DescribeParameters never returned them and the Tier and KeyId
filters matched hardcoded defaults. Tools that read these attributes back,
such as Terraform's aws_ssm_parameter, saw a permanent diff.

PutParameter now stores the four attributes and DescribeParameters returns
them: KeyId for a SecureString (alias/aws/ssm when none was given), Tier
always, AllowedPattern and Policies when set. Intelligent-Tiering resolves
to Advanced when policies are present or the value exceeds 4 KB, an
overwrite that omits Tier keeps the existing tier, and a value that does
not match AllowedPattern is rejected with ParameterPatternMismatchException.

* fix(ssm): keep policies across overwrites and reject malformed patterns

An overwrite that omitted Policies cleared them; AWS keeps existing
policies until new policies or an empty list are sent. A malformed
AllowedPattern escaped as a 500 instead of InvalidAllowedPatternException,
and a Policies string that parsed to something other than a JSON array was
accepted as an empty list instead of rejected.

* fix(ssm): treat an empty AllowedPattern as no pattern

The Terraform AWS provider sends AllowedPattern="" on every PutParameter
when allowed_pattern is unset. An empty regex matches only the empty
string, so every aws_ssm_parameter apply failed with
ParameterPatternMismatchException (compat-terraform / compat-opentofu).

* fix(ssm): treat empty optional PutParameter fields as absent

The Terraform AWS provider sends every optional PutParameter field and
leaves unset ones as an empty string, which AWS reads as absent. Read
KeyId, AllowedPattern, Tier and Policies through one helper so a blank
value falls back to the default instead of being stored or validated.

* fix(ssm): bound AllowedPattern matching and cap its length

PutParameter matches a caller-supplied AllowedPattern against a
caller-supplied Value, so a pattern that backtracks catastrophically
could hold a request thread. Reject patterns over the 1024 characters
the SSM model allows, and match through a deadline-bounded subject that
aborts after one second with InvalidAllowedPatternException.

The deadline subject already lived inside CodePipelineService for
VariableCheck MATCHES; it moves to core.common so both use one copy.

Also cover the Intelligent-Tiering 4096-byte cutoff with ASCII and
multibyte values, and replace inline fully qualified test names with
imports.

* fix(ssm): keep Advanced on Intelligent-Tiering overwrite, validate Tier, serialize PutParameter

An Intelligent-Tiering overwrite with a small value no longer downgrades an
existing Advanced parameter to Standard. Tier outside Standard, Advanced and
Intelligent-Tiering is a ValidationException. putParameter is synchronized like
labelParameterVersion so concurrent overwrites cannot share a version.

* fix(ssm): validate PutParameter before taking the write lock

The tier, tag, name and AllowedPattern checks read only the request, so
they now run before the lock; only the stored-version read and the write
are synchronized. A pattern match running to its one-second deadline no
longer stalls other SSM writers.

The concurrency test now waits for the second overwrite's thread to reach
BLOCKED instead of waiting a fixed 300 ms for a timeout.
2026-10-08 20:18:29 -04:00
..