Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type checker doesn't respect capabilities allow_net for remote schemas #5670

Closed
johanfylling opened this issue Feb 17, 2023 · 0 comments · Fixed by #5671
Closed

Type checker doesn't respect capabilities allow_net for remote schemas #5670

johanfylling opened this issue Feb 17, 2023 · 0 comments · Fixed by #5671
Assignees
Labels

Comments

@johanfylling
Copy link
Contributor

Given the following capabilities.json file, that disallows all outbound network connections:

{
   ...
   "allow_net": []
}

and the following Rego file, that has an inlined schema with a reference to some schema hosted at some web server (this server doesn't need to exist for this example):

package test

# METADATA
# schemas:
# - input: {"$ref": "http://localhost:8000/schema.json"}
q {
    input == 42
}

When running opa eval --capabilities capabilities.json -s schemas -d policy.rego data (the schemasfolder doesn't need to contain any schemas, it's just required for the type-checker to utilize the schemas annotation), we expect the following error, on account of no remote hosts being allowed by capabilities.json:

{
  "errors": [
    {
      "message": "unable to compile the schema: remote reference loading disabled: http://localhost:8000/schema.json",
      "code": "rego_type_error",
      "location": {
        "file": "policy.rego",
        "row": 6,
        "col": 1
      }
    }
  ]
}

but we get the following error, as OPA attempts to fetch the schema (no server listener present on localhost:8000:

{
  "errors": [
    {
      "message": "unable to compile the schema: Get \"http://localhost:8000/schema.json\": dial tcp [::1]:8000: connect: connection refused",
      "code": "rego_type_error",
      "location": {
        "file": "policy.rego",
        "row": 6,
        "col": 1
      }
    }
  ]
}
johanfylling added a commit to johanfylling/opa that referenced this issue Feb 17, 2023
…ng remote schemas

Fixes: open-policy-agent#5670
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
@johanfylling johanfylling self-assigned this Feb 17, 2023
ashutosh-narkar pushed a commit to johanfylling/opa that referenced this issue Feb 22, 2023
…ng remote schemas

Fixes: open-policy-agent#5670
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
johanfylling added a commit that referenced this issue Feb 23, 2023
... when fetching remote schemas

Fixes: #5670
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant