#2951 kojid: extend SCM.assert_allowed with hub policy
Merged by tkopecek. Opened by julian8628.
julian8628/koji issue/2757  into  master

Download 2951.patch

This is a simple extention of SCM.assert_allowed

  • assert_allowed_by_policy will set the default "use_common" to False which is different to the old behavior
  • channel, user_id, scratch are passed in the policy_data with scminfo right now.

This is a prototype for this change, and there are some other solutions could be implemented too

  • Use a scmpolicy plugin in postSCMCheckout callback. The pro is that we can do more checks after the source is initialized on builder, meanwhile, the con is that the source will be downloaded even it is denied by policy. It might be a potential risk?
  • Do the scm check in hub's make_task, this looks straightforward, but may lack some builder's information

fixes: #2757

rebased onto 5288730f7ffbfb7b071d11e62bc3083f52ac80a5

rebased onto 8d720585b663190db405156f683764406e23e80e

rebased onto 840c8fc4483ffd8c2f09f382040af63b4104848b

I really like this approach!

Use a scmpolicy plugin in postSCMCheckout callback. The pro is that we can do more checks after the source is initialized on builder, meanwhile, the con is that the source will be downloaded even it is denied by policy. It might be a potential risk?

In some cases (hello blender repo in fedora), the cloning itself can take hours and timeout so I'd prefer to not do it that way (+ you know, those vulnerabilities here and there).

Do the scm check in hub's make_task, this looks straightforward, but may lack some builder's information

Do you have some hint which one, for example?

Do the scm check in hub's make_task, this looks straightforward, but may lack some builder's information

Do you have some hint which one, for example?

Like which host the task is assigned to. This doesn't happen yet in make_task() 1. BTW, this info is not used by the current approach too.

And, we have to guess which argument is the source, especially for custom tasks.

What do you see as a benefit of checking it in make_task? Is it just that builder is making additional call here?

What do you see as a benefit of checking it in make_task? Is it just that builder is making additional call here?

And a faster response if the source is denied (no need to create a SCM-related task on the builder).

I would leave it in srpm task then. make_task is generic, so we would need to detect if it is some type of task involving SCM. For plugin tasks it would be unusable, as plugin will need to run the check anyway.

This is tricky and I think it might take a few iterations to get right.

I'm not sure I like the idea of working this into the existing assert_allowed call. It doesn't really get us much benefit as it still requires all invocations of the call to have significant updates to take advantage.

OTOH, maybe this is ok for now.

A couple things to consider:

  • What we create here is likely to eventually replace the existing allowed_scms setting, so we should design it with that in mind
  • Other tools will want to use this. Builder plugins, content generators, possibly more. We should make it as straightforward as possible. In particular, an external cg will not be able to use host.evalPolicy, so we might consider adding a hub call for this

When flattening the scm info, I think it would be better to use scm_ as the prefix.

The opts parameter is only used to update the policy_data, so it seems to be misnamed. It is not a general options parameter, but explicitly policy data info.

I'm not sure I like that the default policy doesn't work out of the box, but maybe that is ok? I guess our default allowed_scms='' also blocks builds out of the box.

rebased onto c5de1364a5a6a6d60e53d59a57246d2797a06268

@mikem, updated.

I'm not sure I like that the default policy doesn't work out of the box, but maybe that is ok? I guess our default allowed_scms='' also blocks builds out of the box.

The default policy only allows admin's builds. And although the default allowed_scms='' blocks all builds, the allowed_scms defined in the default kojid.conf contains some dummy items. That's almost equal to "all denied". So I believe it is ok in most cases.

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

pretty please pagure-ci rebuild

pretty please pagure-ci rebuild

pretty please pagure-ci rebuild

rebased onto 47c4b5d70baaea36dbf637bee907a33229cf7a60

Functionality is tested, I add testing-done tag. @julian8628 please, update policy hub documentation related to these changes.

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

1 new commit added

  • [doc][defining_hub_policies] update the doc

doc updated

7 new commits added

  • [doc][defining_hub_policies] update the doc
  • fix config typo
  • [hub] add non-host evalPolicy API
  • use scm_ as the prefix instead of scm for scminfo
  • update doc
  • more reasonable parameter name, and more doc strs
  • kojid: extend SCM.assert_allowed with hub policy

7 new commits added

  • [doc][defining_hub_policies] update the doc
  • fix config typo
  • [hub] add non-host evalPolicy API
  • use scm_ as the prefix instead of scm for scminfo
  • update doc
  • more reasonable parameter name, and more doc strs
  • kojid: extend SCM.assert_allowed with hub policy

:thumbsup:

Commit 6d4abedb fixes this pull-request

Pull-Request has been merged by tkopecek

Metadata