Skip to content

Support Github compatible webhooks from non-Github sources #1353

Closed

Description

@jimmidyson

Some other services, e.g. Gogs (https://github.com/gogits/gogs) have chosen to adopt the Github API as a de-facto standard & be fully compliant with it. This includes webhooks: they are sent in the same format, with the same info as a Github webhook.

The Github webhook currently checks that the webhook actually comes from Github by checking the User-Agent & X-GitHub-Event headers (https://github.com/openshift/origin/blob/master/pkg/build/webhook/github/github.go#L93-L98). Gogs doesn't send these through (I think it sends Gogs equivalent headers).

Could we remove these header checks? They don't really provide any value I can see, security is easily bypassed by adding those headers in to the request. Perhaps it reduces the cost of unmarshalling a webhook which isn't Github-compatible but that is probably only a minor saving.

At the moment we are having to work around this by having Gogs send to a webhook proxy endpoint that strips the body & sends to a configured OpenShift generic webhook endpoint instead (generic webhooks can only accept a body that is of a certain format, not Github-compatible webhook format). Not optimal.

Activity

  1. soltysh commented on Mar 18, 2015

    @soltysh
    Contributor

    For #1317 I've created #1333 to ignore errors from json unmarshalling. Have a look at it and lemme know it that works for you?

  2. jimmidyson commented on Mar 18, 2015

    @jimmidyson
    ContributorAuthor

    Yes that looks fine. We can use generic webhooks instead, even if the gogs webhook is GitHub api compatible AFAIK. Is there any different behaviour when using generic webhook vs GitHub webhook?

  3. soltysh commented on Mar 19, 2015

    @soltysh
    Contributor

    From the user perspective there are none, both trigger a build. The only difference is that github webhook is prepared to specifically run with github whereas generic has broader application.
    Still I'll have a look at gogs to see how much it differs from what we expect in github webhook.

  4. smarterclayton commented on Apr 1, 2015

    @smarterclayton
    Contributor

    We should remove the requirement to have the user agent and x-github-event headers checked unless it's a security issue

  5. soltysh commented on May 8, 2015

    @soltysh
    Contributor

    The Github webhook currently checks that the webhook actually comes from Github by checking the User-Agent & X-GitHub-Event headers (https://github.com/openshift/origin/blob/master/pkg/build/webhook/github/github.go#L93-L98). Gogs doesn't send these through (I think it sends Gogs equivalent headers).

    @jimmidyson right, it's setting X-Gogs-Event (see here). Unfortunately with X-GitHub-Event we know whether there was a push or just ping event, based on which we do or don't trigger a new build. The other option is to match both headers, I guess. @smarterclayton thoughts?

  6. smarterclayton commented on May 8, 2015

    @smarterclayton
    Contributor

    I don't know that we need to check User-Agent for Github, but X-GitHub-Event seems to provide value.

    What do we do on "ping"? Are we positive that ping means we shouldn't trigger a build?

    ----- Original Message -----

    The Github webhook currently checks that the webhook actually comes from
    Github by checking the User-Agent & X-GitHub-Event headers
    (https://github.com/openshift/origin/blob/master/pkg/build/webhook/github/github.go#L93-L98).
    Gogs doesn't send these through (I think it sends Gogs equivalent
    headers).

    @jimmidyson right, it's setting X-Gogs-Event (see
    here).
    Unfortunately with X-GitHub-Event we know whether there was a push or just
    ping event, based on which we do or don't trigger a new build. The other
    option is to match both headers, I guess. @smarterclayton thoughts?


    Reply to this email directly or view it on GitHub:
    #1353 (comment)

  7. soltysh commented on May 8, 2015

    @soltysh
    Contributor

    I don't know that we need to check User-Agent for Github, but X-GitHub-Event seems to provide value.

    Yes, we can remove that.

    What do we do on "ping"? Are we positive that ping means we shouldn't trigger a build?

    We ignore that event, as this is what gets send when you test your webhook.

  8. smarterclayton commented on May 8, 2015

    @smarterclayton
    Contributor

    Ok, so the absence of Ping can probably default to "Push"

    ----- Original Message -----

    I don't know that we need to check User-Agent for Github, but
    X-GitHub-Event seems to provide value.

    Yes, we can remove that.

    What do we do on "ping"? Are we positive that ping means we shouldn't
    trigger a build?

    We ignore that event, as this is what gets send when you test your webhook.


    Reply to this email directly or view it on GitHub:
    #1353 (comment)

  9. soltysh commented on May 8, 2015

    @soltysh
    Contributor

    Still we could check for either X-Github-Event or X-Gogs-Event, as this is not too big overhead IMHO.

  10. smarterclayton commented on May 8, 2015

    @smarterclayton
    Contributor

    Is it X-Gogs-Event=Ping?

    ----- Original Message -----

    Still we could check for either X-Github-Event or X-Gogs-Event, as this
    is not too big overhead IMHO.


    Reply to this email directly or view it on GitHub:
    #1353 (comment)

  11. soltysh commented on May 8, 2015

    @soltysh
    Contributor

    From the current code base here they support just the Push event, but since they state they are github-compatible I'd prefer to check that event name.

  12. smarterclayton commented on May 8, 2015

    @smarterclayton
    Contributor

    Ok

    ----- Original Message -----

    From the current code base
    here
    they support just the Push event, but since they state they are
    github-compatible I'd prefer to check that event name.


    Reply to this email directly or view it on GitHub:
    #1353 (comment)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions