Skip to content
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

Github.repos.contents.update - Missing required parameters #175

Open
ghost opened this issue Jul 1, 2014 · 4 comments
Open

Github.repos.contents.update - Missing required parameters #175

ghost opened this issue Jul 1, 2014 · 4 comments

Comments

@ghost
Copy link

ghost commented Jul 1, 2014

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
@ghost
Copy link
Author

ghost commented Jul 1, 2014

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).

@piotrmurach
Copy link
Owner

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.

@ghost
Copy link
Author

ghost commented Jul 1, 2014

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.

@piotrmurach
Copy link
Owner

I will keep this one open as I certainly want to rewrite the documentation to be more comprehensive and include gotchas like this! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant