Skip to content

Commit 66eeee6

Browse files
committed
Brush up README documentation
1 parent d8da475 commit 66eeee6

1 file changed

Lines changed: 39 additions & 40 deletions

File tree

README.rst

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,35 @@ rejected.
3232

3333

3434
Installing git-secrets
35-
~~~~~~~~~~~~~~~~~~~~~~
35+
----------------------
3636

3737
``git-secrets`` must be placed somewhere in your PATH so that it is picked up
38-
by ``git`` when running ``git secrets``.
38+
by ``git`` when running ``git secrets``.
3939

40-
**\*nix (Linux/OSX)**
40+
\*nix (Linux/OSX)
41+
~~~~~~~~~~~~~~~~~
4142

42-
You can use ``install`` target of the provided Makefile to install
43+
You can use the ``install`` target of the provided Makefile to install
4344
``git secrets`` and the man page. You can customize the install path
4445
using the PREFIX and MANPREFIX variables.
4546

4647
::
4748

4849
make install
4950

50-
**Windows**
51+
Windows
52+
~~~~~~~
5153

52-
Run the provided install.ps1 powershell script. This will copy the needed files
53-
to an installation directory ("%USERPROFILE%/.git-secrets" by default) and add
54-
the directory to the current user PATH.
54+
Run the provided ``install.ps1`` powershell script. This will copy the needed files
55+
to an installation directory (``%USERPROFILE%/.git-secrets`` by default) and add
56+
the directory to the current user ``PATH``.
5557

5658
::
5759

5860
PS > ./install.ps1
5961

60-
**Homebrew (for OS X users).**
62+
Homebrew (for macOS users)
63+
~~~~~~~~~~~~~~~~~~~~~~~~~~
6164

6265
::
6366

@@ -76,10 +79,8 @@ on each commit::
7679
git secrets --register-aws
7780

7881

79-
80-
8182
Advanced configuration
82-
~~~~~~~~~~~~~~~~~~~~~~
83+
----------------------
8384

8485
Add a configuration template if you want to add hooks to all repositories you
8586
initialize or clone in the future.
@@ -105,7 +106,7 @@ Add custom providers to scan for security credentials.
105106

106107

107108
Before making public a repository
108-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
109+
---------------------------------
109110

110111
With git-secrets is also possible to scan a repository including all revisions:
111112

@@ -114,8 +115,6 @@ With git-secrets is also possible to scan a repository including all revisions:
114115
git secrets --scan-history
115116

116117

117-
118-
119118
Options
120119
-------
121120

@@ -125,49 +124,49 @@ Operation Modes
125124
Each of these options must appear first on the command line.
126125

127126
``--install``
128-
Installs hooks for a repository. Once the hooks are installed for a git
129-
repository, commits and non-ff merges for that repository will be prevented
127+
Installs git hooks for a repository. Once the hooks are installed for a git
128+
repository, commits and non-fast-forward merges for that repository will be prevented
130129
from committing secrets.
131130

132131
``--scan``
133132
Scans one or more files for secrets. When a file contains a secret, the
134133
matched text from the file being scanned will be written to stdout and the
135-
script will exit with a non-zero RC. Each matched line will be written with
134+
script will exit with a non-zero status. Each matched line will be written with
136135
the name of the file that matched, a colon, the line number that matched,
137136
a colon, and then the line of text that matched. If no files are provided,
138137
all files returned by ``git ls-files`` are scanned.
139138

140139
``--scan-history``
141140
Scans repository including all revisions. When a file contains a secret, the
142141
matched text from the file being scanned will be written to stdout and the
143-
script will exit with a non-zero RC. Each matched line will be written with
142+
script will exit with a non-zero status. Each matched line will be written with
144143
the name of the file that matched, a colon, the line number that matched,
145144
a colon, and then the line of text that matched.
146145

147146
``--list``
148-
Lists the git-secrets configuration for the current repo or in the global
147+
Lists the ``git-secrets`` configuration for the current repo or in the global
149148
git config.
150149

151150
``--add``
152151
Adds a prohibited or allowed pattern.
153152

154153
``--add-provider``
155154
Registers a secret provider. Secret providers are executables that when
156-
invoked outputs prohibited patterns that ``git-secrets`` should treat as
155+
invoked output prohibited patterns that ``git-secrets`` should treat as
157156
prohibited.
158157

159158
``--register-aws``
160159
Adds common AWS patterns to the git config and ensures that keys present
161160
in ``~/.aws/credentials`` are not found in any commit. The following
162161
checks are added:
163162

164-
- AWS Access Key ID via ``[A-Z0-9]{20}``
163+
- AWS Access Key IDs (strings matching ``[A-Z0-9]{20}``)
165164
- AWS Secret Access Key assignments via ":" or "=" surrounded by optional
166165
quotes
167166
- AWS account ID assignments via ":" or "=" surrounded by optional quotes
168167
- Allowed patterns for example AWS keys (``AKIAIOSFODNN7EXAMPLE`` and
169168
``wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY``)
170-
- Enables using ``~/.aws/credentials`` to scan for known credentials.
169+
- Known credentials from ``~/.aws/credentials``
171170

172171
.. note::
173172

@@ -179,7 +178,7 @@ Each of these options must appear first on the command line.
179178

180179
``--aws-provider``
181180
Secret provider that outputs credentials found in an INI file. You can
182-
optionally provide the path to an ini file.
181+
optionally provide the path to an INI file.
183182

184183

185184
Options for ``--install``
@@ -192,17 +191,17 @@ Options for ``--install``
192191
When provided, installs git hooks to the given directory. The current
193192
directory is assumed if ``<target-directory>`` is not provided.
194193

195-
If the provided ``<target-directory>`` is not in a Git repository, the
194+
If the provided ``<target-directory>`` is not in a git repository, the
196195
directory will be created and hooks will be placed in
197-
``<target-directory>/hooks``. This can be useful for creating Git template
196+
``<target-directory>/hooks``. This can be useful for creating git template
198197
directories using with ``git init --template <target-directory>``.
199198

200199
You can run ``git init`` on a repository that has already been initialized.
201200
From the `git init documentation <https://git-scm.com/docs/git-init>`_:
202201

203-
From the git documentation: Running git init in an existing repository
202+
From the git documentation: Running ``git init`` in an existing repository
204203
is safe. It will not overwrite things that are already there. The
205-
primary reason for rerunning git init is to pick up newly added
204+
primary reason for rerunning ``git init`` is to pick up newly added
206205
templates (or to move the repository to another place if
207206
``--separate-git-dir`` is given).
208207

@@ -219,7 +218,7 @@ Options for ``--install``
219218
.. note::
220219

221220
Git only allows a single script to be executed per hook. If the
222-
repository contains Debian style subdirectories like ``pre-commit.d``
221+
repository contains Debian-style subdirectories like ``pre-commit.d``
223222
and ``commit-msg.d``, then the git hooks will be installed into these
224223
directories, which assumes that you've configured the corresponding
225224
hooks to execute all of the scripts found in these directories. If
@@ -265,7 +264,7 @@ Options for ``--scan``
265264
Searches blobs registered in the index file.
266265

267266
``--no-index``
268-
Searches files in the current directory that is not managed by Git.
267+
Searches files in the current directory that is not managed by git.
269268

270269
``--untracked``
271270
In addition to searching in the tracked files in the working tree,
@@ -393,18 +392,18 @@ Cats secrets out of a file::
393392
Defining prohibited patterns
394393
----------------------------
395394

396-
egrep compatible regular expressions are used to determine if a commit or
395+
``egrep``-compatible regular expressions are used to determine if a commit or
397396
commit message contains any prohibited patterns. These regular expressions are
398397
defined using the ``git config`` command. It is important to note that
399398
different systems use different versions of egrep. For example, when running on
400-
OS X, you will use a different version of egrep than when running on something
399+
macOS, you will use a different version of ``egrep`` than when running on something
401400
like Ubuntu (BSD vs GNU).
402401

403402
You can add prohibited regular expression patterns to your git config using
404403
``git secrets --add <pattern>``.
405404

406405

407-
Ignoring false-positives
406+
Ignoring false positives
408407
------------------------
409408

410409
Sometimes a regular expression might match false positives. For example, git
@@ -415,13 +414,13 @@ regular expression patterns as false positives using the following command:
415414

416415
git secrets --add --allowed 'my regex pattern'
417416

418-
You can also add regular expressions patterns to filter false positives to a
419-
.gitallowed file located in the repository's root directory. Lines starting
420-
with # are skipped (comment line) and empty lines are also skipped.
417+
You can also add regular expressions patterns to filter false positives to a
418+
``.gitallowed`` file located in the repository's root directory. Lines starting
419+
with ``#`` are skipped (comment line) and empty lines are also skipped.
421420

422421
First, git-secrets will extract all lines from a file that contain a prohibited
423422
match. Included in the matched results will be the full path to the name of
424-
the file that was matched, followed ':', followed by the line number that was
423+
the file that was matched, followed by ':', followed by the line number that was
425424
matched, followed by the entire line from the file that was matched by a secret
426425
pattern. Then, if you've defined allowed regular expressions, git-secrets will
427426
check to see if all of the matched lines match at least one of your registered
@@ -509,7 +508,7 @@ like::
509508
git secrets --scan /tmp/example && echo $?
510509
# Outputs: 0
511510

512-
Alternatively, you could whitelist a specific line number of a file if that
511+
Alternatively, you could allow a specific line number of a file if that
513512
line is unlikely to change using something like the following:
514513

515514
::
@@ -526,15 +525,15 @@ included in the subject text that allowed patterns are matched against.
526525
Skipping validation
527526
-------------------
528527

529-
Use the ``--no-verify`` option in the event of a false-positive match in a
528+
Use the ``--no-verify`` option in the event of a false positive match in a
530529
commit, merge, or commit message. This will skip the execution of the
531530
git hook and allow you to make the commit or merge.
532531

533532

534533
About
535534
------
536535

537-
- Author: Michael Dowling <https://github.com/mtdowling>
536+
- Author: `Michael Dowling <https://github.com/mtdowling>`_
538537
- Issue tracker: This project's source code and issue tracker can be found at
539538
`https://github.com/awslabs/git-secrets <https://github.com/awslabs/git-secrets>`_
540539
- Special thanks to Adrian Vatchinsky and Ari Juels of Cornell University for

0 commit comments

Comments
 (0)