Package: gitlab-watchman
GitLab WatchmanAbout GitLab WatchmanGitLab Watchman is an application that uses the GitLab API to detect exposed secrets and personal data. It also enumerates the GitLab instance for any useful information.FeaturesSecrets DetectionIt searches GitLab for internally shared projects and looks at:CodeCommitsWiki pagesIssuesMerge requestsMilestonesNotesSnippetsFor 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 filesTokens for services such as Heroku, PayPal and morePasswords in plaintextand moreTime based searchingYou can run GitLab Watchman to look for results going back as far as:24 hours7 days30 daysAll timeThis means after one deep scan, you can schedule GitLab Watchman to run regularly and only return results from your chosen timeframe.EnumerationGitLab Watchman can enumerate potentially useful information from a GitLab instance:Instance metadataInformation on the calling user/token being usedOutput all users to CSV fileOutput all projects to CSV fileOutput all groups to CSV fileSignaturesGitLab Watchman uses custom YAML signatures to detect matches in GitLab. These signatures are pulled from the centralWatchman Signatures repository. Slack Watchman automatically updates its signature base at runtime to ensure its using the latest signatures to detect secrets.LoggingGitLab Watchman gives the following logging options:Terminal-friendly StdoutJSON to StdoutGitLab Watchman defaults to terminal-friendly stdout logging if no option is given. This is designed to be easier for humans to read.JSON logging is also available, which is perfect for ingesting into a SIEM or other log analysis platforms.JSON formatted logging can be easily redirected to a file as below:gitlab-watchman --timeframe a --all --output json >> gitlab_watchman_log.jsonRequirementsGitLab versionsGitLab Watchman uses the v4 API, and works with GitLab Enterprise Edition versions:13.0 and above - YesGitLab.com - Yes12.0 - 12.10 - Maybe, untested but if using v4 of the API then it could workGitLab Licence & ElasticsearchTo search the scopes:blobswiki_blobscommitsThe GitLab instance must haveElasticsearchconfigured, and be running Enterprise Edition with a minimum GitLab Starter or Bronze Licence.GitLab personal access tokenTo run GitLab Watchman, you will need a GitLab personal access token.You can create a personal access token in the GitLab GUI via Settings -> Access Tokens -> Add a personal access tokenThe token needs permission for the following scopes:apiNote: 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.GitLab URLYou also need to provide the URL of your GitLab instance.Providing token & URLGitLab Watchman will get the GitLab token and URL from the environment variablesGITLAB_WATCHMAN_TOKENandGITLAB_WATCHMAN_URL.InstallationYou can install the latest stable version via pip:python3 -m pip install gitlab-watchmanOr build from source yourself. Download the release source files, then from the top level repository run:python3-mbuild
python3-mpipinstall--force-reinstalldist/*.whlDocker ImageGitLab Watchman is also available from the Docker hub as a Docker image:docker pull papermountain/gitlab-watchman:latestYou can then run GitLab Watchman in a container, making sure you pass the required environment variables:// help
docker run --rm papermountain/gitlab-watchman -h

// scan all
docker run --rm -e GITLAB_WATCHMAN_TOKEN=abc123 -e GITLAB_WATCHMAN_URL=https://example.gitlab.com papermountain/gitlab-watchman --timeframe a --all
docker run --rm --env-file .env papermountain/gitlab-watchman --timeframe a --allUsageGitLab Watchman will be installed as a global command, use as follows:usage: gitlab-watchman [-h] --timeframe {d,w,m,a} [--output {json,stdout}] [--version] [--all] [--blobs] [--commits] [--wiki-blobs] [--issues]
                   [--merge-requests] [--milestones] [--notes] [--snippets] [--enumerate] [--debug] [--verbose]

Finding exposed secrets and personal data in GitLab

options:
  -h, --help            show this help message and exit
  --output {json,stdout}, -o {json,stdout}
                        Where to send results
  --version, -v         show program's version number and exit
  --all, -a             Find everything
  --blobs, -b           Search code blobs
  --commits, -c         Search commits
  --wiki-blobs, -w      Search wiki blobs
  --issues, -i          Search issues
  --merge-requests, -mr
                        Search merge requests
  --milestones, -m      Search milestones
  --notes, -n           Search notes
  --snippets, -s        Search snippets
  --enumerate, -e       Enumerate this GitLab instance for users, groups, projects.Output will be saved to CSV files
  --debug, -d           Turn on debug level logging
  --verbose, -V         Turn on more verbose output for JSON logging. This includes more fields, but is larger

required arguments:
  --timeframe {d,w,m,a}
                        How far back to search: d = 24 hours w = 7 days, m = 30 days, a = all timeOther Watchman appsYou may be interested in the other apps in the Watchman family:Slack WatchmanSlack Watchman for Enterprise GridGitHub WatchmanLicenseThe source code for this project is released under theGNU General Public Licence. This project is not associated with GitLab.[3.0.0] - 2023-05-15This major version release brings multiple updates to GitLab Watchman in usability, functionality and behind the scenes improvements.AddedSupport for centralised signatures from theWatchman Signatures repositoryThis makes it much easier to keep the signature base for all Watchman applications up to date, and to add functionality to GitLab Watchman with new signatures. New signatures are downloaded, and updates to existing signatures are applied, at runtime, meaning GitLab Watchman will always be using the most up to date signatures.Major UI overhaulA lot of feedback said GitLab Watchman was hard to read. This version introduces new terminal optimised logging as a logging option, as well as JSON formatting. This formatting is now the default when running with no output option selected, and is a lot easier for humans to read. Also, colours!Enumeration options addedGitLab Watchman now gathers more information from an instance. Useful if your use case is more red than blue...Instance metadata output to terminalInformation on the user you are authenticated as, and the token you are using, including what permissions it has.All instance users output to CSVAll instance projects output to CSVAll instance groups output to CSVOption choose between verbose or succinct logging when using JSON output. Default is succinct.Debug logging optionRemovedLocal/custom signatures - Centralised signatures mean that user-created custom signatures can't be used with GitLab Watchman for Enterprise Grid anymore. If you have made a signature you think would be good for sharing with the community, feel free to add it to the Watchman Signatures repository, so it can be used in all Watchman applications[2.0.0] - 2022-03-22Added:New scopes for finding exposed data in:notessnippetsDocker image now available from the Docker hub, or by building from source. (Credit@adiossfor the inspiration)Complete rewrite of the codebase to make searching faster and more efficient.More modern packaging and distribution.Logs now include more dataAdditional signatures added to find more leaked dataUpdated logo to play nicely with dark mode displaysRemoved:Logging to file and TCP stream - logs to stdout like a true 12 factor app. Reroute stdout as you see fit. --output.conf file for configuration options. Pass the environment variablesGITLAB_WATCHMAN_TOKENandGITLAB_WATCHMAN_URLBreaking changes:The --output flag is no longer required, and therefore not supported[1.4.0] - 2020-12-24Added:Refactor of rules into directories for easier managementMultiprocessing implemented for searching for matches. GitLab Watchman now splits regex filtering between the cores available on the device, meaning the more cores you have, the faster searching should run.Handling for GitLab API rate limiting, backing off when the rate limit is hit. The rate limit may be more likely to come into effect with multiprocessingRules added to search for:Cloudflare tokensFacebook API tokensGitHub API tokensMailchimp API tokensMailgun API tokensShodan API tokensStripe API tokensTwilio API tokensMicrosoft NuGet keys[1.3.0] - 2020-12-12Added:Add more information about the namespaces a project is in to logsAdded owner details of that namespace, for groups and usersTime based searching now looks at the time a file was committed, not when a project was active, which greatly reduces multiples of the same detection because a project is active but a file has not been modified.Rules added:SSH private keysMastercard datacash tokensHeroku tokensPagerDuty tokensRemoved:Enhanced logging that includes nested information, such as namespace owners, means that CSV logging is no longer practical. CSV logging has been removed and JSON via STDOUT is now the default option.[1.2.0] - 2020-11-16Added:More data on namespaces added to logsBetter search queries for existing rules to filter out false positivesRemoved:CICD variable search no longer works due to GitLab API now only allowing owners of a project to search it for variables. It has been removed.Fixed:Bug on outputting match string for blobs/wiki-blobs[1.1.0] - 2020-11-14FixedRetry added for occasional Requests HTTPSConnectionPool errorAddedExact regex string match added to output from message searches[1.0.0] - 2020-10-01Release