<commit_before>#
# Cookbook Name:: kafka
# Recipe:: _install
#

md5 = node['kafka']['md5_checksum']
sha256 = node['kafka']['checksum']

remote_file kafka_local_download_path do
  source kafka_download_uri(kafka_tar_gz)
  mode '644'
  checksum sha256 if sha256 && !sha256.empty?
  notifies :create, 'ruby_block[kafka-validate-download]', :immediately
  not_if { kafka_installed? }
end

ruby_block 'kafka-validate-download' do
  block do
    if md5 && !md5.empty?
      unless (checksum = Digest::MD5.file(local_file_path).hexdigest) == md5.downcase<commit_msg>Fixed local download path to verify with MD5. Solved security issue - the second chef run wouldn't check downloaded file vs MD5.<commit_after>#
# Cookbook Name:: kafka
# Recipe:: _install
#

md5 = node['kafka']['md5_checksum']
sha256 = node['kafka']['checksum']

remote_file kafka_local_download_path do
  source kafka_download_uri(kafka_tar_gz)
  mode '644'
  checksum sha256 if sha256 && !sha256.empty?
  notifies :create, 'ruby_block[kafka-validate-download]', :immediately
  not_if { kafka_installed? }
end

ruby_block 'kafka-validate-download' do
  block do
    if md5 && !md5.empty?
      unless (checksum = Digest::MD5.file(kafka_local_download_path).hexdigest) == md5.downcase
{'fraction_non_alphanumeric': 0.11906677393403058, 'fraction_numerical': 0.035398230088495575, 'mean_word_length': 5.37948717948718, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4359442', 'n_tokens_mistral': 470, 'n_tokens_neox': 437, 'n_words': 101}