-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_files_correct.rb
More file actions
40 lines (32 loc) · 2.15 KB
/
add_files_correct.rb
File metadata and controls
40 lines (32 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env ruby
require 'securerandom'
project_path = 'Bastion.xcodeproj/project.pbxproj'
content = File.read(project_path)
# Files with CORRECT paths (relative to project root with "Bastion/" prefix)
files = [
{ name: 'SMBModule.swift', path: 'Bastion/Security/ExploitModules/SMBModule.swift' },
{ name: 'DNSModule.swift', path: 'Bastion/Security/ExploitModules/DNSModule.swift' },
{ name: 'LDAPModule.swift', path: 'Bastion/Security/ExploitModules/LDAPModule.swift' },
{ name: 'LateralMovementMapper.swift', path: 'Bastion/Security/LateralMovementMapper.swift' },
{ name: 'VulnerabilityChainer.swift', path: 'Bastion/Security/VulnerabilityChainer.swift' },
{ name: 'MITREATTACKMapper.swift', path: 'Bastion/Security/MITREATTACKMapper.swift' },
{ name: 'RemediationScriptGenerator.swift', path: 'Bastion/Security/RemediationScriptGenerator.swift' },
{ name: 'ContinuousMonitor.swift', path: 'Bastion/Security/ContinuousMonitor.swift' },
{ name: 'AnomalyDetector.swift', path: 'Bastion/Security/AnomalyDetector.swift' },
{ name: 'TimelineReconstructor.swift', path: 'Bastion/Security/TimelineReconstructor.swift' }
]
files.each do |file|
file_ref_id = SecureRandom.uuid.gsub('-', '')[0..23].upcase
build_file_id = SecureRandom.uuid.gsub('-', '')[0..23].upcase
# Add PBXFileReference (look at existing format)
file_ref = "\t\t#{file_ref_id} /* #{file[:name]} */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = #{file[:path]}; sourceTree = \"<group>\"; };\n"
content.sub!(/\/\* End PBXFileReference section \*\//, file_ref + "\t\t/* End PBXFileReference section */")
# Add PBXBuildFile
build_file = "\t\t#{build_file_id} /* #{file[:name]} in Sources */ = {isa = PBXBuildFile; fileRef = #{file_ref_id} /* #{file[:name]} */; };\n"
content.sub!(/\/\* End PBXBuildFile section \*\//, build_file + "\t\t/* End PBXBuildFile section */")
# Add to Sources phase
content.sub!(/(\/\* Sources \*\/ = \{[^}]*files = \([^)]*)/m) { $1 + "\n\t\t\t\t#{build_file_id} /* #{file[:name]} in Sources */," }
puts "✓ #{file[:name]} - #{file_ref_id}"
end
File.write(project_path, content)
puts "\n✅ All files added with correct paths!"