Commit Graph

35 Commits

Author SHA1 Message Date
Tom Hubrecht 1b13355196 fix: Trim the cat output (#720)
`os.ReadFile` includes a trailing EOL, so we have to remove it to get
the correct value
2025-01-12 12:27:16 +01:00
Tom Hubrecht eb7e8f5ba8 feat: Add two template functions (#712)
* chore: replace ioutil.ReadFile by os.ReadFile

* feat: Add two template functions

- cat:        Allows reading a value from a file
- credential: Allows reading a credential passed by systemd
2025-01-12 00:42:22 +01: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
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ć 2e4aea4cbc Merge pull request #486 from moorereason/iss439-raw-body
Add option to send raw request body to command
2020-12-06 08:39:55 +01:00
Cameron Moore 62f9c01cab Add option to send raw request body to command
The existing `entire-payload` option sends a JSON representation of the
parsed request body.  Add a new `raw-request-body` source to send the
raw request body.

Fixes #439
2020-11-25 10:20:10 -06:00
Cameron Moore 6d2f26d952 Add soft signature failure support
Add a new trigger-signature-soft-failures option to allow soft signature
failures in Or rules.

Fixes #234
2020-11-24 21:16:57 -06:00
Cameron Moore 6f5962f8f2 Use strings.ToLower on source name parameters 2020-11-21 10:00:03 -06:00
Cameron Moore 346c761ef6 Add request source
Add "request" source with support for "method" and "remote-addr"
parameters.  Both values are taken from the raw http.Request object.

Fixes #312
2020-11-20 16:32:55 -06:00
Cameron Moore 22c8a1670b Move some request parsing into hook package
Trying to simplify hookHandler.  No functional changes introduced.
2020-11-17 15:00:58 -06:00
Cameron Moore dc184d2737 Fix OrRule logic on parameter lookup failures
Fixes #471
2020-10-24 11:40:27 -05:00
Cameron Moore 6bbf14f7d9 Transition payload hash option names to hmac
The payload-hash-* options are imprecisely named. Clarify their function
as HMAC validations by renaming them. The existing options will continue
to work but are deprecated.  Log a warning if the old options are used.

All tests, examples, and documentation are updated.

Fixes #289
2020-09-27 20:24:36 -05:00
Cameron Moore c6603894c1 Add Request object to hook package to simplify API
To avoid having to pass around so many parameters to the hook package,
create a Request object to store all request-specific data.  Update APIs
accordingly.
2020-09-25 19:46:06 -05:00
Cameron Moore ae5e9e7894 Update ExtractParameterAsString to return JSON on complex types
Fixes #448
2020-07-31 11:58:12 -05:00
Adnan Hajdarević c4f29b5d8b Merge pull request #432 from moorereason/bugfix/logging-gocritic
Fix issues in logging middleware
2020-05-29 09:43:32 +02:00
Cameron Moore c9199d62e4 Tighten file permissions on pidfile creation
Fixes report from gosec: "G306: Expect WriteFile permissions to be 0600
or less."  Also, use new octal number formatting.
2020-05-28 18:23:02 -05:00
Cameron Moore 3d824b47b7 Rename var to avoid shadowing bytes package
importShadow: shadow of imported package 'bytes' (gocritic)
2020-05-28 18:20:07 -05:00
Cameron Moore cc98de88ce Fix godoc comment on LogEntry.Panic 2020-05-28 18:17:41 -05:00
Adnan Hajdarević e71b45b28f Merge pull request #427 from moorereason/feature/empty-payload-signature
Warn on failed validate of empty payload signature
2020-05-23 09:28:09 +02:00
Cameron Moore 41ac427a89 Warn on failed validate of empty payload signature
If signature validation fails on an empty payload, append a note to the
end of the error message.

Updates #423
2020-05-22 14:02:12 -05:00
Cameron Moore 526c9a20ac Fix request dumper
The existing code had a bug in printing request params.  Simplify the
request logger by using httputil.DumpRequest.

Also print the request before handing it downstream.

Fixes #425
2020-05-21 17:47:55 -05:00
Adnan Hajdarević 38294cd0c6 Merge pull request #383 from moorereason/feature/pidfile
Add pidfile support
2020-02-14 19:35:18 +01:00
Adnan Hajdarević dc4f42bb26 Merge pull request #384 from moorereason/feature/value-walk
Show failed parameter node lookups
2020-02-14 19:13:36 +01:00
Wyatt Johnson de626ab2bb fix: updated based on review
- added support for sha512
- added notes to docs
2020-01-06 18:23:30 -06:00
Wyatt Johnson f8c8932866 fix: spelling 2020-01-06 18:23:20 -06:00
Wyatt Johnson 6d3b81fc61 fix: simplify implementation 2020-01-06 18:23:09 -06:00
Wyatt Johnson 11e0031a9f feat: added multiple sig support 2020-01-06 18:22:55 -06:00
Cameron Moore 7fa3a8900c Show failed parameter node lookups
When attempting to match a JSON path for initial setup, it would be
helpful to know where the path failed. This change logs the failed
parameter node. For example, if you are trying to match path "a.b.d.e",
but you failed to include the "c" node, webhook will log an error
"parameter node not found: d.e" to assist in troubleshooting.
2019-12-30 21:51:11 -06:00
Cameron Moore e1634fe669 Add missing windows dependency 2019-12-29 18:08:35 -06:00
Cameron Moore 876c853073 Add pidfile support
Copy a simple implementation from the Moby project, since importing
their package would pull in too many dependencies.

Fixes #320
2019-12-29 18:00:55 -06:00
Cameron Moore a03e812615 Update HTTP methods to sanitize user input 2019-12-26 14:54:27 -06:00
Cameron Moore 3414f34025 Add per-hook HTTP method restrictions 2019-12-26 14:54:01 -06:00
Cameron Moore be815d0a41 Use gorilla/mux for middleware and extend
- Use gorilla/mux for middleware.
- Add Dumper, RequestID, and Logger middlewares.
- Add makeURL helper
2019-12-24 11:57:26 -06:00
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