bin/generate-atomic-docs.rb
#
# Generates a master Markdown index of ATT&CK Tactic -> Technique -> Atomic Tests
#
Generates a master Markdown index of ATT&CK Tactic -> Technique -> Atomic Tests
Generates a master Markdown index of ATT&CK Tactic - > Technique - > Atomic Tests
def generate_index!(title_prefix, output_doc_path, only_platform: /.*/)
    result = ''
    result += "# #{title_prefix} Atomic Tests by ATT&CK Tactic & Technique\n"
    ATTACK_API.techniques_by_tactic(only_platform: only_platform).each do |tactic, techniques|
      result += "# #{tactic}\n"
      techniques.each do |technique|
        result += "- #{ATOMIC_RED_TEAM.github_link_to_technique(technique, include_identifier: true, only_platform: only_platform)}\n"
        ATOMIC_RED_TEAM.atomic_tests_for_technique(technique).each_with_index do |atomic_test, i|
          next unless atomic_test['supported_platforms'].any? {|platform| platform.downcase =~ only_platform}
          result += "  - Atomic Test ##{i+1}: #{atomic_test['name']} [#{atomic_test['supported_platforms'].join(', ')}]\n"
        end
      end
      result += "\n"
    end
    File.write output_doc_path, result
    puts "Generated Atomic Red Team index at #{output_doc_path}"
  end
def generate_index! ( title_prefix , output_doc_path , only_platform : / .* / ) result = '' result += "# #{title_prefix} Atomic Tests by ATT&CK Tactic & Technique\n" ATTACK_API . techniques_by_tactic ( only_platform : only_platform ) . each do | tactic , techniques | result += "# #{tactic}\n" techniques . each do | technique | result += "- #{ATOMIC_RED_TEAM.github_link_to_technique(technique, include_identifier: true, only_platform: only_platform)}\n" ATOMIC_RED_TEAM . atomic_tests_for_technique ( technique ) . each_with_index do | atomic_test , i | next unless atomic_test [ 'supported_platforms' ] . any? { | platform | platform . downcase =~ only_platform } result += "  - Atomic Test ##{i+1}: #{atomic_test['name']} [#{atomic_test['supported_platforms'].join(', ')}]\n" end end result += "\n" end File . write output_doc_path , result puts "Generated Atomic Red Team index at #{output_doc_path}" end
Generates a master Markdown index of ATT&CK Tactic -> Technique -> Atomic Tests
Generates a master Markdown index of ATT&CK Tactic - > Technique - > Atomic Tests
title_prefix
output_doc_path
only_platform