Skip to content

Commit 1b256bb

Browse files
committed
Add module_verification_nonregistry_source rule
1 parent af940dc commit 1b256bb

12 files changed

+454
-404
lines changed

docs/rules/module_verification_local_source.md renamed to docs/rules/module_verification_nonregistry_source.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# module_verification_local_source
1+
# module_verification_nonregistry_source
22

3-
Explicitly allow locally sourced module.
3+
Explicitly allows non Terraform Registry modules.
44

55
## Configuration
66

@@ -9,7 +9,7 @@ Name | Description | Default | Type
99
allowed_modules | List of allowed modules prefix | [] | List of string
1010

1111
```hcl
12-
rule "module_verification_local_source" {
12+
rule "module_verification_nonregistry_source" {
1313
enabled = true
1414
allowed_modules = [] # default
1515
}
@@ -19,14 +19,14 @@ rule "module_verification_local_source" {
1919

2020
```
2121
tflint
22-
1 issue(s) found:
22+
2 issue(s) found:
2323
24-
Error: module "local_fail" should not use local source (module_verification_local_source)
24+
Error: module "local_fail" source is not on the allowed modules list (module_verification_nonregistry_source)
2525
2626
on main.tf line 1:
2727
1: module "local_fail" {
2828
29-
Reference: https://github.com/ringanta/tflint-ruleset-module-verification/blob/v0.1.0/docs/rules/module_verification_local_source.md
29+
Reference: https://github.com/ringanta/tflint-ruleset-module-verification/blob/v0.1.0/docs/rules/module_verification_nonregistry_source.md
3030
```
3131

3232
## Why
@@ -37,7 +37,7 @@ Module is external code that needs to be vet before being used. Explicitly allow
3737

3838
Use the following TFLint config to explicitly allow module from local source
3939
```
40-
rule "module_signature_local_source" {
40+
rule "module_verification_nonregistry_source" {
4141
enabled = true
4242
4343
allowed_modules = [

examples/local-source/main.tf

-7
This file was deleted.

examples/local-source/.tflint.hcl renamed to examples/nonregistry-source/.tflint.hcl

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ plugin "module-verification" {
66
enabled = true
77
}
88

9-
rule "module_verification_local_source" {
9+
rule "module_verification_nonregistry_source" {
1010
enabled = true
1111

1212
// List of allowed module prefix
1313
allowed_modules = [
14-
"../../terraform-modules"
14+
"../../terraform-modules",
15+
"github.com/example/",
16+
"[email protected]:example/"
1517
]
1618
}

examples/local-source/README.md renamed to examples/nonregistry-source/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Local Source Example
1+
# Non Registry Source Example
22

3-
An example of verifying local module usage
3+
An example of verifying module usage that comes from outside Terraform Registry.
44

55
## Requirement
66

examples/nonregistry-source/main.tf

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module "local_fail" {
2+
source = "../.."
3+
}
4+
5+
module "local_success" {
6+
source = "../../terraform-modules"
7+
}
8+
9+
module "github_fail" {
10+
source = "[email protected]:untrusted/example-module"
11+
}
12+
13+
module "github_success" {
14+
source = "[email protected]:example/example-module"
15+
}

go.mod

+1-22
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,34 @@ module github.com/ringanta/tflint-ruleset-module-verification
33
go 1.19
44

55
require (
6-
github.com/hashicorp/go-getter v1.6.2
76
github.com/hashicorp/go-version v1.6.0
87
github.com/hashicorp/hcl/v2 v2.15.0
98
github.com/hashicorp/terraform-registry-address v0.1.0
109
github.com/terraform-linters/tflint-plugin-sdk v0.15.0
1110
)
1211

1312
require (
14-
cloud.google.com/go v0.105.0 // indirect
15-
cloud.google.com/go/compute v1.14.0 // indirect
16-
cloud.google.com/go/compute/metadata v0.2.3 // indirect
17-
cloud.google.com/go/iam v0.8.0 // indirect
18-
cloud.google.com/go/storage v1.28.1 // indirect
1913
github.com/agext/levenshtein v1.2.1 // indirect
2014
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
21-
github.com/aws/aws-sdk-go v1.15.78 // indirect
22-
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
2315
github.com/fatih/color v1.13.0 // indirect
24-
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
2516
github.com/golang/protobuf v1.5.2 // indirect
2617
github.com/google/go-cmp v0.5.9 // indirect
27-
github.com/google/uuid v1.3.0 // indirect
28-
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
29-
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
30-
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
3118
github.com/hashicorp/go-hclog v1.4.0 // indirect
3219
github.com/hashicorp/go-plugin v1.4.8 // indirect
33-
github.com/hashicorp/go-safetemp v1.0.0 // indirect
3420
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
3521
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
36-
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8 // indirect
37-
github.com/klauspost/compress v1.11.2 // indirect
3822
github.com/mattn/go-colorable v0.1.12 // indirect
3923
github.com/mattn/go-isatty v0.0.14 // indirect
40-
github.com/mitchellh/go-homedir v1.0.0 // indirect
4124
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
4225
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
4326
github.com/oklog/run v1.0.0 // indirect
44-
github.com/ulikunitz/xz v0.5.8 // indirect
27+
github.com/stretchr/testify v1.8.1 // indirect
4528
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
4629
github.com/vmihailenco/tagparser v0.1.1 // indirect
4730
github.com/zclconf/go-cty v1.12.1 // indirect
48-
go.opencensus.io v0.24.0 // indirect
4931
golang.org/x/net v0.4.0 // indirect
50-
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect
5132
golang.org/x/sys v0.3.0 // indirect
5233
golang.org/x/text v0.5.0 // indirect
53-
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
54-
google.golang.org/api v0.103.0 // indirect
5534
google.golang.org/appengine v1.6.7 // indirect
5635
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
5736
google.golang.org/grpc v1.51.0 // indirect

0 commit comments

Comments
 (0)