reject-escalated-privileges-yaml/reject-escalated-privileges-yaml.rb
# The below code recurse through each of hash and array and pattern match if
# any of the string is present in any of the key or value field.
The below code recurse through each of hash and array and pattern match if
any of the string is present in any of the key or value field.
The below code recurse through each of hash and array and pattern match if any of the string is present in any of the key or value field .
def main(gh)
  pattern = Regexp.union(STRING_LIST)
  yaml_files_in_pr(gh).find_all { |file|
    if FileTest.exists?(file)
      hash = YAML.load_file(file)
      recurse(hash, pattern) do |path, value|
        line = "#{path}:\t#{value}"
        if pattern.match?(line)
          message = <<~EOF
            The YAML file below
            #{file}
            contain the code 
            #{line}
            which will grant the user escalated privileges.
            Please correct them and resubmit this PR.
          EOF
          gh.reject_pr(message)
          exit 1
        end
      end
    end
  }
end
def main ( gh ) pattern = Regexp . union ( STRING_LIST ) yaml_files_in_pr ( gh ) . find_all { | file | if FileTest . exists? ( file ) hash = YAML . load_file ( file ) recurse ( hash , pattern ) do | path , value | line = "#{path}:\t#{value}" if pattern . match? ( line ) message = <<~EOF 
            The YAML file below
            
             #{ file } 
            
            contain the code 

             #{ line } 

            which will grant the user escalated privileges.

            Please correct them and resubmit this PR.

           EOF gh . reject_pr ( message ) exit 1 end end end } end
The below code recurse through each of hash and array and pattern match if
any of the string is present in any of the key or value field.
The below code recurse through each of hash and array and pattern match if any of the string is present in any of the key or value field .
gh