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

Error upserting policy with AllowedRiskSeverity as list #10

Open
caipre opened this issue May 10, 2018 · 1 comment
Open

Error upserting policy with AllowedRiskSeverity as list #10

caipre opened this issue May 10, 2018 · 1 comment

Comments

@caipre
Copy link
Contributor

caipre commented May 10, 2018

A policy with AllowedRiskSeverity as a list fails to create:

$ curl -XPOST -H'content-type: application/json' -d '{"Policy":{"Name":"High","AllowedRiskSeverity":"[\"Negligible\",\"Low\",\"Medium\"]"}}' localhost:31700/v1/policies
{"Error":{"Message":"error upserting policy: pq: malformed array literal: \"{[\"Negligible\",\"Low\",\"Medium\"]}\""}}

The value is treated as a list when listing an image's vulnerabilities:

err = json.Unmarshal([]byte(policy.AllowedRiskSeverity), &severities)

Maybe there's some marshaling required here: https://github.com/target/portauthority/blob/master/pkg/datastore/pgsql/policy.go#L60 ? My golang isn't too strong. Will try to look more into this tomorrow.

@ErikThoreson
Copy link
Contributor

ErikThoreson commented May 11, 2018

@caipre try it like this. AllowedRiskSeverity is a string on the input currently.

curl -XPOST -H'content-type: application/json' -d '{"Policy":{"Name":"High","AllowedRiskSeverity":"Negligible,Low,Medium"}}' http://localhost:31700/v1/policies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants