Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion script/validate_runner_catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class RunnerCatalogValidator
"privilegedContainers" => "privileged containers",
"ordinaryBuildAndTestTooling" => BASELINE_CAPABILITY
}.freeze
SOURCE_ONLY_FALSE_CAPABILITIES = %w[nestedVirtualization].freeze
PUBLIC_CAPABILITIES = (CAPABILITY_NAMES.values + [BASELINE_CAPABILITY]).freeze
PROFILE_DEFINITIONS = {
"akua-x64-ci-v2" => {
Expand Down Expand Up @@ -385,7 +386,11 @@ def normalize_profile(source_profile)

def normalize_capabilities(capabilities)
fail_with("source capability schema drift") unless capabilities.is_a?(Hash)
fail_with("source capability schema drift") unless capabilities.keys.all? { |key| CAPABILITY_NAMES.key?(key) }
allowed_source_keys = CAPABILITY_NAMES.keys + SOURCE_ONLY_FALSE_CAPABILITIES
fail_with("source capability schema drift") unless capabilities.keys.all? { |key| allowed_source_keys.include?(key) }
SOURCE_ONLY_FALSE_CAPABILITIES.each do |key|
fail_with("source-only capability must remain disabled") unless capabilities.fetch(key, false) == false
end
result = CAPABILITY_NAMES.each_with_object([]) do |(key, name), values|
value = capabilities.fetch(key, false)
fail_with("source capability schema drift") unless value == true || value == false
Expand Down
12 changes: 12 additions & 0 deletions test/runner_catalog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ def test_trusted_validator_rejects_truthy_non_boolean_capabilities
end
end

def test_trusted_validator_rejects_enabled_source_only_capability
with_source_candidate do |candidate, source|
source_file = File.join(source, SOURCE_PATH)
source_catalog = YAML.safe_load(File.read(source_file), aliases: false)
source_catalog.fetch("profiles").last.fetch("capabilities")["nestedVirtualization"] = true
File.write(source_file, YAML.dump(source_catalog))
update_source_hash(candidate, source_file)
assert_validator_failure(candidate, "source-only capability must remain disabled", source)
end
end

def test_trusted_validator_rejects_missing_baseline_capability
with_source_candidate do |candidate, source|
source_file = File.join(source, SOURCE_PATH)
Expand Down Expand Up @@ -343,6 +354,7 @@ def source_catalog
"buildx" => profile.dig("capabilities", "guaranteed").include?("Buildx"),
"serviceContainers" => profile.dig("capabilities", "guaranteed").include?("service containers"),
"privilegedContainers" => profile.dig("capabilities", "guaranteed").include?("privileged containers"),
"nestedVirtualization" => false,
"ordinaryBuildAndTestTooling" => true
}
profile.merge(
Expand Down
Loading