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

Add support for Audit log REST API #1478

Closed
Brend-Smits opened this issue Sep 7, 2022 · 8 comments · Fixed by #1481
Closed

Add support for Audit log REST API #1478

Brend-Smits opened this issue Sep 7, 2022 · 8 comments · Fixed by #1481

Comments

@Brend-Smits
Copy link
Contributor

Brend-Smits commented Sep 7, 2022

Hi all,

Thanks for creating and maintaining this awesome library! I'm working on an open-source replacement for GitHub's dormant user detection. For this project, I need to read data from the audit log API to be able to determine if a user is active or not.

It looks like octokit.rb does not currently support this REST API. Could support be added for the audit log API?
If needed, I can look into contributing this feature.

Relevant documentation: https://docs.github.com/en/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/reviewing-the-audit-log-for-your-organization#using-the-audit-log-api
and
https://docs.github.com/en/enterprise-cloud@latest/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/using-the-audit-log-api-for-your-enterprise#querying-the-audit-log-rest-api

@timrogers
Copy link
Contributor

@Brend-Smits Thanks for reaching out! We'd love to have support for the Audit Log API in Octokit.rb. At the moment, these kinds of efforts are community-driven, so if you wanted to contribute the new code, that would be wonderful. I'd be very happy to review and support.

@Brend-Smits
Copy link
Contributor Author

Brend-Smits commented Sep 7, 2022

Thanks for the swift reply @timrogers.
I will try my best, not very fluent at Ruby. Seeing as the endpoint is part of the /org/ domain, I was thinking of adding a new entry here: https://github.com/octokit/octokit.rb/blob/main/lib/octokit/client/organizations.rb
I will let you know if I run into any difficulties.

@timrogers
Copy link
Contributor

Sounds good! Fortunately, this library is pretty light so you will have to write very minimal amounts of code. I'm here if you need any help.

@Brend-Smits
Copy link
Contributor Author

So far my experience with adding support for this endpoint has been great. It's actually really easy to add, good work on the architecture of this library!
The only thing I experienced minor issues with is getting the tests to run. Even after following the steps in the contributing guidelines, I was still struggling. It turned out that libsodium was not installed on my machine. After manually installing it using brew install libsodium, everything worked like a charm :)
I have a PR ready, it's undergoing internal review now. Hopefully, after the weekend I will get approval and will then open a PR here.

@Brend-Smits
Copy link
Contributor Author

Hmmm @timrogers, seems that after upgrading to version 5.5, I get undefined method errors when calling this endpoint.
NoMethodError: undefined method `organization_audit_log' for #<Octokit::Client:0x00007fad7ca2031. Did you mean? organization
Any idea why this would be happening? Did I miss something when implementing?

@timrogers
Copy link
Contributor

I think I know what we’ve missed. I’ll take a look tomorrow and will get back to you.

@timrogers
Copy link
Contributor

I've tried it locally and it's working for me. Can you try running Octokit::VERSION, just to check that you are on the new version.

Here's my irb output, just to show what I'm seeing:

irb(main):001:0> require 'octokit'
=> true
irb(main):002:0> c = Octokit::Client.new
=> #<Octokit::Client:0x000000010931d6c0 ...>
irb(main):003:0> c.organization_audit_log
/Users/timrogers/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/octokit-5.5.0/lib/octokit/client/organizations.rb:843:in `organization_audit_log': wrong number of arguments (given 0, expected 1..2) (ArgumentError)
	from (irb):3:in `<main>'
	from /Users/timrogers/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/irb-1.4.1/exe/irb:11:in `<top (required)>'
	from /Users/timrogers/.asdf/installs/ruby/3.1.2/bin/irb:25:in `load'
	from /Users/timrogers/.asdf/installs/ruby/3.1.2/bin/irb:25:in `<main>'
irb(main):004:0> Octokit::VERSION
=> "5.5.0"
irb(main):005:0* ^[

@Brend-Smits
Copy link
Contributor Author

You're right @timrogers, it seems like my project had version 5.1 cached or something. Sorry about that! Thanks for the help.

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

Successfully merging a pull request may close this issue.

2 participants