Giter Site home page Giter Site logo

org-audit-action's Introduction

GitHub Membership Audit Action

GitHub Action that provides an Enterprise Account or Organization Audit of members, repositories and which permissions these members have. The output of this action is a published CSV file in the Actions tab. The user can also configure the action to publish the results to an issue.

The output looks like this running on enterprise mode:

enterprise organization repo user login permission
goodcorp goodcorp-os node-utils Vitor Monteiro bitoiu ADMIN
goodcorp goodcorp-os node-utils Richard Erwin rerwinx ADMIN
goodcorp goodcorp-os node-utils Kai Hilton-Jones evil-clone WRITE
goodcorp core innersource-docs Vitor Monteiro bitoiu ADMIN
goodcorp core innersource-docs Richard Erwin rerwinx READ

Action configuration overview

 - name: Membership Audit Log Action
      uses: svanboxel/org-audit-action@master
      with:
        ## `organization` and `enterprise` are mutually exclusive
        enterprise: 'goodcorp'  
        ## repo, read:org, read:enterprise (if running with enterprise option)
        token: ${{ secrets.TOKEN }}
        ## issue is optional
        issue: true
        ## samlIdentities is optional
        samlIdentities: true
        ## affiliation is optional - values are 'ALL', 'DIRECT' (i.e. members only) or 'OUTSIDE' (i.e. outside collaborators only)
        affiliation: 'ALL'

Example workflows

Depending on your needs you might want to trigger the audit on different events. The simplest one to test it out is to trigger the workflow on push. For this workflow to run properly you'll need to provide it with a secret personal access token from someone that is an org owner or from an application that has that privilege. Providing it a lesser scope might not show all the information for the organization.

Single org-audit audit on push (good for testing)

The action in the following workflow is configured to:

  • Work only on a single organization
  • Expose the linked SAML nameId field for your members if your organization is using SAML SSO and you want to retrieve this info (generally a corporate email address used to login with SSO)
  • Publish results also to an issue
on: push

jobs:

  audit_log:
    runs-on: ubuntu-latest
    name: Membership Audit Log

    - name: Membership Audit Log Action
      uses: svanboxel/org-audit-action@v1
      with:
        organization: 'octodemov2'
        token: ${{ secrets.TOKEN }}
        issue: true
        samlIdentities: true

Enterprise Account audit on a schedule (cron)

The action in the following workflow is configured to:

  • Work on an enterprise account
  • Publish results also to an issue
on:
  schedule:   
    # Once a week on Saturday 00:00
    - cron:  '0 0 * * 6'

jobs:

  audit_log:
    runs-on: ubuntu-latest
    name: Membership Audit Log

    - name: Membership Audit Log Action
      uses: svanboxel/org-audit-action@v1
      with:
        enterprise: 'goodcorp'
        token: ${{ secrets.TOKEN }}
        issue: true

Enterprise Audit triggered by an external service

Use a repository_dispatch event to trigger this workflow. The action in the following workflow is configured to:

  • Work on an enterprise account
  • Publish results also to an issue
on: repository_dispatch

jobs:

  audit_log:
    runs-on: ubuntu-latest
    name: Membership Audit Log

    - name: Membership Audit Log Action
      uses: svanboxel/org-audit-action@v1
      with:
        enterprise: 'goodcorp'
        token: ${{ secrets.TOKEN }}
        issue: true

Local testing

You can test this action locally by using the following command:

TOKEN=<github_token> ORGANIZATION=<organization name (or use ENTERPRISE=<enterprise_name>)> GITHUB_REPOSITORY=<owner>/<repository> node src/index.js

Help us improve it

Open an issue on: https://github.com/svanboxel/org-audit-action

org-audit-action's People

Contributors

amaechler avatar bitoiu avatar dependabot[bot] avatar helaili avatar pholleran avatar sennap avatar socalnick avatar spier avatar svanboxel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

org-audit-action's Issues

Error in the generation of the export file

We have an error in the end of the script that blocks the generation of the export file :

  ⚛  Normalizing result.
  Uploading chunk of size 4194304 bytes at offset 0 with content range: bytes 0-4194303/4439402
  Uploading chunk of size 1898701 bytes at offset 0 with content range: bytes 0-1898700/1898701
  (node:1835) UnhandledPromiseRejectionWarning: Error: read ECONNRESET
      at TLSWrap.onStreamRead (internal/stream_base_commons.js:201:27)
  (node:1835) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
  (node:1835) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```

Add pending member invites to the audit

Hi @SvanBoxel !

I was looking at https://docs.github.com/en/graphql/reference/objects#:~:text=to%20look%20for.-,pendingMemberInvitations,-(EnterprisePendingMemberInvitationConnection and i was wondering if this could be added as a query or added into an existing query (https://github.com/SvanBoxel/org-audit-action/blob/master/src/queries.js)? i otherwise don't have graphql experience but was curious if this would allow us to also see all pending invites and get true license counts.

Add Error Handle Logic - Failed Create Export Artifact

Thanks in advance for this nice action. Helps with compliance no doubt. I attempted to execute this against an enterprise cloud account with multiple organizations. It appears one of the Orgs does not contain and repositories to report against. As a result, it seems the action stops at that point and does not continue so that it can finish and generate the csv artifact. @SvanBoxel Here is the error message:

Start collecting for organization
⏸ No data found for , probably you don't have the right permission
Cannot read property 'samlIdentityProvider' of null
⚛ Normalizing result.
Uploading chunk of size 4194304 bytes at offset 0 with content range: bytes 0-4194303/5702770
Uploading chunk of size 2595943 bytes at offset 0 with content range: bytes 0-2595942/2595943
(node:1899) UnhandledPromiseRejectionWarning: Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:201:27)
(node:1899) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1899) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.