Prepare and test your skills
Prepare and test your skills
Free sample question, answered and explained below. The Professional Cloud Security Engineer practice bank has 1,343 more like it. Try 10 free: instant score, no account.
A security engineer needs to author a custom constraint rule using Common Expression Language (CEL) to enforce cryptographic key hygiene across an organization's resource hierarchy. The organization's compliance standard requires that:
cloudkms.googleapis.com/CryptoKey) must explicitly specify an automated rotation period.Which CEL condition should be configured in the custom rule definition to evaluate resource properties and satisfy these requirements?
This expression uses an .exists() member call to check field existence and attempts to perform arithmetic multiplication (60 * 3600) to compare against an integer representing seconds.
exists() is a comprehension macro designed to iterate over collections (e.g., list.exists(item, condition)). It cannot be invoked as a zero-argument method on a single field to check existence.int), whereas resource.data.rotationPeriod is a google.protobuf.Duration. In CEL, comparing a duration to an integer using <= causes a type error.<= would incorrectly permit an exact 60-hour configuration.all() and exists() require collection inputs and predicate parameters.has(msg.field) syntax.The field being evaluated were a repeated collection of items where an administrator needed to verify that at least one item met a numeric seconds threshold.
This expression attempts to use the contains() member method on the resource.data object and invokes an imaginary .toSeconds() method on the duration field to compare against an integer seconds literal.
contains() is a string or list inspection method, not a field existence macro for structured message types. Applying contains() to a resource data map or object fails validation..toSeconds() member method on duration types. Duration objects are manipulated using built-in arithmetic, relational operators, or duration constructor functions (duration('...')).has() macro (e.g., has(resource.data.fieldName)).duration(string_specifier).The custom constraint runtime used a custom Python or JavaScript evaluation engine that exposed native map lookup and object conversion helper methods like toSeconds().
This expression uses standard Common Expression Language (CEL) syntax supported across Google Cloud custom controls and constraints. It uses the has() field selection macro to verify presence and the built-in duration() function to evaluate time-based protobuf fields against a duration literal.
has(resource.data.rotationPeriod) macro inspects the underlying Google Cloud resource API definition to verify whether the rotationPeriod field has been explicitly defined on the CryptoKey object before attempting value comparisons.resource.data.rotationPeriod < duration('60h') converts the string literal '60h' into a native CEL duration type, enabling a valid relational comparison against the protobuf duration property defined on the resource.&& operator guarantees that the duration comparison is only evaluated if rotationPeriod exists, preventing null pointer or runtime field access errors.duration object.'h' for hours, 'm' for minutes, 's' for seconds) for clear, maintainable policy authoring.In Google Cloud policy definitions, CEL does not automatically coerce string representations of time into duration objects, nor does it allow direct access to unset protobuf message fields without checking presence. Combining has() with duration('60h') provides the exact syntax required for robust, error-free policy evaluation.
This expression attempts to use direct null equality checking and a raw string literal comparison (< '60h') to evaluate the rotation period of a Cloud KMS resource.
null; evaluating an unset field directly can cause runtime evaluation errors rather than returning a boolean value.rotationPeriod property in the Cloud KMS API is a google.protobuf.Duration type. Comparing a duration field directly against a string literal ('60h') causes a static type error during CEL expression parsing or runtime evaluation because relational operators (<, <=, >, >=) require identical types on both sides.duration() conversion function to instantiate a duration object from a string format.!= null) are unsupported or ineffective for checking field presence in Protocol Buffer messages within CEL.The target property were stored as an unconstrained JSON string field and evaluated inside a general-purpose programming language that performs dynamic type coercion, rather than CEL evaluating protobuf-backed Google Cloud resource properties.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated