Commit graph

57 commits

Author SHA1 Message Date
Cameron Moore
40d9dcd6d4 Make hook package internal
The hook package API is not meant for public consumption.
2019-12-21 11:55:42 -06:00
Cameron Moore
31e76bcd00 Use constant time string compare for match value
Fixes #364
2019-12-10 22:22:13 -06:00
Adnan Hajdarevic
d4e98281d7 Add SHA512 payload check rule. 2019-12-02 19:48:59 +01:00
Cameron Moore
b016e99ea6 Update GetParameter to support keys with dots
Fixes #333
2019-09-13 13:10:14 -05:00
Cameron Moore
e47f9afb11 Fix failing ip-whitelist tests 2019-09-13 13:09:44 -05:00
Adnan Hajdarević
e86c2cf610
Merge branch 'development' into development 2019-04-17 18:11:12 +02:00
Adnan Hajdarević
896d1608ca
Merge pull request #297 from moorereason/iss207
Return errors on empty secrets during signature validations
2019-01-08 09:30:08 +01:00
Cameron Moore
f056f94305 Allow multiple values for ip-whitelist
Allow the value of ip-whitelist to consist of multiple space-separated
addresses or CIDRs.

Updates #290
2019-01-02 16:50:23 -06:00
Cameron Moore
1a17dc83fe Return errors on empty secrets during signature validations
Fixes #207
2019-01-02 16:09:27 -06:00
Adnan Hajdarevic
f76426e9b0 add handler for the route to be used as a healtcheck endpoint, fixes #233 2018-11-17 19:01:26 +01:00
Andreas Lundblad
b65bdbbb24 Removed trailing tab 2018-09-17 20:35:51 +02:00
Andreas Lundblad
22073d8847 Renamed http-response-code to success-http-response-code 2018-09-15 16:00:42 +02:00
Andreas Lundblad
c05ca8c528 Added HttpResponseCode hook setting 2018-09-15 15:55:28 +02:00
Adnan Hajdarević
f9e799fea0
Merge pull request #206 from dcj/feature/incoming-payload-content-type
added support for incoming-payload-content-type
2018-09-14 11:51:06 +02:00
Cameron Moore
d85ee5e068 Use strings.TrimPrefix 2018-02-16 20:33:17 -06:00
Cameron Moore
7da4d8ba9f Use strings.Contains 2018-02-16 20:31:23 -06:00
Cameron Moore
8d260c6a7e Apply gofmt 2018-02-16 20:26:33 -06:00
Cameron Moore
48061f1508 Simplify boolean some comparisons 2018-02-16 20:23:25 -06:00
Hass_SEA
b595694658
Update to support Scalr Signature Verification
Add a new match rule type that checks for a Scalr webhook signature. Tracking ticket #200

The signature algorithm is described here:
https://scalr-wiki.atlassian.net/wiki/spaces/docs/pages/6193247/Webhook+Security+and+Authentication

An example match rule ifor a Scalr webhook will look like:

"match": {
"type": "scalr-signature",
"secret": ""
}
2017-12-19 12:48:10 -08:00
Donald Clark Jackson
f84edae99d added support for incoming-payload-content-type 2017-11-27 14:02:57 -08:00
Greg Dubicki
a40fba5e29 Add CaptureCommandOutputOnError
to include stdout & stderror in failed executions,
with docs.
2017-11-11 18:46:55 +01:00
Cameron Moore
f5f04ddaa2 Allow hooks file to be parsed as a template
Add a -template command line option that instructs webhook to parse the
hooks files as Go text templates.

Includes a `getenv` template func for retrieving environment variables.
2017-11-08 09:14:58 -06:00
Marco Descher
c9abc252e8 Delete hook files by default 2017-11-07 16:38:12 +01:00
Marco Descher
213e4529e8 #162 do use temporary files, provide env variable 2017-09-15 13:30:44 +02:00
Marco Descher
395fb41d23 Provide means to transfer files #162 add deleteOnExit 2017-08-29 14:42:14 +02:00
Marco Descher
34c4b1c166 Provide means to transfer files #162 2017-08-25 15:01:57 +02:00
Will Rouesnel
2f1ea098c0 Use the github.com/ghodss/yaml library to unserialize webhooks.
This supports both JSON and YAML seamlessly, providing for an easier human
parseable format on disk.
2017-06-12 19:56:09 +10:00
Raphaël Pinson
6b1021925b
Add sha256 payload check 2017-04-06 17:49:31 +02:00
HandcraftedBits
173273b466 Add IP whitelist match rule. 2017-02-20 22:00:39 -05:00
Adnan Hajdarevic
1da40d4634 Merge branch 'master' into development 2017-02-11 12:15:04 +01:00
Mathias Merscher
058f820cbd rename trigger rule http response code config option
Signed-off-by: Mathias Merscher <Mathias.Merscher@dg-i.net>
2017-02-10 18:42:02 +01:00
Mathias Merscher
ddb1f2441a make http return code for mismatched rules configurable
Signed-off-by: Mathias Merscher <Mathias.Merscher@dg-i.net>
2017-02-10 12:32:11 +01:00
Adnan Hajdarevic
8207c6cf12 Started work on multi file hooks loading 2016-12-05 21:22:34 +01:00
Adnan Hajdarevic
ecbcf11153 fix #106 2016-11-01 20:09:41 +01:00
Adnan Hajdarevic
cc0d9b2cba fix tests, return raw output, return 500 if the command did not execute properly - fixes #87
return raw stdout instead of json wrapped message - fixes #88
2016-09-29 19:57:06 +02:00
Adnan Hajdarevic
3b59539a33 do not prefix specified environment variable name with HOOK_ (fixes #98) 2016-09-29 19:15:51 +02:00
Adnan Hajdarević
421fc2cbcd Hotfix backmerge (#89)
* fixes #76, fixes #78, fixes #82, fixes #83 (#84)

* Never disclose expected payload signature (#86)

Fixes #85
2016-08-25 23:42:33 +02:00
Adnan Hajdarevic
30baec91df fixes #76, fixes #78, fixes #82, fixes #83 2016-06-27 22:13:00 +02:00
Florent Aide
18b0573bc4 Add support for naming env variables (#75)
* Adding ignore patterns

* Adding support for env var naming

* Fixed typo in docstring

* Adding tests for the env var extraction w & w/o explicit naming

* remove coverage script from ignore patterns

* Adding the coverage script to help see which code is tested and which is not

* remove coverage script from sources

* Ignore coverage script from sources tree
2016-05-26 23:33:56 +02:00
Adnan Hajdarevic
37698e63b6 add support for setting global response headers using -header flag
add support for setting response headers for a successfuly triggered hook
2016-02-27 22:13:09 +01:00
Adnan Hajdarevic
9cef8ed882 add omitempty to json fields 2015-11-21 17:06:02 +01:00
Cameron Moore
d2e315d9c6 Fix environment and argument passing
Two issues are addressed in this commit:

1. Instead of only sending the predefined environment arguments, this
commit appends the arguments to the existing OS environment.  Fixes #53.

2. If an argument is not found in the payload, allow the command to run
and pass in an empty string as a placeholder.  Fixes #54.

Additionally, I replaced `hook.ErrInvalidPayloadSignature` with a new
`SignatureError` type so that we can embed the signature in the error.
2015-11-18 12:00:47 -06:00
Cameron Moore
8d1498e285 Remove unnecessary else clause 2015-11-03 10:48:16 -06:00
Cameron Moore
ea3dbf3438 Add environment arguments and improve testing
There's a lot in this commit.

 1. Add `pass-environment-to-command` option that works much like
 `pass-arguments-to-command`.  You can see an example usage in the
 "github" test case.

 2. Add a test program called "hookecho" that is used to test the
 webhook package instead of relying upon a system `echo` command.

 3. Move hooks_test.json to a template so that we can update the path to
 hookecho on the fly.

 4. Don't return an error at the end of hook.MatchRule.Evaluate().  All
 tests succeed for me now.
2015-11-02 15:11:23 -06:00
Cameron Moore
2947e5e0e8 Remove logging side-effects from hook package
The hook package should be self-contained and return errors instead of
relying on the log subsystem.  This commit removes the logging
side-effects from the hook package.  Custom errors are returned that
should be transparent to the caller -- they can just treat them as
simple errors if they don't care to check the type.
2015-10-29 11:00:30 -05:00
Adnan Hajdarevic
cbe2440cda add entire query and headers as well 2015-06-06 14:25:32 +02:00
Adnan Hajdarevic
9c545a745f return command output, pass whole payload as json to the command 2015-06-06 14:19:52 +02:00
Adnan Hajdarevic
f1ebc440a4 match all hooks with the same id 2015-05-27 09:16:26 +02:00
Adnan Hajdarevic
4350685330 separated windows and other platforms to different files, removed signal watcher from windows build file so webhook can actually compile on windows, added string as a source, so you can pass static strings to your scripts without having to wrap them around with other scripts 2015-05-16 13:32:21 +02:00
Adnan Hajdarevic
231426da57 removed leftover debug trace, fixed a panic bug 2015-03-21 01:26:04 +01:00