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

Multiple package directives allowed by parser #213

Closed
tsandall opened this issue Jan 16, 2017 · 1 comment · May be fixed by qsays/opa#3, laozhudetui/opa#2, airadier/opa#3 or pcaruana/opa#4
Closed

Multiple package directives allowed by parser #213

tsandall opened this issue Jan 16, 2017 · 1 comment · May be fixed by qsays/opa#3, laozhudetui/opa#2, airadier/opa#3 or pcaruana/opa#4
Labels

Comments

@tsandall
Copy link
Member

The parser currently allows modules to include multiple package directives. Only the first package directive will be processed, others are ignored. This is confusing and should not be allowed. Modules must contain exactly one package directive.

For example:

test.rego:

package xyz
package abc
opa run -s
curl -X PUT localhost:8181/v1/policies/test --data-binary @test.rego
{
  "ID": "test",
  "Module": {
    "Package": {
      "Path": [
        {
          "Type": "var",
          "Value": "data"
        },
        {
          "Type": "string",
          "Value": "xyz"
        }
      ]
    },
    "Imports": null,
    "Rules": []
  }
}
@tsandall tsandall added the bug label Jan 16, 2017
@tsandall
Copy link
Member Author

This should only require a relatively small fix in the parser:

https://github.com/open-policy-agent/opa/blob/master/ast/parser_ext.go#L329

@tsandall tsandall changed the title Multiple package declarations allows by parser Multiple package declarations allowed by parser Jan 16, 2017
@tsandall tsandall changed the title Multiple package declarations allowed by parser Multiple package directives allowed by parser Jan 16, 2017
tsandall added a commit to tsandall/opa that referenced this issue Jan 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant