Commit graph

543 commits

Author SHA1 Message Date
Ian Roberts
36bcb09cf7 fix: return the raw error from Argument.Get
There are other places in the logic that depend on errors extracting Argument values being of type ParameterNodeError specifically, so we shouldn't wrap these errors further.
2024-10-29 21:05:43 +00:00
Ian Roberts
e2c51dc1dd docs: documentation for the template argument type 2024-10-29 20:51:38 +00:00
Ian Roberts
fb0e233dd7 docs: documentation of the new "check-signature" rule 2024-10-29 20:51:38 +00:00
Ian Roberts
9abdb1fffb feat: new rule type specifically for signature checks
Move the signature checking rules out of MatchRule into their own dedicated SignatureRule, configured as "check-signature" in the hooks file.  This takes an algorithm, secret and Argument giving the source of the signature, and by default behaves exactly like the old payload-hmac-<algorithm> match rules.  However it can also take a second optional Argument to customize how to generate the "string to sign", allowing signatures to be computed over something other than the full request body content.

This could be a single header or payload item but more likely will be a "template" argument to combine items from different places in the request, such as the body content and one or more headers, e.g. to compute a signature over the X-Request-Id header, Date header, and request body, concatenated with CRLF, you could specify

check-signature:
  algorithm: sha512
  secret: 5uper5eecret
  signature:
    source: header
    name: X-Hook-Signature
  string-to-sign:
    source: template
    name: |
      {{- printf "%s\r\n" (.GetHeader "x-request-id") -}}
      {{- printf "%s\r\n" (.GetHeader "date") -}}
      {{- .BodyText -}}
2024-10-29 20:51:38 +00:00
Ian Roberts
bb8be5ed9a feat: allow override of template delims
When you want to use "source":"template" arguments inside your hook file but also parse the hook file itself as a template, it is necessary use different delimiters on the two template parsers to avoid having to pepper all the inner templates with constructs like {{"{{"}}.  Added an extra command line argument -template-delims that expects a comma-separated pair of delimiters like '[[,]]' that will be used when parsing the whole hooks file template.  Inner templates in an Argument always use the default double-brace style.
2024-10-27 20:58:48 +00:00
Ian Roberts
9892bc678b feat: an Argument type that evaluates a template against the Request
Added a new "source": "template" argument type, that evaluates a Go text/template against a context containing the request Body, Query, Payload and Headers, enabling much richer mapping from request attributes to argument parameters.
2024-10-27 20:58:48 +00:00
Adnan Hajdarević
9f725b2cb0
Update Systemd-Activation.md 2024-10-25 23:19:13 +02:00
Ian Roberts
98cf5d0163
Add support for systemd socket activation (#704)
* feat: add support for systemd socket activation

If webhook has been launched via systemd socket activation, simply use the systemd-provided socket rather than opening our own.

* docs: documentation for the systemd socket activation mode

* refactor: moved setuid and setgid flags into platform-specific section

The setuid and setgid flags do not work on Windows, so moved them to platform_unix so they are only added to the flag set on compatible platforms.

Also disallow the use of setuid and setgid in combination with -socket, since a setuid webhook process would not be able to clean up a socket that was created while running as root.  If you _need_ to have the socket owned by root but the webhook process running as a normal user, you can achieve the same effect with systemd socket activation.
2024-10-25 23:18:04 +02:00
Adnan Hajdarević
9cd78fca1a
Update README.md 2024-10-25 09:39:58 +02:00
Ian Roberts
eddeb82032
Add option to bind to a Unix socket instead of a TCP port (#703)
* feat: add ability to listen on unix socket/named pipe

Add a -socket option that configures the server to listen on a Unix-domain socket or Windows named pipe instead of a TCP port.  This allows webhook to be used behind a reverse proxy on multi-tenant shared hosting without the need to choose (and the permission to bind to) a free port number.

On Windows, -socket is expected to be a named pipe such as \\.\pipe\webhook, and the code uses https://github.com/microsoft/go-winio to bind the listening socket.  On other platforms, -socket is the path to a Unix domain socket such as /tmp/webhook.sock, or an abstract socket name starting with @, bound using the regular net.Listen function with the "network" parameter set to "unix".

Note: this pushes our minimum Go version up to 1.21 as that is what go-winio requires, but that is already the minimum version against which we are testing in the CI matrix.

* tests: add test for the -socket option

Refactored webhook_test so that the test HTTP requests are made using an explicitly-provided http.Client, so we can run at least one test with the server bound to a socket instead of a port number, using an http.Client whose transport has been configured with a suitable Unix-domain or Windows named pipe dialer function.

* tests: use GOROOT to find go command

This should ensure that, even if a developer or CI server has multiple versions of go installed, the version used to build the tools under test will be the same version that is running the test harness.

* fix: clean up Unix socket file before exit

If webhook is restarted with the same settings but the socket file has not been deleted, webhook will be unable to bind and will exit with an error.

* docs: add -socket option to documentation

* docs: add a note about reverse proxies

- README mentions the idea of using webhook behind a reverse proxy, including with the -socket flag
- added a note in Hook-Rules that the ip-whitelist rule type does not work as expected behind a reverse proxy, and you should configure IP restrictions at the proxy level instead
2024-10-25 09:38:22 +02:00
Adnan Hajdarević
b6f24d00a5
Update README.md 2024-06-28 09:33:04 +02:00
yumeiyin
d84cc5420b
chore: fix some comments (#690) 2024-05-26 20:11:05 +02:00
yudrywet
fc0623363a
chore: fix some typos in comments (#685)
Signed-off-by: yudrywet <yudeyao@yeah.net>
2024-04-14 17:22:46 +02:00
Adnan Hajdarevic
48c76cf80d Bump version 2024-04-13 23:27:55 +02:00
Christopher Conley
85f244c98e
Allow Linux setuid/setgid (#646) 2024-04-13 19:58:24 +02:00
Adnan Hajdarevic
8ee2601081 Bugfix: Unset aux groups when dropping the privileges 2024-04-13 19:55:38 +02:00
Cameron Moore
0fa8bbf710
Update GH actions and dependencies (#681)
* Update go-chi dependency to v5

* Update gofrs/uuid dependency to v5

* Update gorilla/mux dependency to v1.8.1

* Update go-humanize dependency to v1.0.1

* Update mxj dependency to v2.7.0

* Update fsnotify dependency to v1.7.0

* Update Go versions in GH build workflow

* Update gopkg.in/yaml.v2 indirect dependency to v2.4.0

* Bump GH actions
2024-04-13 12:27:49 +02:00
Adnan Hajdarević
dbc6565c35
Update README.md 2024-02-20 08:01:44 +01:00
Pouria Mousavizadeh Tehrani
9a7986681d
Add FreeBSD Instruction and Example to README.md (#675) 2024-02-19 19:37:19 +01:00
Adnan Hajdarević
de4003a7a8
Update README.md 2024-02-19 19:35:15 +01:00
Adnan Hajdarević
bd1aaab0ad
Update Templates.md
Add missing bracket to the Templates.md
2023-12-26 08:49:09 +01:00
Tony Yang
a4eebd6005
Update README.md (#666) 2023-12-02 00:19:29 +01:00
Adnan Hajdarević
56a960e3bd
Update FUNDING.yml 2023-10-05 20:38:29 +02:00
guangwu
6daf4c29ac
fix: additional typo (#652) 2023-09-18 00:09:39 +02:00
Óscar
3944b35d39
Add Zola Guide (#653) 2023-09-18 00:08:43 +02:00
Alfonso Montero
dc5d09a0d7
Hook-Examples.md: improve markdown formatting for code blocks (#637) 2023-09-18 00:07:01 +02:00
Adnan Hajdarevic
f187592147 Bump version to 2.8.1 2023-05-22 21:03:40 +02:00
Adnan Hajdarevic
a79e7d2cef Merge branch 'development' 2023-05-22 21:02:52 +02:00
Abhiram Satpute
5ed642354f
changed src of hookdoo, previous img url was broken (#623)
Co-authored-by: abhiram11 <abhiramsatpute@gmail.com>
2023-02-27 11:35:36 +01:00
Kārlis K
dab29e7267
Update Hook-Examples.md (#576)
Synology webhook example
2022-08-31 10:30:47 +02:00
Arran
0c0bf0b244
Add Gitea and Uberspace Guide (#579) 2022-02-21 13:15:17 +01:00
Marek Isalski
c7f7163aaa
Update Bitbucket example to reference Atlassian's outgoing IP subnets (#578)
* Update Bitbucket example to check all of Atlassian's outgoing IP ranges

Co-authored-by: Marek Isalski <git@maz.nu>
2022-02-14 09:24:38 +01:00
Adnan Hajdarević
36e77b1c7a
Merge pull request #567 from Prince-Mendiratta/master
Fix broken link for guide to Jira and webhook integration
2021-12-31 09:22:42 +01:00
Prince Mendiratta
5189c62651
Fix broken link for guide to Jira and webhook integration
Signed-off-by: Prince Mendiratta <prince.mendi@gmail.com>
2021-12-29 16:51:20 +05:30
Adnan Hajdarević
75f406845f
Update README.md 2021-10-11 12:47:23 +02:00
Adnan Hajdarević
105b019e2b
Merge pull request #559 from Anksus/master
Update README.md
2021-09-27 13:41:06 +02:00
Ankit_Susne
4f00a26293
Update README.md 2021-09-25 22:56:38 +05:30
Adnan Hajdarević
560cbaae74
Merge pull request #554 from moorereason/iss553
Send cli headers on default http handler
2021-09-03 10:05:42 +02:00
Cameron Moore
3285288f03
Send cli headers on default http handler
Fixes #553
2021-09-02 19:24:34 -05:00
Adnan Hajdarević
2a36f24269
Merge pull request #529 from benjaoming/patch-1
Clarify version number for which the example works
2021-07-29 14:20:53 +02:00
Benjamin Balder Bach
1ec494fb0d
Clarify version number for which the example works
#461 changed option name and in https://github.com/adnanh/webhook/pull/528#issuecomment-826165812, @moorereason suggests to look at old tags of example documentation. This would mean that users have to read through random old documentation to discover why their packaged version doesn't work . Suggesting that clarity in the examples is preferable.

Recall that renaming this doesn't give the user some easy exception. It just mean that the trigger isn't satisfied, so there are A LOT of options for debugging.

(which takes a lot of time to do, so that's why this information is important)
2021-04-25 13:26:02 +02:00
Adnan Hajdarević
e329b6d9ff
Merge pull request #518 from adhawkins/busybox-tests
Allow tests to run on systems that use busybox (such as Alpine)
2021-03-15 22:43:13 +01:00
Andy Hawkins
181672afcc Allow tests to run on systems that use busybox (such as Alpine) 2021-03-13 16:02:44 +00:00
Adnan Hajdarević
d523af1b6c
Fixes #497 2021-02-28 09:55:08 +01:00
Adnan Hajdarević
390e3bd772
Merge pull request #503 from TheCatLady/add-alt-docker-images
Add alternative Docker images
2021-01-29 20:08:46 +01:00
TheCatLady
21549749c0
Add alternative Docker images 2021-01-28 12:16:03 -05:00
Adnan Hajdarevic
6184509494 Add build directory to .gitignore 2021-01-26 20:53:07 +01:00
Adnan Hajdarevic
b1f69564a3 Merge branch 'development' 2020-12-06 08:42:20 +01:00
Adnan Hajdarevic
159cb4a911 bump version to 2.8.0 2020-12-06 08:42:09 +01:00
Adnan Hajdarević
b5af9a3968
Merge pull request #489 from moorereason/iss487-doc-string
Add string parameter example to docs
2020-12-06 08:40:31 +01:00