Skip to content

CI Define GHA policies so that we can use pull_request_target after December 9 (ideally before November 9 so we can test it during the first brownout) #35103

Closed

Description

@lesteve

Warning

This issue is not yet ready for a PR. If you are interested in contributing to scikit-learn, please have a look at our contributing guidelines, and in particular the sections for new contributors and the "Needs triage" label.

Setting page
GHA policy doc

Looks like you can not do it through a config file but have to do through the web UI (or maybe via REST API but probably harder and not worth it).

I just saw https://docs.github.com/en/actions/reference/security/securely-using-pull_request_target#default-policy-for-pull_request_target TLDR: from 2 November GitHub will restrict (aka block) workflows that use the pull_request_target trigger. If we want to keep using it we need to setup our own policy,

I think the workflows we have right now need to use pull_request_target and we are fairly sure that we are "doing it right" (famous last words). So I'd add a policy to allow them.

Thoughts anyone? @lesteve ?

Originally posted by @betatim in #34006

Activity

  1. added
    Needs Triage
    on Oct 8, 2026
  2. added
    Needs Investigation
    and removed
    Needs Triage
    on Oct 8, 2026
  3. betatim commented on Oct 9, 2026

    @betatim
    Member

    From reading the docs page I originally linked I was expecting to see something on https://github.com/scikit-learn/scikit-learn/settings/actions/rules/insights because they say they are running this new policy in evaluate mode. However, nothing shows up. Just a "to use this upgrade to enterprise" :-/

  4. lesteve commented on Oct 10, 2026

    @lesteve
    MemberAuthor

    My crude understanding was to use the policies settings page and then manage to figure out how to configure it to allow pull_request_target for the following workflows (based on a quick git grep):

    .github/scripts/label_title_regex.py
    .github/workflows/autoclose-comment.yml
    .github/workflows/cuda-label-remover.yml
    .github/workflows/labeler-module.yml
    .github/workflows/labeler-title-regex.yml
    .github/workflows/pull-request-opened-or-edited.yml
    

    Edit: just saw @betatim has asked in https://github.com/community/maintainers/discussions/907 👀.

  5. betatim commented on Oct 12, 2026

    @betatim
    Member

    It seems like we can't see anything on the insights page :-/ I was hoping to see something now already and then use the "audit" mode to check that we got all workflows and that our policy is set to allow them.

    Maybe what we should do instead is try and configure a policy to allow things and then see what happens? Many of the workflows we can trigger by doing something in the repo, so it would be possible to explicitly test them

  6. lesteve commented on Oct 12, 2026

    @lesteve
    MemberAuthor

    My naive firsts attempt would have been something like this:

    • a policy to allow everything but pull_request_target for all workflows
    • a policy to allow pull_request_target only for the listed workflow above.

    Testing this in a separate repo is maybe a good idea, mostly because with CI, it's easy to get things slightly wrong and you generally need to iterate a few times. I have realized recently, that agents are quite good at creating test repo and testing CI setups 😉.

    If that works, a potential follow-up is to investigate whether pull_request_target is the only one that is problematic. The Astral security blog post says they also forbid workflow_run, which we use for the linting bot comment.

  7. lesteve commented on Nov 3, 2026

    @lesteve
    MemberAuthor

    Good news, looks like this change has been postponed see blog post.

    There are two brownout schedules, one of them is next Monday (Monday November 9) so it would be good to have something in place to test it by next Monday for real (seems like this is the simplest way to test it):

    Date 	            Time (UTC)
    November 9, 2026 	16:00–18:00
    November 16, 2026 	16:00–18:00
    

    @betatim do you want to do it 😉?

  8. changed the title [-]CI Define GHA policies so that we can use `pull_request_target` after November 2[/-] [+]CI Define GHA policies so that we can use `pull_request_target` after November 9[/+] on Nov 3, 2026
  9. changed the title [-]CI Define GHA policies so that we can use `pull_request_target` after November 9[/-] [+]CI Define GHA policies so that we can use `pull_request_target` after December 9 (ideally before November 9 so we can test it during the brownout)[/+] on Nov 3, 2026
  10. changed the title [-]CI Define GHA policies so that we can use `pull_request_target` after December 9 (ideally before November 9 so we can test it during the brownout)[/-] [+]CI Define GHA policies so that we can use `pull_request_target` after December 9 (ideally before November 9 so we can test it during the first brownout)[/+] on Nov 3, 2026
  11. betatim commented on Nov 3, 2026

    @betatim
    Member

    I've created a policy that allows event triggers including pull_request_target for the workflows you listed (minus the python script that grep found).

    Image

    The default list of allowed events to trigger the workflow is very long. I think we can cut it down to just the triggers we use for these workflows. In practice I think this means removing all events except pull_request_target.

    https://github.com/scikit-learn/scikit-learn/settings/actions/rules/insights this now works and shows us that several of the workflows would be blocked. I think with the new policy active we should no longer see things appear there, or they should be listed as allowed instead of "would be blocked" (which is what they are now).

    I will wait a bit before adding a policy that forbids pull_request_target. Maybe until after the brownout?


    I feel that this is a rabbit hole. I mean, what is it trying to tell me with "can't be converted, should we import them"? Makes me think I should be migrating ?? Something for a new issue maybe.
    Image

    (screenshot is from the policies page)

  12. lesteve commented on Nov 3, 2026

    @lesteve
    MemberAuthor

    Nice thanks a lot! I also added .github/workflows/pr-size-labeler.yml which was added in the meantime.

    This seems like a good first step.

    I think it's OK to look at the Insights page in a couple of days or look and at the end of the day on November 9 once the brownout is over to make sure there are no

    Maybe I am missing something, but I don't find the Insights page super useful (to put it nicely 😅), there is no way to know which workflow is blocked ...

  13. betatim commented on Nov 3, 2026

    @betatim
    Member

    Yeah, the insights page is a bit thin. I think you can click the "three dots" icon to get a bit more detail.

    Thanks for the extra workflow

  14. lesteve commented on Nov 3, 2026

    @lesteve
    MemberAuthor

    I saw the three dots but the additional info is not very useful "some rules did not pass", which ones GitHub which ones, tell me 🔮?

    Image

    Anyway I think we are on the right track to be safe when pull_request_target is disabled by default 💪 🤞.

    Related to one of your previous point: no GitHub, now is not the right time to nudge me into converting/importing my branch protection settings into rulesets whatever they are, I couldn't possibly care less about this kind of things right now 😜.

  15. betatim commented on Nov 4, 2026

    @betatim
    Member

    I can't find it again either, but I was 95% sure I had found a way to see the name of the workflow. After a lot of random clicking.

    The good news is that the insights page hasn't had a new entry for about 19hours. My guess is that the new rules that allow pull_request_target are taking effect and hence we don't see "would be blocked" anymore.

  16. lesteve commented on Nov 4, 2026

    @lesteve
    MemberAuthor

    The good news is that the insights page hasn't had a new entry for about 19hours. My guess is that the new rules that allow pull_request_target are taking effect and hence we don't see "would be blocked" anymore.

    Yup agreed.

  17. lesteve commented on Nov 10, 2026

    @lesteve
    MemberAuthor

    Seems like there was no pull_request_target failures during the November 9 brownout https://github.com/scikit-learn/scikit-learn/actions?query=event%3Apull_request_target+is%3Afailure, so this is a confirmation that we should be fine I think.

    Note to our future selves, if we had a workflow with pull_request_target (or rename one) we need to remember to add it to this settings page

  18. betatim commented on Nov 10, 2026

    @betatim
    Member

    Let's close this then. If we find that it is broken after all we can reopen this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Investigation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions