Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tfprovidercheck 1.0.2 (new formula) #206085

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/autobump.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3230,6 +3230,7 @@ tf-profile
tfautomv
tfel
tfmigrate
tfprovidercheck
tfproviderlint
tfschema
tfsec
Expand Down
49 changes: 49 additions & 0 deletions Formula/t/tfprovidercheck.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
class Tfprovidercheck < Formula
desc "CLI to prevent malicious Terraform Providers from being executed"
homepage "https://github.com/suzuki-shunsuke/tfprovidercheck"
url "https://github.com/suzuki-shunsuke/tfprovidercheck/archive/refs/tags/v1.0.2.tar.gz"
sha256 "d6330db7e927dcd89281c2ff8b3545914489a5a09b59e73def8d6525ec8d9596"
license "MIT"
head "https://github.com/suzuki-shunsuke/tfprovidercheck.git", branch: "main"

depends_on "go" => :build
depends_on "opentofu" => :test

def install
system "go", "build", *std_go_args(ldflags: "-s -w -X main.version=#{version}"), "./cmd/tfprovidercheck"
end

test do
assert_match version.to_s, shell_output("#{bin}/tfprovidercheck -version")

(testpath/"test.tf").write <<~HCL
terraform {
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5"
}
}
}

provider "aws" {
region = var.aws_region
}
HCL

# Only google provider and azurerm provider are allowed
(testpath/".tfprovidercheck.yaml").write <<~YAML
providers:
- name: registry.terraform.io/hashicorp/google
version: ">= 4.0.0"
- name: registry.terraform.io/hashicorp/azurerm
YAML

system "tofu", "init"
json_output = shell_output("tofu version -json")
output = pipe_output("#{bin}/tfprovidercheck 2>&1", json_output, 1)
assert_match "Terraform Provider is disallowed", output
end
end
Loading