This is an automated email from the ASF dual-hosted git repository.
rob pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 7caafce This fixes a bug in the plugin_verifier so that it does not
(#5716)
7caafce is described below
commit 7caafcedb359c28086619ecabfb329c63cc95174
Author: John J. Rushford <[email protected]>
AuthorDate: Fri Apr 9 16:59:03 2021 -0600
This fixes a bug in the plugin_verifier so that it does not (#5716)
report a malformed config when a plugin uses a long option
parameter in a @pparam field.
---
traffic_ops_ort/plugin_verifier/plugin_verifier.go | 30 ++++++++++++----------
.../test-files/etc/hdr_rw_mid_bar.config | 19 ++++++++++++++
.../plugin_verifier/test-files/etc/remap.config | 1 +
.../plugin_verifier/test-files/libexec/cachekey.so | 21 +++++++++++++++
4 files changed, 57 insertions(+), 14 deletions(-)
diff --git a/traffic_ops_ort/plugin_verifier/plugin_verifier.go
b/traffic_ops_ort/plugin_verifier/plugin_verifier.go
index 47f8d27..29141da 100644
--- a/traffic_ops_ort/plugin_verifier/plugin_verifier.go
+++ b/traffic_ops_ort/plugin_verifier/plugin_verifier.go
@@ -13,9 +13,10 @@ Description
filesystem or relative to the ATS plugin installation directory by the
absolute or relative plugin filename.
- In addition, any plugin parameters that end in '.config', '.cfg', or '.txt'
- are considered to be plugin configuration files and there existence in the
- filesystem or relative to the ATS configuration files directory is verified.
+ In addition, any plugin parameters that end in '.config', '.cfg', '.txt',
+ 'yml' or 'yaml' are considered to be plugin configuration files and there
+ existence in the filesystem or relative to the ATS configuration files
+ directory is verified.
The configuration file argument is optional. If no config file argument is
supplied, the plugin_verifier reads its config file input from 'stdin'
@@ -81,10 +82,10 @@ var (
// that any specified plugin exists in the file system at the
// complete file path or relative to the ATS plugins installation
// directory. Also, any plugin arguments or plugin parameters that
-// end in '.config', '.cfg', or '.txt' are assumed to be plugin
-// configuration files and they will be verified that the exist
-// at the absolute path in the file name or relative to the ATS
-// configuration files directory.
+// end in '.config', '.cfg', '.txt', '.yml', or '.yaml' are assumed
+// to be plugin configuration files and they will be verified
+// that the exist at the absolute path in the file name or
+// relative to the ATS configuration files directory.
//
// Returns '0' if all plugins on the config line successfully verify
// otherwise, returns the the count of plugins that failed to verify.
@@ -132,14 +133,15 @@ func checkConfigLine(line string, lineNumber int) int {
}
}
} else if strings.HasPrefix(fields[ii], "@pparam") {
- // any plugin parameters that end in '.config |
.cfg | .txt' are
- // assumed to be configuration files and are
checked that they
+ // any plugin parameters that end in '.config |
.cfg | .txt | yml | .yaml'
+ // are assumed to be configuration files and are checked that they
// exist in the filesystem at the absolute
location in the name
// or relative to the ATS configuration files
directory.
- m :=
regexp.MustCompile(`^*(\.config|\.cfg|\.txt)+`)
+ m :=
regexp.MustCompile(`^*(\.config|\.cfg|\.txt|\.yml|\.yaml)+`)
sa := strings.Split(fields[ii], "=")
- if len(sa) != 2 {
- log.Errorf("malformed @pparam
definition on line '%d'\n", lineNumber)
+ if len(sa) != 2 && len(sa) != 3 {
+ log.Errorf("malformed @pparam definition on line '%d': %v\n",
lineNumber, fields)
+ pluginErrorCount++
} else {
param := strings.TrimSpace(sa[1])
if m.MatchString(param) {
@@ -174,11 +176,11 @@ func checkConfigLine(line string, lineNumber int) int {
}
}
// Check the arguments in a plugin.config file for possible
plugin config files.
- // Any plugin argument that ends in '.config | .cfg | .txt' are
+ // Any plugin argument that ends in '.config | .cfg | .txt |
.yml | .yaml' are
// assumed to be configuration files and are checked that they
// exist in the filesystem at the absolute location in the name
// or relative to the ATS configuration files directory.
- m := regexp.MustCompile(`^*(\.config|\.cfg|\.txt)+`)
+ m :=
regexp.MustCompile(`^*(\.config|\.cfg|\.txt|\.yml|\.yaml)+`)
for ii := 1; ii < length; ii++ {
param := strings.TrimSpace(fields[ii])
if m.MatchString(param) {
diff --git
a/traffic_ops_ort/plugin_verifier/test-files/etc/hdr_rw_mid_bar.config
b/traffic_ops_ort/plugin_verifier/test-files/etc/hdr_rw_mid_bar.config
new file mode 100644
index 0000000..17bea77
--- /dev/null
+++ b/traffic_ops_ort/plugin_verifier/test-files/etc/hdr_rw_mid_bar.config
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+config file tests
diff --git a/traffic_ops_ort/plugin_verifier/test-files/etc/remap.config
b/traffic_ops_ort/plugin_verifier/test-files/etc/remap.config
index eaef536..a58c01b 100644
--- a/traffic_ops_ort/plugin_verifier/test-files/etc/remap.config
+++ b/traffic_ops_ort/plugin_verifier/test-files/etc/remap.config
@@ -20,3 +20,4 @@
map http://kabletown.cdn.net/ http://origin.kabletown.cdn.net/
@plugin=header_rewrite.so @pparam=dscp/set_dscp_8.config
@plugin=header_rewrite.so @pparam=hdr_rw.config @plugin=regex_remap.so
@pparam=regex_remap.config
map http://kabletown.top.cdn.net/ http://origin.kabletown.net/
@plugin=header_rewrite.so @pparam=dscp/set_dscp_8.config
@plugin=header_rewrite.so @pparam=hdr_rw.config @plugin=url_sig.so
@pparam=url_sig.config @plugin=regex_remap.so @pparam=regex_remap.config
@plugin=background_fetch.so @pparam=bg_fetch.config
map https://foo.cdn.net/ http://foo-origin.kabletown.cdn.net/
@plugin=header_rewrite.so @pparam=dscp/set_dscp_8.config
@plugin=header_rewrite.so @pparam=hdr_rw.config @plugin=url_sig.so
@pparam=url_sig.config @plugin=regex_remap.so @pparam=regex_remap.config
@plugin=background_fetch.so @pparam=bg_fetch.config
+map http://bar.com http://bar-origin.net @plugin=header_rewrite.so
@pparam=hdr_rw_mid_bar.config @plugin=cachekey.so @pparam=--separator=
@pparam=--remove-all-params=true @pparam=--remove-path=true
@pparam=--capture-prefix-uri=/^([^?]*)/$1/
diff --git a/traffic_ops_ort/plugin_verifier/test-files/libexec/cachekey.so
b/traffic_ops_ort/plugin_verifier/test-files/libexec/cachekey.so
new file mode 100644
index 0000000..27f18b1
--- /dev/null
+++ b/traffic_ops_ort/plugin_verifier/test-files/libexec/cachekey.so
@@ -0,0 +1,21 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+Plugin Test file