<commit_before># Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
apiVersion: templates.gatekeeper.sh/v1alpha1
kind: ConstraintTemplate
metadata:
  name: gcp-enforce-labels-v1
spec:
  crd:
    spec:
      names:
        kind: GCPEnforceLabelConstraintV1
        plural: gcpenforcelabelconstraintsv1
      validation:
        openAPIV3Schema:
          properties: 
            mandatory_labels:
              description: | 
                "List of mandatory label objects to check for on all supported resources. 
                Label objects should be as follow:
                label_key: label_value_regex_to_match 
                Each missing label will result in a violation for scanned resources.
                Each mismatching label will result in a violation for scanned resources.
                "
              type: array
              items: objects
              required: true
            resource_types_to_scan:
              description: | 
                "Optional parameter: list of resource types to scan for labels.
                Any resource that is not of these types will not raise any violation.
                if not passed, all tested resource types will be scanned for violations:

                - cloudresourcemanager.googleapis.com/Project
                - storage.googleapis.com/Bucket
                - compute.googleapis.com/Instance
                - compute.googleapis.com/Image
                - compute.googleapis.com/Disk
                - compute.googleapis.com/Snapshot
                - google.bigtable.Instance
                - sqladmin.googleapis.com/Instance
                "
              type: array
              items: string
              required: false
  targets:
    validation.gcp.forsetisecurity.org:
      rego: | #INLINE("validator/enforce_labels.rego")
       #
       # Copyright 2018 Google LLC
       #
       # Licensed under the Apache License, Version 2.0 (the "License");
       # you may not use this file except in compliance with the License.
       # You may obtain a copy of the License at
       #
       #      http://www.apache.org/licenses/LICENSE-2.0
       #
       # Unless required by applicable law or agreed to in writing, software
       # distributed under the License is distributed on an "AS IS" BASIS,
       # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       # See the License for the specific language governing permissions and
       # limitations under the License.
       #
       <commit_msg>Fixing logical error for get_labels testing when more than one non_standard_type exists. Adding required parameters in template<commit_after># Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
apiVersion: templates.gatekeeper.sh/v1alpha1
kind: ConstraintTemplate
metadata:
  name: gcp-enforce-labels-v1
spec:
  crd:
    spec:
      names:
        kind: GCPEnforceLabelConstraintV1
        plural: gcpenforcelabelconstraintsv1
      validation:
        openAPIV3Schema:
          properties: 
            mandatory_labels:
              description: | 
                "List of mandatory label objects to check for on all supported resources. 
                Label objects should be as follow:
                label_key: label_value_regex_to_match 
                Each missing label will result in a violation for scanned resources.
                Each mismatching label will result in a violation for scanned resources.
                "
              type: array
              items: objects
            resource_types_to_scan:
              description: | 
                "Optional parameter: list of resource types to scan for labels.
                Any resource that is not of these types will not raise any violation.
                if not passed, all tested resource types will be scanned for violations:

                - cloudresourcemanager.googleapis.com/Project
                - storage.googleapis.com/Bucket
                - compute.googleapis.com/Instance
                - compute.googleapis.com/Image
                - compute.googleapis.com/Disk
                - compute.googleapis.com/Snapshot
                - google.bigtable.Instance
                - sqladmin.googleapis.com/Instance
                "
              type: array
              items: string
            required: ["mandatory_labels"]
  targets:
    validation.gcp.forsetisecurity.org:
      rego: | #INLINE("validator/enforce_labels.rego")
       #
       # Copyright 2018 Google LLC
       #
       # Licensed under the Apache License, Version 2.0 (the "License");
       # you may not use this file except in compliance with the License.
       # You may obtain a copy of the License at
       #
       #      http://www.apache.org/licenses/LICENSE-2.0
       #
       # Unless required by applicable law or agreed to in writing, software
       # distributed under the License is distributed on an "AS IS" BASIS,
       # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       # See the License for the specific language governing permissions and
       # limitations under the License.
       #
       
{'fraction_non_alphanumeric': 0.05543022881082823, 'fraction_numerical': 0.007089912987431518, 'mean_word_length': 2.048624754420432, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '405058', 'n_tokens_mistral': 1516, 'n_tokens_neox': 1424, 'n_words': 590}