Package: github-watchman
GitHub WatchmanAbout GitHub WatchmanGitHub Watchman is an application that uses the GitHub API to audit GitHub for sensitive data and credentials exposed internally.FeaturesIt searches GitHub for internally shared projects and looks at:CodeCommitsIssuesRepositoriesFor the following data:GCP keys and service account filesAWS keysAzure keys and service account filesGoogle API keysSlack API tokens & webhooksPrivate keys (SSH, PGP, any other misc private key)Exposed tokens (Bearer tokens, access tokens, client_secret etc.)S3 config filesPasswords in plaintextand moreTime based searchingYou can run GitHub Watchman to look for results going back as far as:24 hours7 days30 daysAll timeThis means after one deep scan, you can schedule GitHub Watchman to run regularly and only return results from your chosen timeframe.RulesGitHub Watchman uses custom YAML rules to detect matches in GitHub.They follow this format:---filename:enabled:#[true|false]meta:name:author:date:description:#what the search should find#severity:#rating out of 100#scope:#what to search, any combination of the below#-code-commits-issues-repositoriestest_cases:match_cases:-#test case that should match the regex#fail_cases:-#test case that should not match the regex#strings:-#search query to use in GitHub#pattern:#Regex pattern to filter out false positives#There are Python tests to ensure rules are formatted properly and that the Regex patterns work in thetestsdirMore information about rules, and how you can add your own, is in the filedocs/rules.md.LoggingGitHub Watchman gives the following logging options:CSVLog fileStdoutTCP streamWhen using CSV logging, searches for rules are returned in separate CSV files, for all other methods of logging, results are output in JSON format, perfect for ingesting into a SIEM or other log analysis platform.For file and TCP stream logging, configuration options need to be passed via.conffile or environment variable. See the filedocs/logging.mdfor instructions on how to set it up.If no logging option is given, GitHub Watchman defaults to CSV logging.RequirementsGitHub versionsGitHub Watchman uses the v3 API, and works with GitHub Enterprise Server versions that support the v3 API.GitHub Watchman also works with GitHub.com (Free, Pro and Team) using the API.GitHub personal access tokenTo run GitHub Watchman, you will need a GitHub personal access token.You can create a personal access token in the GitHub GUI via Settings -> Developer settings -> Personal access tokensThe token needs no specific scopes assigned, as it searches public repositories in the GitHub instance.Note: Personal access tokens act on behalf of the user who creates them, so I would suggest you create a token using a service account, otherwise the app will have access to your private repositories.GitHub URLYou also need to provide the URL of your GitHub instance.Providing token & URLGitHub Watchman will first try to get the the GitHub token and URL from the environment variablesGITHUB_WATCHMAN_TOKENandGITHUB_WATCHMAN_URL, if this fails they will be taken from .conf file (see below)..conf fileConfiguration options can be passed in a file namedwatchman.confwhich must be stored in your home directory. The file should follow the YAML format, and should look like below:github_watchman:token:abc123url:https://github.example.comlogging:file_logging:path:json_tcp:host:port:GitHub Watchman will look for this file at runtime, and use the configuration options from here. If you are not using the advanced logging features, leave them blank.If you are having issues with your .conf file, run it through a YAML linter.An example file is indocs/example.confNoteIf you use any other Watchman applications and already have awatchman.conffile, just append the conf data for GitHub Watchman to the existing file.InstallationInstall via pippip install github-watchmanOr via sourceUsageGitHub Watchman will be installed as a global command, use as follows:usage: github-watchman [-h] --timeframe {d,w,m,a} --output
                   {csv,file,stdout,stream} [--version] [--all] [--code]
                   [--commits] [--issues] [--repositories]

Monitoring GitHub for sensitive data shared publicly

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --all                 Find everything
  --code                Search code
  --commits             Search commits
  --issues              Search issues
  --repositories        Search merge requests

required arguments:
  --timeframe {d,w,m,a}
                        How far back to search: d = 24 hours w = 7 days, m =
                        30 days, a = all time
  --output {csv,file,stdout,stream}
                        Where to send resultsYou can run GitHub Watchman to look for everything, and output to default CSV:github-watchman --timeframe a --allOr arguments can be grouped together to search more granularly. This will look for commits and milestones for the last 30 days, and output the results to a TCP stream:github-watchman --timeframe m --commits --milestones --output streamOther Watchman appsYou may be interested in some of the other apps in the Watchman family:Slack WatchmanGitLab WatchmanLicenseThe source code for this project is released under theGNU General Public Licence. This project is not associated with GitHub.