1// Copyright 2021 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.cloud.binaryauthorization.v1beta1; 18 19import "google/api/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/protobuf/timestamp.proto"; 22 23option cc_enable_arenas = true; 24option csharp_namespace = "Google.Cloud.BinaryAuthorization.V1Beta1"; 25option go_package = "cloud.google.com/go/binaryauthorization/apiv1beta1/binaryauthorizationpb;binaryauthorizationpb"; 26option java_multiple_files = true; 27option java_outer_classname = "BinaryAuthorizationResourcesProto"; 28option java_package = "com.google.cloud.binaryauthorization.v1beta1"; 29option php_namespace = "Google\\Cloud\\BinaryAuthorization\\V1beta1"; 30option ruby_package = "Google::Cloud::BinaryAuthorization::V1beta1"; 31 32// A [policy][google.cloud.binaryauthorization.v1beta1.Policy] for Binary Authorization. 33message Policy { 34 option (google.api.resource) = { 35 type: "binaryauthorization.googleapis.com/Policy" 36 pattern: "projects/{project}/policy" 37 pattern: "locations/{location}/policy" 38 }; 39 40 enum GlobalPolicyEvaluationMode { 41 // Not specified: DISABLE is assumed. 42 GLOBAL_POLICY_EVALUATION_MODE_UNSPECIFIED = 0; 43 44 // Enables system policy evaluation. 45 ENABLE = 1; 46 47 // Disables system policy evaluation. 48 DISABLE = 2; 49 } 50 51 // Output only. The resource name, in the format `projects/*/policy`. There is 52 // at most one policy per project. 53 string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 54 55 // Optional. A descriptive comment. 56 string description = 6 [(google.api.field_behavior) = OPTIONAL]; 57 58 // Optional. Controls the evaluation of a Google-maintained global admission 59 // policy for common system-level images. Images not covered by the global 60 // policy will be subject to the project admission policy. This setting 61 // has no effect when specified inside a global admission policy. 62 GlobalPolicyEvaluationMode global_policy_evaluation_mode = 7 [(google.api.field_behavior) = OPTIONAL]; 63 64 // Optional. Admission policy allowlisting. A matching admission request will 65 // always be permitted. This feature is typically used to exclude Google or 66 // third-party infrastructure images from Binary Authorization policies. 67 repeated AdmissionWhitelistPattern admission_whitelist_patterns = 2 [(google.api.field_behavior) = OPTIONAL]; 68 69 // Optional. Per-cluster admission rules. Cluster spec format: 70 // `location.clusterId`. There can be at most one admission rule per cluster 71 // spec. 72 // A `location` is either a compute zone (e.g. us-central1-a) or a region 73 // (e.g. us-central1). 74 // For `clusterId` syntax restrictions see 75 // https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters. 76 map<string, AdmissionRule> cluster_admission_rules = 3 [(google.api.field_behavior) = OPTIONAL]; 77 78 // Optional. Per-kubernetes-namespace admission rules. K8s namespace spec format: 79 // `[a-z.-]+`, e.g. `some-namespace` 80 map<string, AdmissionRule> kubernetes_namespace_admission_rules = 10 [(google.api.field_behavior) = OPTIONAL]; 81 82 // Optional. Per-kubernetes-service-account admission rules. Service account 83 // spec format: `namespace:serviceaccount`. e.g. `test-ns:default` 84 map<string, AdmissionRule> kubernetes_service_account_admission_rules = 8 [(google.api.field_behavior) = OPTIONAL]; 85 86 // Optional. Per-istio-service-identity admission rules. Istio service 87 // identity spec format: 88 // `spiffe://<domain>/ns/<namespace>/sa/<serviceaccount>` or 89 // `<domain>/ns/<namespace>/sa/<serviceaccount>` 90 // e.g. `spiffe://example.com/ns/test-ns/sa/default` 91 map<string, AdmissionRule> istio_service_identity_admission_rules = 9 [(google.api.field_behavior) = OPTIONAL]; 92 93 // Required. Default admission rule for a cluster without a per-cluster, per- 94 // kubernetes-service-account, or per-istio-service-identity admission rule. 95 AdmissionRule default_admission_rule = 4 [(google.api.field_behavior) = REQUIRED]; 96 97 // Output only. Time when the policy was last updated. 98 google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; 99} 100 101// An [admission allowlist pattern][google.cloud.binaryauthorization.v1beta1.AdmissionWhitelistPattern] exempts images 102// from checks by [admission rules][google.cloud.binaryauthorization.v1beta1.AdmissionRule]. 103message AdmissionWhitelistPattern { 104 // An image name pattern to allowlist, in the form `registry/path/to/image`. 105 // This supports a trailing `*` as a wildcard, but this is allowed only in 106 // text after the `registry/` part. `*` wildcard does not match `/`, i.e., 107 // `gcr.io/nginx*` matches `gcr.io/nginx@latest`, but it does not match 108 // `gcr.io/nginx/image`. This also supports a trailing `**` wildcard which 109 // matches subdirectories, i.e., `gcr.io/nginx**` matches 110 // `gcr.io/nginx/image`. 111 string name_pattern = 1; 112} 113 114// An [admission rule][google.cloud.binaryauthorization.v1beta1.AdmissionRule] specifies either that all container images 115// used in a pod creation request must be attested to by one or more 116// [attestors][google.cloud.binaryauthorization.v1beta1.Attestor], that all pod creations will be allowed, or that all 117// pod creations will be denied. 118// 119// Images matching an [admission allowlist pattern][google.cloud.binaryauthorization.v1beta1.AdmissionWhitelistPattern] 120// are exempted from admission rules and will never block a pod creation. 121message AdmissionRule { 122 enum EvaluationMode { 123 // Do not use. 124 EVALUATION_MODE_UNSPECIFIED = 0; 125 126 // This rule allows all all pod creations. 127 ALWAYS_ALLOW = 1; 128 129 // This rule allows a pod creation if all the attestors listed in 130 // `require_attestations_by` have valid attestations for all of the 131 // images in the pod spec. 132 REQUIRE_ATTESTATION = 2; 133 134 // This rule denies all pod creations. 135 ALWAYS_DENY = 3; 136 } 137 138 // Defines the possible actions when a pod creation is denied by an admission 139 // rule. 140 enum EnforcementMode { 141 // Do not use. 142 ENFORCEMENT_MODE_UNSPECIFIED = 0; 143 144 // Enforce the admission rule by blocking the pod creation. 145 ENFORCED_BLOCK_AND_AUDIT_LOG = 1; 146 147 // Dryrun mode: Audit logging only. This will allow the pod creation as if 148 // the admission request had specified break-glass. 149 DRYRUN_AUDIT_LOG_ONLY = 2; 150 } 151 152 // Required. How this admission rule will be evaluated. 153 EvaluationMode evaluation_mode = 1 [(google.api.field_behavior) = REQUIRED]; 154 155 // Optional. The resource names of the attestors that must attest to 156 // a container image, in the format `projects/*/attestors/*`. Each 157 // attestor must exist before a policy can reference it. To add an attestor 158 // to a policy the principal issuing the policy change request must be able 159 // to read the attestor resource. 160 // 161 // Note: this field must be non-empty when the evaluation_mode field specifies 162 // REQUIRE_ATTESTATION, otherwise it must be empty. 163 repeated string require_attestations_by = 2 [(google.api.field_behavior) = OPTIONAL]; 164 165 // Required. The action when a pod creation is denied by the admission rule. 166 EnforcementMode enforcement_mode = 3 [(google.api.field_behavior) = REQUIRED]; 167} 168 169// An [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] that attests to container image 170// artifacts. An existing attestor cannot be modified except where 171// indicated. 172message Attestor { 173 option (google.api.resource) = { 174 type: "binaryauthorization.googleapis.com/Attestor" 175 pattern: "projects/{project}/attestors/{attestor}" 176 }; 177 178 // Required. The resource name, in the format: 179 // `projects/*/attestors/*`. This field may not be updated. 180 string name = 1 [(google.api.field_behavior) = REQUIRED]; 181 182 // Optional. A descriptive comment. This field may be updated. 183 // The field may be displayed in chooser dialogs. 184 string description = 6 [(google.api.field_behavior) = OPTIONAL]; 185 186 // Required. Identifies an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor] that attests to a 187 // container image artifact. This determines how an attestation will 188 // be stored, and how it will be used during policy 189 // enforcement. Updates may not change the attestor type, but individual 190 // attestor fields may be updated. 191 oneof attestor_type { 192 // A Drydock ATTESTATION_AUTHORITY Note, created by the user. 193 UserOwnedDrydockNote user_owned_drydock_note = 3; 194 } 195 196 // Output only. Time when the attestor was last updated. 197 google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; 198} 199 200// An [user owned drydock note][google.cloud.binaryauthorization.v1beta1.UserOwnedDrydockNote] references a Drydock 201// ATTESTATION_AUTHORITY Note created by the user. 202message UserOwnedDrydockNote { 203 // Required. The Drydock resource name of a ATTESTATION_AUTHORITY Note, 204 // created by the user, in the format: `projects/*/notes/*` (or the legacy 205 // `providers/*/notes/*`). This field may not be updated. 206 // 207 // An attestation by this attestor is stored as a Drydock 208 // ATTESTATION_AUTHORITY Occurrence that names a container image and that 209 // links to this Note. Drydock is an external dependency. 210 string note_reference = 1 [(google.api.field_behavior) = REQUIRED]; 211 212 // Optional. Public keys that verify attestations signed by this 213 // attestor. This field may be updated. 214 // 215 // If this field is non-empty, one of the specified public keys must 216 // verify that an attestation was signed by this attestor for the 217 // image specified in the admission request. 218 // 219 // If this field is empty, this attestor always returns that no 220 // valid attestations exist. 221 repeated AttestorPublicKey public_keys = 2 [(google.api.field_behavior) = OPTIONAL]; 222 223 // Output only. This field will contain the service account email address 224 // that this Attestor will use as the principal when querying Container 225 // Analysis. Attestor administrators must grant this service account the 226 // IAM role needed to read attestations from the [note_reference][Note] in 227 // Container Analysis (`containeranalysis.notes.occurrences.viewer`). 228 // 229 // This email address is fixed for the lifetime of the Attestor, but callers 230 // should not make any other assumptions about the service account email; 231 // future versions may use an email based on a different naming pattern. 232 string delegation_service_account_email = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; 233} 234 235// A public key in the PkixPublicKey format (see 236// https://tools.ietf.org/html/rfc5280#section-4.1.2.7 for details). 237// Public keys of this type are typically textually encoded using the PEM 238// format. 239message PkixPublicKey { 240 // Represents a signature algorithm and other information necessary to verify 241 // signatures with a given public key. 242 // This is based primarily on the public key types supported by Tink's 243 // PemKeyType, which is in turn based on KMS's supported signing algorithms. 244 // See https://cloud.google.com/kms/docs/algorithms. In the future, BinAuthz 245 // might support additional public key types independently of Tink and/or KMS. 246 enum SignatureAlgorithm { 247 option allow_alias = true; 248 249 // Not specified. 250 SIGNATURE_ALGORITHM_UNSPECIFIED = 0; 251 252 // RSASSA-PSS 2048 bit key with a SHA256 digest. 253 RSA_PSS_2048_SHA256 = 1; 254 255 // RSASSA-PSS 3072 bit key with a SHA256 digest. 256 RSA_PSS_3072_SHA256 = 2; 257 258 // RSASSA-PSS 4096 bit key with a SHA256 digest. 259 RSA_PSS_4096_SHA256 = 3; 260 261 // RSASSA-PSS 4096 bit key with a SHA512 digest. 262 RSA_PSS_4096_SHA512 = 4; 263 264 // RSASSA-PKCS1-v1_5 with a 2048 bit key and a SHA256 digest. 265 RSA_SIGN_PKCS1_2048_SHA256 = 5; 266 267 // RSASSA-PKCS1-v1_5 with a 3072 bit key and a SHA256 digest. 268 RSA_SIGN_PKCS1_3072_SHA256 = 6; 269 270 // RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA256 digest. 271 RSA_SIGN_PKCS1_4096_SHA256 = 7; 272 273 // RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA512 digest. 274 RSA_SIGN_PKCS1_4096_SHA512 = 8; 275 276 // ECDSA on the NIST P-256 curve with a SHA256 digest. 277 ECDSA_P256_SHA256 = 9; 278 279 // ECDSA on the NIST P-256 curve with a SHA256 digest. 280 EC_SIGN_P256_SHA256 = 9; 281 282 // ECDSA on the NIST P-384 curve with a SHA384 digest. 283 ECDSA_P384_SHA384 = 10; 284 285 // ECDSA on the NIST P-384 curve with a SHA384 digest. 286 EC_SIGN_P384_SHA384 = 10; 287 288 // ECDSA on the NIST P-521 curve with a SHA512 digest. 289 ECDSA_P521_SHA512 = 11; 290 291 // ECDSA on the NIST P-521 curve with a SHA512 digest. 292 EC_SIGN_P521_SHA512 = 11; 293 } 294 295 // A PEM-encoded public key, as described in 296 // https://tools.ietf.org/html/rfc7468#section-13 297 string public_key_pem = 1; 298 299 // The signature algorithm used to verify a message against a signature using 300 // this key. 301 // These signature algorithm must match the structure and any object 302 // identifiers encoded in `public_key_pem` (i.e. this algorithm must match 303 // that of the public key). 304 SignatureAlgorithm signature_algorithm = 2; 305} 306 307// An [attestor public key][google.cloud.binaryauthorization.v1beta1.AttestorPublicKey] that will be used to verify 308// attestations signed by this attestor. 309message AttestorPublicKey { 310 // Optional. A descriptive comment. This field may be updated. 311 string comment = 1 [(google.api.field_behavior) = OPTIONAL]; 312 313 // The ID of this public key. 314 // Signatures verified by BinAuthz must include the ID of the public key that 315 // can be used to verify them, and that ID must match the contents of this 316 // field exactly. 317 // Additional restrictions on this field can be imposed based on which public 318 // key type is encapsulated. See the documentation on `public_key` cases below 319 // for details. 320 string id = 2; 321 322 // Required. A public key reference or serialized instance. This field may be 323 // updated. 324 oneof public_key { 325 // ASCII-armored representation of a PGP public key, as the entire output by 326 // the command `gpg --export --armor [email protected]` (either LF or CRLF 327 // line endings). 328 // When using this field, `id` should be left blank. The BinAuthz API 329 // handlers will calculate the ID and fill it in automatically. BinAuthz 330 // computes this ID as the OpenPGP RFC4880 V4 fingerprint, represented as 331 // upper-case hex. If `id` is provided by the caller, it will be 332 // overwritten by the API-calculated ID. 333 string ascii_armored_pgp_public_key = 3; 334 335 // A raw PKIX SubjectPublicKeyInfo format public key. 336 // 337 // NOTE: `id` may be explicitly provided by the caller when using this 338 // type of public key, but it MUST be a valid RFC3986 URI. If `id` is left 339 // blank, a default one will be computed based on the digest of the DER 340 // encoding of the public key. 341 PkixPublicKey pkix_public_key = 5; 342 } 343} 344