<commit_before>class Tfsec < Formula
  desc "Static analysis security scanner for your terraform code"
  homepage "https://tfsec.dev/"
  url "https://github.com/aquasecurity/tfsec/archive/v0.48.6.tar.gz"
  sha256 "4bda9220391440bd465005d9bcdfc175ed915da0ef1ca2b78790f340aa34968d"
  license "MIT"
  head "https://github.com/aquasecurity/tfsec.git"

  livecheck do
    url :stable
    strategy :github_latest
  end

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "6a1a80703555d1a0dfade9389c955562a01facf8989e509e16c51c87986e671f"
    sha256 cellar: :any_skip_relocation, big_sur:       "ec9f588b41f24d852d7f58c05572382c2dbfa9bf26fb5a4c4c33647901b37b80"
    sha256 cellar: :any_skip_relocation, catalina:      "b9d33d3f9a198e5246603cc8209bf94c4c3a8cdfc6b0430b50a5df1efd30c190"
    sha256 cellar: :any_skip_relocation, mojave:        "bd4ba351be49a349341d7b848c938a852313e06b0976505457b49dd6dc121b2f"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "05db0756e77c200bb2d68cc7547568671cac69a6fee56f740fdd0f279edbffde"
  end

  depends_on "go" => :build

  def install
    system "scripts/install.sh", "v#{version}"
    bin.install "tfsec"
  end

  test do
    (testpath/"good/brew-validate.tf").write <<~EOS
      resource "aws_alb_listener" "my-alb-listener" {
        port     = "443"
        protocol = "HTTPS"
      }
    EOS
    (testpath/"bad/brew-validate.tf").write <<~EOS
      resource "aws_security_group_rule" "world" {
        description = "A security group triggering tfsec AWS006."
        type        = "ingress"
        cidr_blocks = ["0.0.0.0/0"]
      }
    EOS

    good_output = shell_output("#{bin}/tfsec #{testpath}/good")
    assert_match "No problems detected!", good_output
    bad_output = shell_output("#{bin}/tfsec #{testpath}/bad 2>&1", 1)<commit_msg>tfsec: update 0.48.6 bottle.<commit_after>class Tfsec < Formula
  desc "Static analysis security scanner for your terraform code"
  homepage "https://tfsec.dev/"
  url "https://github.com/aquasecurity/tfsec/archive/v0.48.6.tar.gz"
  sha256 "4bda9220391440bd465005d9bcdfc175ed915da0ef1ca2b78790f340aa34968d"
  license "MIT"
  head "https://github.com/aquasecurity/tfsec.git"

  livecheck do
    url :stable
    strategy :github_latest
  end

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "fe80ed11b5fb424d0431796b38a6761e2e9fe66d7fd077df37ecca3d768d5993"
    sha256 cellar: :any_skip_relocation, big_sur:       "d173229bf340b1c189bcc3ad0162f485b0726bb2e4bfd3c1ec4de06b6985eef0"
    sha256 cellar: :any_skip_relocation, catalina:      "aeb30c14de511996a7a993a1062bccbfe183970bf91f65aceaead8ff0cda7773"
    sha256 cellar: :any_skip_relocation, mojave:        "7e733de57f0b6e9dbb132c558dd82ee2ff8473497ae1dae94f0b58100d7b2599"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "3e6fba16fff69400a470d7d6cfc52de79ce806d4a4f034dbf6cbc161ef1afc22"
  end

  depends_on "go" => :build

  def install
    system "scripts/install.sh", "v#{version}"
    bin.install "tfsec"
  end

  test do
    (testpath/"good/brew-validate.tf").write <<~EOS
      resource "aws_alb_listener" "my-alb-listener" {
        port     = "443"
        protocol = "HTTPS"
      }
    EOS
    (testpath/"bad/brew-validate.tf").write <<~EOS
      resource "aws_security_group_rule" "world" {
        description = "A security group triggering tfsec AWS006."
        type        = "ingress"
        cidr_blocks = ["0.0.0.0/0"]
      }
    EOS

    good_output = shell_output("#{bin}/tfsec #{testpath}/good")
    assert_match "No problems detected!", good_output
    bad_output = shell_output("#{bin}/tfsec #{testpath}/bad 2>&1", 1)
{'fraction_non_alphanumeric': 0.10206896551724139, 'fraction_numerical': 0.1522758620689655, 'mean_word_length': 4.001379310344827, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3048522', 'n_tokens_mistral': 1738, 'n_tokens_neox': 1459, 'n_words': 222}