github
github copied to clipboard
Github.repos.contents.update - Missing required parameters
github_api (0.11.3)
rails (4.1.2)
# Github API gem configuration
Github.configure do |config|
config.basic_auth = 'XXX:XXX'
config.client_id = 'XXX'
config.client_secret = 'XXX'
config.user = 'XXX'
config.repo = 'XXX'
config.adapter = :net_http
end
Github.repos.contents.update path: '/data/plugin_vulns.xml', message: 'Update commit from WPVULNDB', content: Typhoeus.get('/api/v1/export_plugins/').body
Problem:
Missing required parameters: message, content provided for this request.
Summary:
Github gem checks the request parameters passed to ensure that github api is not hit unnecessairly and to fail fast.
Resolution:
Required parameters are: path, message, content, make sure these are the ones you are using
This worked:
sha = Github.repos.contents.get(path: '/data/plugin_vulns.xml')[:sha]
Github.repos.contents.update 'wpvulndb', 'wpscan', '/data/plugin_vulns.xml', path: '/data/plugin_vulns.xml', message: 'Update commit from WPVULNDB', content: Typhoeus.get('/api/v1/export_plugins/').body, sha: sha
It seems that the sha argument also needs passing but this is not mentioned in the error. Also, for some reason I had to pass the user, repo and path to update even though I had configured them previously (other configs such as basic_auth worked).
Thanks for your report!
Regarding the user, repo parameters, I had some problems getting the logic right in the past. Since then it has been rewritten and I should be in position to release it soon. The configuration options are global in a sense and it is much better to pass these per method call anyway.
Not sure why the :sha parameter has been excluded from the error message, I trust it should be fixed in new argument parser. I will add that to the test suite.
Unrelated:
To use the Typhoeus adapter you need to include the Typhoeus faraday code, example:
Github.configure do |config|
require 'typhoeus/adapters/faraday'
config.basic_auth = "wpvulndb:#{password}"
config.user = 'wpvulndb'
config.repo = 'wpscan'
config.adapter = :typhoeus
end
Otherwise you get this error:
undefined method `ssl_cacert=' for #<Typhoeus::Request:0x007fa771cea278>
Not sure if it is worth putting in the readme or not.
I will keep this one open as I certainly want to rewrite the documentation to be more comprehensive and include gotchas like this! Thanks