apply fix (#42969)
This commit is contained in:
+10
-6
@@ -491,15 +491,15 @@ func GetPluginMarkdown(pluginId string, name string) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// nolint:gosec
|
// nolint:gosec
|
||||||
// We can ignore the gosec G304 warning on this one because `plug.PluginDir` is based
|
// We can ignore the gosec G304 warning since we have cleaned the requested file path and subsequently
|
||||||
// on plugin the folder structure on disk and not user input.
|
// use this with a prefix of the plugin's directory, which is set during plugin loading
|
||||||
path := filepath.Join(plug.PluginDir, fmt.Sprintf("%s.md", strings.ToUpper(name)))
|
path := filepath.Join(plug.PluginDir, mdFilepath(strings.ToUpper(name)))
|
||||||
exists, err := fs.Exists(path)
|
exists, err := fs.Exists(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !exists {
|
if !exists {
|
||||||
path = filepath.Join(plug.PluginDir, fmt.Sprintf("%s.md", strings.ToLower(name)))
|
path = filepath.Join(plug.PluginDir, mdFilepath(strings.ToLower(name)))
|
||||||
}
|
}
|
||||||
|
|
||||||
exists, err = fs.Exists(path)
|
exists, err = fs.Exists(path)
|
||||||
@@ -511,8 +511,8 @@ func GetPluginMarkdown(pluginId string, name string) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// nolint:gosec
|
// nolint:gosec
|
||||||
// We can ignore the gosec G304 warning on this one because `plug.PluginDir` is based
|
// We can ignore the gosec G304 warning since we have cleaned the requested file path and subsequently
|
||||||
// on plugin the folder structure on disk and not user input.
|
// use this with a prefix of the plugin's directory, which is set during plugin loading
|
||||||
data, err := ioutil.ReadFile(path)
|
data, err := ioutil.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -520,6 +520,10 @@ func GetPluginMarkdown(pluginId string, name string) ([]byte, error) {
|
|||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mdFilepath(mdFilename string) string {
|
||||||
|
return filepath.Clean(filepath.Join("/", fmt.Sprintf("%s.md", mdFilename)))
|
||||||
|
}
|
||||||
|
|
||||||
// gets plugin filenames that require verification for plugin signing
|
// gets plugin filenames that require verification for plugin signing
|
||||||
func collectPluginFilesWithin(rootDir string) ([]string, error) {
|
func collectPluginFilesWithin(rootDir string) ([]string, error) {
|
||||||
var files []string
|
var files []string
|
||||||
|
|||||||
Reference in New Issue
Block a user