bin/generate-atomic-docs.rb
def generate_index_csv!(output_doc_path_by_tactic, only_platform: /.*/)
    rows = Array.new
    rows << ["Tactic", "Technique #", "Technique Name", "Test #", "Test Name", "Test GUID", "Executor Name"]

    ATTACK_API.techniques_by_tactic(only_platform: only_platform).each do |tactic, techniques|
      techniques.each do |technique|
        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}
          rows << [tactic, technique['identifier'], technique['name'], i+1, atomic_test['name'], atomic_test['auto_generated_guid'], atomic_test['executor']['name']]
        end
      end
    end

    File.write(output_doc_path_by_tactic, rows.map(&:to_csv).join)

    puts "Generated Atomic Red Team CSV indexes at #{output_doc_path_by_tactic}"
  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
Generates a master Markdown index of ATT&CK Tactic - > Technique - > Atomic Tests
def generate_index_csv!(output_doc_path_by_tactic, only_platform: /.*/)
    rows = Array.new
    rows << ["Tactic", "Technique #", "Technique Name", "Test #", "Test Name", "Test GUID", "Executor Name"]
    ATTACK_API.techniques_by_tactic(only_platform: only_platform).each do |tactic, techniques|
      techniques.each do |technique|
        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}
          rows << [tactic, technique['identifier'], technique['name'], i+1, atomic_test['name'], atomic_test['auto_generated_guid'], atomic_test['executor']['name']]
        end
      end
    end
    File.write(output_doc_path_by_tactic, rows.map(&:to_csv).join)
    puts "Generated Atomic Red Team CSV indexes at #{output_doc_path_by_tactic}"
  end
def generate_index_csv! ( output_doc_path_by_tactic , only_platform : / .* / ) rows = Array . new rows << [ "Tactic" , "Technique #" , "Technique Name" , "Test #" , "Test Name" , "Test GUID" , "Executor Name" ] ATTACK_API . techniques_by_tactic ( only_platform : only_platform ) . each do | tactic , techniques | techniques . each do | technique | 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 } rows << [ tactic , technique [ 'identifier' ] , technique [ 'name' ] , i + 1 , atomic_test [ 'name' ] , atomic_test [ 'auto_generated_guid' ] , atomic_test [ 'executor' ] [ 'name' ] ] end end end File . write ( output_doc_path_by_tactic , rows . map ( & :to_csv ) . join ) puts "Generated Atomic Red Team CSV indexes at #{output_doc_path_by_tactic}" 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
output_doc_path_by_tactic
only_platform