Skip to content

Commit c025546

Browse files
authored
plugin: Enable plugin keyless verification by default (#2453)
* Bump github.com/google/go-github to v81 * plugin: Enable plugin keyless verification by default
1 parent 26e8e15 commit c025546

File tree

14 files changed

+164
-281
lines changed

14 files changed

+164
-281
lines changed

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,6 @@ plugin "foo" {
107107
enabled = true
108108
version = "0.1.0"
109109
source = "github.com/org/tflint-ruleset-foo"
110-
111-
signing_key = <<-KEY
112-
-----BEGIN PGP PUBLIC KEY BLOCK-----
113-
114-
mQINBFzpPOMBEADOat4P4z0jvXaYdhfy+UcGivb2XYgGSPQycTgeW1YuGLYdfrwz
115-
9okJj9pMMWgt/HpW8WrJOLv7fGecFT3eIVGDOzyT8j2GIRJdXjv8ZbZIn1Q+1V72
116-
AkqlyThflWOZf8GFrOw+UAR1OASzR00EDxC9BqWtW5YZYfwFUQnmhxU+9Cd92e6i
117-
...
118-
KEY
119110
}
120111
```
121112

cmd/init.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ import (
1212
)
1313

1414
func (cli *CLI) init(opts Options) int {
15-
if plugin.IsExperimentalModeEnabled() {
16-
_, _ = color.New(color.FgYellow).Fprintln(cli.outStream, `Experimental mode is enabled. This behavior may change in future versions without notice`)
17-
}
18-
1915
workingDirs, err := findWorkingDirs(opts)
2016
if err != nil {
2117
cli.formatter.Print(tflint.Issues{}, fmt.Errorf("Failed to find workspaces; %w", err), map[string][]byte{})
@@ -53,7 +49,10 @@ func (cli *CLI) init(opts Options) int {
5349
_, err = installCfg.Install()
5450
if err != nil {
5551
if errors.Is(err, plugin.ErrPluginNotVerified) {
56-
_, _ = color.New(color.FgYellow).Fprintln(cli.outStream, `No signing key configured. Set "signing_key" to verify that the release is signed by the plugin developer`)
52+
_, _ = color.New(color.FgYellow).Fprintln(cli.outStream, `No signing key or attestations found. The plugin signature is not verified`)
53+
err = nil
54+
} else if errors.Is(err, plugin.ErrLegacySigningKeyUsed) {
55+
_, _ = color.New(color.FgYellow).Fprintln(cli.outStream, `The plugin was signed using a legacy PGP signing key. Please update the plugin to the latest version`)
5756
err = nil
5857
} else {
5958
return fmt.Errorf("Failed to install a plugin; %w", err)

docs/developer-guide/plugins.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ The requirements to support automatic installation are as follows:
5555

5656
When signing a release, one of the following requirements must be met:
5757

58+
- [Artifact Attestation](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds)
59+
- Include a step in your GitHub Actions workflow that uses the [`attest-build-provenance` action](https://github.com/actions/attest-build-provenance) for `checksums.txt`.
5860
- PGP signing key
5961
- The release must contain a signature file for the checksum file with the name `checksums.txt.sig`
6062
- The signature file must be binary OpenPGP format
61-
- [Artifact Attestation](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds)
62-
- Include a step in your GitHub Actions workflow that uses the [`attest-build-provenance` action](https://github.com/actions/attest-build-provenance) for `checksums.txt`.
6363

6464
Releases that meet these requirements can be easily created by following the GoReleaser config in the template repository.

docs/user-guide/environment_variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Below is a list of environment variables available in TFLint.
1313
- `GITHUB_TOKEN`
1414
- (Optional) Used for authenticated GitHub API requests when checking for updates and downloading plugins. Increases the rate limit from 60 to 5000 requests per hour. Useful if you encounter rate limit errors. You can obtain a token by creating a [GitHub personal access token](https://github.com/settings/tokens); no special scopes are required.
1515
- `TFLINT_EXPERIMENTAL`
16-
- Enable experimental features. Note that experimental features are subject to change without notice. Currently only [Keyless Verification](./plugins.md#keyless-verification-experimental) are supported.
16+
- Enable experimental features. Note that experimental features are subject to change without notice. Currently there is no impact.
1717
- `TF_VAR_name`
1818
- Set variables for compatibility with Terraform. See [Compatibility with Terraform](./compatibility.md).
1919
- `TF_DATA_DIR`

docs/user-guide/plugins.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ plugin "foo" {
77
enabled = true
88
version = "0.1.0"
99
source = "github.com/org/tflint-ruleset-foo"
10-
11-
signing_key = <<-KEY
12-
-----BEGIN PGP PUBLIC KEY BLOCK-----
13-
14-
mQINBFzpPOMBEADOat4P4z0jvXaYdhfy+UcGivb2XYgGSPQycTgeW1YuGLYdfrwz
15-
9okJj9pMMWgt/HpW8WrJOLv7fGecFT3eIVGDOzyT8j2GIRJdXjv8ZbZIn1Q+1V72
16-
AkqlyThflWOZf8GFrOw+UAR1OASzR00EDxC9BqWtW5YZYfwFUQnmhxU+9Cd92e6i
17-
...
18-
KEY
1910
}
2011
```
2112

@@ -50,11 +41,11 @@ Plugin version. Do not prefix with "v". This attribute cannot be omitted when th
5041

5142
### `signing_key`
5243

53-
Plugin developer's PGP public signing key. When this attribute is set, TFLint will automatically verify the signature of the checksum file downloaded from GitHub. It is recommended to set it to prevent supply chain attacks.
44+
Plugins are verified by default with [Artifact Attestations](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds) when available. If no attestations are found, TFLint falls back to PGP signature verification using the `signing_key`.
5445

55-
Plugins under the terraform-linters organization (AWS/GCP/Azure ruleset plugins) can use the built-in signing key, so this attribute can be omitted.
46+
If the plugin developer distributes a PGP public key, setting the `signing_key` will ensure that the signature of the checksum file downloaded from GitHub is signed by the key.
5647

57-
If the plugin developer generates [Artifact Attestation](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds), you can omit this attribute. See [Keyless Verification](#keyless-verification-experimental) for details.
48+
NOTE: Artifact Attestations will not be verified if the `source` is a private repository. If you want to verify signatures in a private repository, you must set the `signing_key`.
5849

5950
## Plugin directory
6051

@@ -136,11 +127,3 @@ plugin "terraform" {
136127
```
137128

138129
If you have tflint-ruleset-terraform manually installed, the bundled plugin will not be automatically enabled. In this case the manually installed version takes precedence.
139-
140-
## Keyless verification (experimental)
141-
142-
If the plugin developer has generated [Artifact Attestations](https://docs.github.com/en/actions/security-for-github-actions/using-artifact-attestations/using-artifact-attestations-to-establish-provenance-for-builds), TFLint will automatically verify them and prove that the plugin binary was built in that repository.
143-
144-
This verification is experimental and optional: it is only attempted if there is no PGP public signing key, and if there is no artifact attestation, a warning will be output, not an error. If you want to require all plugin installs to be signed with a PGP signing key or an artifact attestation, you can force this behavior to be enabled by setting the `TFLINT_EXPERIMENTAL=1`. This behavior will be the default in future versions, but is subject to change without notice.
145-
146-
Note that this validation, like the PGP signing key, does not guarantee that the plugin is secure. It only attests the source repository/revision from which it was built. It prevents direct upload of malicious release artifacts to GitHub or manipulation of download requests. If an attacker has control over the repository and can perform execution during a build, any resulting malicious release will still be considered "verified."

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/fatih/color v1.18.0
1010
github.com/go-test/deep v1.1.1
1111
github.com/google/go-cmp v0.7.0
12-
github.com/google/go-github/v67 v67.0.0
12+
github.com/google/go-github/v81 v81.0.0
1313
github.com/google/uuid v1.6.0
1414
github.com/hashicorp/go-plugin v1.7.0
1515
github.com/hashicorp/go-uuid v1.0.3

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
229229
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
230230
github.com/google/go-containerregistry v0.20.7 h1:24VGNpS0IwrOZ2ms2P1QE3Xa5X9p4phx0aUgzYzHW6I=
231231
github.com/google/go-containerregistry v0.20.7/go.mod h1:Lx5LCZQjLH1QBaMPeGwsME9biPeo1lPx6lbGj/UmzgM=
232-
github.com/google/go-github/v67 v67.0.0 h1:g11NDAmfaBaCO8qYdI9fsmbaRipHNWRIU/2YGvlh4rg=
233-
github.com/google/go-github/v67 v67.0.0/go.mod h1:zH3K7BxjFndr9QSeFibx4lTKkYS3K9nDanoI1NjaOtY=
232+
github.com/google/go-github/v81 v81.0.0 h1:hTLugQRxSLD1Yei18fk4A5eYjOGLUBKAl/VCqOfFkZc=
233+
github.com/google/go-github/v81 v81.0.0/go.mod h1:upyjaybucIbBIuxgJS7YLOZGziyvvJ92WX6WEBNE3sM=
234234
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
235235
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
236236
github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9Fc=

0 commit comments

Comments
 (0)