-
Notifications
You must be signed in to change notification settings - Fork 280
Allow hooks to be provided in separate gems #498
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| require 'digest' | ||
| require 'json' | ||
| require 'English' | ||
|
|
||
| module Overcommit | ||
| # Stores configuration for Overcommit and the hooks it runs. | ||
|
|
@@ -264,8 +265,10 @@ def ad_hoc_hook?(hook_context, hook_name) | |
| def built_in_hook?(hook_context, hook_name) | ||
| hook_name = Overcommit::Utils.snake_case(hook_name) | ||
|
|
||
| File.exist?(File.join(Overcommit::HOME, 'lib', 'overcommit', 'hook', | ||
| hook_context.hook_type_name, "#{hook_name}.rb")) | ||
| $LOAD_PATH.any? do |dir| | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wary of this approach because it bypasses the standard mechanism for loading hook plugins, which ensures the source code of the plugins is properly signed. By allowing code loading this way, an attacker can easily inject malicious code by simply adding a gem to the Gemfile specified in the |
||
| File.exist?(File.join(dir, 'overcommit', 'hook', | ||
| hook_context.hook_type_name, "#{hook_name}.rb")) | ||
| end | ||
| end | ||
|
|
||
| def hook_exists?(hook_context, hook_name) | ||
|
|
||
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.
Are you sure this is necessary? I'm able to access
$LOAD_PATHin an IRB session withoutrequire 'English'.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.
You probably have
Englishloaded by IRB itself. I have been bitten by this previously, so now I requireEnglishwhenever I use english global constants.