Skip to content

Relative paths for remote policies #2650

@jiparis

Description

@jiparis

When working with policies, it's a common practice to keep .rego scripts in their own files instead of embedding them:

apiVersion: workflowcontract.chainloop.dev/v1
kind: Policy
metadata:
  name: my-policy
spec:
  policies:
    - kind: SBOM_SPDX_JSON
      path: script1.rego
    - kind: ATTESTATION
      path: script2.rego

However, when working with remote HTTP policies, the path field is not interpreted as a relative path. This feature only works with local policies. So policy writers need to prepend the URL to the rego script paths:

    - kind: SBOM_SPDX_JSON
      path: https://server/path/script1.rego
    - kind: ATTESTATION
      path: https://server/path/script2.rego

The proposal is to deprecate the path field in favor of a generic ref like the one used in contracts or policy groups. This ref will support relative URLs out of the box (if the main URL has a folder-like structure).

spec:
  policies:
    - kind: SBOM_SPDX_JSON
      ref: script1.rego. # relative to the policy yaml file
    - kind: ATTESTATION
      ref: file://testdata/script2.rego

Note that AutoMatch configuration is also affected by this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions