<commit_before>module Scanny
  module Checks
    module InsecureMethod
      class SystemMethodCheck < Check
        def pattern
          [
            pattern_system_calls,
            pattern_execute_string
          ].join("|")
        end

        def check(node)
          issue :high, warning_message, :cwe => [88, 78]
        end

        private

        def warning_message
          "Execute system commands can lead the system to run dangerous code"
        end

        # system("rm -rf /")
        def pattern_system_calls
          <<-EOT
            SendWithArguments
              <name =
                :popen          |
                :system         |
                :spawn          |
                :exec
              >
          EOT
        end

        # `system_command`
        def pattern_execute_string
          "ExecuteString"
        end
      end
    end
  end
end<commit_msg>Recognize all methods that begin with a 'popen'<commit_after>module Scanny
  module Checks
    module InsecureMethod
      class SystemMethodCheck < Check
        def pattern
          [
            pattern_system_calls,
            pattern_execute_string,
            pattern_popen
          ].join("|")
        end

        def check(node)
          issue :high, warning_message, :cwe => [88, 78]
        end

        private

        def warning_message
          "Execute system commands can lead the system to run dangerous code"
        end

        # system("rm -rf /")
        def pattern_system_calls
          <<-EOT
            SendWithArguments
              <
                name =  :system         |
                        :spawn          |
                        :exec
              >
          EOT
        end

        def pattern_popen
          "SendWithArguments<name ^= :popen>"
        end

        # `system_command`
        def pattern_execute_string
          "ExecuteString"
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.05629477993858751, 'fraction_numerical': 0.0040941658137154556, 'mean_word_length': 1.1507150715071508, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '3746655', 'n_tokens_mistral': 506, 'n_tokens_neox': 484, 'n_words': 133}