-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Whitelist hooks #302
Whitelist hooks #302
Conversation
@@ -110,6 +110,8 @@ Usage of tusd: | |||
Use Google Cloud Storage with this bucket as storage backend (requires the GCS_SERVICE_ACCOUNT_FILE environment variable to be set) | |||
-hooks-dir string | |||
Directory to search for available hooks scripts | |||
-hooks-enabled-events string | |||
Comma separated list of enabled hook events, set to "-" to disable all (default "*") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set to "-" to disable all
Is that correct? Isn't "" used to disable all hooks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, I used -
in a previous version and forgot to update it in the docs, I fixed that in this commit - c93e37f which I added to the pull request later.
EnabledHooks = append(EnabledHooks, h) | ||
} | ||
} else { | ||
slc := strings.Split(Flags.EnabledHooks, ",") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a check and corresponding output message if the specified hook name actually exists, so users get notified early when they misspell post-receive
as post-recieve
, for example.
Thank you very much for your work here, it's looking good! I am wondering if we should actually allow to disable hook events. If the user does not want hooks at all, they should not specify the |
Ha that did not occur to me, makes sense to not allow to disable all the hook events considering the |
Thank you very much! I cleaned up some code and merged this PR in f1fe5e2. |
Implemented cli option to for hooks whitelisting, based on this comment. I named the cli option
hooks-enabled-events
so it is consistent with the otherhooks
options. I added the following docs to thedocs/hooks.md
in the pull request:## Enabling/Disabling Hook Events
The
--hooks-enabled-events
option for the tusd binary works as a whitelist for hook events and takes a comma separated list of hook events. By default all hook events are enabled.Possible values for the
--hooks-enabled-events
option:*
- enable all hook events (default value)""
- disable all hook eventspre-create,post-create
) - whitelist of hook eventsFeedback on the code quality is more than welcome, I am still quite new to Go.