diff --git a/internal/schemavalidators/internal_schemas/runnercontext/runner-context-response-0.1.schema.json b/internal/schemavalidators/internal_schemas/runnercontext/runner-context-response-0.1.schema.json index 8acfb55de..fbc3262d5 100644 --- a/internal/schemavalidators/internal_schemas/runnercontext/runner-context-response-0.1.schema.json +++ b/internal/schemavalidators/internal_schemas/runnercontext/runner-context-response-0.1.schema.json @@ -1,437 +1,547 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "https://chainloop.dev/schemas/runner-context-response-0.1.json", - "properties": { - "meta": { + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://chainloop.dev/schemas/runner-context-response-0.1.json", + "properties": { + "meta": { + "properties": { + "id": { + "type": "string", + "description": "Unique identifier for the runner context schema version" + }, + "generated_at": { + "type": "string", + "description": "Timestamp when the runner context was generated (RFC3339 format)" + }, + "errors": { + "items": { "properties": { - "id": { - "type": "string", - "description": "Unique identifier for the runner context schema version" - }, - "generated_at": { - "type": "string", - "description": "Timestamp when the runner context was generated (RFC3339 format)" - }, - "errors": { - "items": { + "code": { + "type": "string", + "description": "Error code for identification (e.g: PERMISSION_RULESETS PERMISSION_BRANCHES)" + }, + "message": { + "type": "string", + "description": "Human-readable error message" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "code", + "message" + ] + }, + "type": "array", + "description": "Array of error details with codes" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "id" + ], + "description": "Metadata information for the runner context" + }, + "data": { + "properties": { + "tool": { + "type": "string", + "description": "Tool identifier with version/hash information" + }, + "provider": { + "type": "string", + "description": "Source control provider (e.g." + }, + "repos": { + "items": { + "properties": { + "owner": { + "type": "string", + "description": "Repository owner name" + }, + "repository": { + "type": "string", + "description": "Repository name" + }, + "branches": { + "items": { + "properties": { + "name": { + "type": "string", + "description": "Branch name" + }, + "active_rules": { + "items": { "properties": { - "code": { - "type": "string", - "description": "Error code for identification (e.g: PERMISSION_RULESETS PERMISSION_BRANCHES)" + "name": { + "type": "string", + "description": "Rule name" + }, + "enabled": { + "type": "string", + "description": "Rule enabled state" + }, + "context": { + "items": { + "properties": { + "name": { + "type": "string", + "description": "Context variable name" + }, + "value": { + "type": "string", + "description": "Context variable value" + }, + "enabled": { + "type": "string", + "description": "Context variable enabled state" + }, + "members": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Team member logins (only populated for team contexts)" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "value", + "enabled" + ] + }, + "type": "array", + "description": "Array of context variables" + }, + "bypass_configuration": { + "items": { + "properties": { + "actor_id": { + "type": "integer", + "description": "The ID of the actor allowed to bypass" + }, + "actor_type": { + "type": "string", + "description": "The type of the actor allowed to bypass (e.g." + }, + "bypass_mode": { + "type": "string", + "description": "The bypass mode (e.g." + }, + "actor_name": { + "type": "string", + "description": "Human-readable name of the actor" + }, + "actor_login": { + "type": "string", + "description": "Login or username of the actor (if applicable)" + }, + "actor_metadata": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Provider-specific metadata about the actor" + } + }, + "additionalProperties": false, + "type": "object" }, - "message": { - "type": "string", - "description": "Human-readable error message" - } + "type": "array", + "description": "Configuration for bypassing the rule" + } }, "additionalProperties": false, "type": "object", "required": [ - "code", - "message" + "name", + "enabled" ] + }, + "type": "array", + "description": "Array of active rules for the branch" }, - "type": "array", - "description": "Array of error details with codes" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "id" - ], - "description": "Metadata information for the runner context" - }, - "data": { - "properties": { - "tool": { - "type": "string", - "description": "Tool identifier with version/hash information" - }, - "provider": { - "type": "string", - "description": "Source control provider (e.g." - }, - "repos": { - "items": { + "users": { + "items": { "properties": { - "owner": { - "type": "string", - "description": "Repository owner name" - }, - "repository": { - "type": "string", - "description": "Repository name" + "id": { + "type": "string", + "description": "User identifier" + }, + "name": { + "type": "string", + "description": "User name" + }, + "roles": { + "items": { + "type": "string" }, - "branches": { - "items": { - "properties": { - "name": { - "type": "string", - "description": "Branch name" - }, - "active_rules": { - "items": { - "properties": { - "name": { - "type": "string", - "description": "Rule name" - }, - "enabled": { - "type": "string", - "description": "Rule enabled state" - }, - "context": { - "items": { - "properties": { - "name": { - "type": "string", - "description": "Context variable name" - }, - "value": { - "type": "string", - "description": "Context variable value" - }, - "enabled": { - "type": "string", - "description": "Context variable enabled state" - }, - "members": { - "items": { - "type": "string" - }, - "type": "array", - "description": "Team member logins (only populated for team contexts)" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "value", - "enabled" - ] - }, - "type": "array", - "description": "Array of context variables" - }, - "bypass_configuration": { - "items": { - "properties": { - "actor_id": { - "type": "integer", - "description": "The ID of the actor allowed to bypass" - }, - "actor_type": { - "type": "string", - "description": "The type of the actor allowed to bypass (e.g." - }, - "bypass_mode": { - "type": "string", - "description": "The bypass mode (e.g." - }, - "actor_name": { - "type": "string", - "description": "Human-readable name of the actor" - }, - "actor_login": { - "type": "string", - "description": "Login or username of the actor (if applicable)" - }, - "actor_metadata": { - "additionalProperties": { - "type": "string" - }, - "type": "object", - "description": "Provider-specific metadata about the actor" - } - }, - "additionalProperties": false, - "type": "object" - }, - "type": "array", - "description": "Configuration for bypassing the rule" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "enabled" - ] - }, - "type": "array", - "description": "Array of active rules for the branch" - }, - "users": { - "items": { - "properties": { - "id": { - "type": "string", - "description": "User identifier" - }, - "name": { - "type": "string", - "description": "User name" - }, - "roles": { - "items": { - "type": "string" - }, - "type": "array", - "description": "User roles" - }, - "settings": { - "items": { - "properties": { - "name": { - "type": "string", - "description": "User-specific setting name" - }, - "value": { - "type": "string", - "description": "User-specific setting value" - }, - "context": { - "items": { - "properties": { - "name": { - "type": "string", - "description": "Context variable name" - }, - "value": { - "type": "string", - "description": "Context variable value" - }, - "enabled": { - "type": "string", - "description": "Context variable enabled state" - }, - "members": { - "items": { - "type": "string" - }, - "type": "array", - "description": "Team member logins (only populated for team contexts)" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "value", - "enabled" - ] - }, - "type": "array", - "description": "Array of context variables" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "value" - ] - }, - "type": "array", - "description": "User-specific settings" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "id", - "name" - ] - }, - "type": "array", - "description": "Users with access to this branch" - }, - "commits": { - "items": { - "type": "string" - }, - "type": "array", - "description": "Array of commit SHA identifiers" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name" - ] + "type": "array", + "description": "User roles" + }, + "settings": { + "items": { + "properties": { + "name": { + "type": "string", + "description": "User-specific setting name" }, - "type": "array", - "description": "Array of branch configurations" - }, - "settings": { - "items": { + "value": { + "type": "string", + "description": "User-specific setting value" + }, + "context": { + "items": { "properties": { - "name": { - "type": "string", - "description": "Setting name" - }, - "value": { - "type": "string", - "description": "Setting value" + "name": { + "type": "string", + "description": "Context variable name" + }, + "value": { + "type": "string", + "description": "Context variable value" + }, + "enabled": { + "type": "string", + "description": "Context variable enabled state" + }, + "members": { + "items": { + "type": "string" }, - "context": { - "items": { - "properties": { - "name": { - "type": "string", - "description": "Context variable name" - }, - "value": { - "type": "string", - "description": "Context variable value" - }, - "enabled": { - "type": "string", - "description": "Context variable enabled state" - }, - "members": { - "items": { - "type": "string" - }, - "type": "array", - "description": "Team member logins (only populated for team contexts)" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "value", - "enabled" - ] - }, - "type": "array", - "description": "Array of context variables" - } + "type": "array", + "description": "Team member logins (only populated for team contexts)" + } }, "additionalProperties": false, "type": "object", "required": [ - "name", - "value" + "name", + "value", + "enabled" ] + }, + "type": "array", + "description": "Array of context variables" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "value" + ] + }, + "type": "array", + "description": "User-specific settings" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "id", + "name" + ] + }, + "type": "array", + "description": "Users with access to this branch" + }, + "commits": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Array of commit SHA identifiers" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name" + ] + }, + "type": "array", + "description": "Array of branch configurations" + }, + "tags": { + "items": { + "properties": { + "name": { + "type": "string", + "description": "Tag name or pattern" + }, + "active_rules": { + "items": { + "properties": { + "name": { + "type": "string", + "description": "Rule name" + }, + "enabled": { + "type": "string", + "description": "Rule enabled state" + }, + "context": { + "items": { + "properties": { + "name": { + "type": "string", + "description": "Context variable name" }, - "type": "array", - "description": "Array of repository-level settings" + "value": { + "type": "string", + "description": "Context variable value" + }, + "enabled": { + "type": "string", + "description": "Context variable enabled state" + }, + "members": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Team member logins (only populated for team contexts)" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "value", + "enabled" + ] }, - "users": { - "items": { - "properties": { - "id": { - "type": "string", - "description": "User identifier" - }, - "name": { - "type": "string", - "description": "User name" - }, - "roles": { - "items": { - "type": "string" - }, - "type": "array", - "description": "User roles" - }, - "settings": { - "items": { - "properties": { - "name": { - "type": "string", - "description": "User-specific setting name" - }, - "value": { - "type": "string", - "description": "User-specific setting value" - }, - "context": { - "items": { - "properties": { - "name": { - "type": "string", - "description": "Context variable name" - }, - "value": { - "type": "string", - "description": "Context variable value" - }, - "enabled": { - "type": "string", - "description": "Context variable enabled state" - }, - "members": { - "items": { - "type": "string" - }, - "type": "array", - "description": "Team member logins (only populated for team contexts)" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "value", - "enabled" - ] - }, - "type": "array", - "description": "Array of context variables" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "name", - "value" - ] - }, - "type": "array", - "description": "User-specific settings" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "id", - "name" - ] + "type": "array", + "description": "Array of context variables" + }, + "bypass_configuration": { + "items": { + "properties": { + "actor_id": { + "type": "integer", + "description": "The ID of the actor allowed to bypass" + }, + "actor_type": { + "type": "string", + "description": "The type of the actor allowed to bypass (e.g." }, - "type": "array", - "description": "Array of user configurations" - } + "bypass_mode": { + "type": "string", + "description": "The bypass mode (e.g." + }, + "actor_name": { + "type": "string", + "description": "Human-readable name of the actor" + }, + "actor_login": { + "type": "string", + "description": "Login or username of the actor (if applicable)" + }, + "actor_metadata": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "description": "Provider-specific metadata about the actor" + } + }, + "additionalProperties": false, + "type": "object" + }, + "type": "array", + "description": "Configuration for bypassing the rule" + } }, "additionalProperties": false, "type": "object", "required": [ - "repository" + "name", + "enabled" ] + }, + "type": "array", + "description": "Array of active protection rules for the tag" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name" + ] + }, + "type": "array", + "description": "Array of tag protection configurations" + }, + "settings": { + "items": { + "properties": { + "name": { + "type": "string", + "description": "Setting name" + }, + "value": { + "type": "string", + "description": "Setting value" }, - "type": "array", - "description": "Array of repository configurations" - } + "context": { + "items": { + "properties": { + "name": { + "type": "string", + "description": "Context variable name" + }, + "value": { + "type": "string", + "description": "Context variable value" + }, + "enabled": { + "type": "string", + "description": "Context variable enabled state" + }, + "members": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Team member logins (only populated for team contexts)" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "value", + "enabled" + ] + }, + "type": "array", + "description": "Array of context variables" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "value" + ] + }, + "type": "array", + "description": "Array of repository-level settings" + }, + "users": { + "items": { + "properties": { + "id": { + "type": "string", + "description": "User identifier" + }, + "name": { + "type": "string", + "description": "User name" + }, + "roles": { + "items": { + "type": "string" + }, + "type": "array", + "description": "User roles" + }, + "settings": { + "items": { + "properties": { + "name": { + "type": "string", + "description": "User-specific setting name" + }, + "value": { + "type": "string", + "description": "User-specific setting value" + }, + "context": { + "items": { + "properties": { + "name": { + "type": "string", + "description": "Context variable name" + }, + "value": { + "type": "string", + "description": "Context variable value" + }, + "enabled": { + "type": "string", + "description": "Context variable enabled state" + }, + "members": { + "items": { + "type": "string" + }, + "type": "array", + "description": "Team member logins (only populated for team contexts)" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "value", + "enabled" + ] + }, + "type": "array", + "description": "Array of context variables" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "name", + "value" + ] + }, + "type": "array", + "description": "User-specific settings" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "id", + "name" + ] + }, + "type": "array", + "description": "Array of user configurations" + } }, "additionalProperties": false, "type": "object", "required": [ - "tool", - "provider" - ], - "description": "Main payload data containing tool" + "repository" + ] + }, + "type": "array", + "description": "Array of repository configurations" } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "meta", - "data" - ], - "title": "Runner Context Response Schema", - "description": "JSON Schema for validating the Runner Context Response structure" + }, + "additionalProperties": false, + "type": "object", + "required": [ + "tool", + "provider" + ], + "description": "Main payload data containing tool" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "meta", + "data" + ], + "title": "Runner Context Response Schema", + "description": "JSON Schema for validating the Runner Context Response structure" } \ No newline at end of file diff --git a/pkg/attestation/crafter/materials/runnercontext_test.go b/pkg/attestation/crafter/materials/runnercontext_test.go index a55d2166a..5f5ceccd3 100644 --- a/pkg/attestation/crafter/materials/runnercontext_test.go +++ b/pkg/attestation/crafter/materials/runnercontext_test.go @@ -86,6 +86,11 @@ func TestChainloopRunnerContextCraft(t *testing.T) { filePath: "./testdata/runner-context-branches-v0.1.json", digest: "sha256:3c587dfc0cb5b588b1ac4d9a2301efa45458a9e9c4d0fbd417515a2a5ccc7fa4", }, + { + name: "valid artifact type with tags", + filePath: "./testdata/runner-context-tags-v0.1.json", + digest: "sha256:588638b4a2451ec4b572ecc8e620940ad925e297c49d73887d563350d77cf84e", + }, } assert := assert.New(t) diff --git a/pkg/attestation/crafter/materials/testdata/runner-context-tags-v0.1.json b/pkg/attestation/crafter/materials/testdata/runner-context-tags-v0.1.json new file mode 100644 index 000000000..ae3bfce2a --- /dev/null +++ b/pkg/attestation/crafter/materials/testdata/runner-context-tags-v0.1.json @@ -0,0 +1,73 @@ +{ + "meta": { + "id": "chainloop.dev/runner-context/v0.1" + }, + "data": { + "tool": "platform@test", + "provider": "github", + "repos": [ + { + "owner": "test-org", + "repository": "test-repo", + "branches": [], + "tags": [ + { + "name": "v*", + "active_rules": [ + { + "name": "deletion", + "enabled": "true", + "context": [ + { + "name": "ruleset", + "value": "TagProtection", + "enabled": "true" + }, + { + "name": "ruleset_id", + "value": "12345", + "enabled": "true" + }, + { + "name": "enforcement", + "value": "active", + "enabled": "true" + } + ], + "bypass_configuration": [ + { + "actor_id": 5, + "actor_type": "RepositoryRole", + "bypass_mode": "always", + "actor_name": "Repository Admin" + } + ] + }, + { + "name": "non_fast_forward", + "enabled": "true", + "context": [ + { + "name": "ruleset", + "value": "TagProtection", + "enabled": "true" + }, + { + "name": "ruleset_id", + "value": "12345", + "enabled": "true" + }, + { + "name": "enforcement", + "value": "active", + "enabled": "true" + } + ] + } + ] + } + ] + } + ] + } +}