From 0f4813db4eb49bc76d1d387087adb3a9f79bf2fc Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Tue, 29 Oct 2024 07:13:00 -0600 Subject: [PATCH 1/5] Disallow periods in parameter names --- openc3/lib/openc3/config/config_parser.rb | 5 ++++- openc3/python/openc3/config/config_parser.py | 10 +++++++++- openc3/python/test/config/test_config_parser.py | 8 +++++++- openc3/spec/config/config_parser_spec.rb | 3 ++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/openc3/lib/openc3/config/config_parser.rb b/openc3/lib/openc3/config/config_parser.rb index c2093a33f..571e43087 100644 --- a/openc3/lib/openc3/config/config_parser.rb +++ b/openc3/lib/openc3/config/config_parser.rb @@ -248,7 +248,7 @@ def verify_num_parameters(min_num_params, max_num_params, usage = "") # Verifies the indicated parameter in the config doesn't start or end # with an underscore, doesn't contain a double underscore or double bracket, - # doesn't contain spaces and doesn't start with a close bracket. + # doesn't contain spaces or periods and doesn't start with a close bracket. # # @param [Integer] index The index of the parameter to check def verify_parameter_naming(index, usage = "") @@ -265,6 +265,9 @@ def verify_parameter_naming(index, usage = "") if param.include? ' ' raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot contain a space (' ').", usage, @url) end + if param.include? '.' + raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot contain a period ('.').", usage, @url) + end if param.start_with?('}') raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot start with a close bracket ('}').", usage, @url) end diff --git a/openc3/python/openc3/config/config_parser.py b/openc3/python/openc3/config/config_parser.py index 807471c61..f2d3ff3a7 100644 --- a/openc3/python/openc3/config/config_parser.py +++ b/openc3/python/openc3/config/config_parser.py @@ -138,7 +138,7 @@ def verify_num_parameters(self, min_num_params, max_num_params, usage=""): # Verifies the indicated parameter in the config doesn't start or end # with an underscore, doesn't contain a double underscore or double bracket, - # doesn't contain spaces and doesn't start with a close bracket. + # doesn't contain spaces or periods and doesn't start with a close bracket. # # self.param [Integer] index The index of the parameter to check def verify_parameter_naming(self, index, usage=""): @@ -175,6 +175,14 @@ def verify_parameter_naming(self, index, usage=""): self.url, ) + if "." in param: + raise ConfigParser.Error( + self, + f"Parameter {index} ({param}) for {self.keyword} cannot contain a periods ('.').", + usage, + self.url, + ) + if param[0] == "}": raise ConfigParser.Error( self, diff --git a/openc3/python/test/config/test_config_parser.py b/openc3/python/test/config/test_config_parser.py index fb4e22e2f..108fbb608 100644 --- a/openc3/python/test/config/test_config_parser.py +++ b/openc3/python/test/config/test_config_parser.py @@ -374,7 +374,7 @@ def test_verifies_the_maximum_number_of_parameters(self): def test_verifies_parameters_do_not_have_bad_characters(self): tf = tempfile.NamedTemporaryFile(mode="w+t") - line = "KEYWORD BAD1_ BAD__2 'BAD 3' }BAD_4 BAD[[5]]" + line = "KEYWORD BAD1_ BAD__2 'BAD 3' }BAD_4 BAD[[5]] BAD.6" tf.writelines(line) tf.seek(0) @@ -409,6 +409,12 @@ def test_verifies_parameters_do_not_have_bad_characters(self): self.cp.verify_parameter_naming, 5, ) + self.assertRaisesRegex( + ConfigParser.Error, + "cannot contain a period", + self.cp.verify_parameter_naming, + 6, + ) tf.close() def test_returns_an_error(self): diff --git a/openc3/spec/config/config_parser_spec.rb b/openc3/spec/config/config_parser_spec.rb index d86f8bc98..7c50a54d9 100644 --- a/openc3/spec/config/config_parser_spec.rb +++ b/openc3/spec/config/config_parser_spec.rb @@ -418,7 +418,7 @@ module OpenC3 describe "verify_parameter_naming" do it "verifies parameters do not have bad characters" do tf = Tempfile.new('unittest') - line = "KEYWORD BAD1_ BAD__2 'BAD 3' }BAD_4 BAD[[5]]" + line = "KEYWORD BAD1_ BAD__2 'BAD 3' }BAD_4 BAD[[5]] BAD.6" tf.puts line tf.close @@ -428,6 +428,7 @@ module OpenC3 expect { @cp.verify_parameter_naming(3) }.to raise_error(ConfigParser::Error, /cannot contain a space/) expect { @cp.verify_parameter_naming(4) }.to raise_error(ConfigParser::Error, /cannot start with a close bracket/) expect { @cp.verify_parameter_naming(5) }.to raise_error(ConfigParser::Error, /cannot contain double brackets/) + expect { @cp.verify_parameter_naming(6) }.to raise_error(ConfigParser::Error, /cannot contain a period/) end tf.unlink end From bd2ca54baebab7dc113fd2d547b72729638e4b70 Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Tue, 29 Oct 2024 10:37:50 -0600 Subject: [PATCH 2/5] Disallow brackets and quotes --- openc3/lib/openc3/config/config_parser.rb | 9 ++++--- openc3/python/openc3/config/config_parser.py | 14 +++++++--- .../python/test/config/test_config_parser.py | 26 ++++++++++++++++--- openc3/spec/config/config_parser_spec.rb | 11 +++++--- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/openc3/lib/openc3/config/config_parser.rb b/openc3/lib/openc3/config/config_parser.rb index 571e43087..dbbb8ab1d 100644 --- a/openc3/lib/openc3/config/config_parser.rb +++ b/openc3/lib/openc3/config/config_parser.rb @@ -248,7 +248,7 @@ def verify_num_parameters(min_num_params, max_num_params, usage = "") # Verifies the indicated parameter in the config doesn't start or end # with an underscore, doesn't contain a double underscore or double bracket, - # doesn't contain spaces or periods and doesn't start with a close bracket. + # doesn't contain spaces, periods, quotes or brackets. # # @param [Integer] index The index of the parameter to check def verify_parameter_naming(index, usage = "") @@ -268,8 +268,11 @@ def verify_parameter_naming(index, usage = "") if param.include? '.' raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot contain a period ('.').", usage, @url) end - if param.start_with?('}') - raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot start with a close bracket ('}').", usage, @url) + if param.include?('"') or param.include?("'") + raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot contain a quote (' or \").", usage, @url) + end + if param.include?('{') or param.include?('}') + raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot contain a bracket ('{' or '}').", usage, @url) end end diff --git a/openc3/python/openc3/config/config_parser.py b/openc3/python/openc3/config/config_parser.py index f2d3ff3a7..6081d5890 100644 --- a/openc3/python/openc3/config/config_parser.py +++ b/openc3/python/openc3/config/config_parser.py @@ -138,7 +138,7 @@ def verify_num_parameters(self, min_num_params, max_num_params, usage=""): # Verifies the indicated parameter in the config doesn't start or end # with an underscore, doesn't contain a double underscore or double bracket, - # doesn't contain spaces or periods and doesn't start with a close bracket. + # doesn't contain spaces, periods, quotes or brackets. # # self.param [Integer] index The index of the parameter to check def verify_parameter_naming(self, index, usage=""): @@ -183,10 +183,18 @@ def verify_parameter_naming(self, index, usage=""): self.url, ) - if param[0] == "}": + if "'" in param or '"' in param: raise ConfigParser.Error( self, - f"Parameter {index} ({param}) for {self.keyword} cannot start with a close bracket ('}}').", + f"Parameter {index} ({param}) for {self.keyword} cannot contain a quote (' or \").", + usage, + self.url, + ) + + if "{" in param or "}" in param: + raise ConfigParser.Error( + self, + f"Parameter {index} ({param}) for {self.keyword} cannot contain a bracket ('{{' or '}}').", usage, self.url, ) diff --git a/openc3/python/test/config/test_config_parser.py b/openc3/python/test/config/test_config_parser.py index 108fbb608..dcc3ee237 100644 --- a/openc3/python/test/config/test_config_parser.py +++ b/openc3/python/test/config/test_config_parser.py @@ -374,7 +374,7 @@ def test_verifies_the_maximum_number_of_parameters(self): def test_verifies_parameters_do_not_have_bad_characters(self): tf = tempfile.NamedTemporaryFile(mode="w+t") - line = "KEYWORD BAD1_ BAD__2 'BAD 3' }BAD_4 BAD[[5]] BAD.6" + line = "KEYWORD BAD1_ BAD__2 'BAD 3' BAD{4 BAD}4 BAD[[6]] BAD.7 BAD'8 BAD\"9" tf.writelines(line) tf.seek(0) @@ -399,22 +399,40 @@ def test_verifies_parameters_do_not_have_bad_characters(self): ) self.assertRaisesRegex( ConfigParser.Error, - "cannot start with a close bracket", + "cannot contain a bracket", self.cp.verify_parameter_naming, 4, ) self.assertRaisesRegex( ConfigParser.Error, - "cannot contain double brackets", + "cannot contain a bracket", self.cp.verify_parameter_naming, 5, ) self.assertRaisesRegex( ConfigParser.Error, - "cannot contain a period", + "cannot contain double brackets", self.cp.verify_parameter_naming, 6, ) + self.assertRaisesRegex( + ConfigParser.Error, + "cannot contain a period", + self.cp.verify_parameter_naming, + 7, + ) + self.assertRaisesRegex( + ConfigParser.Error, + "cannot contain a quote", + self.cp.verify_parameter_naming, + 8, + ) + self.assertRaisesRegex( + ConfigParser.Error, + "cannot contain a quote", + self.cp.verify_parameter_naming, + 9, + ) tf.close() def test_returns_an_error(self): diff --git a/openc3/spec/config/config_parser_spec.rb b/openc3/spec/config/config_parser_spec.rb index 7c50a54d9..a3d7bec3d 100644 --- a/openc3/spec/config/config_parser_spec.rb +++ b/openc3/spec/config/config_parser_spec.rb @@ -418,7 +418,7 @@ module OpenC3 describe "verify_parameter_naming" do it "verifies parameters do not have bad characters" do tf = Tempfile.new('unittest') - line = "KEYWORD BAD1_ BAD__2 'BAD 3' }BAD_4 BAD[[5]] BAD.6" + line = "KEYWORD BAD1_ BAD__2 'BAD 3' BAD{4 BAD}4 BAD[[6]] BAD.7 BAD'8 BAD\"9" tf.puts line tf.close @@ -426,9 +426,12 @@ module OpenC3 expect { @cp.verify_parameter_naming(1) }.to raise_error(ConfigParser::Error, /cannot end with an underscore/) expect { @cp.verify_parameter_naming(2) }.to raise_error(ConfigParser::Error, /cannot contain a double underscore/) expect { @cp.verify_parameter_naming(3) }.to raise_error(ConfigParser::Error, /cannot contain a space/) - expect { @cp.verify_parameter_naming(4) }.to raise_error(ConfigParser::Error, /cannot start with a close bracket/) - expect { @cp.verify_parameter_naming(5) }.to raise_error(ConfigParser::Error, /cannot contain double brackets/) - expect { @cp.verify_parameter_naming(6) }.to raise_error(ConfigParser::Error, /cannot contain a period/) + expect { @cp.verify_parameter_naming(4) }.to raise_error(ConfigParser::Error, /cannot contain a bracket/) + expect { @cp.verify_parameter_naming(5) }.to raise_error(ConfigParser::Error, /cannot contain a bracket/) + expect { @cp.verify_parameter_naming(6) }.to raise_error(ConfigParser::Error, /cannot contain double brackets/) + expect { @cp.verify_parameter_naming(7) }.to raise_error(ConfigParser::Error, /cannot contain a period/) + expect { @cp.verify_parameter_naming(8) }.to raise_error(ConfigParser::Error, /cannot contain a quote/) + expect { @cp.verify_parameter_naming(9) }.to raise_error(ConfigParser::Error, /cannot contain a quote/) end tf.unlink end From 5e31fb1c80daca92a837d4bf5983372b01e631ac Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Fri, 1 Nov 2024 13:59:24 -0600 Subject: [PATCH 3/5] Support period in parameter names --- .../targets/INST/cmd_tlm/inst_tlm.txt | 5 +++ .../targets/INST/lib/sim_inst.rb | 5 +++ .../targets/INST/screens/params.txt | 10 ++++-- .../targets/INST2/cmd_tlm/inst_tlm.txt | 5 +++ .../targets/INST2/lib/sim_inst.py | 5 +++ .../targets/INST2/screens/params.txt | 10 ++++-- .../src/tools/CmdTlmServer/CmdPacketsTab.vue | 5 ++- .../src/tools/CmdTlmServer/TlmPacketsTab.vue | 5 ++- .../src/components/widgets/VWidget.js | 6 ++-- openc3-traefik/traefik.yaml | 12 +++---- openc3/lib/openc3/config/config_parser.rb | 5 +-- openc3/python/openc3/config/config_parser.py | 10 +----- .../python/test/config/test_config_parser.py | 32 +++++++++++-------- openc3/spec/config/config_parser_spec.rb | 18 +++++++++-- 14 files changed, 88 insertions(+), 45 deletions(-) diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_tlm.txt b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_tlm.txt index 8d6ca5064..a5b2757ce 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_tlm.txt +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_tlm.txt @@ -127,6 +127,11 @@ TELEMETRY <%= target_name %> PARAMS BIG_ENDIAN "Params set by SETPARAMS command" STATE GOOD 0 GREEN STATE BAD 1 RED <% end %> + APPEND_ITEM P_2.2,2 32 UINT "Test weird characters" + APPEND_ITEM P-3+3=3 32 UINT "Test weird characters" + APPEND_ITEM P4!@#$%^&*? 32 UINT "Test weird characters" + APPEND_ITEM P 32 UINT "Test weird characters" + APPEND_ITEM P(:6;) 32 UINT "Test weird characters" ITEM PACKET_TIME 0 0 DERIVED "Ruby time based on TIMESEC and TIMEUS" READ_CONVERSION unix_time_conversion.rb TIMESEC TIMEUS diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/lib/sim_inst.rb b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/lib/sim_inst.rb index 6e4c8d693..63f60121c 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/lib/sim_inst.rb +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/lib/sim_inst.rb @@ -111,6 +111,11 @@ def initialize(target_name) packet.value3 = 2 packet.value4 = 1 packet.value5 = 0 + packet.write('P_2.2,2', 2) + packet.write('P-3+3=3', 3) + packet.write('P4!@#$%^&*?', 4) + packet.write('P', 5) + packet.write('P(:6;)', 6) packet = @tlm_packets['IMAGE'] packet.enable_method_missing diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/screens/params.txt b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/screens/params.txt index dd271142b..a348d1bb5 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/screens/params.txt +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/screens/params.txt @@ -3,7 +3,7 @@ SCREEN AUTO AUTO 1.0 VERTICAL TITLE Params - HORIZONTAL + HORIZONTAL 20 MATRIXBYCOLUMNS 3 LABEL VALUE5 SETTING WIDTH 100 # Only need width on the first row @@ -60,7 +60,13 @@ VERTICAL SETTING LED_COLOR GOOD GREEN SETTING LED_COLOR BAD RED END - SETTING RAW margin-left 20px + VERTICAL + LABELVALUE <%= target_name %> PARAMS P_2.2,2 + LABELVALUE <%= target_name %> PARAMS P-3+3=3 + LABELVALUE <%= target_name %> PARAMS P4!@#$%^&*? + LABELVALUE <%= target_name %> PARAMS P + LABELVALUE <%= target_name %> PARAMS P(:6;) + END END VERTICAL diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_tlm.txt b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_tlm.txt index d4d15f18c..054a9ee1b 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_tlm.txt +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_tlm.txt @@ -119,6 +119,11 @@ TELEMETRY <%= target_name %> PARAMS BIG_ENDIAN "Params set by SETPARAMS command" STATE GOOD 0 GREEN STATE BAD 1 RED <% end %> + APPEND_ITEM P_2.2,2 32 UINT "Test weird characters" + APPEND_ITEM P-3+3=3 32 UINT "Test weird characters" + APPEND_ITEM P4!@#$%^&*? 32 UINT "Test weird characters" + APPEND_ITEM P 32 UINT "Test weird characters" + APPEND_ITEM P(:6;) 32 UINT "Test weird characters" ITEM PACKET_TIME 0 0 DERIVED "Python time based on TIMESEC and TIMEUS" READ_CONVERSION openc3/conversions/unix_time_conversion.py TIMESEC TIMEUS diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/lib/sim_inst.py b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/lib/sim_inst.py index cc7de440f..b2a94ffa2 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/lib/sim_inst.py +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/lib/sim_inst.py @@ -114,6 +114,11 @@ def __init__(self, target_name): packet.write("value3", 2) packet.write("value4", 1) packet.write("value5", 0) + packet.write('P_2.2,2', 2) + packet.write('P-3+3=3', 3) + packet.write('P4!@#$%^&*?', 4) + packet.write('P', 5) + packet.write('P(:6;)', 6) packet = self.tlm_packets["IMAGE"] packet.write("CcsdsSeqFlags", "NOGROUP") diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/screens/params.txt b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/screens/params.txt index dd271142b..a348d1bb5 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/screens/params.txt +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/screens/params.txt @@ -3,7 +3,7 @@ SCREEN AUTO AUTO 1.0 VERTICAL TITLE Params - HORIZONTAL + HORIZONTAL 20 MATRIXBYCOLUMNS 3 LABEL VALUE5 SETTING WIDTH 100 # Only need width on the first row @@ -60,7 +60,13 @@ VERTICAL SETTING LED_COLOR GOOD GREEN SETTING LED_COLOR BAD RED END - SETTING RAW margin-left 20px + VERTICAL + LABELVALUE <%= target_name %> PARAMS P_2.2,2 + LABELVALUE <%= target_name %> PARAMS P-3+3=3 + LABELVALUE <%= target_name %> PARAMS P4!@#$%^&*? + LABELVALUE <%= target_name %> PARAMS P + LABELVALUE <%= target_name %> PARAMS P(:6;) + END END VERTICAL diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/CmdPacketsTab.vue b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/CmdPacketsTab.vue index c53d10c93..8c87f93b4 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/CmdPacketsTab.vue +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/CmdPacketsTab.vue @@ -160,7 +160,10 @@ export default { packet: packet_name, }, }) - window.open(`/tools/cmdsender/${target_name}/${packet_name}`, '_blank') + window.open( + `/tools/cmdsender/${encodeURIComponent(target_name)}/${encodeURIComponent(packet_name)}`, + '_blank', + ) }, currentItems(event) { this.visible = event.map((i) => { diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/TlmPacketsTab.vue b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/TlmPacketsTab.vue index bfc6f5538..9da6798da 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/TlmPacketsTab.vue +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/TlmPacketsTab.vue @@ -153,7 +153,10 @@ export default { this.rawDialogs.splice(i, 1) }, openPktViewer(target_name, packet_name) { - window.open(`/tools/packetviewer/${target_name}/${packet_name}`, '_blank') + window.open( + `/tools/packetviewer/${encodeURIComponent(target_name)}/${encodeURIComponent(packet_name)}`, + '_blank', + ) }, currentItems(event) { this.visible = event.map((i) => { diff --git a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/VWidget.js b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/VWidget.js index ef1c22312..3db9a3cc4 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/VWidget.js +++ b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/widgets/VWidget.js @@ -69,11 +69,11 @@ export default { action: () => { window.open( '/tools/tlmgrapher/' + - this.parameters[0] + + encodeURIComponent(this.parameters[0]) + '/' + - this.parameters[1] + + encodeURIComponent(this.parameters[1]) + '/' + - this.parameters[2], + encodeURIComponent(this.parameters[2]), '_blank' ) }, diff --git a/openc3-traefik/traefik.yaml b/openc3-traefik/traefik.yaml index 1ff465f6f..eb9ffa33d 100644 --- a/openc3-traefik/traefik.yaml +++ b/openc3-traefik/traefik.yaml @@ -46,10 +46,10 @@ http: service: service-script priority: 7 # Route to other tool plugins hosted statically in Minio - # Matches any path with a file extension which is assumed to be - # a static file + # Matches any path with a valid file extension which is assumed to be a static file + # TODO: We need to make all static tool files use a fixed route tools-router: - rule: Path(`/tools/{id:.*/.*[.].*}`) + rule: Path(`/tools/{id:.*/.*[.](ttf|otf|woff|woff2|html|js|css|png|jpg|jpeg|gif|svg|ico|json|xml|txt|pdf|zip|tar|gz|tgz|csv|tsv|md|yaml|yml|bin|doc|docx|xls|xlsx|ppt|pptx|mp4|mp3|wav|avi|mov|flv|swf|apk|ipa|deb|rpm|exe|msi|dmg|pkg|sh|bat|cmd|ps1|py|pl|rb|php|java|class|jar|war|ear|so|dll|lib|a|o|obj|pdb|pdb|lib|dylib|framework)}`) service: service-minio priority: 6 # Route to other tool plugins hosted statically in Minio @@ -81,10 +81,10 @@ http: service: service-minio priority: 3 # Route to base files hosted statically in Minio - # Matches any path with a file extension which is assumed to be - # a static file + # Matches any path with a valid file extension which is assumed to be a static file + # TODO: We need to make all static tool files use a fixed route base-router: - rule: Path(`/{id:.*[.].*}`) + rule: Path(`/{id:.*[.](ttf|otf|woff|woff2|html|js|css|png|jpg|jpeg|gif|svg|ico|json|xml|txt|pdf|zip|tar|gz|tgz|csv|tsv|md|yaml|yml|bin|doc|docx|xls|xlsx|ppt|pptx|mp4|mp3|wav|avi|mov|flv|swf|apk|ipa|deb|rpm|exe|msi|dmg|pkg|sh|bat|cmd|ps1|py|pl|rb|php|java|class|jar|war|ear|so|dll|lib|a|o|obj|pdb|pdb|lib|dylib|framework)}`) middlewares: # add /tools/base to the beginning - "addToolsBase" diff --git a/openc3/lib/openc3/config/config_parser.rb b/openc3/lib/openc3/config/config_parser.rb index dbbb8ab1d..c58c41ef8 100644 --- a/openc3/lib/openc3/config/config_parser.rb +++ b/openc3/lib/openc3/config/config_parser.rb @@ -248,7 +248,7 @@ def verify_num_parameters(min_num_params, max_num_params, usage = "") # Verifies the indicated parameter in the config doesn't start or end # with an underscore, doesn't contain a double underscore or double bracket, - # doesn't contain spaces, periods, quotes or brackets. + # doesn't contain spaces, quotes or brackets. # # @param [Integer] index The index of the parameter to check def verify_parameter_naming(index, usage = "") @@ -265,9 +265,6 @@ def verify_parameter_naming(index, usage = "") if param.include? ' ' raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot contain a space (' ').", usage, @url) end - if param.include? '.' - raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot contain a period ('.').", usage, @url) - end if param.include?('"') or param.include?("'") raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot contain a quote (' or \").", usage, @url) end diff --git a/openc3/python/openc3/config/config_parser.py b/openc3/python/openc3/config/config_parser.py index 6081d5890..5ca4e4096 100644 --- a/openc3/python/openc3/config/config_parser.py +++ b/openc3/python/openc3/config/config_parser.py @@ -138,7 +138,7 @@ def verify_num_parameters(self, min_num_params, max_num_params, usage=""): # Verifies the indicated parameter in the config doesn't start or end # with an underscore, doesn't contain a double underscore or double bracket, - # doesn't contain spaces, periods, quotes or brackets. + # doesn't contain spaces, quotes or brackets. # # self.param [Integer] index The index of the parameter to check def verify_parameter_naming(self, index, usage=""): @@ -175,14 +175,6 @@ def verify_parameter_naming(self, index, usage=""): self.url, ) - if "." in param: - raise ConfigParser.Error( - self, - f"Parameter {index} ({param}) for {self.keyword} cannot contain a periods ('.').", - usage, - self.url, - ) - if "'" in param or '"' in param: raise ConfigParser.Error( self, diff --git a/openc3/python/test/config/test_config_parser.py b/openc3/python/test/config/test_config_parser.py index dcc3ee237..4c33e742f 100644 --- a/openc3/python/test/config/test_config_parser.py +++ b/openc3/python/test/config/test_config_parser.py @@ -298,7 +298,7 @@ def test_optionally_yields_comment_lines(self): tf.seek(0) lines = [] - for keyword, params in self.cp.parse_file(tf.name, True): + for _, _ in self.cp.parse_file(tf.name, True): lines.append(self.cp.line) self.assertIn("# This is a comment", lines) @@ -344,7 +344,7 @@ def test_verifies_the_minimum_number_of_parameters(self): tf.writelines(line) tf.seek(0) - for keyword, params in self.cp.parse_file(tf.name): + for keyword, _ in self.cp.parse_file(tf.name): self.assertEqual(keyword, "KEYWORD") self.assertRaisesRegex( ConfigParser.Error, @@ -361,7 +361,7 @@ def test_verifies_the_maximum_number_of_parameters(self): tf.writelines(line) tf.seek(0) - for keyword, params in self.cp.parse_file(tf.name): + for keyword, _ in self.cp.parse_file(tf.name): self.assertEqual(keyword, "KEYWORD") self.assertRaisesRegex( ConfigParser.Error, @@ -372,13 +372,23 @@ def test_verifies_the_maximum_number_of_parameters(self): ) tf.close() - def test_verifies_parameters_do_not_have_bad_characters(self): + def test_allows_parameters_with_most_characters(self): tf = tempfile.NamedTemporaryFile(mode="w+t") - line = "KEYWORD BAD1_ BAD__2 'BAD 3' BAD{4 BAD}4 BAD[[6]] BAD.7 BAD'8 BAD\"9" + line = "KEYWORD P[1] P_2.2,2 P-3+3=3 P4!@#$%^&*? P P(:6;)" tf.writelines(line) tf.seek(0) for keyword, params in self.cp.parse_file(tf.name): + self.assertEqual(keyword, "KEYWORD") + self.assertListEqual(params, ["P[1]", "P_2.2,2", "P-3+3=3", "P4!@#$%^&*?", "P", "P(:6;)"]) + + def test_verifies_parameters_do_not_have_bad_characters(self): + tf = tempfile.NamedTemporaryFile(mode="w+t") + line = "KEYWORD BAD1_ BAD__2 'BAD 3' BAD{4 BAD}4 BAD[[6]] BAD'7 BAD\"8" + tf.writelines(line) + tf.seek(0) + + for _, _ in self.cp.parse_file(tf.name): self.assertRaisesRegex( ConfigParser.Error, "cannot end with an underscore", @@ -417,7 +427,7 @@ def test_verifies_parameters_do_not_have_bad_characters(self): ) self.assertRaisesRegex( ConfigParser.Error, - "cannot contain a period", + "cannot contain a quote", self.cp.verify_parameter_naming, 7, ) @@ -427,12 +437,6 @@ def test_verifies_parameters_do_not_have_bad_characters(self): self.cp.verify_parameter_naming, 8, ) - self.assertRaisesRegex( - ConfigParser.Error, - "cannot contain a quote", - self.cp.verify_parameter_naming, - 9, - ) tf.close() def test_returns_an_error(self): @@ -441,7 +445,7 @@ def test_returns_an_error(self): tf.writelines(line) tf.seek(0) - for keyword, params in self.cp.parse_file(tf.name): + for _, _ in self.cp.parse_file(tf.name): error = self.cp.error("Hello") self.assertIn("Hello", repr(error)) self.assertEqual(error.keyword, "KEYWORD") @@ -456,7 +460,7 @@ def test_collects_all_errors_and_returns_all(self): tf.seek(0) try: - for keyword, params in self.cp.parse_file(tf.name): + for keyword, _ in self.cp.parse_file(tf.name): if keyword == "KEYWORD1": raise self.cp.error("Invalid KEYWORD1") # TODO: This doesn't work in Python like Ruby diff --git a/openc3/spec/config/config_parser_spec.rb b/openc3/spec/config/config_parser_spec.rb index a3d7bec3d..4cb1ac1fb 100644 --- a/openc3/spec/config/config_parser_spec.rb +++ b/openc3/spec/config/config_parser_spec.rb @@ -416,9 +416,22 @@ module OpenC3 end describe "verify_parameter_naming" do + it "allows most characters in parameters" do + tf = Tempfile.new('unittest') + line = "KEYWORD P[1] P_2.2,2 P-3+3=3 P4!@#$%^&*? P P(:6;)" + tf.puts line + tf.close + + @cp.parse_file(tf.path) do |keyword, params| + expect(keyword).to eql "KEYWORD" + expect(params).to eql ["P[1]", "P_2.2,2", "P-3+3=3", "P4!@#$%^&*?", "P", "P(:6;)"] + end + tf.unlink + end + it "verifies parameters do not have bad characters" do tf = Tempfile.new('unittest') - line = "KEYWORD BAD1_ BAD__2 'BAD 3' BAD{4 BAD}4 BAD[[6]] BAD.7 BAD'8 BAD\"9" + line = "KEYWORD BAD1_ BAD__2 'BAD 3' BAD{4 BAD}4 BAD[[6]] BAD'7 BAD\"8" tf.puts line tf.close @@ -429,9 +442,8 @@ module OpenC3 expect { @cp.verify_parameter_naming(4) }.to raise_error(ConfigParser::Error, /cannot contain a bracket/) expect { @cp.verify_parameter_naming(5) }.to raise_error(ConfigParser::Error, /cannot contain a bracket/) expect { @cp.verify_parameter_naming(6) }.to raise_error(ConfigParser::Error, /cannot contain double brackets/) - expect { @cp.verify_parameter_naming(7) }.to raise_error(ConfigParser::Error, /cannot contain a period/) + expect { @cp.verify_parameter_naming(7) }.to raise_error(ConfigParser::Error, /cannot contain a quote/) expect { @cp.verify_parameter_naming(8) }.to raise_error(ConfigParser::Error, /cannot contain a quote/) - expect { @cp.verify_parameter_naming(9) }.to raise_error(ConfigParser::Error, /cannot contain a quote/) end tf.unlink end From 467bd786f269b4d54ed97acd44794ad783407e01 Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Fri, 1 Nov 2024 16:26:52 -0600 Subject: [PATCH 4/5] Specify curly bracket --- openc3/lib/openc3/config/config_parser.rb | 2 +- openc3/python/openc3/config/config_parser.py | 2 +- openc3/python/test/config/test_config_parser.py | 4 ++-- openc3/spec/config/config_parser_spec.rb | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openc3/lib/openc3/config/config_parser.rb b/openc3/lib/openc3/config/config_parser.rb index c58c41ef8..3c5681757 100644 --- a/openc3/lib/openc3/config/config_parser.rb +++ b/openc3/lib/openc3/config/config_parser.rb @@ -269,7 +269,7 @@ def verify_parameter_naming(index, usage = "") raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot contain a quote (' or \").", usage, @url) end if param.include?('{') or param.include?('}') - raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot contain a bracket ('{' or '}').", usage, @url) + raise Error.new(self, "Parameter #{index} (#{param}) for #{@keyword} cannot contain a curly bracket ('{' or '}').", usage, @url) end end diff --git a/openc3/python/openc3/config/config_parser.py b/openc3/python/openc3/config/config_parser.py index 5ca4e4096..82697dde3 100644 --- a/openc3/python/openc3/config/config_parser.py +++ b/openc3/python/openc3/config/config_parser.py @@ -186,7 +186,7 @@ def verify_parameter_naming(self, index, usage=""): if "{" in param or "}" in param: raise ConfigParser.Error( self, - f"Parameter {index} ({param}) for {self.keyword} cannot contain a bracket ('{{' or '}}').", + f"Parameter {index} ({param}) for {self.keyword} cannot contain a curly bracket ('{{' or '}}').", usage, self.url, ) diff --git a/openc3/python/test/config/test_config_parser.py b/openc3/python/test/config/test_config_parser.py index 4c33e742f..991164957 100644 --- a/openc3/python/test/config/test_config_parser.py +++ b/openc3/python/test/config/test_config_parser.py @@ -409,13 +409,13 @@ def test_verifies_parameters_do_not_have_bad_characters(self): ) self.assertRaisesRegex( ConfigParser.Error, - "cannot contain a bracket", + "cannot contain a curly bracket", self.cp.verify_parameter_naming, 4, ) self.assertRaisesRegex( ConfigParser.Error, - "cannot contain a bracket", + "cannot contain a curly bracket", self.cp.verify_parameter_naming, 5, ) diff --git a/openc3/spec/config/config_parser_spec.rb b/openc3/spec/config/config_parser_spec.rb index 4cb1ac1fb..5798c64f4 100644 --- a/openc3/spec/config/config_parser_spec.rb +++ b/openc3/spec/config/config_parser_spec.rb @@ -439,8 +439,8 @@ module OpenC3 expect { @cp.verify_parameter_naming(1) }.to raise_error(ConfigParser::Error, /cannot end with an underscore/) expect { @cp.verify_parameter_naming(2) }.to raise_error(ConfigParser::Error, /cannot contain a double underscore/) expect { @cp.verify_parameter_naming(3) }.to raise_error(ConfigParser::Error, /cannot contain a space/) - expect { @cp.verify_parameter_naming(4) }.to raise_error(ConfigParser::Error, /cannot contain a bracket/) - expect { @cp.verify_parameter_naming(5) }.to raise_error(ConfigParser::Error, /cannot contain a bracket/) + expect { @cp.verify_parameter_naming(4) }.to raise_error(ConfigParser::Error, /cannot contain a curly bracket/) + expect { @cp.verify_parameter_naming(5) }.to raise_error(ConfigParser::Error, /cannot contain a curly bracket/) expect { @cp.verify_parameter_naming(6) }.to raise_error(ConfigParser::Error, /cannot contain double brackets/) expect { @cp.verify_parameter_naming(7) }.to raise_error(ConfigParser::Error, /cannot contain a quote/) expect { @cp.verify_parameter_naming(8) }.to raise_error(ConfigParser::Error, /cannot contain a quote/) From 21e61b8082d357cd41c354a652a1db9bd49784af Mon Sep 17 00:00:00 2001 From: Jason Thomas Date: Tue, 5 Nov 2024 07:25:19 -0700 Subject: [PATCH 5/5] Remove dead code and old comment --- .../src/tools/CmdTlmServer/CmdPacketsTab.vue | 7 ------- .../openc3-tool-common/src/components/GraphEditDialog.vue | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/CmdPacketsTab.vue b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/CmdPacketsTab.vue index 8c87f93b4..4ef5582a4 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/CmdPacketsTab.vue +++ b/openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-cmdtlmserver/src/tools/CmdTlmServer/CmdPacketsTab.vue @@ -153,13 +153,6 @@ export default { this.rawDialogs.splice(i, 1) }, openCmdSender(target_name, packet_name) { - let routeData = this.$router.resolve({ - name: 'CommandSender', - params: { - target: target_name, - packet: packet_name, - }, - }) window.open( `/tools/cmdsender/${encodeURIComponent(target_name)}/${encodeURIComponent(packet_name)}`, '_blank', diff --git a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/GraphEditDialog.vue b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/GraphEditDialog.vue index 91b833efa..d4e1c1920 100644 --- a/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/GraphEditDialog.vue +++ b/openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/GraphEditDialog.vue @@ -405,7 +405,7 @@ export default { this.startTime = this.formatTimeHMS(date, this.timeZone) } else { // Create a new date 1 hr in the past as a default - let date = new Date() - 3600000 // last hr data + let date = new Date() - 3600000 this.startDate = this.formatDate(date, this.timeZone) this.startTime = this.formatTimeHMS(date, this.timeZone) }