Debian Codegraph @

CONTRIBUTING.md

raw
1 # How to Contribute to fscrypt
2
3 We'd love to accept your patches and contributions to this project. There are
4 just a few small guidelines we ask you to follow.
5
6 ## Contributor License Agreement
7
8 Contributions to this project must be accompanied by a Contributor License
9 Agreement. You (or your employer) retain the copyright to your contribution,
10 this simply gives us permission to use and redistribute your contributions as
11 part of the project. Head over to <https://cla.developers.google.com/> to see
12 your current agreements on file or to sign a new one.
13
14 You generally only need to submit a CLA once, so if you've already submitted one
15 (even if it was for a different project), you probably don't need to do it
16 again.
17
18 ## Reporting an Issue, Discussing Design, or Asking a Question
19
20 __IMPORTANT__: Any significant security issues should __NOT__ be reported in
21 the public issue tracker. Practice responsible disclosure by emailing
22 <[email protected]> and <[email protected]> directly.
23
24 Any bugs, problems, or design discussion relating to fscrypt should be raised
25 in the [Github Issue Tracker](https://github.com/google/fscrypt/issues/new).
26
27 When reporting an issue or problem, be sure to give as much information as
28 possible. Also, make sure you are running the `fscrypt` and `pam_fscrypt.so`
29 built from the current `master` branch.
30
31 If reporting an issue around the fscrypt command-line tool, post the
32 relevant output from fscrypt, running with the `--verbose` flag. For the
33 `pam_fscrypt` module, use the `debug` option with the module and post the
34 relevant parts of the syslog (usually at `/var/log/syslog`).
35
36 Be sure to correctly tag your issue. The usage for the tags is as follows:
37 * `bug` - General problems with the program's behavior
38 * The program crashes or hangs
39 * Directories cannot be locked/unlocked
40 * Metadata corruption
41 * Data loss/corruption
42 * `documentation`
43 * Typos or unclear explanations in `README.md` or man pages.
44 * Outdated example output
45 * Unclear or ambiguous error messages
46 * `enhancement` - Things you want in fscrypt
47 * `question` - You don't know how something works with fscrypt
48 * This usually turns into a `documentation` issue.
49 * `testing` - Strange test failures or missing tests
50
51 ## Submitting a Change to fscrypt
52
53 All submissions, including submissions by project members, require review. We
54 use GitHub pull requests for this purpose. Consult
55 [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
56 information on using pull requests.
57
58 On every pull request, [GitHub
59 Actions](https://github.com/google/fscrypt/actions) runs tests, code formatters,
60 and linters. To pass these checks you should make sure that in your submission:
61 - `make` properly builds `fscrypt` and `pam_fscrypt.so`.
62 - All tests, including [integration tests](#running-integration-tests) and
63 [command-line interface (CLI)
64 tests](https://github.com/google/fscrypt/blob/master/cli-tests/README.md),
65 should pass. If the CLI tests fail due to an expected change in output, you
66 can use `make cli-test-update`.
67 - `make format` has been run.
68 - If you made any changes to files ending in `.proto`, the corresponding
69 `.pb.go` files should be regenerated with `make gen`.
70 - Any issues found by `make lint` have been addressed.
71 - If any dependencies have changed, run `go mod tidy`.
72 - `make coverage.out` can be used to generate a coverage report for all of the
73 tests, but isn't required for submission
74 (ideally most code would be tested, we are far from that ideal).
75
76 Essentially, if you run:
77 ```
78 make test-setup
79 make all
80 make test-teardown
81 make cli-test
82 go mod tidy
83 ```
84 and everything succeeds, and no files are changed, you're good to submit.
85
86 The `Makefile` will automatically download and build any needed Go dependencies.
87 However, you'll also need to install some non-Go dependencies:
88 - `make format` requires
89 [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html).
90 - `make lint` requires [`shellcheck`](https://github.com/koalaman/shellcheck).
91 - `make test-setup` and `make cli-test` require
92 [`e2fsprogs`](https://en.wikipedia.org/wiki/E2fsprogs) version 1.43 or
93 later.
94 - `make cli-test` requires [`expect`](https://en.wikipedia.org/wiki/Expect)
95 and
96 [`keyutils`](https://manpages.debian.org/testing/keyutils/keyctl.1.en.html).
97
98 On Ubuntu, the following command installs the needed packages:
99 ```
100 sudo apt-get install clang-format shellcheck e2fsprogs expect keyutils
101 ```
102
103 ### Running Integration Tests
104
105 Running `make test` will build each package and run the unit tests, but will
106 skip the integration tests. To run the integration tests, you will need a
107 filesystem that supports encryption. If you already have some empty filesystem
108 at `/foo/bar` that supports filesystem encryption, just run:
109 ```bash
110 make test MOUNT=/foo/bar
111 ```
112
113 Otherwise, you can use the `make test-setup`/`make test-teardown` commands to
114 create/destroy a test filesystem for running integration tests. By default, a
115 filesystem will be created (then destroyed) at `/tmp/fscrypt-mount` (using an
116 image file at `/tmp/fscrypt-image`). To create/test/destroy a filesystem at a
117 custom mountpoint `/foo/bar`, run:
118 ```bash
119 make test-setup MOUNT=/foo/bar
120 make test MOUNT=/foo/bar
121 make test-teardown MOUNT=/foo/bar
122 ```
123 Running the commands without `MOUNT=/foo/bar` uses the default locations.
124
125 Note that the setup/teardown commands require `sudo` to mount/unmount the
126 test filesystem.
127
128 ### Changing dependencies
129
130 fscrypt's dependencies are managed using the
131 [Go module system](https://github.com/golang/go/wiki/Modules).
132 If you add or remove a dependency, be sure to update `go.mod` and `go.sum`.
133
134 Also, when adding a dependency, the license of the package must be compatible
135 with [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0). See the
136 [FSF's article](https://www.gnu.org/licenses/license-list.html) for more
137 information. This (unfortunately) means we cannot use external packages under
138 the [GPL](https://choosealicense.com/licenses/gpl-3.0) or
139 [LGPL](https://choosealicense.com/licenses/lgpl-3.0/). We also cannot use
140 packages with missing, misleading, or joke licenses (e.g.
141 [Unlicense](http://unlicense.org/), [WTFPL](http://www.wtfpl.net/),
142 [CC0](https://creativecommons.org/publicdomain/zero/1.0/)).
143
144 ### Build System Details ###
145
146 Under the hood, the Makefile uses many go tools to generate, format, and lint
147 your code.
148
149 `make gen`:
150 - Downloads [`protoc`](https://github.com/google/protobuf) to compile the
151 `.proto` files.
152 - Turns each `.proto` file into a matching `.pb.go` file using
153 [`protoc-gen-go`](https://go.googlesource.com/protobuf/+/refs/heads/master/cmd/protoc-gen-go).
154
155 `make format` runs:
156 - [`goimports`](https://godoc.org/golang.org/x/tools/cmd/goimports)
157 on the `.go` files.
158 - [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html)
159 on the `.c` and `.h` files.
160
161 `make lint` runs:
162 - [`go vet`](https://golang.org/cmd/vet/)
163 - [`staticcheck`](https://github.com/dominikh/go-tools/tree/master/cmd/staticcheck)