Skip to content

Commit

Permalink
Security - remove all remaining mentions of ports and tokens in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
samaaron committed Jul 29, 2024
1 parent be19bfe commit 6a93b79
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 19 deletions.
4 changes: 2 additions & 2 deletions app/server/beam/tau/src/tau_server/tau_server_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ init(Parent, CueServer, MIDIServer, LinkServer) ->
"+--------------------------------------+~n"
" This is the Sonic Pi API Server ~n"
" Powered by Erlang ~s ~n"
" ~n"
" API listening on port ~p ~n"
% " ~n"
% " API listening on port ~p ~n"
"+--------------------------------------+~n~n~n",
[erlang:system_info(otp_release), APIPort]),

Expand Down
6 changes: 3 additions & 3 deletions app/server/beam/tau/src/tau_server/tau_server_cue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ init(Parent) ->
" == Tau == ~n"
" Powered by Erlang ~s ~n"
" ~n"
" Incoming OSC on port ~p ~n"
" OSC cue forwarding to ~p ~n"
" on port ~p ~n"
% " Incoming OSC on port ~p ~n"
% " OSC cue forwarding to ~p ~n"
% " on port ~p ~n"
"+--------------------------------------+~n~n~n",
[erlang:system_info(otp_release), OSCInUDPPort, CueHost, CuePort]),

Expand Down
26 changes: 18 additions & 8 deletions app/server/ruby/bin/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ def initialize(opts={})
# use a value within the valid range for a 32 bit signed complement integer
@daemon_token = rand(-2147483647..2147483647)

# Uncomment for debugging purposes
# Util.log "Daemon token: #{@daemon_token}"

@safe_exit = SafeExit.new do
@exit_prom.deliver! true
# Register exit routine
Expand Down Expand Up @@ -181,6 +184,9 @@ def initialize(opts={})
# if there are problems detecting port numbers to use.
@ports = PortDiscovery.new(@safe_exit).ports

# Uncomment for debugging purposes
# Util.log "Ports: #{@ports.inspect}"

@kill_switch = KillSwitch.new(@safe_exit)

@api_server = SonicPi::OSC::UDPServer.new(@ports["daemon"], suppress_errors: false, name: "Daemon API Server")
Expand Down Expand Up @@ -214,7 +220,7 @@ def initialize(opts={})
end

@api_server.add_method("/tau/pid") do |args|
Util.log "Daemon received Pid from Tau: #{args.inspect}"
Util.log "Daemon received Pid from Tau"
# Util.log "token: #{@daemon_token}"
if args[0] && args[0] == @daemon_token
@tau_booter.update_pid!(args[1])
Expand Down Expand Up @@ -784,8 +790,11 @@ def disable_internal_log_recording!
end

def boot
Util.log "Process Booter - booting #{@cmd} with args #{@args.inspect}"
Util.log "#{@cmd} #{@args.join(' ')}"
Util.log "Process Booter - booting #{@cmd}"

# Uncomment for debugging
# Util.log "Process Booter - booting #{@cmd} with args #{@args.inspect}"
# Util.log "#{@cmd} #{@args.join(' ')}"
if @env
@stdin, @stdout_and_err, @wait_thr = Open3.popen2e @env, @cmd, *@args
else
Expand Down Expand Up @@ -916,7 +925,7 @@ def initialize(ports, kill_switch, token)

@pid_updater_thread = Thread.new do
while !@tau_pid.delivered?
Util.log "Requesting tau send us its pid. Sending /send-pid-to-daemon, #{token} to localhost:#{ports['tau']}"
Util.log "Requesting tau send us its pid. Sending /send-pid-to-daemon"
begin
@pid_requester.send("/send-pid-to-daemon", token)
rescue Errno::ECONNREFUSED
Expand All @@ -942,7 +951,7 @@ def initialize(ports, kill_switch, token)

@phx_port = unified_opts[:phx_port] || ports["phx"]

Util.log "Daemon listening to info from Tau on port #{ports["daemon"]}"
Util.log "Daemon listening to info from Tau"

ENV["TAU_CUES_ON"] = "true"
ENV["TAU_OSC_IN_UDP_LOOPBACK_RESTRICTED"] = "true"
Expand Down Expand Up @@ -1149,7 +1158,9 @@ def initialize(ports, no_scsynth_inputs=false)
opts = scsynth_inputs_hash.merge(opts)
Util.log "Combined Audio Settings toml hash with GUI scsynth inputs hash: #{opts.inspect}"
opts = merge_scsynth_opts(toml_opts_hash, opts)
Util.log "Merged Audio Settings toml hash: #{opts.inspect}"
redacted_opts = opts.dup
redacted_opts["-u"] = "REDACTED"
Util.log "Merged Audio Settings toml hash: #{redacted_opts.inspect}"
@num_inputs = opts["-i"].to_i
@num_outputs = opts["-o"].to_i

Expand Down Expand Up @@ -1233,7 +1244,7 @@ def wait_for_boot
while continue_pinging
begin
if process_running?
Util.log "Sending /status to server: localhost:#{@port}"
Util.log "Sending /status to server"
boot_s.send("localhost", @port, "/status")
else
@success.deliver! false
Expand Down Expand Up @@ -1522,7 +1533,6 @@ def check_port(port)
begin
socket = UDPSocket.new
socket.bind('127.0.0.1', port)
Util.log "checked port #{port}, #{socket}"
socket.close
available = true
rescue StandardError
Expand Down
8 changes: 4 additions & 4 deletions app/server/ruby/bin/spider-server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@
tau_port: tau_port,
listen_to_tau_port: listen_to_tau_port}.freeze


STDOUT.puts "Ports: #{sonic_pi_ports.inspect}"
STDOUT.puts "Token: #{token}"
# Uncomment for debugging purposes:
# STDOUT.puts "Ports: #{sonic_pi_ports.inspect}"
# STDOUT.puts "Token: #{token}"
STDOUT.flush

# Open up comms to the GUI.
Expand Down Expand Up @@ -188,7 +188,7 @@
when :tcp
osc_server = SonicPi::OSC::TCPServer.new(server_port, use_decoder_cache: true)
when :udp
STDOUT.puts "Opening UDP Server to listen to GUI on port: #{server_port}"
STDOUT.puts "Opening UDP Server to listen to GUI"
osc_server = SonicPi::OSC::UDPServer.new(server_port, use_decoder_cache: true, name: "Spider API Server")
end
rescue Exception => e
Expand Down
2 changes: 1 addition & 1 deletion app/server/ruby/lib/sonicpi/scsynthexternal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def wait_for_boot
__system_thread_locals.set_local(:sonic_pi_local_thread_group, :scsynth_external_boot_ack)
Kernel.loop do
begin
puts "scsynth boot - Sending /status to server: #{@hostname}:#{@send_port}"
puts "scsynth boot - Sending /status to server"
boot_s.send(@hostname, @send_port, "/status")
rescue Exception => e
puts "scsynth boot - Error sending /status to server: #{e.message}"
Expand Down
2 changes: 1 addition & 1 deletion app/server/ruby/lib/sonicpi/tau_comms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def wait_for_tau!
t = Thread.new do
Kernel.loop do
begin
STDOUT.puts "TauComms - Sending /ping to tau: #{@hostname}:#{@port}"
STDOUT.puts "TauComms - Sending /ping to tau"
boot_s.send(@hostname, @port, "/ping")
rescue Exception => e
STDOUT.puts "TauComms - Error sending /ping to tau: #{e.message}"
Expand Down

0 comments on commit 6a93b79

Please sign in to comment.