Skip to content

Commit 6f91359

Browse files
authored
Merge pull request #1691 from dheerajodha/EC-1651
refactor: move all data.lib top-level functions to subcategories
2 parents 6ddb8f6 + 721815d commit 6f91359

File tree

173 files changed

+2351
-2205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+2351
-2205
lines changed

.regal/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ rules:
5151
- "*_schema.rego"
5252
# This is generated by `make sync-test-data` and has many long lines
5353
- policy/lib/tekton/recorded_att_data_test.rego
54+
# Test files often have long assertion lines due to explicit package names from refactoring
55+
- "*_test.rego"
5456
pointless-reassignment:
5557
ignore:
5658
files:

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,16 @@ endif
3636
LICENSE_IGNORE=-ignore '.git/**' -ignore '.idea/**'
3737

3838
TEST_FILES = $(DATA_DIR)/rule_data.yml $(POLICY_DIR) checks
39+
40+
COVERAGE_CMD_DEFAULT=$(OPA) test --coverage --format json $(TEST_FILES)
41+
ifeq ($(shell command -v unshare),)
42+
COVERAGE_CMD=$(COVERAGE_CMD_DEFAULT)
43+
else
44+
COVERAGE_CMD=$(EC) version > /dev/null && unshare -r -n $(COVERAGE_CMD_DEFAULT)
45+
endif
46+
3947
define COVERAGE
40-
@$(OPA) test --coverage --format json $(TEST_FILES) | { \
48+
@$(COVERAGE_CMD) | { \
4149
T=$$(mktemp); tee "$${T}"; $(OPA) eval --format pretty \
4250
--input "$${T}" \
4351
--data hack/simplecov.rego \

antora/docs/modules/ROOT/pages/packages/build_task_build_labels.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Confirm the build task definition has the required build type label.
1616
* Rule type: [rule-type-indicator failure]#FAILURE#
1717
* FAILURE message: `The required build label '%s' is missing`
1818
* Code: `build_labels.build_type_label_set`
19-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/build_task/build_labels/build_labels.rego#L17[Source, window="_blank"]
19+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/build_task/build_labels/build_labels.rego#L18[Source, window="_blank"]
2020

2121
[#build_labels__build_task_has_label]
2222
=== link:#build_labels__build_task_has_label[Build task has label]
@@ -26,4 +26,4 @@ Confirm that the build task definition includes at least one label.
2626
* Rule type: [rule-type-indicator failure]#FAILURE#
2727
* FAILURE message: `The task definition does not include any labels`
2828
* Code: `build_labels.build_task_has_label`
29-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/build_task/build_labels/build_labels.rego#L30[Source, window="_blank"]
29+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/build_task/build_labels/build_labels.rego#L31[Source, window="_blank"]

antora/docs/modules/ROOT/pages/packages/pipeline_required_tasks.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Produce a warning when a task that will be required in the future is not current
1616
* Rule type: [rule-type-indicator warning]#WARNING#
1717
* WARNING message: `%s is missing and will be required on %s`
1818
* Code: `required_tasks.missing_future_required_task`
19-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/required_tasks/required_tasks.rego#L60[Source, window="_blank"]
19+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/required_tasks/required_tasks.rego#L63[Source, window="_blank"]
2020

2121
[#required_tasks__missing_required_task]
2222
=== link:#required_tasks__missing_required_task[Missing required task]
@@ -26,7 +26,7 @@ Ensure that the set of required tasks is included in the Pipeline definition.
2626
* Rule type: [rule-type-indicator failure]#FAILURE#
2727
* FAILURE message: `%s is missing or outdated`
2828
* Code: `required_tasks.missing_required_task`
29-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/required_tasks/required_tasks.rego#L97[Source, window="_blank"]
29+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/required_tasks/required_tasks.rego#L100[Source, window="_blank"]
3030

3131
[#required_tasks__tasks_found]
3232
=== link:#required_tasks__tasks_found[Pipeline contains tasks]
@@ -36,7 +36,7 @@ Confirm at least one task is present in the pipeline definition.
3636
* Rule type: [rule-type-indicator failure]#FAILURE#
3737
* FAILURE message: `No tasks found in pipeline`
3838
* Code: `required_tasks.tasks_found`
39-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/required_tasks/required_tasks.rego#L84[Source, window="_blank"]
39+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/required_tasks/required_tasks.rego#L87[Source, window="_blank"]
4040

4141
[#required_tasks__required_tasks_list_present]
4242
=== link:#required_tasks__required_tasks_list_present[Required task list is present in rule data]
@@ -46,7 +46,7 @@ Confirm the `required-tasks` rule data was provided, since it's required by the
4646
* Rule type: [rule-type-indicator failure]#FAILURE#
4747
* FAILURE message: `The required tasks list is missing from the rule data`
4848
* Code: `required_tasks.required_tasks_list_present`
49-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/required_tasks/required_tasks.rego#L116[Source, window="_blank"]
49+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/required_tasks/required_tasks.rego#L122[Source, window="_blank"]
5050

5151
[#required_tasks__required_tasks_found]
5252
=== link:#required_tasks__required_tasks_found[Required tasks found in pipeline definition]
@@ -56,4 +56,4 @@ Produce a warning if a list of current or future required tasks does not exist i
5656
* Rule type: [rule-type-indicator warning]#WARNING#
5757
* WARNING message: `Required tasks do not exist for pipeline %q`
5858
* Code: `required_tasks.required_tasks_found`
59-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/required_tasks/required_tasks.rego#L41[Source, window="_blank"]
59+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/required_tasks/required_tasks.rego#L44[Source, window="_blank"]

antora/docs/modules/ROOT/pages/packages/pipeline_task_bundle.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Confirm the `trusted_tasks` rule data was provided, since it's required by the p
1616
* Rule type: [rule-type-indicator failure]#FAILURE#
1717
* FAILURE message: `Missing required trusted_tasks data`
1818
* Code: `task_bundle.missing_required_data`
19-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/task_bundle/task_bundle.rego#L123[Source, window="_blank"]
19+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/task_bundle/task_bundle.rego#L124[Source, window="_blank"]
2020

2121
[#task_bundle__untrusted_task_bundle]
2222
=== link:#task_bundle__untrusted_task_bundle[Task bundle is not trusted]
@@ -26,7 +26,7 @@ For each Task in the Pipeline definition, check if the Tekton Bundle used is a t
2626
* Rule type: [rule-type-indicator failure]#FAILURE#
2727
* FAILURE message: `Pipeline task '%s' uses an untrusted task bundle '%s'`
2828
* Code: `task_bundle.untrusted_task_bundle`
29-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/task_bundle/task_bundle.rego#L108[Source, window="_blank"]
29+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/task_bundle/task_bundle.rego#L109[Source, window="_blank"]
3030

3131
[#task_bundle__out_of_date_task_bundle]
3232
=== link:#task_bundle__out_of_date_task_bundle[Task bundle is out of date]
@@ -36,7 +36,7 @@ For each Task in the Pipeline definition, check if the Tekton Bundle used is the
3636
* Rule type: [rule-type-indicator warning]#WARNING#
3737
* WARNING message: `Pipeline task '%s' uses an out of date task bundle '%s', new version of the Task must be used before %s`
3838
* Code: `task_bundle.out_of_date_task_bundle`
39-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/task_bundle/task_bundle.rego#L59[Source, window="_blank"]
39+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/task_bundle/task_bundle.rego#L60[Source, window="_blank"]
4040

4141
[#task_bundle__empty_task_bundle_reference]
4242
=== link:#task_bundle__empty_task_bundle_reference[Task bundle reference is empty]
@@ -46,7 +46,7 @@ Check that a valid task bundle reference is being used.
4646
* Rule type: [rule-type-indicator failure]#FAILURE#
4747
* FAILURE message: `Pipeline task '%s' uses an empty bundle image reference`
4848
* Code: `task_bundle.empty_task_bundle_reference`
49-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/task_bundle/task_bundle.rego#L95[Source, window="_blank"]
49+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/task_bundle/task_bundle.rego#L96[Source, window="_blank"]
5050

5151
[#task_bundle__disallowed_task_reference]
5252
=== link:#task_bundle__disallowed_task_reference[Task bundle was not used or is not defined]
@@ -56,7 +56,7 @@ Check for the existence of a task bundle. This rule will fail if the task is not
5656
* Rule type: [rule-type-indicator failure]#FAILURE#
5757
* FAILURE message: `Pipeline task '%s' does not contain a bundle reference`
5858
* Code: `task_bundle.disallowed_task_reference`
59-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/task_bundle/task_bundle.rego#L81[Source, window="_blank"]
59+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/task_bundle/task_bundle.rego#L82[Source, window="_blank"]
6060

6161
[#task_bundle__unpinned_task_bundle]
6262
=== link:#task_bundle__unpinned_task_bundle[Unpinned task bundle reference]
@@ -66,4 +66,4 @@ Check if the Tekton Bundle used for the Tasks in the Pipeline definition is pinn
6666
* Rule type: [rule-type-indicator warning]#WARNING#
6767
* WARNING message: `Pipeline task '%s' uses an unpinned task bundle reference '%s'`
6868
* Code: `task_bundle.unpinned_task_bundle`
69-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/task_bundle/task_bundle.rego#L45[Source, window="_blank"]
69+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/pipeline/task_bundle/task_bundle.rego#L46[Source, window="_blank"]

antora/docs/modules/ROOT/pages/packages/release_attestation_type.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The Conforma CLI now places the attestation data in a different location. This c
1919
* FAILURE message: `Deprecated policy attestation format found`
2020
* Code: `attestation_type.deprecated_policy_attestation_format`
2121
* Effective from: `2023-08-31T00:00:00Z`
22-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/attestation_type/attestation_type.rego#L80[Source, window="_blank"]
22+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/attestation_type/attestation_type.rego#L82[Source, window="_blank"]
2323

2424
[#attestation_type__known_attestation_type]
2525
=== link:#attestation_type__known_attestation_type[Known attestation type found]
@@ -31,7 +31,7 @@ Confirm the attestation found for the image has a known attestation type.
3131
* Rule type: [rule-type-indicator failure]#FAILURE#
3232
* FAILURE message: `Unknown attestation type '%s'`
3333
* Code: `attestation_type.known_attestation_type`
34-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/attestation_type/attestation_type.rego#L14[Source, window="_blank"]
34+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/attestation_type/attestation_type.rego#L16[Source, window="_blank"]
3535

3636
[#attestation_type__known_attestation_types_provided]
3737
=== link:#attestation_type__known_attestation_types_provided[Known attestation types provided]
@@ -43,7 +43,7 @@ Confirm the `known_attestation_types` rule data was provided.
4343
* Rule type: [rule-type-indicator failure]#FAILURE#
4444
* FAILURE message: `%s`
4545
* Code: `attestation_type.known_attestation_types_provided`
46-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/attestation_type/attestation_type.rego#L42[Source, window="_blank"]
46+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/attestation_type/attestation_type.rego#L44[Source, window="_blank"]
4747

4848
[#attestation_type__pipelinerun_attestation_found]
4949
=== link:#attestation_type__pipelinerun_attestation_found[PipelineRun attestation found]
@@ -55,4 +55,4 @@ Confirm at least one PipelineRun attestation is present.
5555
* Rule type: [rule-type-indicator failure]#FAILURE#
5656
* FAILURE message: `Missing pipelinerun attestation`
5757
* Code: `attestation_type.pipelinerun_attestation_found`
58-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/attestation_type/attestation_type.rego#L60[Source, window="_blank"]
58+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/attestation_type/attestation_type.rego#L62[Source, window="_blank"]

antora/docs/modules/ROOT/pages/packages/release_base_image_registries.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Confirm the `allowed_registry_prefixes` rule data was provided, since it's requi
1818
* Rule type: [rule-type-indicator failure]#FAILURE#
1919
* FAILURE message: `%s`
2020
* Code: `base_image_registries.allowed_registries_provided`
21-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/base_image_registries/base_image_registries.rego#L73[Source, window="_blank"]
21+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/base_image_registries/base_image_registries.rego#L74[Source, window="_blank"]
2222

2323
[#base_image_registries__base_image_permitted]
2424
=== link:#base_image_registries__base_image_permitted[Base image comes from permitted registry]
@@ -30,7 +30,7 @@ Verify that the base images used when building a container image come from a kno
3030
* Rule type: [rule-type-indicator failure]#FAILURE#
3131
* FAILURE message: `Base image %q is from a disallowed registry`
3232
* Code: `base_image_registries.base_image_permitted`
33-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/base_image_registries/base_image_registries.rego#L17[Source, window="_blank"]
33+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/base_image_registries/base_image_registries.rego#L18[Source, window="_blank"]
3434

3535
[#base_image_registries__base_image_info_found]
3636
=== link:#base_image_registries__base_image_info_found[Base images provided]
@@ -42,4 +42,4 @@ Verify the expected information was provided about which base images were used d
4242
* Rule type: [rule-type-indicator failure]#FAILURE#
4343
* FAILURE message: `Base images information is missing`
4444
* Code: `base_image_registries.base_image_info_found`
45-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/base_image_registries/base_image_registries.rego#L47[Source, window="_blank"]
45+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/base_image_registries/base_image_registries.rego#L48[Source, window="_blank"]

antora/docs/modules/ROOT/pages/packages/release_buildah_build_task.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Verify the ADD_CAPABILITIES parameter of a builder Tasks was not used.
1919
* FAILURE message: `ADD_CAPABILITIES parameter is not allowed`
2020
* Code: `buildah_build_task.add_capabilities_param`
2121
* Effective from: `2024-08-31T00:00:00Z`
22-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/buildah_build_task/buildah_build_task.rego#L35[Source, window="_blank"]
22+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/buildah_build_task/buildah_build_task.rego#L38[Source, window="_blank"]
2323

2424
[#buildah_build_task__buildah_uses_local_dockerfile]
2525
=== link:#buildah_build_task__buildah_uses_local_dockerfile[Buildah task uses a local Dockerfile]
@@ -31,7 +31,7 @@ Verify the Dockerfile used in the buildah task was not fetched from an external
3131
* Rule type: [rule-type-indicator failure]#FAILURE#
3232
* FAILURE message: `DOCKERFILE param value (%s) is an external source`
3333
* Code: `buildah_build_task.buildah_uses_local_dockerfile`
34-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/buildah_build_task/buildah_build_task.rego#L14[Source, window="_blank"]
34+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/buildah_build_task/buildah_build_task.rego#L17[Source, window="_blank"]
3535

3636
[#buildah_build_task__platform_param]
3737
=== link:#buildah_build_task__platform_param[PLATFORM parameter]
@@ -44,7 +44,7 @@ Verify the value of the PLATFORM parameter of a builder Task is allowed by match
4444
* FAILURE message: `PLATFORM parameter value %q is disallowed by regex %q`
4545
* Code: `buildah_build_task.platform_param`
4646
* Effective from: `2024-09-01T00:00:00Z`
47-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/buildah_build_task/buildah_build_task.rego#L58[Source, window="_blank"]
47+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/buildah_build_task/buildah_build_task.rego#L61[Source, window="_blank"]
4848

4949
[#buildah_build_task__privileged_nested_param]
5050
=== link:#buildah_build_task__privileged_nested_param[PRIVILEGED_NESTED parameter]
@@ -56,7 +56,7 @@ Verify the PRIVILEGED_NESTED parameter of a builder Tasks was not set to `true`.
5656
* Rule type: [rule-type-indicator failure]#FAILURE#
5757
* FAILURE message: `setting PRIVILEGED_NESTED parameter to true is not allowed`
5858
* Code: `buildah_build_task.privileged_nested_param`
59-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/buildah_build_task/buildah_build_task.rego#L97[Source, window="_blank"]
59+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/buildah_build_task/buildah_build_task.rego#L100[Source, window="_blank"]
6060

6161
[#buildah_build_task__disallowed_platform_patterns_pattern]
6262
=== link:#buildah_build_task__disallowed_platform_patterns_pattern[disallowed_platform_patterns format]
@@ -66,4 +66,4 @@ Confirm the `disallowed_platform_patterns` rule data, if provided matches the ex
6666
* Rule type: [rule-type-indicator failure]#FAILURE#
6767
* FAILURE message: `%s`
6868
* Code: `buildah_build_task.disallowed_platform_patterns_pattern`
69-
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/buildah_build_task/buildah_build_task.rego#L81[Source, window="_blank"]
69+
* https://github.com/conforma/policy/blob/{page-origin-refhash}/policy/release/buildah_build_task/buildah_build_task.rego#L84[Source, window="_blank"]

0 commit comments

Comments
 (0)