resources.proto 14 KB

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