Skip to content

Conversation

@mtrmac
Copy link
Contributor

@mtrmac mtrmac commented Aug 10, 2016

Adds /etc/atomic/policy.json, and a command-line option to override (skopeo --policy some_path copy …), and enforces this policy in skopeo copy.

make install now installs default-policy.json to /etc/atomic/policy.json; the policy is set to insecureAcceptAnything for all images by default. (This may not be desirable long-term, but it is a reasonable transition strategy for now I think. The policy always uses the most specific matching scope, so it is easy to e.g. pin a key and require signatures for a specific repository namespace.)

Note that with merging this, ./skopeo will abort if the policy in /etc/atomic does not exist. This should not affect real deployments, but may be noticeable with local checkouts. A bit regrettable, but we do need to fail closed if a policy can’t be read. (Use ./skopeo --policy default-policy.json … in a checkout.)

This depends on, and vendors in, unmerged containers/image#49 and containers/image#50 , I will revendor as necessary.

@lsm5 , note that adding the config file will affect packaging.

@rhatdan , any comments on the path /etc/atomic/policy.json?

@mtrmac
Copy link
Contributor Author

mtrmac commented Aug 10, 2016

@lsm5
Copy link
Member

lsm5 commented Aug 11, 2016

On Wed, Aug 10, 2016 at 04:03:54PM -0700, Miloslav Trmač wrote:

@lsm5 , note that adding the config file will affect packaging.

sure thing, thanks for the headsup

Lokesh
Freenode: lsm5
GPG: 0xC7C3A0DD

@mtrmac mtrmac force-pushed the verify-on-pull branch 2 times, most recently from 265a829 to a104f2d Compare August 22, 2016 14:59
@runcom
Copy link
Member

runcom commented Aug 25, 2016

I like /etc/atomic/policy.json

Unsure about failing hard if not /etc/atomic exists though - I guess I have no strong opinion, perhaps just tell something useful to the user suffices

LGTM though, reviewed #50 as well

@mtrmac
Copy link
Contributor Author

mtrmac commented Aug 25, 2016

Unsure about failing hard if not /etc/atomic exists though - I guess I have no strong opinion, perhaps just tell something useful to the user suffices

$ ./skopeo copy dir:a dir:b
FATA[0000] Error loading verification policy: open /etc/atomic/policy.json: no such file or directory 

@runcom
Copy link
Member

runcom commented Aug 25, 2016

Unsure about failing hard if not /etc/atomic exists though - I guess I have no strong opinion, perhaps just tell something useful to the user suffices
$ ./skopeo copy dir:a dir:b
FATA[0000] Error loading verification policy: open /etc/atomic/policy.json: no such file or directory

yup, saying I'm fine with that :)

@rhatdan
Copy link
Member

rhatdan commented Aug 25, 2016

Should the path be vendor neutral? Or is this a path handed to container/images?

@runcom
Copy link
Member

runcom commented Aug 25, 2016

after meeting: /etc/container seems ok

@mtrmac
Copy link
Contributor Author

mtrmac commented Aug 25, 2016

The path comes from containers/image, so that various tools all use the same file.

To be precise, the path would be /etc/container/policy.json? (I can’t find any package owning /etc/container in F24, so I’m not sure where to look for other users of that directory and possible problems.)

@mtrmac mtrmac force-pushed the verify-on-pull branch 2 times, most recently from 525aa32 to 28ec068 Compare August 25, 2016 16:33
@mtrmac
Copy link
Contributor Author

mtrmac commented Aug 25, 2016

Revendored to use /etc/containers/policy.json (pending re-review of containers/image#49 ), and simplified getPolicyContext a little.

// getPolicyContext handles the global "policy" flag.
func getPolicyContext(c *cli.Context) (*signature.PolicyContext, error) {
policyPath := c.GlobalString("policy")
var policy *signature.Policy // This could be cached across calls, if we had an application context.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be contacted in a single var block

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*compacted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, OTOH it is easier to attach the “This could be cached” comment to the policy variable when it is on a separate line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's a somehow golang idiom, you can still add comments on top of each variable in a var block

@runcom
Copy link
Member

runcom commented Aug 25, 2016

Just a nit, LGTM otherwise

Feel free to merge containers/image bit, re vendor here and merge here

mtrmac added 4 commits August 25, 2016 19:36
This ordinarily uses the compiled-in default, but allows per-command
override.  No users yet.

Note that this adds an URL to policy documentation within
containers/image, and that URL does not exist at the moment.
…on tests

(skopeo copy) will soon ALWAYS require a present policy file.  So,
install one by (make install), and ensure that integration tests do so
as well.

Also simplifies the usage of install(1) a bit.
Finally, load and enforce the policy.

NOTE that this breaks a simple ./skopeo from a built directory if you
don't have /etc/atomic/policy.json installed for other reasons;
use (./skopeo --policy default-policy.json) instead.
@mtrmac
Copy link
Contributor Author

mtrmac commented Aug 25, 2016

Thanks for the review!

I have decided to drop the dependency on containers/image#50 ; the cost is that the link in skopeo.1 will be pointing at a non-existent URL for a time, the benefit is that this makes containers/image#50 a branch with no relationships and greatly simplifies the structure of outstanding branches.

@mtrmac mtrmac merged commit 821f938 into containers:master Aug 25, 2016
@mtrmac mtrmac deleted the verify-on-pull branch August 25, 2016 18:02
@mtrmac mtrmac mentioned this pull request Sep 1, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants