Commit graph

46 commits

Author SHA1 Message Date
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
Adnan Hajdarevic
688483d6d1 added parse-parameters-as-json property to hooks, fixed some bugs in old code 2015-03-21 01:10:17 +01:00
Adnan Hajdarević
bddb523b67 Merge pull request #16 from moorereason/fix-notrule
Fix infinite loop in NotRule.Evaluate
2015-03-20 23:37:49 +01:00
Cameron Moore
becd8935be Fix infinite loop in NotRule.Evaluate 2015-03-20 16:58:58 -05:00
Cameron Moore
230d16dd93 Only support unsigned ints for slice indexes
This commit changes ExtractParameter to parse slice indexes as unsigned
ints.  Fixes test case "a.-1.b".
2015-03-20 16:54:03 -05:00
Cameron Moore
7dd55f5232 Refactor to remove helpers package
This commit removes the "helpers" package by moving functions from the
package into the other packages that use them.

CheckPayloadSignature() and ExtractParamater() are simply moved to the
"hook" package.  I'm not sure of the usefulness of having these
functions exported, but I left them allow for now.

ValuesToMap() is moved to the "main" webhook package and renamed to
valuesToMap().

Tests were moved into the "hook" package since we only test
ExtractParameter() right now.

This commit closes adnanh/webhook#12.
2015-03-20 08:55:42 -05:00
Adnan Hajdarevic
f83af97138 added per-hook defined response message 2015-03-17 19:34:54 +01:00
Adnan Hajdarevic
90528b2ed9 webhook 2.0.0 2015-03-13 01:31:49 +01:00