resources.proto 15 KB

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