Git Product home page Git Product logo

alphagov.cyber-security-github-usage's Introduction

cyber-security-github-usage

Lambda to report on github usage stats from pre-commit hook invocations

The lambda can be invoked with different actions (declared in the payload).

Most of the actions are internal secondary actions invoked by the audit action via SNS. There are 2 primary actions:

  1. usage
  2. audit

These are triggered by cron lambda triggers defined in the terraform.

action: usage

When someone runs the install script for detect secrets:

  1. They authenticate with Github
  2. A message gets sent to the alert_processor endpoint
  3. It records their username in SSM with a random generated token string
  4. It passes the token back and saves it in the github global config.

The usage lambda runs daily on a cron:

  1. Checks the membership of alphagov
  2. Checks the list of users in SSM
  3. Removes anyone from SSM who's no longer in alphagov
  4. Reports the number of registered users of detect secrets as a percentage of the alphagov membership.

The random token was intended to be used on another pre-commit hook so we could record when a user commits with detect secrets enabled. So for detect secrets we'd have 3 metrics:

  1. % of alphagov members
  2. % of (active) repos with a .secrets.baseline
  3. % of commits protected by pre-commit

action: audit

The aim if the audit is to capture the membership and access of github accounts to a github organisation. It looks at membership of the organisation, membership of teams within the organisation and then at access to repositories within
the organisation both as contributors and via membership of teams.

The audit is run on a schedule. The audit can also be kicked off manually by an event

{"action":"audit"}

Which calls the audit.start function.

From there the lambda is repeatedly triggered by SNS publish/subscribe until all the audit actions have completed.

audit.start

  • log_org_membership
  • log_org_teams
    • log_org_team_membership for each team
    • log_org_team_repos for each team
      • log_org_repo_team_members for each team repo
  • log_org_repos
    • log_org_repo_contributors for each repo

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.